diff --git a/.changeset/intent-skill-cross-package-links.md b/.changeset/intent-skill-cross-package-links.md new file mode 100644 index 0000000000..9d655e9e75 --- /dev/null +++ b/.changeset/intent-skill-cross-package-links.md @@ -0,0 +1,14 @@ +--- +'@tanstack/react-router': patch +'@tanstack/react-start': patch +'@tanstack/router-core': patch +'@tanstack/router-plugin': patch +'@tanstack/solid-router': patch +'@tanstack/solid-start': patch +'@tanstack/start-client-core': patch +'@tanstack/start-server-core': patch +'@tanstack/vue-router': patch +'@tanstack/vue-start': patch +--- + +Reference agent skills in other packages by their `intent load` identifier (`@tanstack/#`) instead of relative file links that break once packages are installed. diff --git a/.changeset/publish-react-router-skills.md b/.changeset/publish-react-router-skills.md new file mode 100644 index 0000000000..db2921a007 --- /dev/null +++ b/.changeset/publish-react-router-skills.md @@ -0,0 +1,5 @@ +--- +'@tanstack/react-router': patch +--- + +Publish the `@tanstack/react-router` agent skills (`react-router`, `compositions/router-query`, `lifecycle/migrate-from-react-router`), which were missing from the package's `files` list. diff --git a/.changeset/remove-enable-route-generation.md b/.changeset/remove-enable-route-generation.md new file mode 100644 index 0000000000..847cede4a5 --- /dev/null +++ b/.changeset/remove-enable-route-generation.md @@ -0,0 +1,5 @@ +--- +'@tanstack/router-plugin': patch +--- + +Remove the `enableRouteGeneration` option. Route generation now always runs, so `autoCodeSplitting` always has the route metadata it needs. diff --git a/.changeset/rsbuild-manifest-module-chunks-once.md b/.changeset/rsbuild-manifest-module-chunks-once.md deleted file mode 100644 index 02febd9d84..0000000000 --- a/.changeset/rsbuild-manifest-module-chunks-once.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild: the Start manifest pass that runs after every client compilation (builds and each dev update) reads an imported module's chunks once per compilation and counts the module once per importing chunk, instead of once per import connection. The manifest is unchanged; the pass takes about 40 % less time (on a 333-route app, tens of milliseconds less per HMR update). diff --git a/.changeset/rsbuild-manifest-own-chunks.md b/.changeset/rsbuild-manifest-own-chunks.md deleted file mode 100644 index 04e8e29928..0000000000 --- a/.changeset/rsbuild-manifest-own-chunks.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild: a route's client manifest entry lists only its own chunks and CSS. When two routes shared a module in a chunk of its own, each route's entry also listed the other route's chunk as a preload and its stylesheet. diff --git a/.changeset/rsbuild-rule-use-falsy-loaders.md b/.changeset/rsbuild-rule-use-falsy-loaders.md deleted file mode 100644 index a84a054fbd..0000000000 --- a/.changeset/rsbuild-rule-use-falsy-loaders.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -fix: the Rsbuild RSC integration skips falsy entries in a rule's `use` array (Rspack's conditionally disabled loaders) instead of treating them as loaders. diff --git a/.changeset/rsbuild-virtual-modules-build.md b/.changeset/rsbuild-virtual-modules-build.md deleted file mode 100644 index 01a0c5ee6e..0000000000 --- a/.changeset/rsbuild-virtual-modules-build.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild: fix the Rsbuild plugin build after two changes to its virtual modules crossed. Without this fix the package does not build, so no release could ship it. The Rsbuild dev manifest is written to its virtual module under the app's root. diff --git a/.changeset/rsbuild-virtual-modules-root.md b/.changeset/rsbuild-virtual-modules-root.md deleted file mode 100644 index 427043a712..0000000000 --- a/.changeset/rsbuild-virtual-modules-root.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Rsbuild: Start writes its virtual modules under the app's root, not the working directory. An app built or served from another directory (`rsbuild build --root ` from a monorepo root) no longer fails with "Module not found" on the packages they import, such as RSC's serialization adapters. diff --git a/.changeset/rsc-security-floor.md b/.changeset/rsc-security-floor.md deleted file mode 100644 index 9c828f13b3..0000000000 --- a/.changeset/rsc-security-floor.md +++ /dev/null @@ -1,8 +0,0 @@ ---- -'@tanstack/react-start-rsc': patch ---- - -Raise the minimum RSC bundler peer dependencies to versions with the React Server Components fixes for GHSA-xqc2-xf4c-x3h3 (CVE-2026-126187, unauthenticated RCE) and GHSA-h3gv-c5rc-p453 (server function DoS): - -- `@vitejs/plugin-rsc` to `>=0.5.38` (GHSA-59pf-q495-3c99), which vendors a fixed `react-server-dom-webpack`. -- `react-server-dom-rspack` to `>=0.1.1`, the first release built from React sources that include the fix. diff --git a/.changeset/skip-disabled-import-protection.md b/.changeset/skip-disabled-import-protection.md new file mode 100644 index 0000000000..700ac5ee51 --- /dev/null +++ b/.changeset/skip-disabled-import-protection.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Skip the Rsbuild import-protection loader and its plugins when import protection is disabled, so modules no longer pass through the loader. diff --git a/.changeset/skip-unchanged-resolver-rebuild.md b/.changeset/skip-unchanged-resolver-rebuild.md new file mode 100644 index 0000000000..0d91fe4cf6 --- /dev/null +++ b/.changeset/skip-unchanged-resolver-rebuild.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Skip the server function resolver rebuild in Rsbuild dev when the resolver has not changed, so most edits no longer rebuild the whole server chunk graph. diff --git a/.changeset/start-compiler-member-call-receivers.md b/.changeset/start-compiler-member-call-receivers.md new file mode 100644 index 0000000000..d94b7b83e4 --- /dev/null +++ b/.changeset/start-compiler-member-call-receivers.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Stop resolving top-level calls such as `z.object()` whose receiver is not a namespace import. They can never be a `createServerOnlyFn` or `createClientOnlyFn` call, and resolving them made the dev compiler load and parse the receiver's module (all of zod, for example). diff --git a/.changeset/start-plugin-core-exsolve-1-1-3.md b/.changeset/start-plugin-core-exsolve-1-1-3.md new file mode 100644 index 0000000000..a59848ee5b --- /dev/null +++ b/.changeset/start-plugin-core-exsolve-1-1-3.md @@ -0,0 +1,5 @@ +--- +'@tanstack/start-plugin-core': patch +--- + +Require `exsolve` `^1.1.3`, which no longer keeps compilers alive through cached failed lookups, so memory no longer grows across builds in one process. diff --git a/.changeset/start-server-fn-custom-id-check.md b/.changeset/start-server-fn-custom-id-check.md deleted file mode 100644 index 384f0ade06..0000000000 --- a/.changeset/start-server-fn-custom-id-check.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -'@tanstack/start-plugin-core': minor ---- - -A server function id that a custom `serverFns.generateFunctionId` returns and that never worked over HTTP now fails the build, with an error naming the file, the function and the id: whitespace, a control or non-ASCII character, any of `"`, `#`, `/`, `<`, `>`, `?`, `\`, `^`, `` ` ``, `{`, `}`, the ids `.` and `..`, and a percent-encoding the server reads as another id (`%41`, lowercase hex, `%2E`) or rejects. The client puts the id in the URL unencoded, so a `#` or `?` ended the path and a `/` cut the id short (the call silently ran another server function of the file or none), and the other characters reached the server percent-encoded and matched no function. An id embedding a non-ASCII `functionName` is one of these. One case did work and now fails the build: such an id on a server function only SSR code called. - -Ids with `%` or the other characters URLs allow (such as `:`, `@`, `+`, `=`, `,`, `;`, `!`, `*`, `(`, `)`, `&`, `'`, `|`, `[`, `]`) still build and reach their handler, with a deprecation warning (from the Vite plugin; the Rsbuild plugin does not print compiler warnings yet): the next major version rejects them, since proxies and servers may decode or rewrite them (hash the inputs instead, as the documented example does). An id with `'` no longer breaks the server bundle. diff --git a/.changeset/start-vite-root-library-discovery.md b/.changeset/start-vite-root-library-discovery.md deleted file mode 100644 index d4e8221c59..0000000000 --- a/.changeset/start-vite-root-library-discovery.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@tanstack/start-plugin-core': patch ---- - -Vite: Start finds the Start libraries it bundles in the SSR build from Vite's root, not the working directory. A `vite build ` run from another directory (a monorepo root, a script) no longer leaves them external and uncompiled, where their server fns returned `undefined`. diff --git a/.github/workflows/compiler-platforms.yml b/.github/workflows/compiler-platforms.yml index ad70e39bb6..a6f9462b47 100644 --- a/.github/workflows/compiler-platforms.yml +++ b/.github/workflows/compiler-platforms.yml @@ -2,8 +2,11 @@ name: Compiler Platforms # The main PR workflow only runs on Linux x64 (glibc). The compilers load a # native Yuku binary per platform and handle platform-specific paths, so run -# their unit tests and a Vite and Rsbuild production build on the other -# platforms we ship to. +# their fast test tier (test:unit), a small integration smoke set without a +# browser (test:integration:smoke: real Vite and Rsbuild builds) and a Vite and +# Rsbuild production build on the other platforms we ship to. The rest of the +# slow tier (test:integration, including the Chromium tests) runs on Linux x64 +# in the main PR workflow. on: pull_request: @@ -12,6 +15,8 @@ on: - 'packages/router-generator/**' - 'packages/router-plugin/**' - 'packages/start-plugin-core/**' + - 'packages/compiler-test-utils/**' + - 'packages/react-start-rsc/**' - 'pnpm-lock.yaml' - '.github/workflows/compiler-platforms.yml' schedule: @@ -70,7 +75,7 @@ jobs: persist-credentials: false - name: Setup pnpm if: ${{ !matrix.container }} - uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1 + uses: pnpm/action-setup@739bfe42ca9233c5e6aca07c1a25a9d34aca49b0 # v6.0.7 - name: Setup Node if: ${{ !matrix.container }} uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0 @@ -88,11 +93,22 @@ jobs: --filter "@tanstack/router-generator..." --filter "@tanstack/router-plugin..." --filter "@tanstack/start-plugin-core..." + --filter "@tanstack/react-start-rsc..." --filter "tanstack-react-start-e2e-basic..." - - name: Unit tests + - name: Unit tests (fast tier) run: >- pnpm nx run-many --targets=test:unit - --projects=@tanstack/router-utils,@tanstack/router-generator,@tanstack/router-plugin,@tanstack/start-plugin-core + --projects=@tanstack/router-generator,@tanstack/router-plugin,@tanstack/start-plugin-core + --skip-nx-cache --outputStyle=static + - name: Noncompiler tests (runtime and build plumbing) + run: >- + pnpm nx run-many --targets=test:noncompiler + --projects=@tanstack/start-plugin-core,@tanstack/react-start-rsc + --skip-nx-cache --outputStyle=static + - name: Integration smoke (no browser) + run: >- + pnpm nx run-many --targets=test:integration:smoke + --projects=@tanstack/router-plugin,@tanstack/start-plugin-core --skip-nx-cache --outputStyle=static - name: Production builds run: >- diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ae19b4f0d2..71026a0a92 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -10,13 +10,6 @@ concurrency: env: NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} SERVER_PRESET: 'node-server' - # Enable dynamic task packing for distributed CI. - NX_CLOUD_AGENT_TASK_QUEUE: true - NX_CLOUD_AUTO_TASK_PACKING: true - NX_CLOUD_AGENT_UNCAPPED_GROUP_WORK: true - NX_CLOUD_PACKING_MEM_MULTIPLIER: 1.5 - NX_CLOUD_BUFFER_TASK_COMPLETIONS: true - NX_CLOUD_CONTINUOUS_ASSIGNMENT: true permissions: contents: read @@ -33,8 +26,8 @@ jobs: with: fetch-depth: 0 persist-credentials: false - - name: Start Nx Workers - run: npx nx-cloud start-workers + - name: Start Nx Agents + run: npx nx-cloud start-ci-run --distribute-on=".nx/workflows/dynamic-changesets.yaml" - name: Setup Tools uses: TanStack/config/.github/setup@e4b48f16568324f76f467aa4c2aac2f05db632c3 # main - name: Get base and head commits for `nx affected` @@ -43,9 +36,9 @@ jobs: main-branch-name: main - name: Run Checks run: pnpm run test:pr --parallel=3 - - name: Stop Nx Workers + - name: Stop Nx Agents if: ${{ always() }} - run: npx nx-cloud stop-all-workers + run: npx nx-cloud stop-all-agents preview: name: Preview runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 70028b2860..53dd3f4a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -94,3 +94,9 @@ vite.config.ts.timestamp_* # local memory flame profiles benchmarks/memory/**/.profiles/ + +# Temporary apps the Start compiler test harnesses created here before they +# moved to the system's temporary directory (compiler-test-utils +# `app-directory`): what a Vite dev server wrote after it closed (upstream Vite +# bug #34) can be left in older checkouts. +packages/*/tests/**/.start-*/ diff --git a/.nvmrc b/.nvmrc index 63f87c20ef..8a94b99127 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -26.12.1 +26.10.0 diff --git a/.nx/ci-config.yaml b/.nx/ci-config.yaml deleted file mode 100644 index 2f0783feb4..0000000000 --- a/.nx/ci-config.yaml +++ /dev/null @@ -1,5 +0,0 @@ -dte: - distribute-on: - small-changeset: 6 linux-medium-js - medium-changeset: 12 linux-medium-js - large-changeset: 18 linux-medium-js diff --git a/.nx/workflows/dynamic-changesets.yaml b/.nx/workflows/dynamic-changesets.yaml new file mode 100644 index 0000000000..39d858d5b2 --- /dev/null +++ b/.nx/workflows/dynamic-changesets.yaml @@ -0,0 +1,4 @@ +distribute-on: + small-changeset: 4 linux-medium-js + medium-changeset: 8 linux-medium-js + large-changeset: 16 linux-medium-js diff --git a/.nx/workflows/ultracache-config.yaml b/.nx/workflows/sandboxing-config.yaml similarity index 88% rename from .nx/workflows/ultracache-config.yaml rename to .nx/workflows/sandboxing-config.yaml index b3ed223621..c6f527f6b2 100644 --- a/.nx/workflows/ultracache-config.yaml +++ b/.nx/workflows/sandboxing-config.yaml @@ -1,21 +1,21 @@ -ignore-reads: +exclude-reads: - e2e/.gitignore - '**/src/routeTree.gen.ts' -ignore-writes: +exclude-writes: - '**/src/routeTree.gen.ts' task-exclusions: - target: test:build - ignore-reads: + exclude-reads: - LICENSE # HMR tests edit these inputs in place and restore their original contents. # Keep them out of cached outputs so cache replay never overwrites source. - project: tanstack-react-start-e2e-deferred-hydration target: test:e2e - ignore-writes: + exclude-writes: - e2e/react-start/deferred-hydration/src/routes/components.tsx - project: tanstack-react-start-e2e-hmr target: test:e2e - ignore-writes: &hmr-source-writes + exclude-writes: &hmr-source-writes - e2e/react-start/hmr/src/components/AliasedRouteImportChildPanel.tsx - e2e/react-start/hmr/src/components/AliasedRouteImportParentPanel.tsx - e2e/react-start/hmr/src/hmr/server-fn-hmr-factory.ts @@ -32,25 +32,25 @@ task-exclusions: - e2e/react-start/hmr/src/routes/inputs.tsx - project: tanstack-react-start-e2e-hmr target: test:e2e--vite-ssr - ignore-writes: *hmr-source-writes + exclude-writes: *hmr-source-writes - project: tanstack-react-start-e2e-hmr target: test:e2e--vite-ssr--bundled-dev - ignore-writes: *hmr-source-writes + exclude-writes: *hmr-source-writes - project: tanstack-react-start-e2e-hmr target: test:e2e--rsbuild-ssr - ignore-writes: *hmr-source-writes + exclude-writes: *hmr-source-writes - project: tanstack-react-start-e2e-rsbuild target: test:e2e--rsbuild-ssr - ignore-writes: + exclude-writes: - e2e/react-start/rsbuild/src/routes/index.tsx - project: tanstack-react-start-e2e-server-functions target: test:e2e - ignore-writes: + exclude-writes: - e2e/react-start/server-functions/src/routes/consistent.tsx # Scaffolding tests deliberately populate tracked empty route fixtures. - project: '@tanstack/router-generator' target: test:unit - ignore-writes: + exclude-writes: - packages/router-generator/tests/generator/custom-scaffolding/routes/__root.tsx - packages/router-generator/tests/generator/custom-scaffolding/routes/api/bar.tsx - packages/router-generator/tests/generator/custom-scaffolding/routes/foo.lazy.tsx @@ -58,67 +58,67 @@ task-exclusions: # These reads are of scratch files created by the same test invocation. - project: tanstack-solid-start-e2e-basic-auth target: test:e2e - ignore-reads: + exclude-reads: - e2e/solid-start/basic-auth/.tmp/dev.db - project: tanstack-vue-start-e2e-basic-auth target: test:e2e - ignore-reads: + exclude-reads: - e2e/vue-start/basic-auth/.tmp/dev.db - project: '@tanstack/router-generator' target: test:unit - ignore-reads: + exclude-reads: - packages/router-generator/tests/generator/file-modification/routes/[(]test[)]/initiallyEmpty.tsx - packages/router-generator/tests/generator/file-modification/routes/[(]test[)]/initiallyEmpty.lazy.tsx # Mutable counters are scratch state, not artifacts to replay from cache. - project: tanstack-react-start-e2e-basic-tsr-config target: test:e2e - ignore-reads: + exclude-reads: - e2e/react-start/basic-tsr-config/count.txt - ignore-writes: + exclude-writes: - e2e/react-start/basic-tsr-config/count.txt - project: tanstack-solid-start-e2e-basic-tsr-config target: test:e2e - ignore-reads: + exclude-reads: - e2e/solid-start/basic-tsr-config/count.txt - ignore-writes: + exclude-writes: - e2e/solid-start/basic-tsr-config/count.txt - project: tanstack-vue-start-e2e-basic-tsr-config target: test:e2e - ignore-reads: + exclude-reads: - e2e/vue-start/basic-tsr-config/count.txt - ignore-writes: + exclude-writes: - e2e/vue-start/basic-tsr-config/count.txt # Paraglide downloads compiler plugins from the URLs in settings.json. # Ignore warm-cache reads; the settings remain inputs and cache files outputs. - project: tanstack-react-start-e2e-i18n-paraglide target: build - ignore-reads: + exclude-reads: - e2e/react-start/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-router-e2e-react-i18n-paraglide target: build - ignore-reads: + exclude-reads: - e2e/react-router/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-react-start-e2e-i18n-paraglide target: test:e2e - ignore-reads: + exclude-reads: - e2e/react-start/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-router-e2e-react-i18n-paraglide target: test:e2e - ignore-reads: + exclude-reads: - e2e/react-router/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-router-i18n-paraglide target: build - ignore-reads: + exclude-reads: - examples/react/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-start-i18n-paraglide target: build - ignore-reads: + exclude-reads: - examples/react/start-i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-router-solid-i18n-paraglide target: build - ignore-reads: + exclude-reads: - examples/solid/i18n-paraglide/project.inlang/cache/plugins/* - project: tanstack-solid-start-i18n-paraglide target: build - ignore-reads: + exclude-reads: - examples/solid/start-i18n-paraglide/project.inlang/cache/plugins/* diff --git a/AGENTS.md b/AGENTS.md index f47b5103e1..3392d013a3 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,16 +15,14 @@ - For sandbox-blocked registry/store access, escalate the same command; report the blocker if unavailable. Do not change stores, delete dependencies/lockfiles, use `--force`/`--ignore-scripts`, or weaken workspace trust/build policies to bypass it. - Never manually edit `pnpm-lock.yaml` or any `routeTree.gen.ts`. Regenerate the lockfile with `pnpm install --no-frozen-lockfile` after intentional dependency changes; regenerate route trees through app builds/dev servers or the generator fixture harness. - Always use control-flow braces. Run `pnpm format` before validation. -- Use Nx: workspace imports consume built packages, so direct runners can test stale dependencies. Inspect resolved targets with `pnpm nx show project --json`; some are inferred. -- Run finite validation through `run-many` with explicit projects and targets, including a single project/target. Nx automatically selects `summary` output when it detects an AI agent: omit `--outputStyle` for normal runs. Read the reported full log files for failures; use `--outputStyle=summary` if agent detection is unavailable. -- Use `--outputStyle=static` or `pnpm nx run :` only when diagnosing a task and its full output is needed. Continuous/watch targets may use live output. +- Use Nx: workspace imports consume built packages, so direct runners can test stale dependencies. Inspect resolved targets; some are inferred. ```sh -CI=1 NX_DAEMON=false pnpm nx run-many -p -t --skipRemoteCache +CI=1 NX_DAEMON=false pnpm nx run : --outputStyle=stream --skipRemoteCache ``` - Run one Nx command at a time. For a ~20-second startup/graph stall, stop, run `pnpm nx reset`, and retry once, then escalate. Do not apply that timeout to running tests. -- For code changes, run affected packages' `test:unit`, `test:types`, and `test:eslint` where available, including affected consumers; use `test:e2e` for browser/app behavior and `test:build` for exports/build changes. Root `pnpm test` includes the full e2e suite. Published-code changes require `pnpm changeset`. +- For code changes, run affected packages' `test:unit`, `test:integration`, `test:noncompiler`, `test:types`, and `test:eslint` where available, including affected consumers; use `test:e2e` for browser/app behavior and `test:build` for exports/build changes. Root `pnpm test` includes the full e2e suite. Published-code changes require `pnpm changeset`. ## Runtime rules diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4b6e808af1..12ba6656d1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -65,6 +65,7 @@ Run the checks relevant to your changes while developing: - `pnpm test:eslint` checks linting for affected packages. - `pnpm test:types` checks types for affected packages. - `pnpm test:unit` runs unit tests for affected packages. +- `pnpm test:integration` runs the slow tier of the compiler packages (`router-plugin`, `start-plugin-core`, `compiler-test-utils`): tests that start real builds, dev servers or browsers. - `pnpm test:build` checks builds for affected packages. - `pnpm test:e2e` runs end-to-end tests and requires the Playwright browsers. diff --git a/benchmarks/bundle-size/package.json b/benchmarks/bundle-size/package.json index ca34cd6cd7..ed1e7410f7 100644 --- a/benchmarks/bundle-size/package.json +++ b/benchmarks/bundle-size/package.json @@ -68,7 +68,7 @@ "vue": "^3.5.16" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-plugin": "workspace:^", "@types/react": "^19.0.8", diff --git a/benchmarks/client-nav/scenarios/async-pipeline/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/async-pipeline/solid/src/routeTree.gen.ts index 27b9498b11..7c15baf4e9 100644 --- a/benchmarks/client-nav/scenarios/async-pipeline/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/async-pipeline/solid/src/routeTree.gen.ts @@ -9,25 +9,25 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' import { Route as NestedRouteImport } from './routes/nested' -import { Route as CtxIdRouteImport } from './routes/ctx.$id' -import { Route as NestedIdRouteImport } from './routes/nested.$id' +import { Route as IndexRouteImport } from './routes/index' import { Route as SlowIdRouteImport } from './routes/slow.$id' +import { Route as NestedIdRouteImport } from './routes/nested.$id' +import { Route as CtxIdRouteImport } from './routes/ctx.$id' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) const NestedRoute = NestedRouteImport.update({ id: '/nested', path: '/nested', getParentRoute: () => rootRouteImport, } as any) -const CtxIdRoute = CtxIdRouteImport.update({ - id: '/ctx/$id', - path: '/ctx/$id', +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => rootRouteImport, +} as any) +const SlowIdRoute = SlowIdRouteImport.update({ + id: '/slow/$id', + path: '/slow/$id', getParentRoute: () => rootRouteImport, } as any) const NestedIdRoute = NestedIdRouteImport.update({ @@ -35,9 +35,9 @@ const NestedIdRoute = NestedIdRouteImport.update({ path: '/$id', getParentRoute: () => NestedRoute, } as any) -const SlowIdRoute = SlowIdRouteImport.update({ - id: '/slow/$id', - path: '/slow/$id', +const CtxIdRoute = CtxIdRouteImport.update({ + id: '/ctx/$id', + path: '/ctx/$id', getParentRoute: () => rootRouteImport, } as any) @@ -80,13 +80,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } '/nested': { id: '/nested' path: '/nested' @@ -94,11 +87,18 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof NestedRouteImport parentRoute: typeof rootRouteImport } - '/ctx/$id': { - id: '/ctx/$id' - path: '/ctx/$id' - fullPath: '/ctx/$id' - preLoaderRoute: typeof CtxIdRouteImport + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } + '/slow/$id': { + id: '/slow/$id' + path: '/slow/$id' + fullPath: '/slow/$id' + preLoaderRoute: typeof SlowIdRouteImport parentRoute: typeof rootRouteImport } '/nested/$id': { @@ -108,11 +108,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof NestedIdRouteImport parentRoute: typeof NestedRoute } - '/slow/$id': { - id: '/slow/$id' - path: '/slow/$id' - fullPath: '/slow/$id' - preLoaderRoute: typeof SlowIdRouteImport + '/ctx/$id': { + id: '/ctx/$id' + path: '/ctx/$id' + fullPath: '/ctx/$id' + preLoaderRoute: typeof CtxIdRouteImport parentRoute: typeof rootRouteImport } } diff --git a/benchmarks/client-nav/scenarios/control-flow/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/control-flow/solid/src/routeTree.gen.ts index cd84f99d5d..44d88e9f8d 100644 --- a/benchmarks/client-nav/scenarios/control-flow/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/control-flow/solid/src/routeTree.gen.ts @@ -9,26 +9,16 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as BrokenRouteImport } from './routes/broken' -import { Route as Hop1RouteImport } from './routes/hop1' -import { Route as Hop2RouteImport } from './routes/hop2' import { Route as TargetRouteImport } from './routes/target' +import { Route as Hop2RouteImport } from './routes/hop2' +import { Route as Hop1RouteImport } from './routes/hop1' +import { Route as BrokenRouteImport } from './routes/broken' +import { Route as IndexRouteImport } from './routes/index' import { Route as MissingIdRouteImport } from './routes/missing.$id' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BrokenRoute = BrokenRouteImport.update({ - id: '/broken', - path: '/broken', - getParentRoute: () => rootRouteImport, -} as any) -const Hop1Route = Hop1RouteImport.update({ - id: '/hop1', - path: '/hop1', +const TargetRoute = TargetRouteImport.update({ + id: '/target', + path: '/target', getParentRoute: () => rootRouteImport, } as any) const Hop2Route = Hop2RouteImport.update({ @@ -36,9 +26,19 @@ const Hop2Route = Hop2RouteImport.update({ path: '/hop2', getParentRoute: () => rootRouteImport, } as any) -const TargetRoute = TargetRouteImport.update({ - id: '/target', - path: '/target', +const Hop1Route = Hop1RouteImport.update({ + id: '/hop1', + path: '/hop1', + getParentRoute: () => rootRouteImport, +} as any) +const BrokenRoute = BrokenRouteImport.update({ + id: '/broken', + path: '/broken', + getParentRoute: () => rootRouteImport, +} as any) +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', getParentRoute: () => rootRouteImport, } as any) const MissingIdRoute = MissingIdRouteImport.update({ @@ -98,25 +98,11 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/broken': { - id: '/broken' - path: '/broken' - fullPath: '/broken' - preLoaderRoute: typeof BrokenRouteImport - parentRoute: typeof rootRouteImport - } - '/hop1': { - id: '/hop1' - path: '/hop1' - fullPath: '/hop1' - preLoaderRoute: typeof Hop1RouteImport + '/target': { + id: '/target' + path: '/target' + fullPath: '/target' + preLoaderRoute: typeof TargetRouteImport parentRoute: typeof rootRouteImport } '/hop2': { @@ -126,11 +112,25 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof Hop2RouteImport parentRoute: typeof rootRouteImport } - '/target': { - id: '/target' - path: '/target' - fullPath: '/target' - preLoaderRoute: typeof TargetRouteImport + '/hop1': { + id: '/hop1' + path: '/hop1' + fullPath: '/hop1' + preLoaderRoute: typeof Hop1RouteImport + parentRoute: typeof rootRouteImport + } + '/broken': { + id: '/broken' + path: '/broken' + fullPath: '/broken' + preLoaderRoute: typeof BrokenRouteImport + parentRoute: typeof rootRouteImport + } + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } '/missing/$id': { diff --git a/benchmarks/client-nav/scenarios/head/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/head/solid/src/routeTree.gen.ts index b6f217e527..ead6a4436a 100644 --- a/benchmarks/client-nav/scenarios/head/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/head/solid/src/routeTree.gen.ts @@ -9,15 +9,15 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as DocsRouteImport } from './routes/docs' import { Route as SettingsRouteImport } from './routes/settings' -import { Route as ArticlesIdRouteImport } from './routes/articles.$id' +import { Route as DocsRouteImport } from './routes/docs' +import { Route as IndexRouteImport } from './routes/index' import { Route as DocsSectionRouteImport } from './routes/docs.$section' +import { Route as ArticlesIdRouteImport } from './routes/articles.$id' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', +const SettingsRoute = SettingsRouteImport.update({ + id: '/settings', + path: '/settings', getParentRoute: () => rootRouteImport, } as any) const DocsRoute = DocsRouteImport.update({ @@ -25,14 +25,9 @@ const DocsRoute = DocsRouteImport.update({ path: '/docs', getParentRoute: () => rootRouteImport, } as any) -const SettingsRoute = SettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => rootRouteImport, -} as any) -const ArticlesIdRoute = ArticlesIdRouteImport.update({ - id: '/articles/$id', - path: '/articles/$id', +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', getParentRoute: () => rootRouteImport, } as any) const DocsSectionRoute = DocsSectionRouteImport.update({ @@ -40,6 +35,11 @@ const DocsSectionRoute = DocsSectionRouteImport.update({ path: '/$section', getParentRoute: () => DocsRoute, } as any) +const ArticlesIdRoute = ArticlesIdRouteImport.update({ + id: '/articles/$id', + path: '/articles/$id', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -86,11 +86,11 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport + '/settings': { + id: '/settings' + path: '/settings' + fullPath: '/settings' + preLoaderRoute: typeof SettingsRouteImport parentRoute: typeof rootRouteImport } '/docs': { @@ -100,18 +100,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof DocsRouteImport parentRoute: typeof rootRouteImport } - '/settings': { - id: '/settings' - path: '/settings' - fullPath: '/settings' - preLoaderRoute: typeof SettingsRouteImport - parentRoute: typeof rootRouteImport - } - '/articles/$id': { - id: '/articles/$id' - path: '/articles/$id' - fullPath: '/articles/$id' - preLoaderRoute: typeof ArticlesIdRouteImport + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } '/docs/$section': { @@ -121,6 +114,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof DocsSectionRouteImport parentRoute: typeof DocsRoute } + '/articles/$id': { + id: '/articles/$id' + path: '/articles/$id' + fullPath: '/articles/$id' + preLoaderRoute: typeof ArticlesIdRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/benchmarks/client-nav/scenarios/history/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/history/solid/src/routeTree.gen.ts index af253f4a15..a6ab2a4fc8 100644 --- a/benchmarks/client-nav/scenarios/history/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/history/solid/src/routeTree.gen.ts @@ -9,24 +9,19 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' import { Route as GalleryRouteImport } from './routes/gallery' -import { Route as PagesNRouteImport } from './routes/pages.$n' +import { Route as IndexRouteImport } from './routes/index' import { Route as PhotosPhotoIdRouteImport } from './routes/photos.$photoId' +import { Route as PagesNRouteImport } from './routes/pages.$n' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) const GalleryRoute = GalleryRouteImport.update({ id: '/gallery', path: '/gallery', getParentRoute: () => rootRouteImport, } as any) -const PagesNRoute = PagesNRouteImport.update({ - id: '/pages/$n', - path: '/pages/$n', +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', getParentRoute: () => rootRouteImport, } as any) const PhotosPhotoIdRoute = PhotosPhotoIdRouteImport.update({ @@ -34,6 +29,11 @@ const PhotosPhotoIdRoute = PhotosPhotoIdRouteImport.update({ path: '/photos/$photoId', getParentRoute: () => rootRouteImport, } as any) +const PagesNRoute = PagesNRouteImport.update({ + id: '/pages/$n', + path: '/pages/$n', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -71,13 +71,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } '/gallery': { id: '/gallery' path: '/gallery' @@ -85,11 +78,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof GalleryRouteImport parentRoute: typeof rootRouteImport } - '/pages/$n': { - id: '/pages/$n' - path: '/pages/$n' - fullPath: '/pages/$n' - preLoaderRoute: typeof PagesNRouteImport + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } '/photos/$photoId': { @@ -99,6 +92,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof PhotosPhotoIdRouteImport parentRoute: typeof rootRouteImport } + '/pages/$n': { + id: '/pages/$n' + path: '/pages/$n' + fullPath: '/pages/$n' + preLoaderRoute: typeof PagesNRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/benchmarks/client-nav/scenarios/links/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/links/solid/src/routeTree.gen.ts index 0da70513e8..b61431e40d 100644 --- a/benchmarks/client-nav/scenarios/links/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/links/solid/src/routeTree.gen.ts @@ -9,20 +9,20 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' import { Route as ItemsIdRouteImport } from './routes/items.$id' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) const AboutRoute = AboutRouteImport.update({ id: '/about', path: '/about', getParentRoute: () => rootRouteImport, } as any) +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => rootRouteImport, +} as any) const ItemsIdRoute = ItemsIdRouteImport.update({ id: '/items/$id', path: '/items/$id', @@ -61,13 +61,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } '/about': { id: '/about' path: '/about' @@ -75,6 +68,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof AboutRouteImport parentRoute: typeof rootRouteImport } + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } '/items/$id': { id: '/items/$id' path: '/items/$id' diff --git a/benchmarks/client-nav/scenarios/loaders/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/loaders/solid/src/routeTree.gen.ts index fa5d032141..bdec400237 100644 --- a/benchmarks/client-nav/scenarios/loaders/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/loaders/solid/src/routeTree.gen.ts @@ -9,24 +9,19 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' import { Route as DepsRouteImport } from './routes/deps' -import { Route as CachedIdRouteImport } from './routes/cached.$id' +import { Route as IndexRouteImport } from './routes/index' import { Route as FreshIdRouteImport } from './routes/fresh.$id' +import { Route as CachedIdRouteImport } from './routes/cached.$id' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) const DepsRoute = DepsRouteImport.update({ id: '/deps', path: '/deps', getParentRoute: () => rootRouteImport, } as any) -const CachedIdRoute = CachedIdRouteImport.update({ - id: '/cached/$id', - path: '/cached/$id', +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', getParentRoute: () => rootRouteImport, } as any) const FreshIdRoute = FreshIdRouteImport.update({ @@ -34,6 +29,11 @@ const FreshIdRoute = FreshIdRouteImport.update({ path: '/fresh/$id', getParentRoute: () => rootRouteImport, } as any) +const CachedIdRoute = CachedIdRouteImport.update({ + id: '/cached/$id', + path: '/cached/$id', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -71,13 +71,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } '/deps': { id: '/deps' path: '/deps' @@ -85,11 +78,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof DepsRouteImport parentRoute: typeof rootRouteImport } - '/cached/$id': { - id: '/cached/$id' - path: '/cached/$id' - fullPath: '/cached/$id' - preLoaderRoute: typeof CachedIdRouteImport + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } '/fresh/$id': { @@ -99,6 +92,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof FreshIdRouteImport parentRoute: typeof rootRouteImport } + '/cached/$id': { + id: '/cached/$id' + path: '/cached/$id' + fullPath: '/cached/$id' + preLoaderRoute: typeof CachedIdRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/benchmarks/client-nav/scenarios/mount/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/mount/solid/src/routeTree.gen.ts index 30247636dd..dc0acc183d 100644 --- a/benchmarks/client-nav/scenarios/mount/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/mount/solid/src/routeTree.gen.ts @@ -9,35 +9,20 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as AboutRouteImport } from './routes/about' -import { Route as BlogRouteImport } from './routes/blog' -import { Route as SearchRouteImport } from './routes/search' -import { Route as SettingsRouteImport } from './routes/settings' import { Route as ShopRouteImport } from './routes/shop' -import { Route as BlogIndexRouteImport } from './routes/blog.index' -import { Route as BlogSlugRouteImport } from './routes/blog.$slug' +import { Route as SettingsRouteImport } from './routes/settings' +import { Route as SearchRouteImport } from './routes/search' +import { Route as BlogRouteImport } from './routes/blog' +import { Route as AboutRouteImport } from './routes/about' +import { Route as IndexRouteImport } from './routes/index' import { Route as ShopIndexRouteImport } from './routes/shop.index' +import { Route as BlogIndexRouteImport } from './routes/blog.index' import { Route as ShopProductIdRouteImport } from './routes/shop.$productId' +import { Route as BlogSlugRouteImport } from './routes/blog.$slug' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const AboutRoute = AboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRoute = BlogRouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) -const SearchRoute = SearchRouteImport.update({ - id: '/search', - path: '/search', +const ShopRoute = ShopRouteImport.update({ + id: '/shop', + path: '/shop', getParentRoute: () => rootRouteImport, } as any) const SettingsRoute = SettingsRouteImport.update({ @@ -45,31 +30,46 @@ const SettingsRoute = SettingsRouteImport.update({ path: '/settings', getParentRoute: () => rootRouteImport, } as any) -const ShopRoute = ShopRouteImport.update({ - id: '/shop', - path: '/shop', +const SearchRoute = SearchRouteImport.update({ + id: '/search', + path: '/search', getParentRoute: () => rootRouteImport, } as any) -const BlogIndexRoute = BlogIndexRouteImport.update({ +const BlogRoute = BlogRouteImport.update({ + id: '/blog', + path: '/blog', + getParentRoute: () => rootRouteImport, +} as any) +const AboutRoute = AboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => rootRouteImport, +} as any) +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => BlogRoute, -} as any) -const BlogSlugRoute = BlogSlugRouteImport.update({ - id: '/$slug', - path: '/$slug', - getParentRoute: () => BlogRoute, + getParentRoute: () => rootRouteImport, } as any) const ShopIndexRoute = ShopIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => ShopRoute, } as any) +const BlogIndexRoute = BlogIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => BlogRoute, +} as any) const ShopProductIdRoute = ShopProductIdRouteImport.update({ id: '/$productId', path: '/$productId', getParentRoute: () => ShopRoute, } as any) +const BlogSlugRoute = BlogSlugRouteImport.update({ + id: '/$slug', + path: '/$slug', + getParentRoute: () => BlogRoute, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -154,32 +154,11 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/about': { - id: '/about' - path: '/about' - fullPath: '/about' - preLoaderRoute: typeof AboutRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogRouteImport - parentRoute: typeof rootRouteImport - } - '/search': { - id: '/search' - path: '/search' - fullPath: '/search' - preLoaderRoute: typeof SearchRouteImport + '/shop': { + id: '/shop' + path: '/shop' + fullPath: '/shop' + preLoaderRoute: typeof ShopRouteImport parentRoute: typeof rootRouteImport } '/settings': { @@ -189,26 +168,33 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof SettingsRouteImport parentRoute: typeof rootRouteImport } - '/shop': { - id: '/shop' - path: '/shop' - fullPath: '/shop' - preLoaderRoute: typeof ShopRouteImport + '/search': { + id: '/search' + path: '/search' + fullPath: '/search' + preLoaderRoute: typeof SearchRouteImport parentRoute: typeof rootRouteImport } - '/blog/': { - id: '/blog/' - path: '/' - fullPath: '/blog/' - preLoaderRoute: typeof BlogIndexRouteImport - parentRoute: typeof BlogRoute + '/blog': { + id: '/blog' + path: '/blog' + fullPath: '/blog' + preLoaderRoute: typeof BlogRouteImport + parentRoute: typeof rootRouteImport } - '/blog/$slug': { - id: '/blog/$slug' - path: '/$slug' - fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugRouteImport - parentRoute: typeof BlogRoute + '/about': { + id: '/about' + path: '/about' + fullPath: '/about' + preLoaderRoute: typeof AboutRouteImport + parentRoute: typeof rootRouteImport + } + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport } '/shop/': { id: '/shop/' @@ -217,6 +203,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof ShopIndexRouteImport parentRoute: typeof ShopRoute } + '/blog/': { + id: '/blog/' + path: '/' + fullPath: '/blog/' + preLoaderRoute: typeof BlogIndexRouteImport + parentRoute: typeof BlogRoute + } '/shop/$productId': { id: '/shop/$productId' path: '/$productId' @@ -224,6 +217,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof ShopProductIdRouteImport parentRoute: typeof ShopRoute } + '/blog/$slug': { + id: '/blog/$slug' + path: '/$slug' + fullPath: '/blog/$slug' + preLoaderRoute: typeof BlogSlugRouteImport + parentRoute: typeof BlogRoute + } } } diff --git a/benchmarks/client-nav/scenarios/preload/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/preload/solid/src/routeTree.gen.ts index 97e215b6da..645d925238 100644 --- a/benchmarks/client-nav/scenarios/preload/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/preload/solid/src/routeTree.gen.ts @@ -9,20 +9,20 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' import { Route as DocsRouteImport } from './routes/docs' +import { Route as IndexRouteImport } from './routes/index' import { Route as SectionsSectionRouteImport } from './routes/sections.$section' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) const DocsRoute = DocsRouteImport.update({ id: '/docs', path: '/docs', getParentRoute: () => rootRouteImport, } as any) +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => rootRouteImport, +} as any) const SectionsSectionRoute = SectionsSectionRouteImport.update({ id: '/sections/$section', path: '/sections/$section', @@ -61,13 +61,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } '/docs': { id: '/docs' path: '/docs' @@ -75,6 +68,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof DocsRouteImport parentRoute: typeof rootRouteImport } + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport + } '/sections/$section': { id: '/sections/$section' path: '/sections/$section' diff --git a/benchmarks/client-nav/scenarios/route-tree-scale/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/route-tree-scale/solid/src/routeTree.gen.ts index e6f3596562..20b4af6146 100644 --- a/benchmarks/client-nav/scenarios/route-tree-scale/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/route-tree-scale/solid/src/routeTree.gen.ts @@ -9,72 +9,48 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as LayoutRouteImport } from './routes/_layout' -import { Route as SecARouteImport } from './routes/sec-a' -import { Route as SecBRouteImport } from './routes/sec-b' -import { Route as SecCRouteImport } from './routes/sec-c' -import { Route as SecDRouteImport } from './routes/sec-d' -import { Route as SecERouteImport } from './routes/sec-e' import { Route as SecFRouteImport } from './routes/sec-f' -import { Route as marketingPricingRouteImport } from './routes/(marketing)/pricing' -import { Route as marketingPromoRouteImport } from './routes/(marketing)/promo' -import { Route as LayoutAlphaRouteImport } from './routes/_layout.alpha' -import { Route as LayoutBetaRouteImport } from './routes/_layout.beta' -import { Route as FilesSplatRouteImport } from './routes/files.$' -import { Route as ReleaseVChar123versionChar125RouteImport } from './routes/release.v{$version}' -import { Route as SecAIndexRouteImport } from './routes/sec-a.index' -import { Route as SecAIdRouteImport } from './routes/sec-a.$id' -import { Route as SecAAboutRouteImport } from './routes/sec-a.about' -import { Route as SecASettingsRouteImport } from './routes/sec-a.settings' -import { Route as SecBIndexRouteImport } from './routes/sec-b.index' -import { Route as SecBIdRouteImport } from './routes/sec-b.$id' -import { Route as SecBAboutRouteImport } from './routes/sec-b.about' -import { Route as SecBSettingsRouteImport } from './routes/sec-b.settings' -import { Route as SecCIndexRouteImport } from './routes/sec-c.index' -import { Route as SecCIdRouteImport } from './routes/sec-c.$id' -import { Route as SecCAboutRouteImport } from './routes/sec-c.about' -import { Route as SecCSettingsRouteImport } from './routes/sec-c.settings' -import { Route as SecDIndexRouteImport } from './routes/sec-d.index' -import { Route as SecDIdRouteImport } from './routes/sec-d.$id' -import { Route as SecDAboutRouteImport } from './routes/sec-d.about' -import { Route as SecDSettingsRouteImport } from './routes/sec-d.settings' -import { Route as SecEIndexRouteImport } from './routes/sec-e.index' -import { Route as SecEIdRouteImport } from './routes/sec-e.$id' -import { Route as SecEAboutRouteImport } from './routes/sec-e.about' -import { Route as SecESettingsRouteImport } from './routes/sec-e.settings' +import { Route as SecERouteImport } from './routes/sec-e' +import { Route as SecDRouteImport } from './routes/sec-d' +import { Route as SecCRouteImport } from './routes/sec-c' +import { Route as SecBRouteImport } from './routes/sec-b' +import { Route as SecARouteImport } from './routes/sec-a' +import { Route as LayoutRouteImport } from './routes/_layout' +import { Route as IndexRouteImport } from './routes/index' import { Route as SecFIndexRouteImport } from './routes/sec-f.index' -import { Route as SecFIdRouteImport } from './routes/sec-f.$id' -import { Route as SecFAboutRouteImport } from './routes/sec-f.about' +import { Route as SecEIndexRouteImport } from './routes/sec-e.index' +import { Route as SecDIndexRouteImport } from './routes/sec-d.index' +import { Route as SecCIndexRouteImport } from './routes/sec-c.index' +import { Route as SecBIndexRouteImport } from './routes/sec-b.index' +import { Route as SecAIndexRouteImport } from './routes/sec-a.index' import { Route as SecFSettingsRouteImport } from './routes/sec-f.settings' +import { Route as SecFAboutRouteImport } from './routes/sec-f.about' +import { Route as SecFIdRouteImport } from './routes/sec-f.$id' +import { Route as SecESettingsRouteImport } from './routes/sec-e.settings' +import { Route as SecEAboutRouteImport } from './routes/sec-e.about' +import { Route as SecEIdRouteImport } from './routes/sec-e.$id' +import { Route as SecDSettingsRouteImport } from './routes/sec-d.settings' +import { Route as SecDAboutRouteImport } from './routes/sec-d.about' +import { Route as SecDIdRouteImport } from './routes/sec-d.$id' +import { Route as SecCSettingsRouteImport } from './routes/sec-c.settings' +import { Route as SecCAboutRouteImport } from './routes/sec-c.about' +import { Route as SecCIdRouteImport } from './routes/sec-c.$id' +import { Route as SecBSettingsRouteImport } from './routes/sec-b.settings' +import { Route as SecBAboutRouteImport } from './routes/sec-b.about' +import { Route as SecBIdRouteImport } from './routes/sec-b.$id' +import { Route as SecASettingsRouteImport } from './routes/sec-a.settings' +import { Route as SecAAboutRouteImport } from './routes/sec-a.about' +import { Route as SecAIdRouteImport } from './routes/sec-a.$id' +import { Route as ReleaseVChar123versionChar125RouteImport } from './routes/release.v{$version}' +import { Route as FilesSplatRouteImport } from './routes/files.$' +import { Route as LayoutBetaRouteImport } from './routes/_layout.beta' +import { Route as LayoutAlphaRouteImport } from './routes/_layout.alpha' +import { Route as marketingPromoRouteImport } from './routes/(marketing)/promo' +import { Route as marketingPricingRouteImport } from './routes/(marketing)/pricing' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutRoute = LayoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const SecARoute = SecARouteImport.update({ - id: '/sec-a', - path: '/sec-a', - getParentRoute: () => rootRouteImport, -} as any) -const SecBRoute = SecBRouteImport.update({ - id: '/sec-b', - path: '/sec-b', - getParentRoute: () => rootRouteImport, -} as any) -const SecCRoute = SecCRouteImport.update({ - id: '/sec-c', - path: '/sec-c', - getParentRoute: () => rootRouteImport, -} as any) -const SecDRoute = SecDRouteImport.update({ - id: '/sec-d', - path: '/sec-d', +const SecFRoute = SecFRouteImport.update({ + id: '/sec-f', + path: '/sec-f', getParentRoute: () => rootRouteImport, } as any) const SecERoute = SecERouteImport.update({ @@ -82,150 +58,68 @@ const SecERoute = SecERouteImport.update({ path: '/sec-e', getParentRoute: () => rootRouteImport, } as any) -const SecFRoute = SecFRouteImport.update({ - id: '/sec-f', - path: '/sec-f', +const SecDRoute = SecDRouteImport.update({ + id: '/sec-d', + path: '/sec-d', getParentRoute: () => rootRouteImport, } as any) -const marketingPricingRoute = marketingPricingRouteImport.update({ - id: '/(marketing)/pricing', - path: '/pricing', +const SecCRoute = SecCRouteImport.update({ + id: '/sec-c', + path: '/sec-c', getParentRoute: () => rootRouteImport, } as any) -const marketingPromoRoute = marketingPromoRouteImport.update({ - id: '/(marketing)/promo', - path: '/promo', +const SecBRoute = SecBRouteImport.update({ + id: '/sec-b', + path: '/sec-b', getParentRoute: () => rootRouteImport, } as any) -const LayoutAlphaRoute = LayoutAlphaRouteImport.update({ - id: '/alpha', - path: '/alpha', - getParentRoute: () => LayoutRoute, -} as any) -const LayoutBetaRoute = LayoutBetaRouteImport.update({ - id: '/beta', - path: '/beta', - getParentRoute: () => LayoutRoute, -} as any) -const FilesSplatRoute = FilesSplatRouteImport.update({ - id: '/files/$', - path: '/files/$', +const SecARoute = SecARouteImport.update({ + id: '/sec-a', + path: '/sec-a', getParentRoute: () => rootRouteImport, } as any) -const ReleaseVChar123versionChar125Route = - ReleaseVChar123versionChar125RouteImport.update({ - id: '/release/v{$version}', - path: '/release/v{$version}', - getParentRoute: () => rootRouteImport, - } as any) -const SecAIndexRoute = SecAIndexRouteImport.update({ +const LayoutRoute = LayoutRouteImport.update({ + id: '/_layout', + getParentRoute: () => rootRouteImport, +} as any) +const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', - getParentRoute: () => SecARoute, -} as any) -const SecAIdRoute = SecAIdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => SecARoute, -} as any) -const SecAAboutRoute = SecAAboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => SecARoute, -} as any) -const SecASettingsRoute = SecASettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => SecARoute, -} as any) -const SecBIndexRoute = SecBIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => SecBRoute, -} as any) -const SecBIdRoute = SecBIdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => SecBRoute, -} as any) -const SecBAboutRoute = SecBAboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => SecBRoute, -} as any) -const SecBSettingsRoute = SecBSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => SecBRoute, -} as any) -const SecCIndexRoute = SecCIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => SecCRoute, -} as any) -const SecCIdRoute = SecCIdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => SecCRoute, -} as any) -const SecCAboutRoute = SecCAboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => SecCRoute, -} as any) -const SecCSettingsRoute = SecCSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => SecCRoute, -} as any) -const SecDIndexRoute = SecDIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => SecDRoute, -} as any) -const SecDIdRoute = SecDIdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => SecDRoute, -} as any) -const SecDAboutRoute = SecDAboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => SecDRoute, -} as any) -const SecDSettingsRoute = SecDSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => SecDRoute, -} as any) -const SecEIndexRoute = SecEIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => SecERoute, -} as any) -const SecEIdRoute = SecEIdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => SecERoute, -} as any) -const SecEAboutRoute = SecEAboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => SecERoute, -} as any) -const SecESettingsRoute = SecESettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => SecERoute, + getParentRoute: () => rootRouteImport, } as any) const SecFIndexRoute = SecFIndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => SecFRoute, } as any) -const SecFIdRoute = SecFIdRouteImport.update({ - id: '/$id', - path: '/$id', +const SecEIndexRoute = SecEIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => SecERoute, +} as any) +const SecDIndexRoute = SecDIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => SecDRoute, +} as any) +const SecCIndexRoute = SecCIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => SecCRoute, +} as any) +const SecBIndexRoute = SecBIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => SecBRoute, +} as any) +const SecAIndexRoute = SecAIndexRouteImport.update({ + id: '/', + path: '/', + getParentRoute: () => SecARoute, +} as any) +const SecFSettingsRoute = SecFSettingsRouteImport.update({ + id: '/settings', + path: '/settings', getParentRoute: () => SecFRoute, } as any) const SecFAboutRoute = SecFAboutRouteImport.update({ @@ -233,10 +127,116 @@ const SecFAboutRoute = SecFAboutRouteImport.update({ path: '/about', getParentRoute: () => SecFRoute, } as any) -const SecFSettingsRoute = SecFSettingsRouteImport.update({ +const SecFIdRoute = SecFIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecFRoute, +} as any) +const SecESettingsRoute = SecESettingsRouteImport.update({ id: '/settings', path: '/settings', - getParentRoute: () => SecFRoute, + getParentRoute: () => SecERoute, +} as any) +const SecEAboutRoute = SecEAboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => SecERoute, +} as any) +const SecEIdRoute = SecEIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecERoute, +} as any) +const SecDSettingsRoute = SecDSettingsRouteImport.update({ + id: '/settings', + path: '/settings', + getParentRoute: () => SecDRoute, +} as any) +const SecDAboutRoute = SecDAboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => SecDRoute, +} as any) +const SecDIdRoute = SecDIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecDRoute, +} as any) +const SecCSettingsRoute = SecCSettingsRouteImport.update({ + id: '/settings', + path: '/settings', + getParentRoute: () => SecCRoute, +} as any) +const SecCAboutRoute = SecCAboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => SecCRoute, +} as any) +const SecCIdRoute = SecCIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecCRoute, +} as any) +const SecBSettingsRoute = SecBSettingsRouteImport.update({ + id: '/settings', + path: '/settings', + getParentRoute: () => SecBRoute, +} as any) +const SecBAboutRoute = SecBAboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => SecBRoute, +} as any) +const SecBIdRoute = SecBIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecBRoute, +} as any) +const SecASettingsRoute = SecASettingsRouteImport.update({ + id: '/settings', + path: '/settings', + getParentRoute: () => SecARoute, +} as any) +const SecAAboutRoute = SecAAboutRouteImport.update({ + id: '/about', + path: '/about', + getParentRoute: () => SecARoute, +} as any) +const SecAIdRoute = SecAIdRouteImport.update({ + id: '/$id', + path: '/$id', + getParentRoute: () => SecARoute, +} as any) +const ReleaseVChar123versionChar125Route = + ReleaseVChar123versionChar125RouteImport.update({ + id: '/release/v{$version}', + path: '/release/v{$version}', + getParentRoute: () => rootRouteImport, + } as any) +const FilesSplatRoute = FilesSplatRouteImport.update({ + id: '/files/$', + path: '/files/$', + getParentRoute: () => rootRouteImport, +} as any) +const LayoutBetaRoute = LayoutBetaRouteImport.update({ + id: '/beta', + path: '/beta', + getParentRoute: () => LayoutRoute, +} as any) +const LayoutAlphaRoute = LayoutAlphaRouteImport.update({ + id: '/alpha', + path: '/alpha', + getParentRoute: () => LayoutRoute, +} as any) +const marketingPromoRoute = marketingPromoRouteImport.update({ + id: '/(marketing)/promo', + path: '/promo', + getParentRoute: () => rootRouteImport, +} as any) +const marketingPricingRoute = marketingPricingRouteImport.update({ + id: '/(marketing)/pricing', + path: '/pricing', + getParentRoute: () => rootRouteImport, } as any) export interface FileRoutesByFullPath { @@ -484,46 +484,11 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/sec-a': { - id: '/sec-a' - path: '/sec-a' - fullPath: '/sec-a' - preLoaderRoute: typeof SecARouteImport - parentRoute: typeof rootRouteImport - } - '/sec-b': { - id: '/sec-b' - path: '/sec-b' - fullPath: '/sec-b' - preLoaderRoute: typeof SecBRouteImport - parentRoute: typeof rootRouteImport - } - '/sec-c': { - id: '/sec-c' - path: '/sec-c' - fullPath: '/sec-c' - preLoaderRoute: typeof SecCRouteImport - parentRoute: typeof rootRouteImport - } - '/sec-d': { - id: '/sec-d' - path: '/sec-d' - fullPath: '/sec-d' - preLoaderRoute: typeof SecDRouteImport + '/sec-f': { + id: '/sec-f' + path: '/sec-f' + fullPath: '/sec-f' + preLoaderRoute: typeof SecFRouteImport parentRoute: typeof rootRouteImport } '/sec-e': { @@ -533,194 +498,47 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof SecERouteImport parentRoute: typeof rootRouteImport } - '/sec-f': { - id: '/sec-f' - path: '/sec-f' - fullPath: '/sec-f' - preLoaderRoute: typeof SecFRouteImport + '/sec-d': { + id: '/sec-d' + path: '/sec-d' + fullPath: '/sec-d' + preLoaderRoute: typeof SecDRouteImport parentRoute: typeof rootRouteImport } - '/(marketing)/pricing': { - id: '/(marketing)/pricing' - path: '/pricing' - fullPath: '/pricing' - preLoaderRoute: typeof marketingPricingRouteImport + '/sec-c': { + id: '/sec-c' + path: '/sec-c' + fullPath: '/sec-c' + preLoaderRoute: typeof SecCRouteImport parentRoute: typeof rootRouteImport } - '/(marketing)/promo': { - id: '/(marketing)/promo' - path: '/promo' - fullPath: '/promo' - preLoaderRoute: typeof marketingPromoRouteImport + '/sec-b': { + id: '/sec-b' + path: '/sec-b' + fullPath: '/sec-b' + preLoaderRoute: typeof SecBRouteImport parentRoute: typeof rootRouteImport } - '/_layout/alpha': { - id: '/_layout/alpha' - path: '/alpha' - fullPath: '/alpha' - preLoaderRoute: typeof LayoutAlphaRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/beta': { - id: '/_layout/beta' - path: '/beta' - fullPath: '/beta' - preLoaderRoute: typeof LayoutBetaRouteImport - parentRoute: typeof LayoutRoute - } - '/files/$': { - id: '/files/$' - path: '/files/$' - fullPath: '/files/$' - preLoaderRoute: typeof FilesSplatRouteImport + '/sec-a': { + id: '/sec-a' + path: '/sec-a' + fullPath: '/sec-a' + preLoaderRoute: typeof SecARouteImport parentRoute: typeof rootRouteImport } - '/release/v{$version}': { - id: '/release/v{$version}' - path: '/release/v{$version}' - fullPath: '/release/v{$version}' - preLoaderRoute: typeof ReleaseVChar123versionChar125RouteImport + '/_layout': { + id: '/_layout' + path: '' + fullPath: '/' + preLoaderRoute: typeof LayoutRouteImport parentRoute: typeof rootRouteImport } - '/sec-a/': { - id: '/sec-a/' + '/': { + id: '/' path: '/' - fullPath: '/sec-a/' - preLoaderRoute: typeof SecAIndexRouteImport - parentRoute: typeof SecARoute - } - '/sec-a/$id': { - id: '/sec-a/$id' - path: '/$id' - fullPath: '/sec-a/$id' - preLoaderRoute: typeof SecAIdRouteImport - parentRoute: typeof SecARoute - } - '/sec-a/about': { - id: '/sec-a/about' - path: '/about' - fullPath: '/sec-a/about' - preLoaderRoute: typeof SecAAboutRouteImport - parentRoute: typeof SecARoute - } - '/sec-a/settings': { - id: '/sec-a/settings' - path: '/settings' - fullPath: '/sec-a/settings' - preLoaderRoute: typeof SecASettingsRouteImport - parentRoute: typeof SecARoute - } - '/sec-b/': { - id: '/sec-b/' - path: '/' - fullPath: '/sec-b/' - preLoaderRoute: typeof SecBIndexRouteImport - parentRoute: typeof SecBRoute - } - '/sec-b/$id': { - id: '/sec-b/$id' - path: '/$id' - fullPath: '/sec-b/$id' - preLoaderRoute: typeof SecBIdRouteImport - parentRoute: typeof SecBRoute - } - '/sec-b/about': { - id: '/sec-b/about' - path: '/about' - fullPath: '/sec-b/about' - preLoaderRoute: typeof SecBAboutRouteImport - parentRoute: typeof SecBRoute - } - '/sec-b/settings': { - id: '/sec-b/settings' - path: '/settings' - fullPath: '/sec-b/settings' - preLoaderRoute: typeof SecBSettingsRouteImport - parentRoute: typeof SecBRoute - } - '/sec-c/': { - id: '/sec-c/' - path: '/' - fullPath: '/sec-c/' - preLoaderRoute: typeof SecCIndexRouteImport - parentRoute: typeof SecCRoute - } - '/sec-c/$id': { - id: '/sec-c/$id' - path: '/$id' - fullPath: '/sec-c/$id' - preLoaderRoute: typeof SecCIdRouteImport - parentRoute: typeof SecCRoute - } - '/sec-c/about': { - id: '/sec-c/about' - path: '/about' - fullPath: '/sec-c/about' - preLoaderRoute: typeof SecCAboutRouteImport - parentRoute: typeof SecCRoute - } - '/sec-c/settings': { - id: '/sec-c/settings' - path: '/settings' - fullPath: '/sec-c/settings' - preLoaderRoute: typeof SecCSettingsRouteImport - parentRoute: typeof SecCRoute - } - '/sec-d/': { - id: '/sec-d/' - path: '/' - fullPath: '/sec-d/' - preLoaderRoute: typeof SecDIndexRouteImport - parentRoute: typeof SecDRoute - } - '/sec-d/$id': { - id: '/sec-d/$id' - path: '/$id' - fullPath: '/sec-d/$id' - preLoaderRoute: typeof SecDIdRouteImport - parentRoute: typeof SecDRoute - } - '/sec-d/about': { - id: '/sec-d/about' - path: '/about' - fullPath: '/sec-d/about' - preLoaderRoute: typeof SecDAboutRouteImport - parentRoute: typeof SecDRoute - } - '/sec-d/settings': { - id: '/sec-d/settings' - path: '/settings' - fullPath: '/sec-d/settings' - preLoaderRoute: typeof SecDSettingsRouteImport - parentRoute: typeof SecDRoute - } - '/sec-e/': { - id: '/sec-e/' - path: '/' - fullPath: '/sec-e/' - preLoaderRoute: typeof SecEIndexRouteImport - parentRoute: typeof SecERoute - } - '/sec-e/$id': { - id: '/sec-e/$id' - path: '/$id' - fullPath: '/sec-e/$id' - preLoaderRoute: typeof SecEIdRouteImport - parentRoute: typeof SecERoute - } - '/sec-e/about': { - id: '/sec-e/about' - path: '/about' - fullPath: '/sec-e/about' - preLoaderRoute: typeof SecEAboutRouteImport - parentRoute: typeof SecERoute - } - '/sec-e/settings': { - id: '/sec-e/settings' - path: '/settings' - fullPath: '/sec-e/settings' - preLoaderRoute: typeof SecESettingsRouteImport - parentRoute: typeof SecERoute + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport + parentRoute: typeof rootRouteImport } '/sec-f/': { id: '/sec-f/' @@ -729,11 +547,46 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof SecFIndexRouteImport parentRoute: typeof SecFRoute } - '/sec-f/$id': { - id: '/sec-f/$id' - path: '/$id' - fullPath: '/sec-f/$id' - preLoaderRoute: typeof SecFIdRouteImport + '/sec-e/': { + id: '/sec-e/' + path: '/' + fullPath: '/sec-e/' + preLoaderRoute: typeof SecEIndexRouteImport + parentRoute: typeof SecERoute + } + '/sec-d/': { + id: '/sec-d/' + path: '/' + fullPath: '/sec-d/' + preLoaderRoute: typeof SecDIndexRouteImport + parentRoute: typeof SecDRoute + } + '/sec-c/': { + id: '/sec-c/' + path: '/' + fullPath: '/sec-c/' + preLoaderRoute: typeof SecCIndexRouteImport + parentRoute: typeof SecCRoute + } + '/sec-b/': { + id: '/sec-b/' + path: '/' + fullPath: '/sec-b/' + preLoaderRoute: typeof SecBIndexRouteImport + parentRoute: typeof SecBRoute + } + '/sec-a/': { + id: '/sec-a/' + path: '/' + fullPath: '/sec-a/' + preLoaderRoute: typeof SecAIndexRouteImport + parentRoute: typeof SecARoute + } + '/sec-f/settings': { + id: '/sec-f/settings' + path: '/settings' + fullPath: '/sec-f/settings' + preLoaderRoute: typeof SecFSettingsRouteImport parentRoute: typeof SecFRoute } '/sec-f/about': { @@ -743,13 +596,160 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof SecFAboutRouteImport parentRoute: typeof SecFRoute } - '/sec-f/settings': { - id: '/sec-f/settings' - path: '/settings' - fullPath: '/sec-f/settings' - preLoaderRoute: typeof SecFSettingsRouteImport + '/sec-f/$id': { + id: '/sec-f/$id' + path: '/$id' + fullPath: '/sec-f/$id' + preLoaderRoute: typeof SecFIdRouteImport parentRoute: typeof SecFRoute } + '/sec-e/settings': { + id: '/sec-e/settings' + path: '/settings' + fullPath: '/sec-e/settings' + preLoaderRoute: typeof SecESettingsRouteImport + parentRoute: typeof SecERoute + } + '/sec-e/about': { + id: '/sec-e/about' + path: '/about' + fullPath: '/sec-e/about' + preLoaderRoute: typeof SecEAboutRouteImport + parentRoute: typeof SecERoute + } + '/sec-e/$id': { + id: '/sec-e/$id' + path: '/$id' + fullPath: '/sec-e/$id' + preLoaderRoute: typeof SecEIdRouteImport + parentRoute: typeof SecERoute + } + '/sec-d/settings': { + id: '/sec-d/settings' + path: '/settings' + fullPath: '/sec-d/settings' + preLoaderRoute: typeof SecDSettingsRouteImport + parentRoute: typeof SecDRoute + } + '/sec-d/about': { + id: '/sec-d/about' + path: '/about' + fullPath: '/sec-d/about' + preLoaderRoute: typeof SecDAboutRouteImport + parentRoute: typeof SecDRoute + } + '/sec-d/$id': { + id: '/sec-d/$id' + path: '/$id' + fullPath: '/sec-d/$id' + preLoaderRoute: typeof SecDIdRouteImport + parentRoute: typeof SecDRoute + } + '/sec-c/settings': { + id: '/sec-c/settings' + path: '/settings' + fullPath: '/sec-c/settings' + preLoaderRoute: typeof SecCSettingsRouteImport + parentRoute: typeof SecCRoute + } + '/sec-c/about': { + id: '/sec-c/about' + path: '/about' + fullPath: '/sec-c/about' + preLoaderRoute: typeof SecCAboutRouteImport + parentRoute: typeof SecCRoute + } + '/sec-c/$id': { + id: '/sec-c/$id' + path: '/$id' + fullPath: '/sec-c/$id' + preLoaderRoute: typeof SecCIdRouteImport + parentRoute: typeof SecCRoute + } + '/sec-b/settings': { + id: '/sec-b/settings' + path: '/settings' + fullPath: '/sec-b/settings' + preLoaderRoute: typeof SecBSettingsRouteImport + parentRoute: typeof SecBRoute + } + '/sec-b/about': { + id: '/sec-b/about' + path: '/about' + fullPath: '/sec-b/about' + preLoaderRoute: typeof SecBAboutRouteImport + parentRoute: typeof SecBRoute + } + '/sec-b/$id': { + id: '/sec-b/$id' + path: '/$id' + fullPath: '/sec-b/$id' + preLoaderRoute: typeof SecBIdRouteImport + parentRoute: typeof SecBRoute + } + '/sec-a/settings': { + id: '/sec-a/settings' + path: '/settings' + fullPath: '/sec-a/settings' + preLoaderRoute: typeof SecASettingsRouteImport + parentRoute: typeof SecARoute + } + '/sec-a/about': { + id: '/sec-a/about' + path: '/about' + fullPath: '/sec-a/about' + preLoaderRoute: typeof SecAAboutRouteImport + parentRoute: typeof SecARoute + } + '/sec-a/$id': { + id: '/sec-a/$id' + path: '/$id' + fullPath: '/sec-a/$id' + preLoaderRoute: typeof SecAIdRouteImport + parentRoute: typeof SecARoute + } + '/release/v{$version}': { + id: '/release/v{$version}' + path: '/release/v{$version}' + fullPath: '/release/v{$version}' + preLoaderRoute: typeof ReleaseVChar123versionChar125RouteImport + parentRoute: typeof rootRouteImport + } + '/files/$': { + id: '/files/$' + path: '/files/$' + fullPath: '/files/$' + preLoaderRoute: typeof FilesSplatRouteImport + parentRoute: typeof rootRouteImport + } + '/_layout/beta': { + id: '/_layout/beta' + path: '/beta' + fullPath: '/beta' + preLoaderRoute: typeof LayoutBetaRouteImport + parentRoute: typeof LayoutRoute + } + '/_layout/alpha': { + id: '/_layout/alpha' + path: '/alpha' + fullPath: '/alpha' + preLoaderRoute: typeof LayoutAlphaRouteImport + parentRoute: typeof LayoutRoute + } + '/(marketing)/promo': { + id: '/(marketing)/promo' + path: '/promo' + fullPath: '/promo' + preLoaderRoute: typeof marketingPromoRouteImport + parentRoute: typeof rootRouteImport + } + '/(marketing)/pricing': { + id: '/(marketing)/pricing' + path: '/pricing' + fullPath: '/pricing' + preLoaderRoute: typeof marketingPricingRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/benchmarks/client-nav/scenarios/search-params/solid/src/routeTree.gen.ts b/benchmarks/client-nav/scenarios/search-params/solid/src/routeTree.gen.ts index b15beed09b..96d211d64c 100644 --- a/benchmarks/client-nav/scenarios/search-params/solid/src/routeTree.gen.ts +++ b/benchmarks/client-nav/scenarios/search-params/solid/src/routeTree.gen.ts @@ -9,13 +9,13 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as CatalogRouteImport } from './routes/catalog' import { Route as ProductsRouteImport } from './routes/products' +import { Route as CatalogRouteImport } from './routes/catalog' +import { Route as IndexRouteImport } from './routes/index' -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', +const ProductsRoute = ProductsRouteImport.update({ + id: '/products', + path: '/products', getParentRoute: () => rootRouteImport, } as any) const CatalogRoute = CatalogRouteImport.update({ @@ -23,9 +23,9 @@ const CatalogRoute = CatalogRouteImport.update({ path: '/catalog', getParentRoute: () => rootRouteImport, } as any) -const ProductsRoute = ProductsRouteImport.update({ - id: '/products', - path: '/products', +const IndexRoute = IndexRouteImport.update({ + id: '/', + path: '/', getParentRoute: () => rootRouteImport, } as any) @@ -61,11 +61,11 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport + '/products': { + id: '/products' + path: '/products' + fullPath: '/products' + preLoaderRoute: typeof ProductsRouteImport parentRoute: typeof rootRouteImport } '/catalog': { @@ -75,11 +75,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof CatalogRouteImport parentRoute: typeof rootRouteImport } - '/products': { - id: '/products' - path: '/products' - fullPath: '/products' - preLoaderRoute: typeof ProductsRouteImport + '/': { + id: '/' + path: '/' + fullPath: '/' + preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } } diff --git a/benchmarks/ssr/scenarios/control-flow/solid/src/routeTree.gen.ts b/benchmarks/ssr/scenarios/control-flow/solid/src/routeTree.gen.ts index 3cec17d9c8..5e7342c172 100644 --- a/benchmarks/ssr/scenarios/control-flow/solid/src/routeTree.gen.ts +++ b/benchmarks/ssr/scenarios/control-flow/solid/src/routeTree.gen.ts @@ -10,30 +10,20 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as IndexRouteImport } from './routes/index' -import { Route as BoomIdRouteImport } from './routes/boom.$id' -import { Route as FromIdRouteImport } from './routes/from.$id' -import { Route as HeadersIdRouteImport } from './routes/headers.$id' -import { Route as MissingIdRouteImport } from './routes/missing.$id' import { Route as TargetIdRouteImport } from './routes/target.$id' +import { Route as MissingIdRouteImport } from './routes/missing.$id' +import { Route as HeadersIdRouteImport } from './routes/headers.$id' +import { Route as FromIdRouteImport } from './routes/from.$id' +import { Route as BoomIdRouteImport } from './routes/boom.$id' const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRouteImport, } as any) -const BoomIdRoute = BoomIdRouteImport.update({ - id: '/boom/$id', - path: '/boom/$id', - getParentRoute: () => rootRouteImport, -} as any) -const FromIdRoute = FromIdRouteImport.update({ - id: '/from/$id', - path: '/from/$id', - getParentRoute: () => rootRouteImport, -} as any) -const HeadersIdRoute = HeadersIdRouteImport.update({ - id: '/headers/$id', - path: '/headers/$id', +const TargetIdRoute = TargetIdRouteImport.update({ + id: '/target/$id', + path: '/target/$id', getParentRoute: () => rootRouteImport, } as any) const MissingIdRoute = MissingIdRouteImport.update({ @@ -41,9 +31,19 @@ const MissingIdRoute = MissingIdRouteImport.update({ path: '/missing/$id', getParentRoute: () => rootRouteImport, } as any) -const TargetIdRoute = TargetIdRouteImport.update({ - id: '/target/$id', - path: '/target/$id', +const HeadersIdRoute = HeadersIdRouteImport.update({ + id: '/headers/$id', + path: '/headers/$id', + getParentRoute: () => rootRouteImport, +} as any) +const FromIdRoute = FromIdRouteImport.update({ + id: '/from/$id', + path: '/from/$id', + getParentRoute: () => rootRouteImport, +} as any) +const BoomIdRoute = BoomIdRouteImport.update({ + id: '/boom/$id', + path: '/boom/$id', getParentRoute: () => rootRouteImport, } as any) @@ -117,25 +117,11 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } - '/boom/$id': { - id: '/boom/$id' - path: '/boom/$id' - fullPath: '/boom/$id' - preLoaderRoute: typeof BoomIdRouteImport - parentRoute: typeof rootRouteImport - } - '/from/$id': { - id: '/from/$id' - path: '/from/$id' - fullPath: '/from/$id' - preLoaderRoute: typeof FromIdRouteImport - parentRoute: typeof rootRouteImport - } - '/headers/$id': { - id: '/headers/$id' - path: '/headers/$id' - fullPath: '/headers/$id' - preLoaderRoute: typeof HeadersIdRouteImport + '/target/$id': { + id: '/target/$id' + path: '/target/$id' + fullPath: '/target/$id' + preLoaderRoute: typeof TargetIdRouteImport parentRoute: typeof rootRouteImport } '/missing/$id': { @@ -145,11 +131,25 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof MissingIdRouteImport parentRoute: typeof rootRouteImport } - '/target/$id': { - id: '/target/$id' - path: '/target/$id' - fullPath: '/target/$id' - preLoaderRoute: typeof TargetIdRouteImport + '/headers/$id': { + id: '/headers/$id' + path: '/headers/$id' + fullPath: '/headers/$id' + preLoaderRoute: typeof HeadersIdRouteImport + parentRoute: typeof rootRouteImport + } + '/from/$id': { + id: '/from/$id' + path: '/from/$id' + fullPath: '/from/$id' + preLoaderRoute: typeof FromIdRouteImport + parentRoute: typeof rootRouteImport + } + '/boom/$id': { + id: '/boom/$id' + path: '/boom/$id' + fullPath: '/boom/$id' + preLoaderRoute: typeof BoomIdRouteImport parentRoute: typeof rootRouteImport } } diff --git a/benchmarks/ssr/scenarios/global-middleware/solid/src/routeTree.gen.ts b/benchmarks/ssr/scenarios/global-middleware/solid/src/routeTree.gen.ts index 65f7fa5848..28d816525e 100644 --- a/benchmarks/ssr/scenarios/global-middleware/solid/src/routeTree.gen.ts +++ b/benchmarks/ssr/scenarios/global-middleware/solid/src/routeTree.gen.ts @@ -10,8 +10,8 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as IndexRouteImport } from './routes/index' -import { Route as ApiFnUrlsRouteImport } from './routes/api.fn-urls' import { Route as PageIdRouteImport } from './routes/page.$id' +import { Route as ApiFnUrlsRouteImport } from './routes/api.fn-urls' import { Route as ApiPingIdRouteImport } from './routes/api.ping.$id' const IndexRoute = IndexRouteImport.update({ @@ -19,16 +19,16 @@ const IndexRoute = IndexRouteImport.update({ path: '/', getParentRoute: () => rootRouteImport, } as any) -const ApiFnUrlsRoute = ApiFnUrlsRouteImport.update({ - id: '/api/fn-urls', - path: '/api/fn-urls', - getParentRoute: () => rootRouteImport, -} as any) const PageIdRoute = PageIdRouteImport.update({ id: '/page/$id', path: '/page/$id', getParentRoute: () => rootRouteImport, } as any) +const ApiFnUrlsRoute = ApiFnUrlsRouteImport.update({ + id: '/api/fn-urls', + path: '/api/fn-urls', + getParentRoute: () => rootRouteImport, +} as any) const ApiPingIdRoute = ApiPingIdRouteImport.update({ id: '/api/ping/$id', path: '/api/ping/$id', @@ -78,13 +78,6 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } - '/api/fn-urls': { - id: '/api/fn-urls' - path: '/api/fn-urls' - fullPath: '/api/fn-urls' - preLoaderRoute: typeof ApiFnUrlsRouteImport - parentRoute: typeof rootRouteImport - } '/page/$id': { id: '/page/$id' path: '/page/$id' @@ -92,6 +85,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof PageIdRouteImport parentRoute: typeof rootRouteImport } + '/api/fn-urls': { + id: '/api/fn-urls' + path: '/api/fn-urls' + fullPath: '/api/fn-urls' + preLoaderRoute: typeof ApiFnUrlsRouteImport + parentRoute: typeof rootRouteImport + } '/api/ping/$id': { id: '/api/ping/$id' path: '/api/ping/$id' diff --git a/benchmarks/ssr/scenarios/serialization/solid/src/routeTree.gen.ts b/benchmarks/ssr/scenarios/serialization/solid/src/routeTree.gen.ts index b9e25f918e..69b63cffe9 100644 --- a/benchmarks/ssr/scenarios/serialization/solid/src/routeTree.gen.ts +++ b/benchmarks/ssr/scenarios/serialization/solid/src/routeTree.gen.ts @@ -9,19 +9,19 @@ // Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. import { Route as rootRouteImport } from './routes/__root' -import { Route as PlainIdRouteImport } from './routes/plain.$id' import { Route as RichIdRouteImport } from './routes/rich.$id' +import { Route as PlainIdRouteImport } from './routes/plain.$id' -const PlainIdRoute = PlainIdRouteImport.update({ - id: '/plain/$id', - path: '/plain/$id', - getParentRoute: () => rootRouteImport, -} as any) const RichIdRoute = RichIdRouteImport.update({ id: '/rich/$id', path: '/rich/$id', getParentRoute: () => rootRouteImport, } as any) +const PlainIdRoute = PlainIdRouteImport.update({ + id: '/plain/$id', + path: '/plain/$id', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/plain/$id': typeof PlainIdRoute @@ -51,13 +51,6 @@ export interface RootRouteChildren { declare module '@tanstack/solid-router' { interface FileRoutesByPath { - '/plain/$id': { - id: '/plain/$id' - path: '/plain/$id' - fullPath: '/plain/$id' - preLoaderRoute: typeof PlainIdRouteImport - parentRoute: typeof rootRouteImport - } '/rich/$id': { id: '/rich/$id' path: '/rich/$id' @@ -65,6 +58,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof RichIdRouteImport parentRoute: typeof rootRouteImport } + '/plain/$id': { + id: '/plain/$id' + path: '/plain/$id' + fullPath: '/plain/$id' + preLoaderRoute: typeof PlainIdRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/benchmarks/ssr/scenarios/server-fns/solid/src/routeTree.gen.ts b/benchmarks/ssr/scenarios/server-fns/solid/src/routeTree.gen.ts index 3d0bd34eaa..3db5e487b3 100644 --- a/benchmarks/ssr/scenarios/server-fns/solid/src/routeTree.gen.ts +++ b/benchmarks/ssr/scenarios/server-fns/solid/src/routeTree.gen.ts @@ -10,24 +10,24 @@ import { Route as rootRouteImport } from './routes/__root' import { Route as IndexRouteImport } from './routes/index' -import { Route as ApiFnUrlsRouteImport } from './routes/api.fn-urls' import { Route as SsrCallIdRouteImport } from './routes/ssr-call.$id' +import { Route as ApiFnUrlsRouteImport } from './routes/api.fn-urls' const IndexRoute = IndexRouteImport.update({ id: '/', path: '/', getParentRoute: () => rootRouteImport, } as any) -const ApiFnUrlsRoute = ApiFnUrlsRouteImport.update({ - id: '/api/fn-urls', - path: '/api/fn-urls', - getParentRoute: () => rootRouteImport, -} as any) const SsrCallIdRoute = SsrCallIdRouteImport.update({ id: '/ssr-call/$id', path: '/ssr-call/$id', getParentRoute: () => rootRouteImport, } as any) +const ApiFnUrlsRoute = ApiFnUrlsRouteImport.update({ + id: '/api/fn-urls', + path: '/api/fn-urls', + getParentRoute: () => rootRouteImport, +} as any) export interface FileRoutesByFullPath { '/': typeof IndexRoute @@ -68,13 +68,6 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof IndexRouteImport parentRoute: typeof rootRouteImport } - '/api/fn-urls': { - id: '/api/fn-urls' - path: '/api/fn-urls' - fullPath: '/api/fn-urls' - preLoaderRoute: typeof ApiFnUrlsRouteImport - parentRoute: typeof rootRouteImport - } '/ssr-call/$id': { id: '/ssr-call/$id' path: '/ssr-call/$id' @@ -82,6 +75,13 @@ declare module '@tanstack/solid-router' { preLoaderRoute: typeof SsrCallIdRouteImport parentRoute: typeof rootRouteImport } + '/api/fn-urls': { + id: '/api/fn-urls' + path: '/api/fn-urls' + fullPath: '/api/fn-urls' + preLoaderRoute: typeof ApiFnUrlsRouteImport + parentRoute: typeof rootRouteImport + } } } diff --git a/docs/router/api/file-based-routing.md b/docs/router/api/file-based-routing.md index 7c94d484d1..ad3e07fad7 100644 --- a/docs/router/api/file-based-routing.md +++ b/docs/router/api/file-based-routing.md @@ -188,7 +188,7 @@ By default, this value is set to `false`. ### `autoCodeSplitting` -This feature is only available if you are using the TanStack Router Bundler Plugin with Vite, Rspack/Rsbuild or Webpack. With Esbuild, setting it to `true` is an error. +This feature is only available if you are using the TanStack Router Bundler Plugin. This option is used to enable automatic code-splitting for non-critical route configuration items. See the "Automatic Code-Splitting" guide for more information. diff --git a/docs/router/guide/automatic-code-splitting.md b/docs/router/guide/automatic-code-splitting.md index 859a19ff09..be599845bc 100644 --- a/docs/router/guide/automatic-code-splitting.md +++ b/docs/router/guide/automatic-code-splitting.md @@ -4,7 +4,7 @@ title: Automatic Code Splitting The automatic code splitting feature in TanStack Router allows you to optimize your application's bundle size by lazily loading route components and their associated data. This is particularly useful for large applications where you want to minimize the initial load time by only loading the necessary code for the current route. -To turn this feature on, simply set the `autoCodeSplitting` option to `true` in your bundler plugin configuration. This enables the router to automatically handle code splitting for your routes without requiring any additional setup. It is available with Vite, Rspack/Rsbuild and Webpack, not with Esbuild. +To turn this feature on, simply set the `autoCodeSplitting` option to `true` in your bundler plugin configuration. This enables the router to automatically handle code splitting for your routes without requiring any additional setup. ```ts // vite.config.ts diff --git a/docs/router/guide/external-data-loading.md b/docs/router/guide/external-data-loading.md index 4ffb318686..664468752d 100644 --- a/docs/router/guide/external-data-loading.md +++ b/docs/router/guide/external-data-loading.md @@ -6,7 +6,7 @@ title: External Data Loading > [!IMPORTANT] > This guide is geared towards external state management libraries and their integration with TanStack Router for data fetching, ssr, hydration/dehydration and streaming. If you haven't read the standard [Data Loading](./data-loading.md) guide, please do so first. -Router can coordinate loaders and an existing API without Start. If you also want an integrated server runtime and typed server functions for your React application, follow [TanStack Query with Start](/start/latest/docs/framework/react/guide/tanstack-query) for request-scoped SSR, hydration, and mutation invalidation with a tested example. +For a full-stack React application, follow [TanStack Query with Start](/start/latest/docs/framework/react/guide/tanstack-query) for request-scoped SSR, hydration, and mutation invalidation with a tested example. ## To **Store** or to **Coordinate**? diff --git a/docs/router/installation/with-esbuild.md b/docs/router/installation/with-esbuild.md index 8ecd9b8d0a..b5cad0622c 100644 --- a/docs/router/installation/with-esbuild.md +++ b/docs/router/installation/with-esbuild.md @@ -25,6 +25,7 @@ export default { plugins: [ tanstackRouter({ target: 'react', + autoCodeSplitting: true, }), ], } @@ -49,7 +50,10 @@ const ctx = await esbuild.context({ format: 'esm', target: ['esnext'], sourcemap: true, - plugins: [solidPlugin(), tanstackRouter({ target: 'solid' })], + plugins: [ + solidPlugin(), + tanstackRouter({ target: 'solid', autoCodeSplitting: true }), + ], }) if (isDev) { @@ -68,9 +72,6 @@ Or, you can clone our [Quickstart Esbuild example](https://github.com/TanStack/r Now that you've added the plugin to your Esbuild configuration, you're all set to start using file-based routing with TanStack Router. -> [!NOTE] -> Automatic code splitting is not available with Esbuild: the plugin throws an error when `autoCodeSplitting` is `true`. Route generation works as usual. To split routes, use [manual code splitting](../guide/code-splitting.md) or another bundler. - ## Ignoring the generated route tree file If your project is configured to use a linter and/or formatter, you may want to ignore the generated route tree file. This file is managed by TanStack Router and therefore shouldn't be changed by your linter or formatter. diff --git a/docs/start/framework/react/guide/environment-functions.md b/docs/start/framework/react/guide/environment-functions.md index 94fbb52501..f472a3a26a 100644 --- a/docs/start/framework/react/guide/environment-functions.md +++ b/docs/start/framework/react/guide/environment-functions.md @@ -121,37 +121,3 @@ Environment functions are tree-shaken based on the environment for each bundle p Functions created using `createIsomorphicFn()` are tree-shaken. All codes inside `.client()` are not included in server bundle, and vice-versa. On the server, functions created using `createClientOnlyFn()` are replaced with a function that throws an `Error` on the server. The reverse is true for `createServerOnlyFn` functions on the client. - -## Troubleshooting - -### A loader works on refresh but throws during navigation - -If a loader throws `createServerOnlyFn() functions can only be called on the server!` after clicking a link, check whether it calls a server-only helper directly. Route loaders also run in the browser during client navigation. `createServerOnlyFn` guards a local function, it does not send a request to the server. - -Wrap the server work in `createServerFn` and call that function from the loader: - -```tsx -import { createFileRoute } from '@tanstack/react-router' -import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' - -const readOnlyOnServer = createServerOnlyFn(() => 'Read on the server') -const readThroughRpc = createServerFn().handler(() => readOnlyOnServer()) - -export const Route = createFileRoute('/example')({ - loader: () => readThroughRpc(), -}) -``` - -The server function runs directly during SSR and makes a request to the server when called in the browser. Test both a direct page request and navigation from another route. A successful refresh alone does not exercise the browser loader. - -The [execution-boundary tests](https://github.com/TanStack/router/blob/main/e2e/react-start/basic/tests/environment-functions.spec.ts) include the failing direct call and the working server-function version. See [Server Functions](./server-functions.md) for validation and middleware when the function accepts user input. - -### Browser code throws `window is not defined` on the server - -This means browser-only code ran during server execution. Use the stack trace to find the first application or dependency module that reads `window`, `document`, or another browser API. - -For a browser-only component, render it inside `ClientOnly` from `@tanstack/react-router` with a useful fallback. The Start compiler removes its children from the server bundle, which lets the bundler remove imports used only by those children. The [ClientOnly example](https://github.com/TanStack/router/blob/main/e2e/react-start/basic/src/routes/client-only.tsx) covers a component that reads `window` at module scope, and its [tests](https://github.com/TanStack/router/blob/main/e2e/react-start/basic/tests/client-only.spec.ts) check the server fallback and hydrated content. - -A browser API used elsewhere, such as a route loader or server function, still needs the correct execution boundary. Move component side effects into an effect or event handler. For logic that needs different server and browser implementations, use `createIsomorphicFn` with both implementations. Wrapping a function in `createClientOnlyFn` does not defer its call until the browser, calling that wrapper on the server throws the client-only guard error instead. - -If the stack points into build tooling or the error persists in a minimal app with the correct boundary, include that app and the installed Start and bundler versions in a [bug report](https://github.com/TanStack/router/issues/new/choose). A compiler or dependency bug needs a reproducible fix, not a blanket change to rendering mode. diff --git a/docs/start/framework/react/guide/hosting.md b/docs/start/framework/react/guide/hosting.md index 2d02f881b3..c8da672208 100644 --- a/docs/start/framework/react/guide/hosting.md +++ b/docs/start/framework/react/guide/hosting.md @@ -116,32 +116,6 @@ Deploy your application to Cloudflare Workers using their one-click deployment p A full TanStack Start example for Cloudflare Workers is available [here](https://github.com/TanStack/router/tree/main/examples/react/start-basic-cloudflare). -#### Deployment fails even though the Vite build succeeds - -If Wrangler reports a missing server entry or unresolved Start virtual modules, check whether your deployment command passes `--config wrangler.jsonc`. With the Cloudflare Vite plugin, that file is the build input. The plugin generates a deployment config with the built server entry and client assets, then writes `.wrangler/deploy/config.json` so Wrangler can find it. Forcing Wrangler to read the source config bypasses that redirect. - -Run these commands from the application directory to validate the generated deployment without publishing: - -```sh -pnpm run build -pnpm exec wrangler deploy --dry-run -``` - -Check that Wrangler reports the generated config under `dist`, rather than just the source `wrangler.jsonc`. Keep the source `main` set to `@tanstack/react-start/server-entry` or your custom server entry, and let the Vite plugin generate the deployment entry. Marking unresolved Start modules as external does not fix the missing build transformation. - -If your build and deployment run in separate jobs, preserve the build output and `.wrangler/deploy/config.json` with their relative paths, or explicitly pass the generated deployment config. Do not edit generated files to repair the source configuration. See Cloudflare's [generated configuration documentation](https://developers.cloudflare.com/workers/wrangler/configuration/#generated-configuration) for how Wrangler finds that output. - -For a named Cloudflare environment, select it when building. For example, if `env.staging` is defined in your source config: - -```sh -CLOUDFLARE_ENV=staging pnpm run build -pnpm exec wrangler deploy --dry-run -``` - -The plugin resolves the environment into the generated config. A later `wrangler deploy --env staging` does not select a different built environment. See [Cloudflare environments](https://developers.cloudflare.com/workers/vite-plugin/reference/cloudflare-environments/). - -The [Cloudflare fixture tests](https://github.com/TanStack/router/blob/main/e2e/react-start/basic-cloudflare/tests/app.spec.ts) exercise a generated-config dry run and preview the built app locally. A dry run validates packaging, it does not verify account permissions, a live domain, or deployed bindings. - ### Netlify ⭐ _Official Partner_ diff --git a/docs/start/framework/react/guide/rendering-markdown.md b/docs/start/framework/react/guide/rendering-markdown.md index bf644124d9..4258d6f4f1 100644 --- a/docs/start/framework/react/guide/rendering-markdown.md +++ b/docs/start/framework/react/guide/rendering-markdown.md @@ -3,85 +3,191 @@ id: rendering-markdown title: Rendering Markdown --- -Use [TanStack Markdown](https://tanstack.com/markdown/latest/docs/overview) to render Markdown in your TanStack Start application. Its React renderer works synchronously during server rendering and client navigation, so content does not need to wait for a client effect. +This guide covers two methods for importing and rendering markdown content in your TanStack Start application: -This guide covers static posts loaded with Content Collections and remote content fetched through a server function. Both use the same Markdown component. +1. **Static markdown** with `content-collections` for build-time loading (e.g., blog posts) +2. **Dynamic markdown** fetched at runtime from GitHub or any remote source -## Rendering Markdown +Both methods share a common rendering pipeline using the `unified` ecosystem. -Install TanStack Markdown: +## Setting Up the Markdown Processor + +Both approaches use the same markdown-to-HTML processing pipeline. First, install the required dependencies: ```bash -npm install @tanstack/markdown +npm install unified remark-parse remark-gfm remark-rehype rehype-raw rehype-slug rehype-autolink-headings rehype-stringify shiki html-react-parser gray-matter ``` -Create a shared component that accepts either Markdown source or a parsed document: +Create a markdown processor utility: + +```tsx +// src/utils/markdown.ts +import { unified } from 'unified' +import remarkParse from 'remark-parse' +import remarkGfm from 'remark-gfm' +import remarkRehype from 'remark-rehype' +import rehypeRaw from 'rehype-raw' +import rehypeSlug from 'rehype-slug' +import rehypeAutolinkHeadings from 'rehype-autolink-headings' +import rehypeStringify from 'rehype-stringify' + +export type MarkdownHeading = { + id: string + text: string + level: number +} + +export type MarkdownResult = { + markup: string + headings: Array +} + +export async function renderMarkdown(content: string): Promise { + const headings: Array = [] + + const result = await unified() + .use(remarkParse) // Parse markdown + .use(remarkGfm) // Support GitHub Flavored Markdown + .use(remarkRehype, { allowDangerousHtml: true }) // Convert to HTML AST + .use(rehypeRaw) // Process raw HTML in markdown + .use(rehypeSlug) // Add IDs to headings + .use(rehypeAutolinkHeadings, { + behavior: 'wrap', + properties: { className: ['anchor'] }, + }) + .use(() => (tree) => { + // Extract headings for table of contents + const { visit } = require('unist-util-visit') + const { toString } = require('hast-util-to-string') + + visit(tree, 'element', (node: any) => { + if (['h1', 'h2', 'h3', 'h4', 'h5', 'h6'].includes(node.tagName)) { + headings.push({ + id: node.properties?.id || '', + text: toString(node), + level: parseInt(node.tagName.charAt(1), 10), + }) + } + }) + }) + .use(rehypeStringify) // Serialize to HTML string + .process(content) + + return { + markup: String(result), + headings, + } +} +``` + +## Creating a Markdown Component + +Create a React component that renders the processed HTML with custom element handling: ```tsx // src/components/Markdown.tsx -import { Markdown as ReactMarkdown } from '@tanstack/markdown/react' -import type { MarkdownDocument } from '@tanstack/markdown' +import parse, { type HTMLReactParserOptions, Element } from 'html-react-parser' +import { renderMarkdown, type MarkdownResult } from '~/utils/markdown' type MarkdownProps = { - content: string | MarkdownDocument + content: string className?: string } export function Markdown({ content, className }: MarkdownProps) { - return ( -
- {content} -
- ) + const [result, setResult] = useState(null) + + useEffect(() => { + renderMarkdown(content).then(setResult) + }, [content]) + + if (!result) { + return
Loading...
+ } + + const options: HTMLReactParserOptions = { + replace: (domNode) => { + if (domNode instanceof Element) { + // Customize rendering of specific elements + if (domNode.name === 'a') { + // Handle links + const href = domNode.attribs.href + if (href?.startsWith('/')) { + // Internal link - use your router's Link component + return ( + {domToReact(domNode.children, options)} + ) + } + } + + if (domNode.name === 'img') { + // Add lazy loading to images + return ( + + ) + } + } + }, + } + + return
{parse(result.markup, options)}
} ``` -Headings receive stable IDs, and `headingAnchors` adds links to them. Raw HTML is escaped and unsafe URL protocols are removed by default. Keep these defaults for remote or user-written content. TanStack Markdown does not execute MDX or implement every CommonMark or GFM feature, so check the [supported syntax](https://tanstack.com/markdown/latest/docs/core-concepts/syntax-profile) when migrating existing content. +## Method 1: Static Markdown with content-collections -Use the `components` prop to customize elements, for example to lazy-load images: +The `content-collections` package is ideal for static content like blog posts that are included in your repository. It processes markdown files at build time and provides type-safe access to the content. -```tsx - , - }} -> - {content} - -``` - -The examples below use `~/*` for the `src/*` import alias. The `prose` class is optional and requires your own typography styles, such as Tailwind Typography. - -## Static Markdown with Content Collections - -[Content Collections](https://www.content-collections.dev/docs/quickstart/tanstack-start) loads local Markdown files and validates their frontmatter. Pass the Markdown body from the generated collection to the shared renderer. - -### Installation and Configuration +### Installation ```bash -npm install -D @content-collections/core @content-collections/vite zod +npm install @content-collections/core @content-collections/vite ``` -```ts +### Configuration + +Create a `content-collections.ts` file in your project root: + +```tsx // content-collections.ts import { defineCollection, defineConfig } from '@content-collections/core' -import { z } from 'zod' +import matter from 'gray-matter' + +function extractFrontMatter(content: string) { + const { data, content: body, excerpt } = matter(content, { excerpt: true }) + return { data, body, excerpt: excerpt || '' } +} const posts = defineCollection({ name: 'posts', - directory: './src/blog', + directory: './src/blog', // Directory containing your .md files include: '*.md', - schema: z.object({ + schema: (z) => ({ title: z.string(), - published: z.string().regex(/^\d{4}-\d{2}-\d{2}$/), - description: z.string(), - authors: z.array(z.string()), - content: z.string(), - }), - transform: (post) => ({ - ...post, - slug: post._meta.path, + published: z.string().date(), + description: z.string().optional(), + authors: z.string().array(), }), + transform: ({ content, ...post }) => { + const frontMatter = extractFrontMatter(content) + + // Extract header image (first image in the document) + const headerImageMatch = content.match(/!\[([^\]]*)\]\(([^)]+)\)/) + const headerImage = headerImageMatch ? headerImageMatch[2] : undefined + + return { + ...post, + slug: post._meta.path, + excerpt: frontMatter.excerpt, + description: frontMatter.data.description, + headerImage, + content: frontMatter.body, + } + }, }) export default defineConfig({ @@ -89,56 +195,40 @@ export default defineConfig({ }) ``` -Content Collections already separates frontmatter from `content`, so this transform does not need a second frontmatter parser. +### Vite Integration -Add the plugin to your existing Vite configuration, keeping any deployment plugins your app needs: +Add the content-collections plugin to your Vite config: -```ts -// vite.config.ts +```tsx +// app.config.ts +import { defineConfig } from '@tanstack/react-start/config' import contentCollections from '@content-collections/vite' -import { tanstackStart } from '@tanstack/react-start/plugin/vite' -import viteReact from '@vitejs/plugin-react' -import { defineConfig } from 'vite' -import tsConfigPaths from 'vite-tsconfig-paths' export default defineConfig({ - plugins: [ - contentCollections(), - tsConfigPaths({ projects: ['./tsconfig.json'] }), - tanstackStart(), - viteReact(), - ], + vite: { + plugins: [contentCollections()], + }, }) ``` -Add the generated collection alias to your existing `tsconfig.json`: +### Creating Blog Posts -```json -{ - "compilerOptions": { - "paths": { - "~/*": ["./src/*"], - "content-collections": ["./.content-collections/generated"] - } - } -} -``` - -Add `.content-collections` to `.gitignore`. Starting the Vite dev server or running a build generates the collection. - -### Creating a Post - -Create `src/blog/hello-world.md`: +Create markdown files in your designated directory: ````markdown ---- +## + title: Hello World -published: '2026-01-15' -description: My first blog post +published: 2024-01-15 authors: - - Jane Doe + +- Jane Doe + description: My first blog post + --- +![Hero Image](/images/hero.jpg) + Welcome to my blog! This is my first post. ## Getting Started @@ -150,11 +240,13 @@ console.log('Hello, world!') ``` ```` -### Listing Posts +### Using the Collection + +Access your posts through the generated collection: ```tsx // src/routes/blog.index.tsx -import { createFileRoute, Link } from '@tanstack/react-router' +import { createFileRoute } from '@tanstack/react-router' import { allPosts } from 'content-collections' export const Route = createFileRoute('/blog/')({ @@ -162,30 +254,31 @@ export const Route = createFileRoute('/blog/')({ }) function BlogIndex() { - const sortedPosts = [...allPosts].sort((a, b) => - b.published.localeCompare(a.published), + // Posts are sorted by published date + const sortedPosts = allPosts.sort( + (a, b) => new Date(b.published).getTime() - new Date(a.published).getTime(), ) return ( -
+

Blog

    {sortedPosts.map((post) => (
  • - {post.title} +

    {post.title}

    +

    {post.excerpt}

    + {post.published} -

    {post.description}

    -
  • ))}
-
+ ) } ``` -### Rendering a Post +### Rendering a Single Post ```tsx // src/routes/blog.$slug.tsx @@ -195,7 +288,7 @@ import { Markdown } from '~/components/Markdown' export const Route = createFileRoute('/blog/$slug')({ loader: ({ params }) => { - const post = allPosts.find((post) => post.slug === params.slug) + const post = allPosts.find((p) => p.slug === params.slug) if (!post) { throw notFound() } @@ -209,169 +302,202 @@ function BlogPost() { return (
-

{post.title}

-

- By {post.authors.join(', ')} on {post.published} -

+
+

{post.title}

+

+ By {post.authors.join(', ')} on {post.published} +

+
) } ``` -The renderer parses the Markdown synchronously and renders React elements on both the server and client. +## Method 2: Dynamic Markdown from Remote Sources -## Remote Markdown with a Server Function +For content stored externally (like GitHub repositories), you can fetch and render markdown dynamically using server functions. -Fetch remote content in a server function and parse it before returning it to the route. Install `gray-matter` if the remote files contain frontmatter: - -```bash -npm install gray-matter -``` - -Keep the repository, branch, and content directory in server code. Validate the requested filename before building the URL: - -```ts -// src/utils/docs.ts -import { createServerFn } from '@tanstack/react-start' -import { notFound } from '@tanstack/react-router' -import { parseMarkdown } from '@tanstack/markdown/parser' -import matter from 'gray-matter' - -export const fetchDocs = createServerFn({ method: 'GET' }) - .validator((slug: unknown) => { - if (typeof slug !== 'string' || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(slug)) { - throw new Error('Invalid document slug') - } - return slug - }) - .handler(async ({ data: slug }) => { - // Replace this with your public repository's content directory. - const baseUrl = - 'https://raw.githubusercontent.com/your-org/your-repo/main/docs' - const response = await fetch(`${baseUrl}/${slug}.md`) - - if (response.status === 404) { - throw notFound() - } - if (!response.ok) { - throw new Error(`Failed to fetch document: ${response.status}`) - } - - const { data, content } = matter(await response.text()) - - return { - title: typeof data.title === 'string' ? data.title : slug, - document: parseMarkdown(content), - } - }) -``` +### Creating a Fetch Utility ```tsx -// src/routes/docs.$slug.tsx -import { createFileRoute } from '@tanstack/react-router' -import { Markdown } from '~/components/Markdown' -import { fetchDocs } from '~/utils/docs' +// src/utils/docs.server.ts +import { createServerFn } from '@tanstack/react-start' +import matter from 'gray-matter' -export const Route = createFileRoute('/docs/$slug')({ - loader: ({ params }) => fetchDocs({ data: params.slug }), +type FetchDocsParams = { + repo: string // e.g., 'tanstack/router' + branch: string // e.g., 'main' + filePath: string // e.g., 'docs/guide/getting-started.md' +} + +export const fetchDocs = createServerFn({ method: 'GET' }) + .validator((params: FetchDocsParams) => params) + .handler(async ({ data: { repo, branch, filePath } }) => { + const url = `https://raw.githubusercontent.com/${repo}/${branch}/${filePath}` + + const response = await fetch(url, { + headers: { + // Add GitHub token for private repos or higher rate limits + // Authorization: `token ${process.env.GITHUB_TOKEN}`, + }, + }) + + if (!response.ok) { + throw new Error(`Failed to fetch: ${response.status}`) + } + + const rawContent = await response.text() + const { data: frontmatter, content } = matter(rawContent) + + return { + frontmatter, + content, + filePath, + } + }) +``` + +### Adding Cache Headers + +For production, add appropriate cache headers: + +```tsx +export const fetchDocs = createServerFn({ method: 'GET' }) + .validator((params: FetchDocsParams) => params) + .handler(async ({ data: { repo, branch, filePath }, context }) => { + // Set cache headers for CDN caching + context.response.headers.set( + 'Cache-Control', + 'public, max-age=0, must-revalidate', + ) + context.response.headers.set( + 'CDN-Cache-Control', + 'max-age=300, stale-while-revalidate=300', + ) + + // ... fetch logic + }) +``` + +### Using Dynamic Markdown in Routes + +```tsx +// src/routes/docs.$path.tsx +import { createFileRoute } from '@tanstack/react-router' +import { fetchDocs } from '~/utils/docs.server' +import { Markdown } from '~/components/Markdown' + +export const Route = createFileRoute('/docs/$path')({ + loader: async ({ params }) => { + return fetchDocs({ + data: { + repo: 'your-org/your-repo', + branch: 'main', + filePath: `docs/${params.path}.md`, + }, + }) + }, component: DocsPage, }) function DocsPage() { - const { title, document } = Route.useLoaderData() + const { frontmatter, content } = Route.useLoaderData() return (
-

{title}

- +

{frontmatter.title}

+
) } ``` -Relative Markdown links and image URLs resolve against your app's URL, not the source repository. Use app-relative or absolute URLs in the content, or transform them for your site's route and asset layout. +### Fetching Directory Contents -## Syntax Highlighting with TanStack Highlight - -Install [TanStack Highlight](https://tanstack.com/highlight/latest/docs/overview). The Markdown adapter requires version `0.0.6` or newer: - -```bash -npm install @tanstack/highlight -``` - -Register the languages your content uses and create the Markdown adapter: - -```ts -// src/utils/markdown-highlighter.ts -import { createHighlighter } from '@tanstack/highlight/core' -import { js } from '@tanstack/highlight/languages/js' -import { plaintext } from '@tanstack/highlight/languages/plaintext' -import { ts } from '@tanstack/highlight/languages/ts' -import { tsx } from '@tanstack/highlight/languages/tsx' -import { createTanStackMarkdownHighlighter } from '@tanstack/highlight/markdown' - -const highlighter = createHighlighter({ - languages: [plaintext, js, ts, tsx], -}) - -export const highlightMarkdownCode = - createTanStackMarkdownHighlighter(highlighter) -``` - -Update the shared component to pass the highlighter and include its theme styles: +To build navigation from a GitHub directory: ```tsx -// src/components/Markdown.tsx -import { createThemeCss } from '@tanstack/highlight/theme' -import { githubDarkTheme } from '@tanstack/highlight/themes/github-dark' -import { githubLightTheme } from '@tanstack/highlight/themes/github-light' -import { Markdown as ReactMarkdown } from '@tanstack/markdown/react' -import type { MarkdownDocument } from '@tanstack/markdown' -import { highlightMarkdownCode } from '~/utils/markdown-highlighter' - -const themeCss = createThemeCss({ - light: githubLightTheme, - dark: githubDarkTheme, - lightSelector: '.markdown-renderer', - darkSelector: '.dark .markdown-renderer', - codeBlockSelector: '.markdown-renderer pre.tm-code', - lineNumbersSelector: '.markdown-renderer .tm-code--line-numbers', -}) - -type MarkdownProps = { - content: string | MarkdownDocument - className?: string +// src/utils/docs.server.ts +type GitHubContent = { + name: string + path: string + type: 'file' | 'dir' } -export function Markdown({ content, className }: MarkdownProps) { - return ( -
- - - {content} - -
+export const fetchRepoContents = createServerFn({ method: 'GET' }) + .validator((params: { repo: string; branch: string; path: string }) => params) + .handler(async ({ data: { repo, branch, path } }) => { + const url = `https://api.github.com/repos/${repo}/contents/${path}?ref=${branch}` + + const response = await fetch(url, { + headers: { + Accept: 'application/vnd.github.v3+json', + // Authorization: `token ${process.env.GITHUB_TOKEN}`, + }, + }) + + if (!response.ok) { + throw new Error(`Failed to fetch contents: ${response.status}`) + } + + const contents: Array = await response.json() + + return contents + .filter((item) => item.type === 'file' && item.name.endsWith('.md')) + .map((item) => ({ + name: item.name.replace('.md', ''), + path: item.path, + })) + }) +``` + +## Adding Syntax Highlighting with Shiki + +For code blocks with syntax highlighting, integrate Shiki into your markdown processor: + +```tsx +// src/utils/markdown.ts +import { codeToHtml } from 'shiki' + +// Process code blocks after parsing +export async function highlightCode( + code: string, + language: string, +): Promise { + return codeToHtml(code, { + lang: language, + themes: { + light: 'github-light', + dark: 'tokyo-night', + }, + }) +} +``` + +Then handle code blocks in your Markdown component: + +```tsx +// In your Markdown component's replace function +if (domNode.name === 'pre') { + const codeElement = domNode.children.find( + (child) => child instanceof Element && child.name === 'code', ) + if (codeElement) { + const className = codeElement.attribs.class || '' + const language = className.replace('language-', '') || 'text' + const code = getText(codeElement) + + return + } } ``` -The adapter returns escaped token markup inside the renderer's own `
` elements. Unknown languages fall back to plain text. Add a `dark` class to an ancestor to select the dark theme. See the [syntax highlighting guide](https://tanstack.com/markdown/latest/docs/guides/syntax-highlighting) for line numbers and highlighted lines.
+## Summary
 
-## Table of Contents
+| Approach            | Best For                                  | Pros                                           | Cons                                      |
+| ------------------- | ----------------------------------------- | ---------------------------------------------- | ----------------------------------------- |
+| content-collections | Blog posts, static docs bundled with app  | Type-safe, build-time processing, fast runtime | Requires rebuild for content updates      |
+| Dynamic fetching    | External docs, frequently updated content | Always fresh, no rebuild needed                | Runtime overhead, requires error handling |
 
-To collect headings, add the docs preset when parsing the document:
-
-```ts
-import { docsMarkdownExtensions } from '@tanstack/markdown/extensions/docs'
-import { parseMarkdown } from '@tanstack/markdown/parser'
-
-const document = parseMarkdown(content, {
-  extensions: docsMarkdownExtensions(),
-})
-
-const headings = document.headings ?? []
-// Each heading has an id, text, and level.
-```
-
-Use this in the server function, then render links to each heading's `id`. The [docs preset guide](https://tanstack.com/markdown/latest/docs/guides/docs-preset) also covers callouts and custom comment components. Those features need the same extensions passed to the renderer.
+Choose the approach that best fits your content update frequency and deployment workflow. For hybrid scenarios, you can use both methods in the same application.
diff --git a/docs/start/framework/react/guide/server-functions.md b/docs/start/framework/react/guide/server-functions.md
index 879aa9e867..68a6b8ac72 100644
--- a/docs/start/framework/react/guide/server-functions.md
+++ b/docs/start/framework/react/guide/server-functions.md
@@ -425,9 +425,7 @@ Customization:
 
 You can customize function ID generation for the production build by providing a `generateFunctionId` function when configuring the TanStack Start build tool plugin.
 
-Return `undefined` (or an empty string) to use the default ID. Prefer deterministic inputs (filename + functionName) so IDs remain stable between builds.
-
-The ID becomes one segment of the server function's URL (`/_serverFn/`), unencoded, so use only ASCII letters, digits, `-`, `.`, `_`, `~` and `$`, and not `.` or `..`. An ID with whitespace, a control or non-ASCII character, or any of `"`, `#`, `/`, `<`, `>`, `?`, `\`, `^`, `` ` ``, `{` and `}`, an ID that is `.` or `..`, or one with a percent-encoding the server reads as another ID (`%41` for `A`, lowercase hex, `%2E`) or rejects, fails the build with an error naming the file, the function and the ID: the request would reach another function or none. Other characters (`%`, `+`, `:`, `;`, `@`, `'`, `|`, `[`, `]`, …) still work, with a deprecation warning: the next major version rejects them, since proxies and servers may encode or normalise them in the URL. `filename` contains `/`, so hash it (as in the example below) rather than embedding it as is.
+Prefer deterministic inputs (filename + functionName) so IDs remain stable between builds.
 
 Please note that this customization is **experimental** and subject to change.
 
diff --git a/docs/start/framework/react/guide/tanstack-query.md b/docs/start/framework/react/guide/tanstack-query.md
index dec42ca26c..7797ae306b 100644
--- a/docs/start/framework/react/guide/tanstack-query.md
+++ b/docs/start/framework/react/guide/tanstack-query.md
@@ -1,12 +1,6 @@
 ---
 id: tanstack-query
 title: TanStack Query
-updated: '2026-09-11'
-testedWith:
-  '@tanstack/react-start': '1.168.52'
-  '@tanstack/react-query': '5.102.0'
-  react: '19.2.3'
-  vite: '8.0.14'
 description: Use TanStack Query with TanStack Start for request-isolated SSR, hydration, route preloading, streaming, and mutation invalidation.
 ---
 
diff --git a/docs/start/framework/react/migrate-from-next-js.md b/docs/start/framework/react/migrate-from-next-js.md
index dc5377df08..a9e6158444 100644
--- a/docs/start/framework/react/migrate-from-next-js.md
+++ b/docs/start/framework/react/migrate-from-next-js.md
@@ -10,7 +10,7 @@ Start does not interpret Next.js route conventions or configuration. Keep your a
 
 ## Run the reference application
 
-Use Node 24 or newer and pnpm 12:
+Use Node 24 or newer and pnpm 11:
 
 ```sh
 git clone --depth 1 https://github.com/TanStack/router.git
diff --git a/e2e/react-router/basic-esbuild-file-based/src/esbuild.config.js b/e2e/react-router/basic-esbuild-file-based/src/esbuild.config.js
index 954ddc026f..5f0f4fce03 100644
--- a/e2e/react-router/basic-esbuild-file-based/src/esbuild.config.js
+++ b/e2e/react-router/basic-esbuild-file-based/src/esbuild.config.js
@@ -2,5 +2,9 @@ import { tanstackRouter } from '@tanstack/router-plugin/esbuild'
 
 export default {
   // ...
-  plugins: [tanstackRouter()],
+  plugins: [
+    tanstackRouter({
+      autoCodeSplitting: true,
+    }),
+  ],
 }
diff --git a/e2e/react-router/basic-file-based/src/routeTree.gen.ts b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
index 83b504992f..0d17f94eb0 100644
--- a/e2e/react-router/basic-file-based/src/routeTree.gen.ts
+++ b/e2e/react-router/basic-file-based/src/routeTree.gen.ts
@@ -1711,7 +1711,7 @@ declare module '@tanstack/react-router' {
     '/(group)/_layout': {
       id: '/(group)/_layout'
       path: ''
-      fullPath: '/'
+      fullPath: ''
       preLoaderRoute: typeof groupLayoutRouteImport
       parentRoute: typeof rootRouteImport
     }
diff --git a/e2e/react-router/basic/package.json b/e2e/react-router/basic/package.json
index 4ff68f5cda..667b016896 100644
--- a/e2e/react-router/basic/package.json
+++ b/e2e/react-router/basic/package.json
@@ -17,8 +17,7 @@
     "react": "^19.0.0",
     "react-dom": "^19.0.0",
     "redaxios": "catalog:",
-    "tailwindcss": "^4.2.2",
-    "zod": "catalog:"
+    "tailwindcss": "^4.2.2"
   },
   "devDependencies": {
     "@playwright/test": "^1.61.0",
diff --git a/e2e/react-router/basic/src/main.tsx b/e2e/react-router/basic/src/main.tsx
index 49fa054776..36e5106654 100644
--- a/e2e/react-router/basic/src/main.tsx
+++ b/e2e/react-router/basic/src/main.tsx
@@ -1,5 +1,3 @@
-import { useState } from 'react'
-import { createPortal } from 'react-dom'
 import ReactDOM from 'react-dom/client'
 import {
   ErrorComponent,
@@ -11,19 +9,12 @@ import {
   createRouter,
   redirect,
 } from '@tanstack/react-router'
-import {
-  TanStackRouterDevtoolsInProd as TanStackRouterDevtools,
-  TanStackRouterDevtoolsPanelInProd as TanStackRouterDevtoolsPanel,
-} from '@tanstack/react-router-devtools'
-import { z } from 'zod'
+import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
 import { NotFoundError, fetchPost, fetchPosts } from './posts'
 import './styles.css'
 import type { ErrorComponentProps } from '@tanstack/react-router'
 
 const rootRoute = createRootRoute({
-  validateSearch: z.object({
-    devtools: z.enum(['panel', 'shadow']).optional().catch(undefined),
-  }),
   component: RootComponent,
   notFoundComponent: () => {
     return (
@@ -36,8 +27,6 @@ const rootRoute = createRootRoute({
 })
 
 function RootComponent() {
-  const { devtools } = rootRoute.useSearch()
-
   return (
     <>
       
@@ -97,57 +86,12 @@ function RootComponent() {
-
- Devtools: - {(['floating', 'panel', 'shadow'] as const).map((mode) => ( - ({ - ...prev, - devtools: mode === 'floating' ? undefined : mode, - })} - className={ - (devtools ?? 'floating') === mode ? 'font-bold' : undefined - } - > - {mode} - - ))} -
- {devtools === 'panel' ? ( - - ) : devtools === 'shadow' ? ( - - ) : ( - - )} + ) } - -function ShadowDevtoolsPanel() { - const [shadowRoot, setShadowRoot] = useState() - - return ( -
{ - if (host) { - setShadowRoot(host.shadowRoot ?? host.attachShadow({ mode: 'open' })) - } - }} - > - {shadowRoot - ? createPortal( - , - shadowRoot, - ) - : null} -
- ) -} const indexRoute = createRoute({ getParentRoute: () => rootRoute, path: '/', diff --git a/e2e/react-router/basic/tests/devtools.spec.ts b/e2e/react-router/basic/tests/devtools.spec.ts deleted file mode 100644 index b8a7e803e6..0000000000 --- a/e2e/react-router/basic/tests/devtools.spec.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { expect } from '@playwright/test' -import { test } from '@tanstack/router-e2e-utils' - -for (const mode of ['panel', 'shadow', 'floating']) { - test(`devtools preserve typography and explorer indentation in ${mode} mode`, async ({ - page, - }) => { - await page.goto(mode === 'floating' ? '/' : `/?devtools=${mode}`) - if (mode === 'floating') { - await page - .getByRole('button', { name: 'Open TanStack Router Devtools' }) - .click() - } - - const panel = page.locator('.TanStackRouterDevtoolsPanel') - const router = panel.getByRole('button', { name: /^Router\s*\d+ items/ }) - const state = panel.getByRole('button', { name: /^state\s*\d+ items/ }) - await expect(router).toBeVisible() - await expect(state).toBeVisible() - await expect(router).toHaveCSS('font-size', '12px') - await expect(router).toHaveCSS('gap', '4px') - await expect( - panel.getByText('Pathname', { exact: true }).locator('..'), - ).toHaveCSS('padding-left', '8px') - - const routerBox = await router.boundingBox() - const stateBox = await state.boundingBox() - expect(stateBox!.x - routerBox!.x).toBe(18) - - if (mode !== 'floating') { - await page.addStyleTag({ content: ':root { font-size: 20px; }' }) - await expect(router).toHaveCSS('font-size', '15px') - await expect(router).toHaveCSS('gap', '5px') - - await page.addStyleTag({ - content: ':root { --tsrd-font-size: 24px; }', - }) - await expect(router).toHaveCSS('font-size', '18px') - await expect(router).toHaveCSS('gap', '6px') - } - }) -} diff --git a/e2e/react-router/rspack-basic-file-based/package.json b/e2e/react-router/rspack-basic-file-based/package.json index 5ec9ed9862..4bff5e7801 100644 --- a/e2e/react-router/rspack-basic-file-based/package.json +++ b/e2e/react-router/rspack-basic-file-based/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", diff --git a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/package.json b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/package.json index 30c62d0af1..efd3f6e2c3 100644 --- a/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/package.json +++ b/e2e/react-router/rspack-basic-virtual-named-export-config-file-based/package.json @@ -18,7 +18,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", diff --git a/e2e/react-start/basic-cloudflare/tests/app.spec.ts b/e2e/react-start/basic-cloudflare/tests/app.spec.ts index c9497070dd..add28cb73e 100644 --- a/e2e/react-start/basic-cloudflare/tests/app.spec.ts +++ b/e2e/react-start/basic-cloudflare/tests/app.spec.ts @@ -1,5 +1,3 @@ -import { execFileSync } from 'node:child_process' -import { fileURLToPath } from 'node:url' import { existsSync } from 'node:fs' import { join } from 'node:path' import { expect } from '@playwright/test' @@ -31,19 +29,3 @@ test('prerender with Cloudflare Workers runtime', async ({ page }) => { 'The value is Hello from Cloudflare', ) }) - -test('the built Cloudflare app passes a deployment dry run', () => { - const wrangler = fileURLToPath( - new URL('../node_modules/wrangler/bin/wrangler.js', import.meta.url), - ) - const output = execFileSync( - process.execPath, - [wrangler, 'deploy', '--dry-run'], - { - encoding: 'utf8', - env: { ...process.env, WRANGLER_SEND_METRICS: 'false' }, - }, - ) - expect(output).toContain('dist/server/wrangler.json') - expect(output).toContain('--dry-run: exiting now.') -}) diff --git a/e2e/react-start/basic/package.json b/e2e/react-start/basic/package.json index 3a1a4ea9c8..be5caf72d4 100644 --- a/e2e/react-start/basic/package.json +++ b/e2e/react-start/basic/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tailwindcss/vite": "^4.2.2", @@ -50,18 +50,6 @@ "zod": "^4.4.3" }, "nx": { - "targets": { - "test:e2e--vite-spa--dev": { - "dependsOn": [ - "^build" - ] - }, - "test:e2e--rsbuild-spa--dev": { - "dependsOn": [ - "^build" - ] - } - }, "metadata": { "playwrightModes": [ { @@ -72,14 +60,6 @@ "toolchain": "vite", "mode": "spa" }, - { - "toolchain": "vite", - "mode": "spa", - "name": "dev", - "env": { - "E2E_DEV_SERVER": "true" - } - }, { "toolchain": "vite", "mode": "prerender", @@ -107,14 +87,6 @@ "toolchain": "rsbuild", "mode": "spa" }, - { - "toolchain": "rsbuild", - "mode": "spa", - "name": "dev", - "env": { - "E2E_DEV_SERVER": "true" - } - }, { "toolchain": "rsbuild", "mode": "prerender", diff --git a/e2e/react-start/basic/playwright.config.ts b/e2e/react-start/basic/playwright.config.ts index bb4c2cb761..bdf5fd74ca 100644 --- a/e2e/react-start/basic/playwright.config.ts +++ b/e2e/react-start/basic/playwright.config.ts @@ -5,8 +5,6 @@ const mode = process.env.MODE ?? 'ssr' const toolchain = process.env.E2E_TOOLCHAIN ?? 'vite' const distDir = process.env.E2E_DIST_DIR ?? 'dist' -// The dev runs start the dev server and run only the SPA shell spec -const devServer = process.env.E2E_DEV_SERVER === 'true' const PORT = Number(process.env.E2E_APP_PORT ?? 0) const baseURL = `http://localhost:${PORT}` @@ -14,26 +12,12 @@ const previewCommand = toolchain === 'rsbuild' ? `pnpm preview:rsbuild --host 0.0.0.0 --port ${PORT}` : `pnpm preview --host 0.0.0.0 --outDir ${distDir} --port ${PORT}` -const devCommand = - toolchain === 'rsbuild' - ? `pnpm dev:rsbuild --port ${PORT}` - : `pnpm dev:vite --port ${PORT}` -const commandByMode = devServer - ? devCommand - : mode === 'preview' - ? previewCommand - : 'pnpm start' +const commandByMode = mode === 'preview' ? previewCommand : 'pnpm start' /** * See https://playwright.dev/docs/test-configuration. */ export default defineConfig({ testDir: './tests', - ...(devServer - ? { - testMatch: 'spa-shell.spec.ts', - globalSetup: './tests/setup/dev-server.setup.ts', - } - : {}), workers: 1, reporter: [['line']], diff --git a/e2e/react-start/basic/src/routeTree.gen.ts b/e2e/react-start/basic/src/routeTree.gen.ts index b6603dd01d..d5416aa352 100644 --- a/e2e/react-start/basic/src/routeTree.gen.ts +++ b/e2e/react-start/basic/src/routeTree.gen.ts @@ -15,8 +15,6 @@ import { Route as AsyncScriptsRouteImport } from './routes/async-scripts' import { Route as AuthDocsRouteImport } from './routes/auth-docs' import { Route as ClientOnlyRouteImport } from './routes/client-only' import { Route as DeferredRouteImport } from './routes/deferred' -import { Route as ExecutionLocalRouteImport } from './routes/execution-local' -import { Route as ExecutionRpcRouteImport } from './routes/execution-rpc' import { Route as InlineScriptsRouteImport } from './routes/inline-scripts' import { Route as LinksRouteImport } from './routes/links' import { Route as NotFoundRouteRouteImport } from './routes/not-found/route' @@ -115,16 +113,6 @@ const DeferredRoute = DeferredRouteImport.update({ path: '/deferred', getParentRoute: () => rootRouteImport, } as any) -const ExecutionLocalRoute = ExecutionLocalRouteImport.update({ - id: '/execution-local', - path: '/execution-local', - getParentRoute: () => rootRouteImport, -} as any) -const ExecutionRpcRoute = ExecutionRpcRouteImport.update({ - id: '/execution-rpc', - path: '/execution-rpc', - getParentRoute: () => rootRouteImport, -} as any) const InlineScriptsRoute = InlineScriptsRouteImport.update({ id: '/inline-scripts', path: '/inline-scripts', @@ -491,8 +479,6 @@ export interface FileRoutesByFullPath { '/auth-docs': typeof AuthDocsRouteWithChildren '/client-only': typeof ClientOnlyRoute '/deferred': typeof DeferredRoute - '/execution-local': typeof ExecutionLocalRoute - '/execution-rpc': typeof ExecutionRpcRoute '/inline-scripts': typeof InlineScriptsRoute '/links': typeof LinksRoute '/plain-ts-type-assertion': typeof PlainTsTypeAssertionRoute @@ -565,8 +551,6 @@ export interface FileRoutesByTo { '/auth-docs': typeof AuthDocsRouteWithChildren '/client-only': typeof ClientOnlyRoute '/deferred': typeof DeferredRoute - '/execution-local': typeof ExecutionLocalRoute - '/execution-rpc': typeof ExecutionRpcRoute '/inline-scripts': typeof InlineScriptsRoute '/links': typeof LinksRoute '/plain-ts-type-assertion': typeof PlainTsTypeAssertionRoute @@ -636,8 +620,6 @@ export interface FileRoutesById { '/auth-docs': typeof AuthDocsRouteWithChildren '/client-only': typeof ClientOnlyRoute '/deferred': typeof DeferredRoute - '/execution-local': typeof ExecutionLocalRoute - '/execution-rpc': typeof ExecutionRpcRoute '/inline-scripts': typeof InlineScriptsRoute '/links': typeof LinksRoute '/plain-ts-type-assertion': typeof PlainTsTypeAssertionRoute @@ -715,8 +697,6 @@ export interface FileRouteTypes { | '/auth-docs' | '/client-only' | '/deferred' - | '/execution-local' - | '/execution-rpc' | '/inline-scripts' | '/links' | '/plain-ts-type-assertion' @@ -789,8 +769,6 @@ export interface FileRouteTypes { | '/auth-docs' | '/client-only' | '/deferred' - | '/execution-local' - | '/execution-rpc' | '/inline-scripts' | '/links' | '/plain-ts-type-assertion' @@ -859,8 +837,6 @@ export interface FileRouteTypes { | '/auth-docs' | '/client-only' | '/deferred' - | '/execution-local' - | '/execution-rpc' | '/inline-scripts' | '/links' | '/plain-ts-type-assertion' @@ -938,8 +914,6 @@ export interface RootRouteChildren { AuthDocsRoute: typeof AuthDocsRouteWithChildren ClientOnlyRoute: typeof ClientOnlyRoute DeferredRoute: typeof DeferredRoute - ExecutionLocalRoute: typeof ExecutionLocalRoute - ExecutionRpcRoute: typeof ExecutionRpcRoute InlineScriptsRoute: typeof InlineScriptsRoute LinksRoute: typeof LinksRoute PlainTsTypeAssertionRoute: typeof PlainTsTypeAssertionRoute @@ -1005,20 +979,6 @@ declare module '@tanstack/react-router' { preLoaderRoute: typeof DeferredRouteImport parentRoute: typeof rootRouteImport } - '/execution-local': { - id: '/execution-local' - path: '/execution-local' - fullPath: '/execution-local' - preLoaderRoute: typeof ExecutionLocalRouteImport - parentRoute: typeof rootRouteImport - } - '/execution-rpc': { - id: '/execution-rpc' - path: '/execution-rpc' - fullPath: '/execution-rpc' - preLoaderRoute: typeof ExecutionRpcRouteImport - parentRoute: typeof rootRouteImport - } '/inline-scripts': { id: '/inline-scripts' path: '/inline-scripts' @@ -1769,8 +1729,6 @@ const rootRouteChildren: RootRouteChildren = { AuthDocsRoute: AuthDocsRouteWithChildren, ClientOnlyRoute: ClientOnlyRoute, DeferredRoute: DeferredRoute, - ExecutionLocalRoute: ExecutionLocalRoute, - ExecutionRpcRoute: ExecutionRpcRoute, InlineScriptsRoute: InlineScriptsRoute, LinksRoute: LinksRoute, PlainTsTypeAssertionRoute: PlainTsTypeAssertionRoute, diff --git a/e2e/react-start/basic/src/routes/__root.tsx b/e2e/react-start/basic/src/routes/__root.tsx index ed521817d6..d8fc0d3b24 100644 --- a/e2e/react-start/basic/src/routes/__root.tsx +++ b/e2e/react-start/basic/src/routes/__root.tsx @@ -197,9 +197,6 @@ function RootDocument({ children }: { children: React.ReactNode }) { > Client Only {' '} - - Server function loader - {' '} readOnlyOnServer(), - component: Result, - errorComponent: ({ error }) => ( -

{error instanceof Error ? error.message : String(error)}

- ), -}) - -function Result() { - return

{Route.useLoaderData()}

-} diff --git a/e2e/react-start/basic/src/routes/execution-rpc.tsx b/e2e/react-start/basic/src/routes/execution-rpc.tsx deleted file mode 100644 index f934015522..0000000000 --- a/e2e/react-start/basic/src/routes/execution-rpc.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { createFileRoute, Link } from '@tanstack/react-router' -import { readThroughRpc } from '~/utils/execution-functions' - -export const Route = createFileRoute('/execution-rpc')({ - loader: () => readThroughRpc(), - component: Result, -}) - -function Result() { - return ( - <> -

{Route.useLoaderData()}

- - Call the server-only helper directly - - - ) -} diff --git a/e2e/react-start/basic/src/utils/execution-functions.ts b/e2e/react-start/basic/src/utils/execution-functions.ts deleted file mode 100644 index 97e66573d8..0000000000 --- a/e2e/react-start/basic/src/utils/execution-functions.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' - -export const readOnlyOnServer = createServerOnlyFn(() => 'Read on the server') - -export const readThroughRpc = createServerFn().handler(() => readOnlyOnServer()) diff --git a/e2e/react-start/basic/tests/client-only.spec.ts b/e2e/react-start/basic/tests/client-only.spec.ts index 299744f636..a3b6f99442 100644 --- a/e2e/react-start/basic/tests/client-only.spec.ts +++ b/e2e/react-start/basic/tests/client-only.spec.ts @@ -1,6 +1,5 @@ import { expect } from '@playwright/test' import { test } from '@tanstack/router-e2e-utils' -import { isSpaMode } from './utils/isSpaMode' /** * These tests verify the compiler optimization. @@ -16,15 +15,7 @@ import { isSpaMode } from './utils/isSpaMode' test('ClientOnly renders fallback on server, then client content after hydration', async ({ page, - request, }) => { - const response = await request.get('/client-only') - expect(response.status()).toBe(200) - const html = await response.text() - expect(html).not.toContain('data-testid="window-size"') - if (!isSpaMode) { - expect(html).toContain('Loading window size...') - } // Navigate directly to the client-only route // If the compiler optimization isn't working, this would crash the server // because WindowSize.tsx accesses `window` at module scope diff --git a/e2e/react-start/basic/tests/environment-functions.spec.ts b/e2e/react-start/basic/tests/environment-functions.spec.ts deleted file mode 100644 index 410b1d999e..0000000000 --- a/e2e/react-start/basic/tests/environment-functions.spec.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { expect, test } from '@playwright/test' -import { isSpaMode } from './utils/isSpaMode' - -const guardError = - 'createServerOnlyFn() functions can only be called on the server!' - -test('a server-only loader works on the server but rejects client navigation', async ({ - page, - request, -}) => { - const direct = await request.get('/execution-local') - expect(direct.status()).toBe(200) - if (!isSpaMode) { - expect(await direct.text()).toContain('Read on the server') - } - await page.goto('/execution-rpc') - await expect(page.getByTestId('execution-result')).toHaveText( - 'Read on the server', - ) - await page - .getByRole('link', { name: 'Call the server-only helper directly' }) - .click() - await expect(page.getByRole('alert')).toHaveText(guardError) -}) - -test('a server function preserves the loader result on direct requests and navigation', async ({ - page, - request, -}) => { - const direct = await request.get('/execution-rpc') - expect(direct.status()).toBe(200) - if (!isSpaMode) { - expect(await direct.text()).toContain('Read on the server') - } - await page.goto('/') - await page - .getByRole('link', { name: 'Server function loader', exact: true }) - .click() - await expect(page.getByTestId('execution-result')).toHaveText( - 'Read on the server', - ) - await page.reload() - await expect(page.getByTestId('execution-result')).toHaveText( - 'Read on the server', - ) -}) diff --git a/e2e/react-start/basic/tests/setup/dev-server.setup.ts b/e2e/react-start/basic/tests/setup/dev-server.setup.ts deleted file mode 100644 index d16ff0bb54..0000000000 --- a/e2e/react-start/basic/tests/setup/dev-server.setup.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { preOptimizeDevServer, waitForServer } from '@tanstack/router-e2e-utils' - -export default async function setup() { - const port = Number(process.env.E2E_APP_PORT ?? 0) - const baseURL = `http://localhost:${port}` - - await waitForServer(baseURL) - await preOptimizeDevServer({ - baseURL, - warmup: async (page) => { - await page.getByRole('heading').getByText('Welcome Home').waitFor() - await page.goto(`${baseURL}/specialChars/search?searchParam=warmup`) - await page.getByTestId('special-search-loaded-info').waitFor() - await page.goto(`${baseURL}/posts`) - await page.getByRole('link', { name: 'sunt aut facere repe' }).waitFor() - await page.waitForLoadState('networkidle') - }, - }) -} diff --git a/e2e/react-start/basic/tests/spa-shell.spec.ts b/e2e/react-start/basic/tests/spa-shell.spec.ts deleted file mode 100644 index f42195e762..0000000000 --- a/e2e/react-start/basic/tests/spa-shell.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { expect } from '@playwright/test' -import { test } from '@tanstack/router-e2e-utils' -import { isSpaMode } from './utils/isSpaMode' - -// The prod SPA run and the dev SPA runs (`E2E_DEV_SERVER`) all run this file. -// The dev runs run nothing else. -test.skip(!isSpaMode, 'only SPA mode answers documents with the shell') - -// Its loader and beforeLoad report where they ran. -const searchRoute = '/specialChars/search?searchParam=shell' - -test('a document request gets the shell, not the rendered route', async ({ - request, -}) => { - const response = await request.get(searchRoute) - - expect(response.status()).toBe(200) - const html = await response.text() - // The root route's document renders... - expect(html).toContain('This Route Does Not Exist') - // ...but not the matched route, nor its loader's output. - expect(html).not.toContain('special-search-loaded-info') - expect(html).not.toContain('Loaded on: server') -}) - -test('the route loads in the browser', async ({ page }) => { - await page.goto(searchRoute) - - await expect(page.getByTestId('special-search-loaded-info')).toHaveText( - 'Loaded on: client', - ) - await expect(page.getByTestId('special-search-before-load-info')).toHaveText( - 'Before load on: client', - ) - await expect(page.getByTestId('special-search-param')).toHaveText('shell') -}) - -test('client navigation works from the shell', async ({ page }) => { - await page.goto('/') - await expect(page.getByRole('heading')).toContainText('Welcome Home') - await expect(page.getByTestId('router-status')).toHaveText('idle') - - // A full page load would drop this. - await page.evaluate(() => { - ;(window as any).__spaShellPage = true - }) - await page.getByRole('link', { name: 'Posts' }).click() - await page.waitForURL('/posts') - await expect( - page.getByRole('link', { name: 'sunt aut facere repe' }), - ).toBeVisible() - expect(await page.evaluate(() => (window as any).__spaShellPage)).toBe(true) -}) diff --git a/e2e/react-start/css-inline/package.json b/e2e/react-start/css-inline/package.json index 6c5dd031c6..8e77dba817 100644 --- a/e2e/react-start/css-inline/package.json +++ b/e2e/react-start/css-inline/package.json @@ -24,7 +24,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", diff --git a/e2e/react-start/css-modules/.gitignore b/e2e/react-start/css-modules/.gitignore index a1fbca128d..229709a89d 100644 --- a/e2e/react-start/css-modules/.gitignore +++ b/e2e/react-start/css-modules/.gitignore @@ -3,4 +3,3 @@ dist test-results playwright-report port*.txt -.cloudflare diff --git a/e2e/react-start/css-modules/cloudflare.config.ts b/e2e/react-start/css-modules/cloudflare.config.ts deleted file mode 100644 index e2bd5e13f1..0000000000 --- a/e2e/react-start/css-modules/cloudflare.config.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { defineConfig } from 'cf/config' - -// Used by rsbuild-plugin-cloudflare (E2E_RSBUILD_CLOUDFLARE=true). -// The Vite Cloudflare variant still reads wrangler.jsonc. -export default defineConfig({ - worker: { - name: 'tanstack-start-css-modules', - entrypoint: '@tanstack/react-start/server-entry', - compatibilityDate: '2026-11-01', - }, -}) diff --git a/e2e/react-start/css-modules/package.json b/e2e/react-start/css-modules/package.json index 25c11d7321..93f9dadd74 100644 --- a/e2e/react-start/css-modules/package.json +++ b/e2e/react-start/css-modules/package.json @@ -12,8 +12,6 @@ "dev:e2e:basepath": "VITE_BASE_PATH=/my-app vite dev --port $PORT", "dev:cloudflare": "echo 'Cloudflare dev mode has React duplication issues - use build+preview instead' && exit 1", "dev:e2e:cloudflare": "echo 'Cloudflare dev mode has React duplication issues - use build+preview instead' && exit 1", - "dev:e2e:rsbuild": "rsbuild dev --port $PORT", - "dev:e2e:rsbuild-cloudflare": "E2E_RSBUILD_CLOUDFLARE=true rsbuild dev --port $PORT", "build": "vite build && tsc --noEmit", "preview": "vite preview", "start": "pnpx srvx --prod -s ../client dist/server/server.js", @@ -21,8 +19,6 @@ "test:e2e:dev:nitro": "MODE=dev VITE_CONFIG=nitro playwright test --project=chromium", "test:e2e:dev:basepath": "MODE=dev VITE_CONFIG=basepath playwright test --project=chromium", "_test:e2e:dev:cloudflare": "MODE=dev VITE_CONFIG=cloudflare playwright test --project=chromium", - "test:e2e:dev:rsbuild": "MODE=dev VITE_CONFIG=rsbuild playwright test --project=chromium", - "test:e2e:dev:rsbuild-cloudflare": "MODE=dev VITE_CONFIG=rsbuild-cloudflare playwright test --project=chromium", "test:e2e:prod:default": "MODE=prod playwright test --project=chromium", "test:e2e:prod": "pnpm run test:e2e:prod:default && pnpm run test:e2e:prod:css-code-split-false", "test:e2e:prod:css-code-split-false": "MODE=prod VITE_CSS_CODE_SPLIT=false playwright test tests/css.prod.spec.ts --project=chromium", @@ -41,7 +37,7 @@ "devDependencies": { "@cloudflare/vite-plugin": "^1.29.0", "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@rsbuild/plugin-sass": "^2.0.1", "@tanstack/router-e2e-utils": "workspace:*", @@ -50,10 +46,8 @@ "@types/react-dom": "^19.0.3", "@typescript/native": "npm:typescript@^7.0.2", "@vitejs/plugin-react": "^6.0.1", - "cf": "1.0.0-beta.28", "nitro": "^3.0.260903-beta", - "rsbuild-plugin-cloudflare": "^0.0.4", - "sass": "^1.97.2", + "sass": "^1.105.1", "srvx": "^1.0.0", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/e2e/react-start/css-modules/rsbuild.config.ts b/e2e/react-start/css-modules/rsbuild.config.ts index 499ed67ebc..e9d4068c5c 100644 --- a/e2e/react-start/css-modules/rsbuild.config.ts +++ b/e2e/react-start/css-modules/rsbuild.config.ts @@ -2,25 +2,9 @@ import { defineConfig } from '@rsbuild/core' import { pluginReact } from '@rsbuild/plugin-react' import { pluginSass } from '@rsbuild/plugin-sass' import { tanstackStart } from '@tanstack/react-start/plugin/rsbuild' -import { cloudflare } from 'rsbuild-plugin-cloudflare' - -// E2E_RSBUILD_CLOUDFLARE: Set to 'true' to run the SSR environment in workerd -const useCloudflare = process.env.E2E_RSBUILD_CLOUDFLARE === 'true' export default defineConfig({ - plugins: [ - pluginReact(), - pluginSass(), - ...(useCloudflare - ? [ - cloudflare({ - rsbuildEnvironment: { name: 'ssr' }, - inspectorPort: false, - }), - ] - : []), - tanstackStart(), - ], + plugins: [pluginReact(), pluginSass(), tanstackStart()], output: { distPath: { root: process.env.E2E_DIST_DIR ?? 'dist-rsbuild-ssr', diff --git a/e2e/react-start/custom-server-rsbuild/package.json b/e2e/react-start/custom-server-rsbuild/package.json index 1c5b3af393..41a825e6ff 100644 --- a/e2e/react-start/custom-server-rsbuild/package.json +++ b/e2e/react-start/custom-server-rsbuild/package.json @@ -21,7 +21,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", diff --git a/e2e/react-start/deferred-hydration/package.json b/e2e/react-start/deferred-hydration/package.json index 5a33407435..221fceba2b 100644 --- a/e2e/react-start/deferred-hydration/package.json +++ b/e2e/react-start/deferred-hydration/package.json @@ -26,7 +26,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", diff --git a/e2e/react-start/hmr/package.json b/e2e/react-start/hmr/package.json index 76a5d86b1f..7a6dc23f76 100644 --- a/e2e/react-start/hmr/package.json +++ b/e2e/react-start/hmr/package.json @@ -21,7 +21,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tailwindcss/vite": "^4.2.2", diff --git a/e2e/react-start/hmr/tests/app.spec.ts b/e2e/react-start/hmr/tests/app.spec.ts index 645c9b06f3..eedb4eed98 100644 --- a/e2e/react-start/hmr/tests/app.spec.ts +++ b/e2e/react-start/hmr/tests/app.spec.ts @@ -932,7 +932,6 @@ test.describe('react-start hmr', () => { await waitForRouteModuleUpdate(page, '/child', 'Child Updated') }, ) - await waitForHydrationSafeReload(page, '/child', 'Child Updated') // Second edit: change child loader again while still on / await replaceRouteTextAndWait( diff --git a/e2e/react-start/import-protection/package.json b/e2e/react-start/import-protection/package.json index ad06ba41ea..a87df63d6f 100644 --- a/e2e/react-start/import-protection/package.json +++ b/e2e/react-start/import-protection/package.json @@ -22,7 +22,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", diff --git a/e2e/react-start/response-reconciliation/package.json b/e2e/react-start/response-reconciliation/package.json index 7ba0224962..7ec4e14415 100644 --- a/e2e/react-start/response-reconciliation/package.json +++ b/e2e/react-start/response-reconciliation/package.json @@ -23,7 +23,7 @@ }, "devDependencies": { "@playwright/test": "^1.57.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.0.8", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "25.0.9", diff --git a/e2e/react-start/rsbuild/package.json b/e2e/react-start/rsbuild/package.json index d03ef22542..a1e1877e32 100644 --- a/e2e/react-start/rsbuild/package.json +++ b/e2e/react-start/rsbuild/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", diff --git a/e2e/react-start/rsc-deferred-hydration/package.json b/e2e/react-start/rsc-deferred-hydration/package.json index 06317e59d0..e9ef601352 100644 --- a/e2e/react-start/rsc-deferred-hydration/package.json +++ b/e2e/react-start/rsc-deferred-hydration/package.json @@ -45,7 +45,7 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^6.0.1", - "@vitejs/plugin-rsc": "^0.5.39", + "@vitejs/plugin-rsc": "^0.5.37", "srvx": "^1.0.0", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", diff --git a/e2e/react-start/rsc-query/package.json b/e2e/react-start/rsc-query/package.json index 68a99cd432..0b19a3244c 100644 --- a/e2e/react-start/rsc-query/package.json +++ b/e2e/react-start/rsc-query/package.json @@ -28,7 +28,7 @@ "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^6.0.1", - "@vitejs/plugin-rsc": "^0.5.39", + "@vitejs/plugin-rsc": "^0.5.37", "srvx": "^1.0.0", "typescript": "^5.7.2", "vite": "^8.0.14" diff --git a/e2e/react-start/rsc-rsbuild/package.json b/e2e/react-start/rsc-rsbuild/package.json index 067394fc08..e9367727e5 100644 --- a/e2e/react-start/rsc-rsbuild/package.json +++ b/e2e/react-start/rsc-rsbuild/package.json @@ -28,7 +28,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", diff --git a/e2e/react-start/rsc/package.json b/e2e/react-start/rsc/package.json index a30227d509..5a6bcceedc 100644 --- a/e2e/react-start/rsc/package.json +++ b/e2e/react-start/rsc/package.json @@ -13,8 +13,7 @@ "build:vite": "vite build && tsc --noEmit", "preview": "vite preview", "start": "node server.js", - "test:e2e-full": "pnpm build && playwright test --project=chromium", - "test:e2e:dev:rsbuild": "MODE=dev E2E_TOOLCHAIN=rsbuild playwright test --project=chromium" + "test:e2e-full": "pnpm build && playwright test --project=chromium" }, "nx": { "metadata": { @@ -41,7 +40,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/eslint-plugin-start": "workspace:^", "@tanstack/router-e2e-utils": "workspace:^", @@ -50,7 +49,7 @@ "@types/react-dom": "^19.0.3", "@typescript-eslint/parser": "^8.23.0", "@vitejs/plugin-react": "^6.0.1", - "@vitejs/plugin-rsc": "^0.5.39", + "@vitejs/plugin-rsc": "^0.5.37", "eslint": "^9.22.0", "srvx": "^1.0.0", "typescript": "^5.7.2", diff --git a/e2e/react-start/rsc/playwright.config.ts b/e2e/react-start/rsc/playwright.config.ts index 075efdc5b9..6cbc07f75a 100644 --- a/e2e/react-start/rsc/playwright.config.ts +++ b/e2e/react-start/rsc/playwright.config.ts @@ -2,8 +2,6 @@ import { defineConfig, devices } from '@playwright/test' import { appServerReady } from '@tanstack/router-e2e-utils' const distDir = process.env.E2E_DIST_DIR ?? 'dist' -// MODE=dev runs the suite against the Rsbuild dev server instead of a build -const isRsbuildDev = process.env.MODE === 'dev' const PORT = Number(process.env.E2E_APP_PORT ?? 0) const baseURL = `http://localhost:${PORT}` @@ -18,7 +16,7 @@ export default defineConfig({ }, webServer: { - command: isRsbuildDev ? 'pnpm dev:rsbuild --port 0' : 'pnpm start', + command: 'pnpm start', wait: appServerReady, reuseExistingServer: false, stdout: 'pipe', diff --git a/e2e/react-start/rsc/tests/rsc-css-preload-complex.spec.ts b/e2e/react-start/rsc/tests/rsc-css-preload-complex.spec.ts index 35db86eca9..f5d8e04928 100644 --- a/e2e/react-start/rsc/tests/rsc-css-preload-complex.spec.ts +++ b/e2e/react-start/rsc/tests/rsc-css-preload-complex.spec.ts @@ -116,16 +116,15 @@ test.describe('RSC Complex CSS Preload Tests', () => { test('CSS module classes are scoped for all widgets', async ({ page }) => { await page.goto('/rsc-css-preload-complex') - // Widget A classes should be hashed (accept Vite `_widget_xxx`, Rspack - // `widget-xxx`, and Rsbuild dev `src-...-module__widget-xxx` scoped names) + // Widget A classes should be hashed (accept Vite `_widget_xxx` or Rspack `widget-xxx` scoped names) const widgetA = page.locator('[data-testid="client-widget-a"]') const widgetAClass = await widgetA.getAttribute('class') - expect(widgetAClass).toMatch(/(^|\s|__)(_widget_|widget[-_])[\w-]+/) + expect(widgetAClass).toMatch(/(^|\s)(_widget_|widget[-_])[\w-]+/) // Widget B classes should be hashed const widgetB = page.locator('[data-testid="client-widget-b"]') const widgetBClass = await widgetB.getAttribute('class') - expect(widgetBClass).toMatch(/(^|\s|__)(_widget_|widget[-_])[\w-]+/) + expect(widgetBClass).toMatch(/(^|\s)(_widget_|widget[-_])[\w-]+/) // Classes should be different (different modules) expect(widgetAClass).not.toBe(widgetBClass) diff --git a/e2e/react-start/server-functions/package.json b/e2e/react-start/server-functions/package.json index 63d8661717..0fe7507b78 100644 --- a/e2e/react-start/server-functions/package.json +++ b/e2e/react-start/server-functions/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", "@tailwindcss/postcss": "^4.2.2", "@tailwindcss/vite": "^4.2.2", diff --git a/e2e/react-start/session-handling/package.json b/e2e/react-start/session-handling/package.json index 9dda8b2843..0fd5adb908 100644 --- a/e2e/react-start/session-handling/package.json +++ b/e2e/react-start/session-handling/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@playwright/test": "^1.57.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.0.8", "@rsbuild/plugin-react": "^2.0.0", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "25.0.9", diff --git a/e2e/solid-router/basic-esbuild-file-based/src/esbuild.config.js b/e2e/solid-router/basic-esbuild-file-based/src/esbuild.config.js index 68d31fe754..2d6ea80c1b 100644 --- a/e2e/solid-router/basic-esbuild-file-based/src/esbuild.config.js +++ b/e2e/solid-router/basic-esbuild-file-based/src/esbuild.config.js @@ -6,6 +6,7 @@ export default { plugins: [ tanstackRouter({ target: 'solid', + autoCodeSplitting: true, }), solidPlugin(), ], diff --git a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts index 7601b581cc..c7cbb94b56 100644 --- a/e2e/solid-router/basic-file-based/src/routeTree.gen.ts +++ b/e2e/solid-router/basic-file-based/src/routeTree.gen.ts @@ -1451,7 +1451,7 @@ declare module '@tanstack/solid-router' { '/(group)/_layout': { id: '/(group)/_layout' path: '' - fullPath: '/' + fullPath: '' preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof rootRouteImport } diff --git a/e2e/solid-router/rspack-basic-file-based/package.json b/e2e/solid-router/rspack-basic-file-based/package.json index 4015f0f606..bf1902750a 100644 --- a/e2e/solid-router/rspack-basic-file-based/package.json +++ b/e2e/solid-router/rspack-basic-file-based/package.json @@ -17,9 +17,9 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", - "@rsbuild/plugin-solid": "^1.1.1", + "@rsbuild/plugin-solid": "^1.2.2", "@tailwindcss/postcss": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", "@tanstack/router-plugin": "workspace:^", diff --git a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/package.json b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/package.json index 3772d7beb1..734a3f6a39 100644 --- a/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/package.json +++ b/e2e/solid-router/rspack-basic-virtual-named-export-config-file-based/package.json @@ -17,9 +17,9 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", - "@rsbuild/plugin-solid": "^1.1.1", + "@rsbuild/plugin-solid": "^1.2.2", "@tailwindcss/postcss": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", "@tanstack/router-plugin": "workspace:^", diff --git a/e2e/solid-start/basic/package.json b/e2e/solid-start/basic/package.json index e83ed11775..b638373f7a 100644 --- a/e2e/solid-start/basic/package.json +++ b/e2e/solid-start/basic/package.json @@ -27,9 +27,9 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", - "@rsbuild/plugin-solid": "^1.1.1", + "@rsbuild/plugin-solid": "^1.2.2", "@tailwindcss/postcss": "^4.2.2", "@tailwindcss/vite": "^4.2.2", "@tanstack/router-e2e-utils": "workspace:^", diff --git a/e2e/solid-start/css-modules/package.json b/e2e/solid-start/css-modules/package.json index 107659f43c..e3812ad8f6 100644 --- a/e2e/solid-start/css-modules/package.json +++ b/e2e/solid-start/css-modules/package.json @@ -22,7 +22,7 @@ "@playwright/test": "^1.61.0", "@tanstack/router-e2e-utils": "workspace:*", "@types/node": "^22.10.2", - "sass": "^1.97.2", + "sass": "^1.105.1", "srvx": "^1.0.0", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", diff --git a/e2e/solid-start/deferred-hydration/package.json b/e2e/solid-start/deferred-hydration/package.json index 4e2a3a1665..cc7ee33710 100644 --- a/e2e/solid-start/deferred-hydration/package.json +++ b/e2e/solid-start/deferred-hydration/package.json @@ -23,9 +23,9 @@ "solid-js": "^1.9.10" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", - "@rsbuild/plugin-solid": "^1.1.1", + "@rsbuild/plugin-solid": "^1.2.2", "@tanstack/router-e2e-utils": "workspace:^", "@types/node": "^22.10.2", "srvx": "^1.0.0", diff --git a/e2e/vue-router/basic-esbuild-file-based/src/esbuild.config.js b/e2e/vue-router/basic-esbuild-file-based/src/esbuild.config.js index 16f6fbca44..c4aba8798e 100644 --- a/e2e/vue-router/basic-esbuild-file-based/src/esbuild.config.js +++ b/e2e/vue-router/basic-esbuild-file-based/src/esbuild.config.js @@ -9,6 +9,7 @@ export default { }), tanstackRouter({ target: 'vue', + autoCodeSplitting: true, }), ], } diff --git a/e2e/vue-router/basic-file-based-jsx/src/routeTree.gen.ts b/e2e/vue-router/basic-file-based-jsx/src/routeTree.gen.ts index 5922c5f7b1..3922025c82 100644 --- a/e2e/vue-router/basic-file-based-jsx/src/routeTree.gen.ts +++ b/e2e/vue-router/basic-file-based-jsx/src/routeTree.gen.ts @@ -364,7 +364,7 @@ declare module '@tanstack/vue-router' { '/(group)/_layout': { id: '/(group)/_layout' path: '' - fullPath: '/' + fullPath: '' preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof rootRouteImport } diff --git a/e2e/vue-router/basic-file-based-sfc/src/routeTree.gen.ts b/e2e/vue-router/basic-file-based-sfc/src/routeTree.gen.ts index 0bfdddab3d..09d62b0706 100644 --- a/e2e/vue-router/basic-file-based-sfc/src/routeTree.gen.ts +++ b/e2e/vue-router/basic-file-based-sfc/src/routeTree.gen.ts @@ -454,7 +454,7 @@ declare module '@tanstack/vue-router' { '/(group)/_layout': { id: '/(group)/_layout' path: '' - fullPath: '/' + fullPath: '' preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof rootRouteImport } diff --git a/e2e/vue-router/rspack-basic-file-based/package.json b/e2e/vue-router/rspack-basic-file-based/package.json index 93439f7d5b..b420125e51 100644 --- a/e2e/vue-router/rspack-basic-file-based/package.json +++ b/e2e/vue-router/rspack-basic-file-based/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", "@rsbuild/plugin-vue": "^1.2.7", "@rsbuild/plugin-vue-jsx": "^2.0.0", diff --git a/e2e/vue-router/rspack-basic-virtual-named-export-config-file-based/package.json b/e2e/vue-router/rspack-basic-virtual-named-export-config-file-based/package.json index 536435a09e..f1259e5e7a 100644 --- a/e2e/vue-router/rspack-basic-virtual-named-export-config-file-based/package.json +++ b/e2e/vue-router/rspack-basic-virtual-named-export-config-file-based/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", "@rsbuild/plugin-vue": "^1.2.7", "@rsbuild/plugin-vue-jsx": "^2.0.0", diff --git a/e2e/vue-start/basic/package.json b/e2e/vue-start/basic/package.json index 2ff8329543..a8f77e633f 100644 --- a/e2e/vue-start/basic/package.json +++ b/e2e/vue-start/basic/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@playwright/test": "^1.61.0", - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", "@rsbuild/plugin-vue": "^1.2.7", "@rsbuild/plugin-vue-jsx": "^2.0.0", diff --git a/e2e/vue-start/css-modules/package.json b/e2e/vue-start/css-modules/package.json index 3671774644..03303f6921 100644 --- a/e2e/vue-start/css-modules/package.json +++ b/e2e/vue-start/css-modules/package.json @@ -23,7 +23,7 @@ "@tanstack/router-e2e-utils": "workspace:*", "@types/node": "^22.10.2", "@vitejs/plugin-vue-jsx": "^5.1.5", - "sass": "^1.97.2", + "sass": "^1.105.1", "srvx": "^1.0.0", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", diff --git a/examples/react/authenticated-routes-firebase/package.json b/examples/react/authenticated-routes-firebase/package.json index 1efa172047..b42843fe11 100644 --- a/examples/react/authenticated-routes-firebase/package.json +++ b/examples/react/authenticated-routes-firebase/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "firebase": "^11.4.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/authenticated-routes/package.json b/examples/react/authenticated-routes/package.json index 6af48f1d34..2d45efbecb 100644 --- a/examples/react/authenticated-routes/package.json +++ b/examples/react/authenticated-routes/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-default-search-params/package.json b/examples/react/basic-default-search-params/package.json index 96c68fecd4..6152bd2424 100644 --- a/examples/react/basic-default-search-params/package.json +++ b/examples/react/basic-default-search-params/package.json @@ -11,8 +11,8 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-devtools-panel/package.json b/examples/react/basic-devtools-panel/package.json index ccae95d73f..f71816fe1e 100644 --- a/examples/react/basic-devtools-panel/package.json +++ b/examples/react/basic-devtools-panel/package.json @@ -12,8 +12,8 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.67.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-file-based/package.json b/examples/react/basic-file-based/package.json index 9c3cacada1..b437b66d4f 100644 --- a/examples/react/basic-file-based/package.json +++ b/examples/react/basic-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-non-nested-devtools/package.json b/examples/react/basic-non-nested-devtools/package.json index 32e856ebcf..c75ce0ab7b 100644 --- a/examples/react/basic-non-nested-devtools/package.json +++ b/examples/react/basic-non-nested-devtools/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-react-query-file-based/package.json b/examples/react/basic-react-query-file-based/package.json index d01a02872e..8c3be01fdc 100644 --- a/examples/react/basic-react-query-file-based/package.json +++ b/examples/react/basic-react-query-file-based/package.json @@ -12,9 +12,9 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-react-query/package.json b/examples/react/basic-react-query/package.json index edab96afac..2511400465 100644 --- a/examples/react/basic-react-query/package.json +++ b/examples/react/basic-react-query/package.json @@ -12,8 +12,8 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/basic-ssr-file-based/package.json b/examples/react/basic-ssr-file-based/package.json index 3222c33e19..1664016588 100644 --- a/examples/react/basic-ssr-file-based/package.json +++ b/examples/react/basic-ssr-file-based/package.json @@ -11,8 +11,8 @@ "debug": "node --inspect-brk server" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "compression": "^1.8.0", "express": "^5.2.1", "get-port": "^7.1.0", @@ -21,7 +21,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router-devtools": "^1.167.2", "@types/express": "^5.0.6", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.1", diff --git a/examples/react/basic-ssr-streaming-file-based/package.json b/examples/react/basic-ssr-streaming-file-based/package.json index c3c87c8d88..2c7c671bfb 100644 --- a/examples/react/basic-ssr-streaming-file-based/package.json +++ b/examples/react/basic-ssr-streaming-file-based/package.json @@ -11,8 +11,8 @@ "debug": "node --inspect-brk server" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "compression": "^1.8.0", "express": "^5.2.1", "get-port": "^7.1.0", @@ -21,7 +21,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router-devtools": "^1.167.2", "@types/express": "^5.0.6", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.1", diff --git a/examples/react/basic-virtual-file-based/package.json b/examples/react/basic-virtual-file-based/package.json index 84d326435c..81bb6e2530 100644 --- a/examples/react/basic-virtual-file-based/package.json +++ b/examples/react/basic-virtual-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/virtual-file-routes": "^1.162.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/basic-virtual-inside-file-based/package.json b/examples/react/basic-virtual-inside-file-based/package.json index c04cb6012e..b36b7516b2 100644 --- a/examples/react/basic-virtual-inside-file-based/package.json +++ b/examples/react/basic-virtual-inside-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/virtual-file-routes": "^1.162.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/basic/package.json b/examples/react/basic/package.json index 2c09a3dfdf..6ae78632db 100644 --- a/examples/react/basic/package.json +++ b/examples/react/basic/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/deferred-data/package.json b/examples/react/deferred-data/package.json index 99afb661ee..f43183fe1e 100644 --- a/examples/react/deferred-data/package.json +++ b/examples/react/deferred-data/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/i18n-paraglide/package.json b/examples/react/i18n-paraglide/package.json index 88140e8911..0caadc7cde 100644 --- a/examples/react/i18n-paraglide/package.json +++ b/examples/react/i18n-paraglide/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.1.1", "react-dom": "^19.1.1", "tailwindcss": "^4.2.2" diff --git a/examples/react/kitchen-sink-file-based/package.json b/examples/react/kitchen-sink-file-based/package.json index e02defb3ce..34fa355660 100644 --- a/examples/react/kitchen-sink-file-based/package.json +++ b/examples/react/kitchen-sink-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "immer": "^10.1.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/kitchen-sink-react-query-file-based/package.json b/examples/react/kitchen-sink-react-query-file-based/package.json index e3dd032ac2..a37a8fcfa9 100644 --- a/examples/react/kitchen-sink-react-query-file-based/package.json +++ b/examples/react/kitchen-sink-react-query-file-based/package.json @@ -12,9 +12,9 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "immer": "^10.1.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/kitchen-sink-react-query/package.json b/examples/react/kitchen-sink-react-query/package.json index 14d0dc8e86..88ce1fa255 100644 --- a/examples/react/kitchen-sink-react-query/package.json +++ b/examples/react/kitchen-sink-react-query/package.json @@ -12,8 +12,8 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "immer": "^10.1.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/kitchen-sink/package.json b/examples/react/kitchen-sink/package.json index f738efc37e..acc3517abd 100644 --- a/examples/react/kitchen-sink/package.json +++ b/examples/react/kitchen-sink/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "immer": "^10.1.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/large-file-based/package.json b/examples/react/large-file-based/package.json index 23d469d120..4fb5033386 100644 --- a/examples/react/large-file-based/package.json +++ b/examples/react/large-file-based/package.json @@ -13,9 +13,9 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/location-masking/package.json b/examples/react/location-masking/package.json index fe005c0d2f..22d8988ba3 100644 --- a/examples/react/location-masking/package.json +++ b/examples/react/location-masking/package.json @@ -12,8 +12,8 @@ "@radix-ui/react-dialog": "^1.1.6", "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/navigation-blocking/package.json b/examples/react/navigation-blocking/package.json index a7677dfd51..4101cab757 100644 --- a/examples/react/navigation-blocking/package.json +++ b/examples/react/navigation-blocking/package.json @@ -11,8 +11,8 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/quickstart-esbuild-file-based/esbuild.config.js b/examples/react/quickstart-esbuild-file-based/esbuild.config.js index 2f83a79984..fb7950d1fa 100644 --- a/examples/react/quickstart-esbuild-file-based/esbuild.config.js +++ b/examples/react/quickstart-esbuild-file-based/esbuild.config.js @@ -7,5 +7,5 @@ export default { bundle: true, format: 'esm', target: ['esnext'], - plugins: [tanstackRouter({ target: 'react' })], + plugins: [tanstackRouter({ target: 'react', autoCodeSplitting: true })], } diff --git a/examples/react/quickstart-esbuild-file-based/package.json b/examples/react/quickstart-esbuild-file-based/package.json index d855694fec..61df630774 100644 --- a/examples/react/quickstart-esbuild-file-based/package.json +++ b/examples/react/quickstart-esbuild-file-based/package.json @@ -9,9 +9,9 @@ "start": "dev" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/quickstart-file-based/package.json b/examples/react/quickstart-file-based/package.json index 976ec838d1..e17e2fb58b 100644 --- a/examples/react/quickstart-file-based/package.json +++ b/examples/react/quickstart-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/quickstart-rspack-file-based/package.json b/examples/react/quickstart-rspack-file-based/package.json index 824998f428..2e1af2e196 100644 --- a/examples/react/quickstart-rspack-file-based/package.json +++ b/examples/react/quickstart-rspack-file-based/package.json @@ -9,17 +9,17 @@ }, "dependencies": { "@tailwindcss/postcss": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "postcss": "^8.5.1", "react": "^19.0.0", "react-dom": "^19.0.0", "tailwindcss": "^4.2.2" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-react": "^2.0.0", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@typescript/native": "npm:typescript@^7.0.2", diff --git a/examples/react/quickstart-webpack-file-based/package.json b/examples/react/quickstart-webpack-file-based/package.json index baa14b89dd..218cc4b074 100644 --- a/examples/react/quickstart-webpack-file-based/package.json +++ b/examples/react/quickstart-webpack-file-based/package.json @@ -7,14 +7,14 @@ "build": "webpack build && tsc --noEmit" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0" }, "devDependencies": { "@swc/core": "^1.15.33", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "html-webpack-plugin": "^5.6.3", diff --git a/examples/react/quickstart/package.json b/examples/react/quickstart/package.json index b6db476ea8..b3cd7eb3f3 100644 --- a/examples/react/quickstart/package.json +++ b/examples/react/quickstart/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "react": "^19.0.0", "react-dom": "^19.0.0", "tailwindcss": "^4.2.2" diff --git a/examples/react/router-monorepo-react-query/package.json b/examples/react/router-monorepo-react-query/package.json index b158eeda56..cb04422391 100644 --- a/examples/react/router-monorepo-react-query/package.json +++ b/examples/react/router-monorepo-react-query/package.json @@ -12,9 +12,9 @@ "dependencies": { "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1" diff --git a/examples/react/router-monorepo-react-query/packages/app/package.json b/examples/react/router-monorepo-react-query/packages/app/package.json index f0994165c2..59b68d58f0 100644 --- a/examples/react/router-monorepo-react-query/packages/app/package.json +++ b/examples/react/router-monorepo-react-query/packages/app/package.json @@ -16,7 +16,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router-devtools": "^1.167.2", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^6.0.1", diff --git a/examples/react/router-monorepo-react-query/packages/router/package.json b/examples/react/router-monorepo-react-query/packages/router/package.json index 1397db14b5..8017682a4e 100644 --- a/examples/react/router-monorepo-react-query/packages/router/package.json +++ b/examples/react/router-monorepo-react-query/packages/router/package.json @@ -11,8 +11,8 @@ "@router-mono-react-query/post-query": "workspace:*", "@tanstack/history": "^1.162.5", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/router-monorepo-simple-lazy/package.json b/examples/react/router-monorepo-simple-lazy/package.json index e044d86681..5a616900bd 100644 --- a/examples/react/router-monorepo-simple-lazy/package.json +++ b/examples/react/router-monorepo-simple-lazy/package.json @@ -8,9 +8,9 @@ "dev": "pnpm router build && pnpm post-feature build && pnpm app dev" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1" diff --git a/examples/react/router-monorepo-simple-lazy/packages/app/package.json b/examples/react/router-monorepo-simple-lazy/packages/app/package.json index cfc7a94942..48d2ae7206 100644 --- a/examples/react/router-monorepo-simple-lazy/packages/app/package.json +++ b/examples/react/router-monorepo-simple-lazy/packages/app/package.json @@ -15,7 +15,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router-devtools": "^1.167.2", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^6.0.1", diff --git a/examples/react/router-monorepo-simple-lazy/packages/router/package.json b/examples/react/router-monorepo-simple-lazy/packages/router/package.json index afd4702b5d..d54a5e007a 100644 --- a/examples/react/router-monorepo-simple-lazy/packages/router/package.json +++ b/examples/react/router-monorepo-simple-lazy/packages/router/package.json @@ -9,8 +9,8 @@ "types": "./dist/index.d.ts", "dependencies": { "@tanstack/history": "^1.162.5", - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/router-monorepo-simple/package.json b/examples/react/router-monorepo-simple/package.json index 800d948c81..77dd24f75f 100644 --- a/examples/react/router-monorepo-simple/package.json +++ b/examples/react/router-monorepo-simple/package.json @@ -8,9 +8,9 @@ "dev": "pnpm router build && pnpm post-feature build && pnpm app dev" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1" diff --git a/examples/react/router-monorepo-simple/packages/app/package.json b/examples/react/router-monorepo-simple/packages/app/package.json index a06431ef86..30f39f4a52 100644 --- a/examples/react/router-monorepo-simple/packages/app/package.json +++ b/examples/react/router-monorepo-simple/packages/app/package.json @@ -15,7 +15,7 @@ "react-dom": "^19.0.0" }, "devDependencies": { - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router-devtools": "^1.167.2", "@types/react": "^19.0.8", "@types/react-dom": "^19.0.3", "@vitejs/plugin-react": "^6.0.1", diff --git a/examples/react/router-monorepo-simple/packages/router/package.json b/examples/react/router-monorepo-simple/packages/router/package.json index 391b72e610..707dc26c6e 100644 --- a/examples/react/router-monorepo-simple/packages/router/package.json +++ b/examples/react/router-monorepo-simple/packages/router/package.json @@ -9,8 +9,8 @@ "types": "./dist/index.d.ts", "dependencies": { "@tanstack/history": "^1.162.5", - "@tanstack/react-router": "^1.170.46", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/scroll-restoration/package.json b/examples/react/scroll-restoration/package.json index 704ff13838..33adda056c 100644 --- a/examples/react/scroll-restoration/package.json +++ b/examples/react/scroll-restoration/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "@tanstack/react-virtual": "^3.13.0", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/search-validator-adapters/package.json b/examples/react/search-validator-adapters/package.json index 35e041e825..4ec71d4a07 100644 --- a/examples/react/search-validator-adapters/package.json +++ b/examples/react/search-validator-adapters/package.json @@ -13,9 +13,9 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/arktype-adapter": "^1.167.0", "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/valibot-adapter": "^1.167.0", "@tanstack/zod-adapter": "^1.167.0", "arktype": "^2.1.7", diff --git a/examples/react/start-bare/package.json b/examples/react/start-bare/package.json index 4ab9aff272..94b6382250 100644 --- a/examples/react/start-bare/package.json +++ b/examples/react/start-bare/package.json @@ -10,9 +10,9 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "zod": "^4.4.3" diff --git a/examples/react/start-basic-auth/package.json b/examples/react/start-basic-auth/package.json index 9ab89bdac9..b618de4d5f 100644 --- a/examples/react/start-basic-auth/package.json +++ b/examples/react/start-basic-auth/package.json @@ -14,9 +14,9 @@ "@libsql/client": "^0.15.15", "@prisma/adapter-libsql": "^7.0.0", "@prisma/client": "^7.0.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "iron-session": "^9.0.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/start-basic-authjs/package.json b/examples/react/start-basic-authjs/package.json index e9fa789ea6..07e9514298 100644 --- a/examples/react/start-basic-authjs/package.json +++ b/examples/react/start-basic-authjs/package.json @@ -11,9 +11,9 @@ }, "dependencies": { "@auth/core": "^0.41.1", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "start-authjs": "^1.0.0", diff --git a/examples/react/start-basic-cloudflare/package.json b/examples/react/start-basic-cloudflare/package.json index 2108922446..9b418feb37 100644 --- a/examples/react/start-basic-cloudflare/package.json +++ b/examples/react/start-basic-cloudflare/package.json @@ -12,9 +12,9 @@ "postinstall": "WRANGLER_LOG=warn npm run --silent cf-typegen" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0" }, diff --git a/examples/react/start-basic-react-query/package.json b/examples/react/start-basic-react-query/package.json index 9d819d4390..e48a13a232 100644 --- a/examples/react/start-basic-react-query/package.json +++ b/examples/react/start-basic-react-query/package.json @@ -13,10 +13,10 @@ "dependencies": { "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "@tanstack/react-router-ssr-query": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/start-basic-rsbuild/package.json b/examples/react/start-basic-rsbuild/package.json index bea4ba26ef..d750ec7698 100644 --- a/examples/react/start-basic-rsbuild/package.json +++ b/examples/react/start-basic-rsbuild/package.json @@ -10,16 +10,16 @@ "start": "srvx --prod -s ../client dist/server/index.js" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.2.3", "react-dom": "^19.2.3", "tailwind-merge": "^3.6.0", "zod": "^4.4.3" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.0.11", "@rsbuild/plugin-react": "^2.0.0", "@rsbuild/plugin-tailwindcss": "^2.0.3", "@types/node": "25.0.9", diff --git a/examples/react/start-basic-static/package.json b/examples/react/start-basic-static/package.json index 58d573ca36..0fb8219061 100644 --- a/examples/react/start-basic-static/package.json +++ b/examples/react/start-basic-static/package.json @@ -10,10 +10,10 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", - "@tanstack/start-static-server-functions": "^1.167.44", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", + "@tanstack/start-static-server-functions": "^1.167.43", "@vitejs/plugin-react": "^6.0.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/start-basic/package.json b/examples/react/start-basic/package.json index 46df8e4650..392937939c 100644 --- a/examples/react/start-basic/package.json +++ b/examples/react/start-basic/package.json @@ -10,9 +10,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "tailwind-merge": "^3.6.0", diff --git a/examples/react/start-bun/package.json b/examples/react/start-bun/package.json index 24f7113912..b06bd53db7 100644 --- a/examples/react/start-bun/package.json +++ b/examples/react/start-bun/package.json @@ -15,11 +15,11 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/react-devtools": "^0.7.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "@tanstack/react-router-ssr-query": "^1.167.3", - "@tanstack/react-start": "^1.169.6", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-start": "^1.169.3", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.1.1", "react-dom": "^19.1.1", "tailwindcss": "^4.2.2" diff --git a/examples/react/start-clerk-basic/package.json b/examples/react/start-clerk-basic/package.json index 022300e159..defdcf9f9e 100644 --- a/examples/react/start-clerk-basic/package.json +++ b/examples/react/start-clerk-basic/package.json @@ -11,9 +11,9 @@ }, "dependencies": { "@clerk/tanstack-react-start": "^0.27.14", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "@vitejs/plugin-react": "^6.0.1", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/start-convex-trellaux/package.json b/examples/react/start-convex-trellaux/package.json index 3452f910d0..275f32ec74 100644 --- a/examples/react/start-convex-trellaux/package.json +++ b/examples/react/start-convex-trellaux/package.json @@ -15,10 +15,10 @@ "@convex-dev/react-query": "0.0.0-alpha.8", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "@tanstack/react-router-ssr-query": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-start": "^1.169.3", "concurrently": "^8.2.2", "convex": "^1.19.0", "ky": "^1.7.4", diff --git a/examples/react/start-counter/package.json b/examples/react/start-counter/package.json index 8f4673143e..bf2daa3406 100644 --- a/examples/react/start-counter/package.json +++ b/examples/react/start-counter/package.json @@ -10,9 +10,9 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0" }, diff --git a/examples/react/start-i18n-paraglide/package.json b/examples/react/start-i18n-paraglide/package.json index 074f714d5c..f579671cb7 100644 --- a/examples/react/start-i18n-paraglide/package.json +++ b/examples/react/start-i18n-paraglide/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tanstack/react-devtools": "^0.7.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.1.1", "react-dom": "^19.1.1" }, diff --git a/examples/react/start-large/package.json b/examples/react/start-large/package.json index f9f86b81d1..cb781b57f4 100644 --- a/examples/react/start-large/package.json +++ b/examples/react/start-large/package.json @@ -13,9 +13,9 @@ }, "dependencies": { "@tanstack/react-query": "^5.102.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/start-material-ui/package.json b/examples/react/start-material-ui/package.json index 1647e95f20..ef64b978ad 100644 --- a/examples/react/start-material-ui/package.json +++ b/examples/react/start-material-ui/package.json @@ -15,9 +15,9 @@ "@emotion/styled": "11.14.0", "@fontsource-variable/roboto": "5.2.5", "@mui/material": "6.4.7", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "zod": "^4.4.3" diff --git a/examples/react/start-next-migration/README.md b/examples/react/start-next-migration/README.md index 03bb53244e..5b80b006b3 100644 --- a/examples/react/start-next-migration/README.md +++ b/examples/react/start-next-migration/README.md @@ -6,7 +6,7 @@ The private page saves one article in an encrypted session cookie. This keeps th ## Run -Use Node 24 or newer and pnpm 12. From the repository root: +Use Node 24 or newer and pnpm 11. From the repository root: ```sh pnpm install diff --git a/examples/react/start-next-migration/package.json b/examples/react/start-next-migration/package.json index 0c2a2a9563..da574710cd 100644 --- a/examples/react/start-next-migration/package.json +++ b/examples/react/start-next-migration/package.json @@ -12,8 +12,8 @@ "test:e2e": "playwright test" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-start": "^1.169.3", "iron-session": "^9.0.1", "next": "16.3.4", "react": "^19.2.3", diff --git a/examples/react/start-rscs/package.json b/examples/react/start-rscs/package.json index 00c88681d7..80ce34a7a3 100644 --- a/examples/react/start-rscs/package.json +++ b/examples/react/start-rscs/package.json @@ -10,9 +10,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "dexie": "^4.0.10", "react": "^19.2.0", "react-dom": "^19.2.0", @@ -26,7 +26,7 @@ "@types/react": "^19.2.2", "@types/react-dom": "^19.2.2", "@vitejs/plugin-react": "^6.0.1", - "@vitejs/plugin-rsc": "^0.5.39", + "@vitejs/plugin-rsc": "^0.5.37", "nitro": "^3.0.260903-beta", "tailwindcss": "^4.1.18", "typescript": "^5.7.2", diff --git a/examples/react/start-streaming-data-from-server-functions/package.json b/examples/react/start-streaming-data-from-server-functions/package.json index 762bbff733..6e9b588d5a 100644 --- a/examples/react/start-streaming-data-from-server-functions/package.json +++ b/examples/react/start-streaming-data-from-server-functions/package.json @@ -10,9 +10,9 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "zod": "^4.4.3" diff --git a/examples/react/start-supabase-basic/package.json b/examples/react/start-supabase-basic/package.json index 0bf4b2c246..ce00c07051 100644 --- a/examples/react/start-supabase-basic/package.json +++ b/examples/react/start-supabase-basic/package.json @@ -15,9 +15,9 @@ "dependencies": { "@supabase/ssr": "^0.5.2", "@supabase/supabase-js": "^2.48.1", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1" diff --git a/examples/react/start-tailwind-v4/package.json b/examples/react/start-tailwind-v4/package.json index b58fbe4ff0..6f1730d0c4 100644 --- a/examples/react/start-tailwind-v4/package.json +++ b/examples/react/start-tailwind-v4/package.json @@ -10,9 +10,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "react": "^19.0.0", "react-dom": "^19.0.0", "tailwind-merge": "^3.6.0", diff --git a/examples/react/start-trellaux/package.json b/examples/react/start-trellaux/package.json index 7755d227fc..7f0cfb7870 100644 --- a/examples/react/start-trellaux/package.json +++ b/examples/react/start-trellaux/package.json @@ -12,10 +12,10 @@ "dependencies": { "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "@tanstack/react-router-ssr-query": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-start": "^1.169.3", "ky": "^1.7.4", "msw": "^2.7.0", "react": "^19.0.0", diff --git a/examples/react/start-workos/package.json b/examples/react/start-workos/package.json index 0ab7e89c2d..4ffc5f3800 100644 --- a/examples/react/start-workos/package.json +++ b/examples/react/start-workos/package.json @@ -14,9 +14,9 @@ "license": "MIT", "dependencies": { "@radix-ui/themes": "^3.3.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/react-start": "^1.169.6", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/react-start": "^1.169.3", "@workos/authkit-tanstack-react-start": "^0.5.0", "react": "^19.0.0", "react-dom": "^19.0.0" diff --git a/examples/react/view-transitions/package.json b/examples/react/view-transitions/package.json index 0be3c60e8f..d09368e23a 100644 --- a/examples/react/view-transitions/package.json +++ b/examples/react/view-transitions/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "react": "^19.0.0", "react-dom": "^19.0.0", "redaxios": "^0.5.1", diff --git a/examples/react/with-framer-motion/package.json b/examples/react/with-framer-motion/package.json index c606070dfb..8972302b87 100644 --- a/examples/react/with-framer-motion/package.json +++ b/examples/react/with-framer-motion/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", "framer-motion": "^11.18.2", "react": "^19.0.0", "react-dom": "^19.0.0", diff --git a/examples/react/with-trpc-react-query/package.json b/examples/react/with-trpc-react-query/package.json index 11df7bf03b..f7d9af5e6b 100644 --- a/examples/react/with-trpc-react-query/package.json +++ b/examples/react/with-trpc-react-query/package.json @@ -13,9 +13,9 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/react-query": "^5.102.0", "@tanstack/react-query-devtools": "^5.90.0", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@trpc/client": "^11.4.3", "@trpc/server": "^11.4.3", "@trpc/tanstack-react-query": "^11.4.3", diff --git a/examples/react/with-trpc/package.json b/examples/react/with-trpc/package.json index 5612419cae..14a438b194 100644 --- a/examples/react/with-trpc/package.json +++ b/examples/react/with-trpc/package.json @@ -11,9 +11,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/react-router": "^1.170.46", - "@tanstack/react-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/react-router": "^1.170.45", + "@tanstack/react-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@trpc/client": "^11.4.3", "@trpc/server": "^11.4.3", "express": "^5.2.1", diff --git a/examples/solid/authenticated-routes-firebase/package.json b/examples/solid/authenticated-routes-firebase/package.json index 110b4d2621..07347a59f0 100644 --- a/examples/solid/authenticated-routes-firebase/package.json +++ b/examples/solid/authenticated-routes-firebase/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "firebase": "^11.4.0", "redaxios": "^0.5.1", "simple-icons": "^14.9.0", diff --git a/examples/solid/authenticated-routes/package.json b/examples/solid/authenticated-routes/package.json index ea7d05c902..69210c87b8 100644 --- a/examples/solid/authenticated-routes/package.json +++ b/examples/solid/authenticated-routes/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/basic-default-search-params/package.json b/examples/solid/basic-default-search-params/package.json index 830df7b9cf..9fc0fffa79 100644 --- a/examples/solid/basic-default-search-params/package.json +++ b/examples/solid/basic-default-search-params/package.json @@ -11,8 +11,8 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/basic-devtools-panel/package.json b/examples/solid/basic-devtools-panel/package.json index e7d608f5fe..82b74f5274 100644 --- a/examples/solid/basic-devtools-panel/package.json +++ b/examples/solid/basic-devtools-panel/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" diff --git a/examples/solid/basic-file-based/package.json b/examples/solid/basic-file-based/package.json index 867118382e..cbb91bf475 100644 --- a/examples/solid/basic-file-based/package.json +++ b/examples/solid/basic-file-based/package.json @@ -10,15 +10,15 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", "zod": "^4.4.3" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/examples/solid/basic-non-nested-devtools/package.json b/examples/solid/basic-non-nested-devtools/package.json index c8e00ee43e..da3b25878b 100644 --- a/examples/solid/basic-non-nested-devtools/package.json +++ b/examples/solid/basic-non-nested-devtools/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" diff --git a/examples/solid/basic-solid-query-file-based/package.json b/examples/solid/basic-solid-query-file-based/package.json index fdb5f05f52..9b5a7fd073 100644 --- a/examples/solid/basic-solid-query-file-based/package.json +++ b/examples/solid/basic-solid-query-file-based/package.json @@ -13,15 +13,15 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", "zod": "^4.4.3" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/examples/solid/basic-solid-query/package.json b/examples/solid/basic-solid-query/package.json index 7b132b11a1..28ed396438 100644 --- a/examples/solid/basic-solid-query/package.json +++ b/examples/solid/basic-solid-query/package.json @@ -12,14 +12,14 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/examples/solid/basic-ssr-file-based/package.json b/examples/solid/basic-ssr-file-based/package.json index e3699970a9..758554403d 100644 --- a/examples/solid/basic-ssr-file-based/package.json +++ b/examples/solid/basic-ssr-file-based/package.json @@ -11,8 +11,8 @@ "debug": "node --inspect-brk server" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/router-plugin": "^1.168.47", "compression": "^1.8.0", "express": "^5.2.1", "get-port": "^7.1.0", @@ -20,7 +20,7 @@ "solid-js": "^1.9.10" }, "devDependencies": { - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router-devtools": "^1.167.2", "@types/express": "^5.0.6", "vite-plugin-solid": "^2.11.11", "@typescript/native": "npm:typescript@^7.0.2", diff --git a/examples/solid/basic-ssr-streaming-file-based/package.json b/examples/solid/basic-ssr-streaming-file-based/package.json index 92367442fc..49b170a1c1 100644 --- a/examples/solid/basic-ssr-streaming-file-based/package.json +++ b/examples/solid/basic-ssr-streaming-file-based/package.json @@ -12,8 +12,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "compression": "^1.8.0", "express": "^5.2.1", "get-port": "^7.1.0", @@ -24,7 +24,7 @@ "zod": "^4.4.3" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@types/express": "^5.0.6", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", diff --git a/examples/solid/basic-virtual-file-based/package.json b/examples/solid/basic-virtual-file-based/package.json index 801b452192..dbec4e1174 100644 --- a/examples/solid/basic-virtual-file-based/package.json +++ b/examples/solid/basic-virtual-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@tanstack/virtual-file-routes": "^1.162.0", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/basic-virtual-inside-file-based/package.json b/examples/solid/basic-virtual-inside-file-based/package.json index a9cc6360a5..c611fa9394 100644 --- a/examples/solid/basic-virtual-inside-file-based/package.json +++ b/examples/solid/basic-virtual-inside-file-based/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@tanstack/virtual-file-routes": "^1.162.0", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/basic/package.json b/examples/solid/basic/package.json index 95ec804011..19fc299dab 100644 --- a/examples/solid/basic/package.json +++ b/examples/solid/basic/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" diff --git a/examples/solid/deferred-data/package.json b/examples/solid/deferred-data/package.json index 56114afd04..4c488d845f 100644 --- a/examples/solid/deferred-data/package.json +++ b/examples/solid/deferred-data/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/i18n-paraglide/package.json b/examples/solid/i18n-paraglide/package.json index 6493a3c7c8..83335a0479 100644 --- a/examples/solid/i18n-paraglide/package.json +++ b/examples/solid/i18n-paraglide/package.json @@ -11,8 +11,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/router-plugin": "^1.168.47", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, diff --git a/examples/solid/kitchen-sink-file-based/package.json b/examples/solid/kitchen-sink-file-based/package.json index 8cd73e38ff..2fa753832a 100644 --- a/examples/solid/kitchen-sink-file-based/package.json +++ b/examples/solid/kitchen-sink-file-based/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "immer": "^10.1.1", "redaxios": "^0.5.1", "solid-js": "^1.9.10", @@ -19,7 +19,7 @@ "zod": "^4.4.3" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/examples/solid/kitchen-sink-solid-query-file-based/package.json b/examples/solid/kitchen-sink-solid-query-file-based/package.json index 25a1c29953..e2245e8a94 100644 --- a/examples/solid/kitchen-sink-solid-query-file-based/package.json +++ b/examples/solid/kitchen-sink-solid-query-file-based/package.json @@ -10,11 +10,11 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "immer": "^10.1.1", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/kitchen-sink-solid-query/package.json b/examples/solid/kitchen-sink-solid-query/package.json index 7a7dc81025..5d576c7635 100644 --- a/examples/solid/kitchen-sink-solid-query/package.json +++ b/examples/solid/kitchen-sink-solid-query/package.json @@ -12,8 +12,8 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "immer": "^10.1.1", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/kitchen-sink/package.json b/examples/solid/kitchen-sink/package.json index 08ad918a60..743768916c 100644 --- a/examples/solid/kitchen-sink/package.json +++ b/examples/solid/kitchen-sink/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "immer": "^10.1.1", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/large-file-based/package.json b/examples/solid/large-file-based/package.json index cd758ab704..a341d667ca 100644 --- a/examples/solid/large-file-based/package.json +++ b/examples/solid/large-file-based/package.json @@ -12,10 +12,10 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/location-masking/package.json b/examples/solid/location-masking/package.json index 7d2fbb6756..33ce22e799 100644 --- a/examples/solid/location-masking/package.json +++ b/examples/solid/location-masking/package.json @@ -11,8 +11,8 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "solid-js": "^1.9.10", "redaxios": "^0.5.1", "tailwindcss": "^4.2.2" diff --git a/examples/solid/navigation-blocking/package.json b/examples/solid/navigation-blocking/package.json index 2338d32305..117864a6ac 100644 --- a/examples/solid/navigation-blocking/package.json +++ b/examples/solid/navigation-blocking/package.json @@ -11,8 +11,8 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "solid-js": "^1.9.10", "redaxios": "^0.5.1", "tailwindcss": "^4.2.2" diff --git a/examples/solid/quickstart-esbuild-file-based/build.js b/examples/solid/quickstart-esbuild-file-based/build.js index af5e01b4cd..f8d31fbbd9 100644 --- a/examples/solid/quickstart-esbuild-file-based/build.js +++ b/examples/solid/quickstart-esbuild-file-based/build.js @@ -14,7 +14,10 @@ const ctx = await esbuild.context({ target: ['esnext'], sourcemap: true, conditions: ['style'], - plugins: [solidPlugin(), tanstackRouter({ target: 'solid' })], + plugins: [ + solidPlugin(), + tanstackRouter({ target: 'solid', autoCodeSplitting: true }), + ], }) if (isDev) { diff --git a/examples/solid/quickstart-esbuild-file-based/package.json b/examples/solid/quickstart-esbuild-file-based/package.json index 9bcc9a08d0..68848866d4 100644 --- a/examples/solid/quickstart-esbuild-file-based/package.json +++ b/examples/solid/quickstart-esbuild-file-based/package.json @@ -9,9 +9,9 @@ "start": "dev" }, "dependencies": { - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/quickstart-file-based/package.json b/examples/solid/quickstart-file-based/package.json index 920154566d..f658074624 100644 --- a/examples/solid/quickstart-file-based/package.json +++ b/examples/solid/quickstart-file-based/package.json @@ -10,15 +10,15 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", "zod": "^4.4.3" }, "devDependencies": { - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", "vite": "^8.0.14", diff --git a/examples/solid/quickstart-rspack-file-based/package.json b/examples/solid/quickstart-rspack-file-based/package.json index 2d9c886ac3..0e8b94994b 100644 --- a/examples/solid/quickstart-rspack-file-based/package.json +++ b/examples/solid/quickstart-rspack-file-based/package.json @@ -9,17 +9,17 @@ }, "dependencies": { "@tailwindcss/postcss": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "postcss": "^8.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, "devDependencies": { - "@rsbuild/core": "^2.3.1", + "@rsbuild/core": "^2.1.0", "@rsbuild/plugin-babel": "^1.1.2", - "@rsbuild/plugin-solid": "^1.1.1", - "@tanstack/router-plugin": "^1.169.0", + "@rsbuild/plugin-solid": "^1.2.2", + "@tanstack/router-plugin": "^1.168.47", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2" } diff --git a/examples/solid/quickstart-webpack-file-based/package.json b/examples/solid/quickstart-webpack-file-based/package.json index 16167be207..6989f7ca6c 100644 --- a/examples/solid/quickstart-webpack-file-based/package.json +++ b/examples/solid/quickstart-webpack-file-based/package.json @@ -7,15 +7,15 @@ "build": "webpack build && tsc --noEmit" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, "devDependencies": { "@babel/core": "^7.28.5", "@babel/preset-typescript": "^7.27.1", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/router-plugin": "^1.168.47", "babel-loader": "^10.0.0", "babel-preset-solid": "^1.9.10", "css-loader": "^7.1.2", diff --git a/examples/solid/quickstart/package.json b/examples/solid/quickstart/package.json index 454382e8cc..df0ce2927e 100644 --- a/examples/solid/quickstart/package.json +++ b/examples/solid/quickstart/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, diff --git a/examples/solid/router-monorepo-simple-lazy/package.json b/examples/solid/router-monorepo-simple-lazy/package.json index 1d60ab2765..336ada682b 100644 --- a/examples/solid/router-monorepo-simple-lazy/package.json +++ b/examples/solid/router-monorepo-simple-lazy/package.json @@ -8,9 +8,9 @@ "dev": "pnpm router build && pnpm post-feature build && pnpm app dev" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "solid-js": "^1.9.10", "redaxios": "^0.5.1" }, diff --git a/examples/solid/router-monorepo-simple-lazy/packages/app/package.json b/examples/solid/router-monorepo-simple-lazy/packages/app/package.json index a2e018fa96..976a2ad861 100644 --- a/examples/solid/router-monorepo-simple-lazy/packages/app/package.json +++ b/examples/solid/router-monorepo-simple-lazy/packages/app/package.json @@ -20,7 +20,7 @@ "@vitejs/plugin-react": "^6.0.1", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router-devtools": "^1.167.2", "tailwindcss": "^4.2.2", "vite": "^8.0.14", "vite-plugin-dts": "^4.5.4", diff --git a/examples/solid/router-monorepo-simple-lazy/packages/router/package.json b/examples/solid/router-monorepo-simple-lazy/packages/router/package.json index 0672c42931..1738eac380 100644 --- a/examples/solid/router-monorepo-simple-lazy/packages/router/package.json +++ b/examples/solid/router-monorepo-simple-lazy/packages/router/package.json @@ -9,8 +9,8 @@ "types": "./dist/index.d.ts", "dependencies": { "@tanstack/history": "^1.162.5", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/router-plugin": "^1.168.47", "redaxios": "^0.5.1", "zod": "^4.4.3", "solid-js": "^1.9.10" diff --git a/examples/solid/router-monorepo-simple/package.json b/examples/solid/router-monorepo-simple/package.json index 3770256692..c08102bfba 100644 --- a/examples/solid/router-monorepo-simple/package.json +++ b/examples/solid/router-monorepo-simple/package.json @@ -8,9 +8,9 @@ "dev": "pnpm router build && pnpm post-feature build && pnpm app dev" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "solid-js": "^1.9.10", "redaxios": "^0.5.1" }, diff --git a/examples/solid/router-monorepo-simple/packages/app/package.json b/examples/solid/router-monorepo-simple/packages/app/package.json index 61234ac455..b10a4109b5 100644 --- a/examples/solid/router-monorepo-simple/packages/app/package.json +++ b/examples/solid/router-monorepo-simple/packages/app/package.json @@ -17,7 +17,7 @@ "vite-plugin-solid": "^2.11.11", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router-devtools": "^1.167.2", "vite": "^8.0.14", "tailwindcss": "^4.2.2", "vite-plugin-dts": "^4.5.4", diff --git a/examples/solid/router-monorepo-simple/packages/router/package.json b/examples/solid/router-monorepo-simple/packages/router/package.json index ca08511d3e..b68482921a 100644 --- a/examples/solid/router-monorepo-simple/packages/router/package.json +++ b/examples/solid/router-monorepo-simple/packages/router/package.json @@ -9,8 +9,8 @@ "types": "./dist/index.d.ts", "dependencies": { "@tanstack/history": "^1.162.5", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/router-plugin": "^1.168.47", "redaxios": "^0.5.1", "zod": "^4.4.3", "solid-js": "^1.9.10" diff --git a/examples/solid/router-monorepo-solid-query/package.json b/examples/solid/router-monorepo-solid-query/package.json index 3d9fd2e2d0..b0b76ba585 100644 --- a/examples/solid/router-monorepo-solid-query/package.json +++ b/examples/solid/router-monorepo-solid-query/package.json @@ -12,9 +12,9 @@ "dependencies": { "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "solid-js": "^1.9.10", "redaxios": "^0.5.1" }, diff --git a/examples/solid/router-monorepo-solid-query/packages/app/package.json b/examples/solid/router-monorepo-solid-query/packages/app/package.json index 76bb059de5..80f711e201 100644 --- a/examples/solid/router-monorepo-solid-query/packages/app/package.json +++ b/examples/solid/router-monorepo-solid-query/packages/app/package.json @@ -18,7 +18,7 @@ "vite-plugin-solid": "^2.11.11", "@typescript/native": "npm:typescript@^7.0.2", "typescript": "npm:@typescript/typescript6@^6.0.2", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router-devtools": "^1.167.2", "tailwindcss": "^4.2.2", "vite": "^8.0.14", "vite-plugin-dts": "^4.5.4", diff --git a/examples/solid/router-monorepo-solid-query/packages/router/package.json b/examples/solid/router-monorepo-solid-query/packages/router/package.json index 93943a1df8..5104ef63ba 100644 --- a/examples/solid/router-monorepo-solid-query/packages/router/package.json +++ b/examples/solid/router-monorepo-solid-query/packages/router/package.json @@ -10,8 +10,8 @@ "dependencies": { "@tanstack/history": "^1.162.5", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/router-plugin": "^1.168.47", "@router-solid-mono-solid-query/post-query": "workspace:*", "redaxios": "^0.5.1", "zod": "^4.4.3", diff --git a/examples/solid/scroll-restoration/package.json b/examples/solid/scroll-restoration/package.json index eaa5a5aaea..52e8fc7eda 100644 --- a/examples/solid/scroll-restoration/package.json +++ b/examples/solid/scroll-restoration/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@tanstack/solid-virtual": "^3.13.0", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" diff --git a/examples/solid/search-validator-adapters/package.json b/examples/solid/search-validator-adapters/package.json index 59991edb36..e5d61370d1 100644 --- a/examples/solid/search-validator-adapters/package.json +++ b/examples/solid/search-validator-adapters/package.json @@ -13,9 +13,9 @@ "@tailwindcss/vite": "^4.2.2", "@tanstack/arktype-adapter": "^1.167.0", "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/router-plugin": "^1.168.47", "@tanstack/valibot-adapter": "^1.167.0", "@tanstack/zod-adapter": "^1.167.0", "arktype": "^2.1.7", diff --git a/examples/solid/start-basic-auth/package.json b/examples/solid/start-basic-auth/package.json index d686fdf616..fb5716a0c1 100644 --- a/examples/solid/start-basic-auth/package.json +++ b/examples/solid/start-basic-auth/package.json @@ -14,9 +14,9 @@ "@libsql/client": "^0.15.15", "@prisma/adapter-libsql": "^7.0.0", "@prisma/client": "^7.0.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "iron-session": "^9.0.1", "redaxios": "^0.5.1", "solid-js": "^1.9.10", diff --git a/examples/solid/start-basic-authjs/package.json b/examples/solid/start-basic-authjs/package.json index 2c910663bd..c87268c0f9 100644 --- a/examples/solid/start-basic-authjs/package.json +++ b/examples/solid/start-basic-authjs/package.json @@ -11,9 +11,9 @@ }, "dependencies": { "@auth/core": "^0.41.1", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10", "start-authjs": "^1.0.0", "tailwind-merge": "^3.6.0" diff --git a/examples/solid/start-basic-cloudflare/package.json b/examples/solid/start-basic-cloudflare/package.json index 7ece143f61..e0c643e566 100644 --- a/examples/solid/start-basic-cloudflare/package.json +++ b/examples/solid/start-basic-cloudflare/package.json @@ -12,9 +12,9 @@ "postinstall": "WRANGLER_LOG=warn npm run --silent cf-typegen" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10" }, "devDependencies": { diff --git a/examples/solid/start-basic-netlify/package.json b/examples/solid/start-basic-netlify/package.json index 69299cdb79..2d7ee89bce 100644 --- a/examples/solid/start-basic-netlify/package.json +++ b/examples/solid/start-basic-netlify/package.json @@ -9,9 +9,9 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10" }, "devDependencies": { diff --git a/examples/solid/start-basic-nitro/package.json b/examples/solid/start-basic-nitro/package.json index 2c0dc7dad6..58b5e53902 100644 --- a/examples/solid/start-basic-nitro/package.json +++ b/examples/solid/start-basic-nitro/package.json @@ -9,9 +9,9 @@ "preview": "vite preview" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10" }, "devDependencies": { diff --git a/examples/solid/start-basic-solid-query/package.json b/examples/solid/start-basic-solid-query/package.json index ddbb7d8764..9acb83adbe 100644 --- a/examples/solid/start-basic-solid-query/package.json +++ b/examples/solid/start-basic-solid-query/package.json @@ -12,10 +12,10 @@ "dependencies": { "@tanstack/solid-query": "^5.90.9", "@tanstack/solid-query-devtools": "^5.90.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@tanstack/solid-router-ssr-query": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-start": "^1.169.3", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0" diff --git a/examples/solid/start-basic-static/package.json b/examples/solid/start-basic-static/package.json index 8b639da68a..23f7279166 100644 --- a/examples/solid/start-basic-static/package.json +++ b/examples/solid/start-basic-static/package.json @@ -10,10 +10,10 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", - "@tanstack/start-static-server-functions": "^1.167.44", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", + "@tanstack/start-static-server-functions": "^1.167.43", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0" diff --git a/examples/solid/start-basic/package.json b/examples/solid/start-basic/package.json index 758815b669..f487631ec0 100644 --- a/examples/solid/start-basic/package.json +++ b/examples/solid/start-basic/package.json @@ -10,9 +10,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0" diff --git a/examples/solid/start-bun/package.json b/examples/solid/start-bun/package.json index d1ad9a9563..384b795e0b 100644 --- a/examples/solid/start-bun/package.json +++ b/examples/solid/start-bun/package.json @@ -15,11 +15,11 @@ "dependencies": { "@tailwindcss/vite": "^4.2.2", "@tanstack/solid-devtools": "^0.7.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@tanstack/solid-router-ssr-query": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", - "@tanstack/router-plugin": "^1.169.0", + "@tanstack/solid-start": "^1.169.3", + "@tanstack/router-plugin": "^1.168.47", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2" }, diff --git a/examples/solid/start-convex-better-auth/package.json b/examples/solid/start-convex-better-auth/package.json index ea13a1c1e3..90659b752c 100644 --- a/examples/solid/start-convex-better-auth/package.json +++ b/examples/solid/start-convex-better-auth/package.json @@ -13,9 +13,9 @@ "dependencies": { "@convex-dev/better-auth": "^0.9.7", "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "better-auth": "^1.6.19", "clsx": "^2.1.1", "convex": "^1.28.2", diff --git a/examples/solid/start-counter/package.json b/examples/solid/start-counter/package.json index 8b49c516bd..ab9f9af834 100644 --- a/examples/solid/start-counter/package.json +++ b/examples/solid/start-counter/package.json @@ -10,9 +10,9 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0", diff --git a/examples/solid/start-i18n-paraglide/package.json b/examples/solid/start-i18n-paraglide/package.json index 076c9b41dc..d34877b070 100644 --- a/examples/solid/start-i18n-paraglide/package.json +++ b/examples/solid/start-i18n-paraglide/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tanstack/solid-devtools": "^0.7.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10" }, "devDependencies": { diff --git a/examples/solid/start-large/package.json b/examples/solid/start-large/package.json index 83f3589cc2..ec394e8780 100644 --- a/examples/solid/start-large/package.json +++ b/examples/solid/start-large/package.json @@ -13,9 +13,9 @@ }, "dependencies": { "@tanstack/solid-query": "^5.90.9", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0", diff --git a/examples/solid/start-streaming-data-from-server-functions/package.json b/examples/solid/start-streaming-data-from-server-functions/package.json index 83e0719b39..7378a57ef8 100644 --- a/examples/solid/start-streaming-data-from-server-functions/package.json +++ b/examples/solid/start-streaming-data-from-server-functions/package.json @@ -10,9 +10,9 @@ "start": "pnpx srvx --prod -s ../client dist/server/server.js" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10", "zod": "^4.4.3" }, diff --git a/examples/solid/start-supabase-basic/package.json b/examples/solid/start-supabase-basic/package.json index 81ab5cd63c..847fb114e4 100644 --- a/examples/solid/start-supabase-basic/package.json +++ b/examples/solid/start-supabase-basic/package.json @@ -14,9 +14,9 @@ "dependencies": { "@supabase/ssr": "^0.5.2", "@supabase/supabase-js": "^2.48.1", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.9", "redaxios": "^0.5.1" }, diff --git a/examples/solid/start-tailwind-v4/package.json b/examples/solid/start-tailwind-v4/package.json index 94db6ac790..fac7532b71 100644 --- a/examples/solid/start-tailwind-v4/package.json +++ b/examples/solid/start-tailwind-v4/package.json @@ -10,9 +10,9 @@ "start": "node .output/server/index.mjs" }, "dependencies": { - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", - "@tanstack/solid-start": "^1.169.6", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", + "@tanstack/solid-start": "^1.169.3", "solid-js": "^1.9.10", "tailwind-merge": "^3.6.0", "zod": "^4.4.3" diff --git a/examples/solid/view-transitions/package.json b/examples/solid/view-transitions/package.json index 2acb2432bf..1b359d8086 100644 --- a/examples/solid/view-transitions/package.json +++ b/examples/solid/view-transitions/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "tailwindcss": "^4.2.2", diff --git a/examples/solid/with-framer-motion/package.json b/examples/solid/with-framer-motion/package.json index 449d8a3927..596035c694 100644 --- a/examples/solid/with-framer-motion/package.json +++ b/examples/solid/with-framer-motion/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "solid-js": "^1.9.10", "solid-motionone": "^1.0.4", diff --git a/examples/solid/with-trpc/package.json b/examples/solid/with-trpc/package.json index 46d33436db..d7ff034514 100644 --- a/examples/solid/with-trpc/package.json +++ b/examples/solid/with-trpc/package.json @@ -11,9 +11,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/solid-router": "^1.170.43", - "@tanstack/solid-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/solid-router": "^1.170.42", + "@tanstack/solid-router-devtools": "^1.167.2", "@trpc/client": "^11.4.3", "@trpc/server": "^11.4.3", "express": "^5.2.1", diff --git a/examples/vue/basic-file-based-jsx/package.json b/examples/vue/basic-file-based-jsx/package.json index 9cc36a6991..d324ac958d 100644 --- a/examples/vue/basic-file-based-jsx/package.json +++ b/examples/vue/basic-file-based-jsx/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/vue-router": "^1.170.42", - "@tanstack/vue-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/vue-router": "^1.170.41", + "@tanstack/vue-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "tailwindcss": "^4.2.2", "vue": "^3.5.16", diff --git a/examples/vue/basic-file-based-jsx/src/routeTree.gen.ts b/examples/vue/basic-file-based-jsx/src/routeTree.gen.ts index 5922c5f7b1..3922025c82 100644 --- a/examples/vue/basic-file-based-jsx/src/routeTree.gen.ts +++ b/examples/vue/basic-file-based-jsx/src/routeTree.gen.ts @@ -364,7 +364,7 @@ declare module '@tanstack/vue-router' { '/(group)/_layout': { id: '/(group)/_layout' path: '' - fullPath: '/' + fullPath: '' preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof rootRouteImport } diff --git a/examples/vue/basic-file-based-sfc/package.json b/examples/vue/basic-file-based-sfc/package.json index 87ab2c332b..233aef0784 100644 --- a/examples/vue/basic-file-based-sfc/package.json +++ b/examples/vue/basic-file-based-sfc/package.json @@ -10,9 +10,9 @@ }, "dependencies": { "@tailwindcss/vite": "^4.2.2", - "@tanstack/router-plugin": "^1.169.0", - "@tanstack/vue-router": "^1.170.42", - "@tanstack/vue-router-devtools": "^1.167.3", + "@tanstack/router-plugin": "^1.168.47", + "@tanstack/vue-router": "^1.170.41", + "@tanstack/vue-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "tailwindcss": "^4.2.2", "vue": "^3.5.16", diff --git a/examples/vue/basic-file-based-sfc/src/routeTree.gen.ts b/examples/vue/basic-file-based-sfc/src/routeTree.gen.ts index 0bfdddab3d..09d62b0706 100644 --- a/examples/vue/basic-file-based-sfc/src/routeTree.gen.ts +++ b/examples/vue/basic-file-based-sfc/src/routeTree.gen.ts @@ -454,7 +454,7 @@ declare module '@tanstack/vue-router' { '/(group)/_layout': { id: '/(group)/_layout' path: '' - fullPath: '/' + fullPath: '' preLoaderRoute: typeof groupLayoutRouteImport parentRoute: typeof rootRouteImport } diff --git a/examples/vue/basic/package.json b/examples/vue/basic/package.json index af74afff3a..81961fc7b5 100644 --- a/examples/vue/basic/package.json +++ b/examples/vue/basic/package.json @@ -9,8 +9,8 @@ "start": "vite" }, "dependencies": { - "@tanstack/vue-router": "^1.170.42", - "@tanstack/vue-router-devtools": "^1.167.3", + "@tanstack/vue-router": "^1.170.41", + "@tanstack/vue-router-devtools": "^1.167.2", "redaxios": "^0.5.1", "vue": "^3.5.13", "tailwindcss": "4.1.18" diff --git a/nx.json b/nx.json index b7df8b2c09..e068010e05 100644 --- a/nx.json +++ b/nx.json @@ -1,7 +1,6 @@ { "$schema": "./node_modules/nx/schemas/nx-schema.json", "defaultBase": "main", - "bust": "nx24-exclusive-e2e-16-medium-baseline-2026-10-25-05", "nxCloudId": "6442f7de8226a6291646a813", "useInferencePlugins": false, "parallel": 5, @@ -11,10 +10,7 @@ "namedInputs": { "sharedGlobals": [ "{workspaceRoot}/.npmrc", - "{workspaceRoot}/nx.json", - "{workspaceRoot}/.github/workflows/pr.yml", - "{workspaceRoot}/.nx/ci-config.yaml", - "{workspaceRoot}/.nx/workflows/ultracache-config.yaml", + "{workspaceRoot}/.nx/workflows/sandboxing-config.yaml", "{workspaceRoot}/.nvmrc", "{workspaceRoot}/package.json", "{workspaceRoot}/tsconfig.json" @@ -45,7 +41,7 @@ "targetDefaults": { "test:docs": { "cache": true, - "inputs": ["sharedGlobals", "{workspaceRoot}/docs/**/*"] + "inputs": ["{workspaceRoot}/docs/**/*"] }, "test:eslint": { "cache": true, @@ -62,12 +58,34 @@ "dependsOn": ["^build"], "inputs": [ "default", + "!{projectRoot}/tests/integration/**/*", "^production", "{workspaceRoot}/eslint.config.js", "dependentTaskOutputs" ], "outputs": ["{projectRoot}/coverage"] }, + "test:integration": { + "cache": true, + "dependsOn": ["^build"], + "inputs": [ + "default", + "^production", + "{workspaceRoot}/eslint.config.js", + "dependentTaskOutputs" + ], + "outputs": ["{projectRoot}/coverage"] + }, + "test:integration:smoke": { + "cache": true, + "dependsOn": ["^build"], + "inputs": [ + "default", + "^production", + "{workspaceRoot}/eslint.config.js", + "dependentTaskOutputs" + ] + }, "test:e2e": { "cache": true, "dependsOn": ["^build", "test:e2e--*"], @@ -152,6 +170,18 @@ }, "test:e2e*": { "parallelism": false + }, + "test:noncompiler": { + "cache": true, + "dependsOn": ["^build"], + "inputs": [ + "default", + "!{projectRoot}/tests/integration/**/*", + "^production", + "{workspaceRoot}/eslint.config.js", + "dependentTaskOutputs" + ], + "outputs": ["{projectRoot}/coverage"] } }, "plugins": [ diff --git a/package.json b/package.json index 3ef11b1969..c84b04f044 100644 --- a/package.json +++ b/package.json @@ -5,19 +5,20 @@ "type": "git", "url": "git+https://github.com/TanStack/router.git" }, - "packageManager": "pnpm@12.18.0", + "packageManager": "pnpm@11.21.0", "engines": { - "pnpm": ">=12.18.0" + "pnpm": ">=11.21.0" }, "type": "module", "scripts": { "cleanNodeModules": "pnpm -r exec rm -rf node_modules", "clean": "pnpm --filter \"./packages/**\" run clean", "test": "pnpm run test:ci", - "test:pr": "nx affected --targets=test:eslint,test:unit,test:integration,test:e2e,test:types,test:build,build", - "test:ci": "nx run-many --targets=test:eslint,test:unit,test:integration,test:e2e,test:types,test:build,build", + "test:pr": "nx affected --targets=test:eslint,test:unit,test:integration,test:noncompiler,test:e2e,test:types,test:build,build", + "test:ci": "nx run-many --targets=test:eslint,test:unit,test:integration,test:noncompiler,test:e2e,test:types,test:build,build", "test:eslint": "nx affected --target=test:eslint --exclude=examples/**,e2e/**", "test:unit": "nx affected --target=test:unit --exclude=examples/**,e2e/**", + "test:integration": "nx affected --target=test:integration --exclude=examples/**,e2e/**", "test:unit:dev": "pnpm run test:unit && nx watch --all -- pnpm run test:unit", "test:build": "nx affected --target=test:build --exclude=examples/**", "test:types": "nx affected --target=test:types --exclude=examples/**", @@ -55,7 +56,8 @@ "ts:symbol-references": "node scripts/ts-symbol-references.mjs", "vite-ecosystem-ci:build": "nx run-many --targets=build --projects=@tanstack/router-plugin,@tanstack/start-plugin-core,@tanstack/react-start,@tanstack/react-start-client,@tanstack/react-start-server --skipRemoteCache", "vite-ecosystem-ci:before-test": "pnpm exec playwright install chromium", - "vite-ecosystem-ci:test": "nx run-many --targets=test:unit --projects=@tanstack/router-plugin,@tanstack/start-plugin-core,@tanstack/react-start-client --skipRemoteCache && nx run-many --target=test:e2e --projects=tanstack-router-e2e-react-basic-file-based,tanstack-router-e2e-react-basic-file-based-code-splitting,tanstack-react-start-e2e-basic,tanstack-vue-start-e2e-basic,tanstack-solid-start-e2e-basic --skipRemoteCache" + "vite-ecosystem-ci:test": "nx run-many --targets=test:unit,test:integration,test:noncompiler --projects=@tanstack/router-plugin,@tanstack/start-plugin-core,@tanstack/react-start-client --skipRemoteCache && nx run-many --target=test:e2e --projects=tanstack-router-e2e-react-basic-file-based,tanstack-router-e2e-react-basic-file-based-code-splitting,tanstack-react-start-e2e-basic,tanstack-vue-start-e2e-basic,tanstack-solid-start-e2e-basic --skipRemoteCache", + "test:noncompiler": "nx affected --target=test:noncompiler --exclude=examples/**,e2e/**" }, "nx": { "includedScripts": [ @@ -65,7 +67,7 @@ "devDependencies": { "@changesets/changelog-github": "^0.7.0", "@changesets/cli": "^2.30.0", - "@nx/devkit": "24.0.0", + "@nx/devkit": "23.2.0", "@playwright/test": "catalog:", "@swc-node/register": "^1.11.1", "@tanstack/eslint-config": "0.4.0", @@ -73,7 +75,7 @@ "eslint": "catalog:", "eslint-plugin-unused-imports": "^4.1.4", "markdown-link-extractor": "^4.0.3", - "nx": "24.0.0", + "nx": "23.2.0", "prettier": "^3.8.0", "tinyglobby": "^0.2.15", "typescript": "npm:@typescript/typescript6@^6.0.2", diff --git a/packages/compiler-test-utils/AGENTS.md b/packages/compiler-test-utils/AGENTS.md new file mode 100644 index 0000000000..57825f1d81 --- /dev/null +++ b/packages/compiler-test-utils/AGENTS.md @@ -0,0 +1,92 @@ +# Compiler test harness + +Shared by the compiler test suites of router-generator, router-plugin, start-plugin-core, react-start-rsc and this +package. What the suite is and how to read it: [oracle/README.md](oracle/README.md). The contract the tests cite: +[oracle/SPEC.md](oracle/SPEC.md). + +## Hard rules + +- Real tools only: real Vite, Rsbuild, Rspack and webpack builds and dev servers, the framework's own plugin, the + real HMR client and renderer. Never copy a tool's logic into a test. +- Reach a compiler only through public entry points: the plugins and options a user configures. No compiler + internals, module ids, queries, generated names, printed code or chunk layout. +- Client code runs in a real browser (`runClient`, `runInPage`, `openPage`); server code in Node, inside real requests + through Start's server entry. No jsdom, no fake `window` or `import.meta.hot`. +- No tests of the helpers' internals; this package's own tests are controls of the harness. +- Tests never write into the repository. Apps live in the run's temp dir (`./app-directory`); checked-in fixtures run + on a copy (router-generator `copyFixture`). +- Diagnostics are checked by severity, file and position only, never by wording. +- Edits settle on their outcome within one bound, never on counts of events, compiles or updates. + +## Helpers + +- `./plugin-host` (`createPluginHost`): the public Vite plugins on a real Vite dev server (server code through the + environment's module runner, client code in the browser) and `vite build`. +- `./rsbuild-plugin-host` (`createRsbuildPluginHost`): the same through Rsbuild's JavaScript API. +- `./build-harness`: real builds (Vite, Rsbuild, Rspack, webpack), with provenance of emitted modules and the + dangling-name check (SPEC G8). +- `./dev-server`, `./rsbuild-dev-server`: dev servers on a temp app with `edit`/`settle`; `closeViteServer`. +- `./browser`: Chromium pages; `runInPage` (bounded run pages, a fresh document per run), `openPage`. +- `./hmr-sync` (`settlePage`): whether a page reloaded or updated in place, told by the page. +- `./outcome` (`waitForOutcome`): wait for an edit's outcome within one bound. +- `./diagnostic-channel`, `./diagnostics` (`expectDiagnostic`, `expectNoProblems`): every reporting channel merged; + checks by severity, file and position. +- `./importers` (`importerSource`, `loadMarker`, `expectNotLoaded`): real importers and load markers. +- `./free-names`, `./known-globals`: a module's free names (Yuku), minus the environment's globals. +- `./global-trap`: trap a page's dev-only globals (SPEC G7). +- `./source-maps`: map assertions through `@jridgewell/trace-mapping`. +- `./determinism`: compare builds across roots and orders (SPEC G4). +- `./dead-code-shapes`: the dependency shapes every removal runs through (SPEC G16); inputs, no judging logic. +- `./app-directory` (`createAppDirectory`, `servedDirectories`): temp app directories that resolve like the package. +- `./run-directory` (Vitest `globalSetup`): the run's temp dir, removed when the run ends. +- `./test-scope` (`currentTest`, `onTestFinished`) with `./test-scope-setup` (`setupFiles`): per-test resources in + concurrent files. +- `./pins` (`runPins`) with `./pins-setup` (`setupFiles`): `COMPILER_TESTS_PINS=run` runs every known-bug pin as an + ordinary test; the shared reporter lists the pins that passed. +- `./workspace-packages`: link built `@tanstack/*` packages into test apps (not declared, to avoid Nx cycles). +- `./run-node`: run built output in a child Node. + +Package hosts build on these: router-plugin `tests/route-app.ts` (`loadRoute`), start-plugin-core +`tests/start-host.ts` (`useStartHost`). Start apps use `tanstackStart()` of the built framework package +(`tests/start-plugins.ts`), entries only through `client.entry`/`server.entry`. + +## Running + +```sh +CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-plugin:test:unit --outputStyle=stream --skipRemoteCache -- tests/code-splitter-scope.test.ts -t "unlike computed keys" +``` + +- The whole oracle (this package's tests, the harness controls, are not part of it): the `nx run-many --parallel=1` + command of [oracle/README.md](oracle/README.md). +- Always through Nx, one command at a time. A file path is a substring filter. +- 4 workers by default (`maxWorkers` in each `vite.config.ts`). +- No `|` inside `-t`; run one command per filter. +- `--skip-nx-cache` only for measurements. +- Slow tier: at most two `test:integration` runs on the machine at once: + `until [ "$(pgrep -fc '[v]itest --project integration')" -lt 2 ]; do sleep 30; done`. +- Tiers: `test:unit` (in process, the inner loop); `test:integration` (`tests/integration/`: real builds, dev servers, + browser pages; `tests/integration/pages/` is the `integration-pages` project). `integration` projects keep modules + across files (`isolate: false`): a file leaves nothing behind but what the harness owns. + +## Budgets + +`test-budgets.json`: per package and tier, a target and a hard limit at 4 workers; 15 s per slow-tier file; 10 s from +edit to result for one fast-tier file. `src/budget-reporter.ts` reports after every run. To enforce, run a whole tier +on a quiet machine (1-minute load below 4, no other test run): + +```sh +COMPILER_TEST_BUDGETS=strict CI=1 NX_DAEMON=false pnpm nx run :test:integration --outputStyle=stream --skipRemoteCache --skip-nx-cache +``` + +A run with a failed test or file is not a measurement. A tier over budget is fixed (shared hosts, bounded pages, +moving page tests to `integration-pages`), not re-budgeted or sharded. + +## Setup facts + +- Framework packages and tools are test-only devDependencies (`solid-js`, `vite-plugin-solid`, `@rsbuild/plugin-react`, + `@rsbuild/plugin-solid` ≥ 1.2.2, `@vitejs/plugin-react`, `@vitejs/plugin-vue`, `miniflare`, …). +- The integration targets build `@tanstack/react-start` first (linked at test time). +- Harness servers listen on `127.0.0.1` and never pass port 0 to Vite or Rsbuild (Rsbuild runs in middleware mode on + the harness's own server). +- The Rsbuild hosts stay silent (`logLevel` and `dev.client.logLevel` `silent`); read output through the diagnostic + channel. diff --git a/packages/compiler-test-utils/eslint.config.js b/packages/compiler-test-utils/eslint.config.js new file mode 100644 index 0000000000..8ce6ad05fc --- /dev/null +++ b/packages/compiler-test-utils/eslint.config.js @@ -0,0 +1,5 @@ +// @ts-check + +import rootConfig from '../../eslint.config.js' + +export default [...rootConfig] diff --git a/packages/compiler-test-utils/oracle/KNOWN-BUGS.md b/packages/compiler-test-utils/oracle/KNOWN-BUGS.md new file mode 100644 index 0000000000..7cd3194ac4 --- /dev/null +++ b/packages/compiler-test-utils/oracle/KNOWN-BUGS.md @@ -0,0 +1,769 @@ +# Known bugs of today's compilers + +Each bug is pinned by `.fails` tests that assert the correct outcome and accept any correct fix. When your compiler +fixes a bug, its pins fail with "Expect test to fail": remove the `.fails` and keep the test. + +One entry per root cause: the bug, the SPEC clause, the pins (`file` and test names; paths under `packages/`; +`$name`, `%s` and `${…}` are table-row placeholders), and what a fix must achieve. The test comment (`Bug:`, +`Impact:`) has the details. "Cause" files name today's implementation; a rewrite may have no such file. + +Totals: 380 pin sites in 105 test files (a table test counts once; Vitest counts each row). + +Pins whose input picks a name today's compiler generates (S6) flip with a compiler that generates other names. The +adaptive pins next to them, which read the names a compiler actually generates, are the real check. + +## Shared causes (several jobs) + +**S1. JSX pragmas are not kept effective.** Code the compilers insert lands above a file's leading pragma (Oxc reads +leading pragmas only); a non-leading pragma becomes leading in a chunk; dead-code elimination does not count a +classic pragma as a use of its factory, so the factory import is dropped. SPEC J2.16, G12. Fix: every emitted module +compiles its JSX under the runtime the untouched file has, and keeps the factory it needs. 13 pins: + +- `router-plugin/tests/code-splitter-pragmas.test.ts`: "keeps a @jsxImportSource written after the imports as + ineffective as in the untouched file (leading-pragma project)"; "keeps the pragma in effect in every module that + contains JSX"; "in the route module, when the code calling the factory is split". +- `router-plugin/tests/integration/code-splitter-pragmas.test.ts`: "means in the split route what it means in the + untouched route (Vite: Oxc ignores it)". +- `router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts`: "a split component renders + through the factory of a classic JSX pragma"; "a split component renders through $name"; "a factory the route + module creates and the loader reads is created once for the split component ($name)". +- `router-plugin/tests/integration/pages/known-bugs-code-splitter-shapes.test.ts`: "a module without JSX does not + import the classic factory ($name)". +- `start-plugin-core/tests/start-compiler-jsx-pragma.test.ts`: "inserted server function imports stay below the + @jsxImportSource pragma: %s"; "client: the parent keeps selecting the pragma JSX runtime when the import it sits on + $name". +- `start-plugin-core/tests/known-bugs-start-compiler.test.ts`: "client: the factory of a classic JSX pragma stays + imported"; "ssr: a module with a classic JSX runtime pragma keeps its React import". +- `start-plugin-core/tests/integration/pages/known-bugs-hydrate-module-level.test.ts`: "client: a module with a + classic JSX pragma renders through its factory". + +**S2. Dead-code elimination keeps what only types or non-reads mention, and never removes some declaration kinds.** +babel-dead-code-elimination counts `typeof x` type queries, TypeScript-only positions (enum members, overload and +constructor parameters) and a local of a function's own name as reads, and never removes classes, enums, namespaces, +overloaded functions or redeclared `var`s. Server-only imports then stay on the client (and client-only imports on +the server). SPEC J4.12, J4.11, J2.5, G16. Fix: code only server code (or only types) reads is gone from the client, +with its imports, and code only client-only code reads is gone from the server. 10 pins: + +- `start-plugin-core/tests/known-bugs-start-compiler.test.ts`: "client: $name does not load its server-only import"; + "client: a server-only import last mentioned by a type alias is not loaded with verbatimModuleSyntax"; "client: a + validator schema that a type alias reads with typeof is not loaded"; "ssr: a declaration a client-only fn reads and + a type alias reads with typeof is not loaded"; "ssr: a class only a client-only fn uses does not load its + client-only import". +- `start-plugin-core/tests/integration/known-bugs-start-compiler.test.ts`: "client: the server-only module of a class + only server code uses is not bundled"; "client: a server-only module a type mentions is not bundled with + verbatimModuleSyntax". +- `start-plugin-core/tests/integration/start-build-user-code.test.ts`: "the decorated class only a server fn handler + uses is not in the client bundle". +- `start-plugin-core/tests/createServerFn/caller-dead-code.test.ts`: "when client code uses its name in $name"; + "callers drop a handler-only function that declares a local of its own name". + +**S3. The printer drops required parentheses** (`@babel/generator`): `count as number++`, `a as any ? -x : y`, +`.props` do not parse. SPEC G12. Fix: printed code parses and means the same. 5 pins: + +- `router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts`: "an asserted update operand keeps + its parentheses in a split component"; "an asserted conditional test keeps its parentheses in a split component"; + "a JSX element read as an object keeps its parentheses in the route module". +- `start-plugin-core/tests/start-compiler-preserves-user-code.test.ts`: "keeps the parentheses of asserted update + operands"; "keeps the parentheses of an asserted conditional test". + +**S4. Source maps are lost on webpack and Rspack.** unplugin's webpack and Rspack transform loaders drop the map a +plugin returns when no earlier loader passed one in. SPEC G6. Fix: a throw in a split chunk maps to the route file's +line (and column). 4 pins: + +- `router-plugin/tests/integration/build-source-maps.test.ts`: "a throw in a split component maps to its line in the + route file ($name)"; "a throw in $name maps to its line and column in the route file". +- `router-plugin/tests/integration/dev-source-maps.test.ts`: "the route module and every module derived from it map a + throw to its line in the route file". +- `start-plugin-core/tests/integration/start-build-source-maps.test.ts`: "rsbuild build: client: a throw in a split + route component maps to its line in the route file ($name)". + +**S5. A type-only import re-exported as `export { Settings }` loses its import** (valid TypeScript without +`verbatimModuleSyntax`), so the TypeScript transform can no longer erase the export. SPEC G1, §2.1. Fix: the module +still compiles and the type export is erased. 2 pins: + +- `router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts`: "a type-only import re-exported + as `export { Settings }` is erased (%s)". +- `start-plugin-core/tests/known-bugs-start-compiler.test.ts`: "client and SSR: a type-only import re-exported as + `export { Settings }` is erased (%s)". + +**S6. Generated names collide with user bindings.** SPEC G15, §5.1. Fix: no generated name shadows or redeclares a +user binding. 8 pins: + +- `router-plugin/tests/integration/pages/known-bugs-code-splitter-shapes.test.ts`: "a route file binding named $name + keeps its value"; "route file bindings named like what the compiled modules introduce keep their values" + (adaptive). +- `router-plugin/tests/known-bugs-route-hmr.test.ts`: "a user binding named hot ($name) does not collide with the + injected HMR code". +- `router-plugin/tests/known-bugs-route-hmr-bindings.test.ts`: "a route file importing a binding named Map renders + with route HMR". +- `start-plugin-core/tests/known-bugs-start-compiler.test.ts`: "a user binding named %s does not collide with + generated code"; "a server fn named opts runs on the server"; "no name the compiler introduces collides with a user + binding or a server fn of that name" (adaptive). +- `start-plugin-core/tests/integration/pages/known-bugs-hydrate-module-level.test.ts`: "client: module-level $name, + named like the generated bindings, do not collide". + +**S7. Dead-code elimination removes the const half of a class and const cycle.** When only removed code used a +class whose static field reads a const that points back to the class (`const registry = { make: () => new Repo() }; +class Repo { static registry = registry }`), babel-dead-code-elimination takes the pair for one removable cycle and +deletes the const, but it never removes a class (S2), so the class stays and its static field reads a deleted name. +SPEC G16, G1. Fix: both halves go together, or both stay; the module loads. 2 pins, one cell per removal: + +- `start-plugin-core/tests/start-compiler-dead-code-shapes.test.ts`: "takes with it what only it uses through a class + and a const that read each other" (server fn handler, `createServerOnlyFn`, isomorphic `.server()` on the client; + `createClientOnlyFn`, isomorphic `.client()` on the server: `ReferenceError` when the module loads there). +- `router-plugin/tests/integration/pages/code-splitter-dead-code-shapes.test.ts`: the same name (a split component and + a `deleteNodes` server handler: the route module throws when it loads). + +## J1 Route file upkeep (30 pins) + +- **A `(group).tsx` route file is reported relative to the routes directory** (neither absolute nor project-relative). + SPEC §2.2, §5.7. `router-generator/tests/deny-route-group-config.test.ts`: "a (group).tsx route file is reported by + name or routes correctly: $name". Fix: name the file unambiguously, or route it. +- **A running generator loses child routes when their layout file is deleted.** SPEC J1.10, J1.4. + `router-generator/tests/generator-dev.test.ts`: "deleting a layout route keeps its child routes in the route tree". + Fix: a watch run gives the tree a fresh run gives. +- **A deleted route tree is never written again** (the next run fails with ENOENT). SPEC J1.10. + `router-generator/tests/generator-dev.test.ts`: "a deleted route tree is written again on its delete event"; "after + the route tree is deleted, adding a route writes the route tree". Fix: regenerate the tree. +- **Edits of the `virtualRouteConfig` file and of `__virtual.ts` files are ignored** (the event's absolute path is + compared with the configured relative path; the config comes from jiti's cache; Rsbuild never sees the file). + SPEC J1.10. `router-generator/tests/generator-dev.test.ts`: "editing the virtualRouteConfig file updates the route + tree"; `router-plugin/tests/integration/dev-server-generator-watching.test.ts` and + `router-plugin/tests/integration/rsbuild-dev-server-generator-watching.test.ts`: "an edit of the virtual route config + file changes the live routes"; "an edit of a \_\_virtual.ts file changes the live routes". Fix: reload the config and + regenerate on each such edit. +- **An event that arrives while a run checks no-op events is dropped.** SPEC J1.10. + `router-generator/tests/generator-dev.test.ts`: "a route created while an update event that changed nothing is + checked joins the route tree". Fix: no delivered event is lost. +- **An empty `.ts` route file is scaffolded with JSX, then parsed as TypeScript** and the run fails. SPEC J1.3. + `router-generator/tests/generator-options.test.ts`: "an empty .ts route file is scaffolded, and the other routes + still generate". Fix: a valid scaffold, and the other routes generate. +- **`importRoutesUsingAbsolutePaths` is not applied to lazy route imports.** SPEC J1.4. + `router-generator/tests/generator-options.test.ts`: "importRoutesUsingAbsolutePaths imports the lazy route files by + absolute paths too". +- **`tmpDir` on another filesystem fails every write with EXDEV.** SPEC J1.16. + `router-generator/tests/generator-options.test.ts`: "with tmpDir on another filesystem, the route file and the route + tree are replaced atomically" (skipped without a writable `/dev/shm`). Fix: rename a temp file written beside the + destination. +- **A layout in a route-group directory is typed `fullPath: ''`**, while the router gives it `/`. SPEC J1.13. + `router-generator/tests/integration/fixture-types-physical.test.ts`: "the "%s" route tree types its routes like the + router"; `router-generator/tests/integration/route-types.test.ts`: "the layout route of a route group directory has + the full path of the router in the types". +- **The generator recognises `createFileRoute` by name, not by binding.** An aliased import is missed; an app's own + `createFileRoute` is rebound to the router package. SPEC G15, J1.1. `router-generator/tests/known-bugs.test.ts`: "a + moved route with an aliased import of the constructor gets the id of its new path"; "a moved route importing + createFileRoute from a module of the app stays a valid module"; `router-generator/tests/route-file-upkeep.test.ts`: + "a createFileRoute $name keeps its meaning: the file is left as it is, or reported". Fix: follow the import. +- **A pathless layout present only as a lazy file or a Vue piece loses its directory path.** SPEC J1.8. + `router-generator/tests/real-router.test.ts`: "a pathless layout with only a lazy route file keeps its directory + path"; `router-generator/tests/route-paths.test.ts`: "a pathless layout with only $name under a path keeps the path + in the URLs of its children". +- **A childless pathless layout gives "Conflicting configuration paths".** SPEC J1.15. + `router-generator/tests/route-paths.test.ts`: "a pathless layout without child routes yet ($name) next to the index + route is added to the route tree". +- **A pathless layout under a lazy-only route attaches to the next real ancestor.** SPEC J1.14. + `router-generator/tests/route-paths.test.ts`: "a pathless layout in a directory under a route with only a lazy + route file nests under that route". +- **File paths and ids are written into quoted strings unescaped** (an apostrophe breaks the tree). SPEC J1.6. + `router-generator/tests/route-paths.test.ts`: "a route file name with an apostrophe gets a route with it in its + URL". +- **Routes whose paths differ only in non-identifier characters or case get the same variable.** SPEC J1.6. + `router-generator/tests/route-paths.test.ts`: "routes $ids get their own routes". +- **A piece next to a directory route (`posts/route.component.vue`) makes its own route `/posts/route`.** SPEC J1.4. + `router-generator/tests/route-pieces.test.ts`: "a component piece of a directory route (route.component.vue) is the + component of the route". +- **`.lazy.vue` is wired as a lazy route, and an empty one is scaffolded with TypeScript.** SPEC J1.17, J1.3. + `router-generator/tests/route-pieces.test.ts`: "a .lazy.vue route file is the lazily loaded component of the + route"; "an empty .lazy.vue route file is not filled with TypeScript route code". +- **With pieces on the root route only, the tree calls `lazyRouteComponent` without importing it.** SPEC G1, J1.4. + `router-generator/tests/route-pieces.test.ts`: "pieces of the root route only are lazy components of their default + export". +- **Rsbuild: a route file created under a `physical()` mount outside the routes directory is never seen.** SPEC + J1.10. `router-plugin/tests/integration/known-bugs-rsbuild-generator-physical.test.ts`: "a route file created under a + physical() mount outside the routes directory reaches the live routes". +- **Rsbuild: a route file the generator cannot parse is left out of the bundle, so its fix is never seen.** SPEC + J1.10, G5. `router-plugin/tests/integration/known-bugs-rsbuild-generator.test.ts`: "a created route file the + generator cannot parse is reported, and fixing it adds the route". + +## J2 Route code splitting (108 pins: 90 below, 18 in S1, S3–S7) + +Router-plugin paths below are under `router-plugin/tests/`; `pages/` means `integration/pages/`. + +- **Imported route options are not read** (only an object literal of the route file is): nothing is split or + deleted, silently. SPEC J2.8, J2.14. `code-splitter-imported-options.test.ts`: "are split, or reported once naming + the route file"; "lose the options of deleteNodes and what only they import, or are reported once naming the route + file". (Start's client build: J2.14 section.) +- **A JSX tag starting with `_`, `$` or a non-ASCII lowercase letter is taken for an intrinsic element.** SPEC J2.4. + `code-splitter-jsx.test.ts`: "gives separate loader and component chunks the one JSX component %s". +- **The esbuild adapter never runs the generator in a build**, so nothing is split and nothing refuses. SPEC J2.18. + `integration/build-harness.test.ts`: "router plugin with esbuild loads a split component lazily and renders it, or + refuses the build (%s)". +- **An already-lazy option value is wrapped again** and suspends after preload. SPEC §6 OQ13. + `integration/code-splitter-router.test.ts`: "renders without a new request or a pending fallback once the router + preloaded it". +- **Default-exported declarations shared by options are duplicated** ("Duplicate declaration"). SPEC J2.4. + `integration/code-splitter-runtime.test.ts`: "preserves executable route contracts with shared named-default + declarations"; `pages/known-bugs-code-splitter-bindings.test.ts`: "a split option renders the default-exported + component other modules import"; "a default-exported function the loader and the split component call works on one + state". +- **Split chunks keep exports of the route file their option does not use.** SPEC J2.5. + `integration/known-bugs-code-splitter-page-code.test.ts`: "$name loads with its chunk"; "${exportedSharedByOptions.name} + loads with its chunk"; "${unreadExport.name} is not in its chunk"; `pages/known-bugs-code-splitter-shapes.test.ts`: "a + split chunk holds only what its option needs, not the other exports of the route file"; "split chunks do not + re-export or declare the re-exports and default class of the route file". Fix: a chunk carries only what its group + needs. +- **Split chunks copy exported declarations they read instead of importing them** (two instances), or miss an + export written as `X as any`. SPEC J2.4. `integration/known-bugs-code-splitter-ssr-builds.test.ts`: "the split + component and other modules share an exported $name"; `integration/known-bugs-code-splitter-client-builds.test.ts`: + "an exported errorComponent written as `PostErrorComponent as any` is one instance in the client (vite build)"; + `pages/known-bugs-code-splitter-bindings.test.ts`: "an exported errorComponent written as `%s` is the instance its + importers get". Fix: one instance for importers and chunks. +- **Bindings that read `Route` are never shared**, so chunks copy them. SPEC J2.4. + `pages/known-bugs-code-splitter-bindings.test.ts`: "an exported function that reads Route is the one the split + component calls"; "a destructuring whose sibling reads Route keeps one cache for the loader and the component". +- **A split component reading `Route` declared with `const` and exported later (`export { Route }`) recreates the + route.** SPEC J2.4. `pages/known-bugs-code-splitter-bindings.test.ts`: "a split component reads the route the route + module exports through export { Route }". +- **Root routes are never split.** SPEC J2.7 (goal). `integration/known-bugs-code-splitter-page-code.test.ts`: "a root + route's %s loads lazily". +- **A component declared by a destructuring is not split, or the build throws.** SPEC J2.8, J2.9. + `integration/known-bugs-code-splitter-page-code.test.ts`: "${destructured.name} load with their chunk or are + reported"; `integration/known-bugs-code-splitter-client-builds.test.ts`: "a component declared by an array + destructuring of a call shared with the errorComponent is split or reported"; + `pages/known-bugs-code-splitter-shapes.test.ts`: "a component declared by an array destructuring of a call shared + with the errorComponent renders". +- **The split compiler accepts a fixed list of value shapes** ("Unexpected splitNode type": object-form loaders, + classes, casts, `satisfies`, member/logical/tagged-template/class expressions; a call is printed and re-parsed + without JSX or TypeScript). SPEC J2.8, J2.9. `integration/known-bugs-code-splitter-ssr-builds.test.ts`: "a split + loader in object form with $name loads route data"; "a split loader in object form passed by reference loads route + data"; `pages/known-bugs-code-splitter-server.test.ts`: "a class component declared in the route file renders + (exported: $exported)"; "a class component and the imports of its static fields leave the route module"; + `pages/known-bugs-code-splitter-shapes.test.ts`: "a component is split with $name"; "an option written as $name is + split and works"; "a component written as $name is split and renders"; `pages/known-bugs-code-splitter.test.ts`: "the + handler of a split loader in object form with $name loads lazily"; "a split loader in object form keeps $name + working, created once". Fix: split any valid value, or keep it unsplit and warn. +- **Top-level statements that write a moved binding stay behind** (`Page.displayName = …` throws). SPEC J2.12, G3. + `integration/known-bugs-code-splitter-property-write.test.ts`: "a component the route file writes a property of + loads with its chunk and renders the property ($hint)"; `pages/known-bugs-code-splitter.test.ts`: "top-level writes + to $name stay with the binding they write". +- **A split binding's declaration or import is deleted from the route module although other code still reads it.** + SPEC J2.12. `pages/known-bugs-code-splitter-server.test.ts`: "a split component that $name reads renders from both"; + "a split component renders through a function $name"; "a component read by a split and an unsplit option renders + from both"; "an unsplit option that reads the split component with typeof sees a function"; "a split component that + a top-level call reads renders from both"; "an imported split component that head() reads renders, and head() reads + it"; "an imported split errorComponent that an exported component renders works for an importer"; "an imported + pendingComponent split by custom groupings renders, and an unsplit option renders it"; + `integration/known-bugs-code-splitter-ssr-builds.test.ts`: "an imported split component that head() reads renders, + and head() reads it (%s build)"; `integration/known-bugs-code-splitter-client-builds.test.ts`: "a split component that + an unused object names renders (vite)"; `pages/known-bugs-code-splitter-bindings.test.ts`: "a split component renders + the exported component of another option that reads Route ($name)". +- **Export lists and aliases of a moved declaration are left without it** ("Export 'load' is not defined"). SPEC + J2.12, J3.3. `pages/known-bugs-code-splitter-bindings.test.ts`: "a split loader exported through an export list keeps + working"; `known-bugs-dev-server.test.ts`: "keep a $name component exported as the route option value"; + `integration/known-bugs-route-hmr-components.test.ts`: "vite: a split component exported by an export list renders, + and an edit shows in place"; `known-bugs-route-hmr.test.ts`: "a component exported by an export list renders for a + module importing it and as the route component" (the last two count under J3). +- **The user's own `import './Page'` is removed with the split component's import.** SPEC G3, J2.12. + `pages/known-bugs-code-splitter-server.test.ts`: "a side-effect import of the split component's module runs when the + route module loads". +- **`deleteNodes` removes only options written as `key: value`**: methods, spreads, computed keys and options in a cast + or `satisfies` keep their server code on the client. SPEC J2.14, J4.12. + `pages/known-bugs-code-splitter-server.test.ts`: "a server-only option written as a method is removed with its + imports (%s)"; "a server-only option given through $name is removed, or the route is refused"; "a server-only option + of options wrapped in `%s` is removed with its imports"; `integration/known-bugs-code-splitter-client-output.test.ts`: + "a client build has no server code of an `ssr()` method (vite)"; "a client build has no server code of options + wrapped in `%s` (vite)". (Start: J2.14 section.) +- **A local function named `createFileRoute` is treated as the router's.** SPEC G15. + `pages/known-bugs-code-splitter-server.test.ts`: "a local factory shadowing createFileRoute in a route file keeps + its own semantics". +- **Only `createFileRoute(` by that name and without a type argument is recognised**; nothing is reported. SPEC J2.1, + J2.8. `pages/known-bugs-code-splitter-shapes.test.ts`: "a component is split when createFileRoute is imported under + an alias"; "a component is split when createFileRoute has a type argument". +- **Route options returned by a call are neither split nor reported.** SPEC J2.8. + `pages/known-bugs-code-splitter-shapes.test.ts`: "route options returned by a call are split or reported". +- **Options inside a route factory are split as if module-level** (closures over parameters break). SPEC J2.10. + `pages/code-splitter-plugin-pipeline-routes.test.ts`: "a route built from $name renders what the factory was given, + split or reported". +- **Two file routes in one module share chunk names**, so one renders the other's component. SPEC J2.11. + `pages/known-bugs-code-splitter-shapes.test.ts`: "each of two file routes of one module renders its own component, + or the module is reported". +- **A symlinked route file is never compiled** (looked up by the scanned path, resolved by its real path). SPEC J2.1, + J4.12, G11. `integration/known-bugs-code-splitter-client-output.test.ts`: "a client build of a symlinked route file + has no server handler code (%s)". +- **Dev-only code follows the process `NODE_ENV`, not the bundler's mode.** SPEC G7, J3.7. + `integration/known-bugs-code-splitter-client-output.test.ts`: "a production client bundle logs no development + warning in the page when NODE_ENV is unset (%s)"; `integration/build-production.test.ts` and + `integration/build-production-webpack-unsplit.test.ts`: "a production %s client bundle without code splitting has no + dev-only code" (these two count under J3). +- **Chunk ids paste the absolute file path into a URL and a quoted string** (`#`, `'` and the split marker text in a + directory name break builds). SPEC G1, G11. `integration/known-bugs-code-splitter-ssr-builds.test.ts`: "an app in a + directory with # in its name builds and preloads a split component"; "an app in a directory whose name contains what + split module ids contain builds and preloads a split component"; "an app in a directory with ' in its name builds and + preloads a split component". +- **A `let` reassigned in another module becomes a read-only import.** SPEC J2.4, G1. + `integration/known-bugs-code-splitter-ssr-builds.test.ts`: "a let $name stays writable and the split component reads + its value". +- **Shared bindings are computed by the route-module transform and stored per file**; chunks served first read stale + state. SPEC G4, J2.13. `integration/known-bugs-dev-server.test.ts`: "a page loading the modules of the route file + before the route module renders the edited route after $name". +- **Ambient declarations (`declare const`, a var merged with an interface, a global) are treated as module bindings.** + SPEC G1, J2.12. `pages/code-splitter-imports-exports.test.ts`: "reads an ambient var merged with an interface from + the environment in a shared declaration, with verbatimModuleSyntax"; `pages/known-bugs-code-splitter.test.ts`: "an + ambient declare const read by the loader and the split component stays a global"; + `pages/known-bugs-code-splitter-bindings.test.ts`: "a component read from $name renders". +- **The shared-binding analysis misses readers** (method options, computed keys, nested `var`s, enums, namespaces, + class static initialisers), so state is created twice. SPEC J2.4, G3. + `pages/code-splitter-module-state-bindings.test.ts`: "$name"; `pages/known-bugs-code-splitter-bindings.test.ts`: + "module state a method option shares with a split option is created once"; `pages/known-bugs-code-splitter.test.ts`: + "a binding read by a computed-key option and a split option is created once"; "a binding declared by $name and read + by the loader and the split component is initialized once"; "module state that the reference module keeps for $name + is initialized once". +- **Chunks keep unreferenced top-level statements** (side effects run twice; `export *` repeated). SPEC G3, J2.5. + `pages/known-bugs-code-splitter.test.ts`: "an unreferenced top-level side effect ($name) runs once, with the route + module"; "split chunks do not re-export a module-level export \*, which importers of the route file still get". +- **A declaration only an exported type alias reads loses its initializer.** SPEC G3. + `pages/known-bugs-code-splitter.test.ts`: "the initializers of $name run when the route module loads"; "the + initializer of a declaration only an exported type alias reads runs when a route module compiled for HMR loads". +- **Code only the split component needs stays when something looks like a read** (a type of the same name, an + overload signature, a second `var`, an unused renderer). SPEC J2.5. `pages/known-bugs-code-splitter.test.ts`: "a split + component and its imports leave the route module next to $name". +- **A value import only types read is copied into every chunk.** SPEC J2.5. + `pages/known-bugs-code-splitter-bindings.test.ts`: "split chunks do not import what only $name reads". +- **`codeSplitGroupings` in a module-level constant is refused.** SPEC J2.2. + `pages/known-bugs-code-splitter-bindings.test.ts`: "groupings declared in a module-level constant are honoured". +- **The not-split warning is printed only when the splitter changed the module.** SPEC J2.8. + `pages/known-bugs-code-splitter-bindings.test.ts`: "an exported component ($name) that is the only split candidate is + split or reported as not code-split". +- **Decorators after `export` and parameter decorators do not parse.** SPEC §2.1, G1. + `pages/known-bugs-code-splitter-bindings.test.ts`: "a decorator after `export` compiles"; "a class with a parameter + decorator that the split component uses compiles into parseable modules". +- **A namespace is copied into a chunk without its body.** SPEC G1. `pages/known-bugs-code-splitter-bindings.test.ts`: + "a namespace the split component reads keeps its body". +- **A route module's CSS import loads on every page**: the code splitter keeps the bare import in the route module, + which the route tree imports eagerly (in dev the CSS is injected once the client runs; a build merges it into the + entry's CSS). SPEC J2.22. `start-plugin-core/tests/integration/known-bugs-route-css.test.ts` (Vite) and + `known-bugs-route-css-rsbuild.test.ts` (Rsbuild), rows of `route-css-cases.ts`: "the CSS of the /${name} route + applies only once the route matches" (the five `shows-*` rows; dev and build). Fix: the CSS loads when its route + matches. +- **Rsbuild: a route's manifest entry lists the chunks and CSS of a sibling route** when the routes share a module in + a chunk of its own: Start's Rsbuild manifest counts a chunk as available when any one of the importing chunk's groups + has it, not every one, so the shared chunk depends on each route's copy of the module it imports (#8780). SPEC J2.22. + `start-plugin-core/tests/integration/known-bugs-route-css-rsbuild.test.ts`, rows of `route-css-cases.ts`: "the CSS + of the /${name} route applies only once the route matches" (`shares-module-a`, `shares-module-c`; dev and build; + Vite passes). Cause: `computeStaticDependencyChunks`, `start-plugin-core/src/rsbuild/normalized-client-build.ts`. + Fix: the page of a route links only the CSS of the chunks that route loads. +- **Vite dev: the maps of the split and shared modules name the route file with the splitter's query** + (`index.tsx?tsr-split=component`), so a debugger sees another file than the route file. SPEC G6. + `integration/dev-source-maps.test.ts`: "a throw in $name maps to its line in the route file, which its module names + as its source". Fix: every module derived from the route file names the route file itself as its source. +- **Overload signatures of a shared function stay next to its import**, and the TypeScript transform drops the import. + SPEC G1, J2.12. `pages/known-bugs-code-splitter-bindings.test.ts`: "an overloaded function the route module and a + split loader share keeps working"; `known-bugs-dev-server.test.ts`: "keep exported overloads and their aliases that + unsplit and split options call". + +## J2.14/J2.15 Start's router wiring (12 pins) + +Paths under `start-plugin-core/tests/integration/`. + +- **Rsbuild does not prune server-only routes from the client route tree.** SPEC J2.15. + `known-bugs-route-options.test.ts`: "a route with only server handlers is not in the client route tree" (two + tables); `start-build-manifest.test.ts`: "the client route tree is the SSR route tree without the server-only + subtree"; `start-compose-server-only-routes.test.ts`: "the client route tree leaves out the server-only subtree"; + "client-side navigation to a server-only route finds nothing". +- **The generator records only plain option keys**, so a route with server handlers and computed, method or spread + client options is pruned. SPEC J1.9, J2.15. `known-bugs-route-options.test.ts`: "a route with server handlers and these + options is in the client route tree"; `start-compose-server-only-routes.test.ts`: "the client route tree keeps the + page whose component is spread in"; "client-side navigation reaches the page whose component is spread in". Fix: + never prune because a key was missed. +- **Options in a cast skip `deleteNodes`** (see J2). `known-bugs-route-options.test.ts`: "the server handler code of + the route is not in the client bundle". +- **Imported route options keep `server.handlers` on the client** (see J2). `start-compose-imported-options.test.ts`: + "the client build never ships the server handlers of imported route options silently". +- **The client route tree module is matched by `new RegExp()`, unescaped.** SPEC J2.15, G11. + `start-compose-project-path.test.ts`: "the client route tree leaves out the server-only route"; "the client gets the + file, not the client route tree". + +## J3 Route HMR (28 pins: 22 below, 2 in S6, 4 in J2) + +Paths under `router-plugin/tests/`. + +- **Inline components that are not plain functions** (`memo`, `forwardRef`, method shorthand, `as`/`satisfies`), and + components inside a route helper function, **are not registered for React Refresh**, so edits do not show. SPEC J3.2, + J3.3. `integration/known-bugs-route-hmr-components.test.ts`: "vite: an edit of an inline component written as $name + shows in place (autoCodeSplitting: $pluginOptions.autoCodeSplitting)"; `integration/known-bugs-route-hmr.test.ts`: + "%s: an edit of a route a helper function creates shows its new component, reloading only when the file is reported + (autoCodeSplitting: false)". +- **Lowercase components break under React HMR** (renamed in a chunk, renamed in the route module after the code + splitter chose the shared bindings, not registered, or hoisted out of order). SPEC J3.2, J2.4, G1. `integration/known-bugs-route-hmr-components.test.ts`: "vite: an edit of a split component declared + lowercase as $name shows in place"; "vite: a lowercase function component that is also the unsplit pendingComponent + renders, and an edit shows in place"; `integration/known-bugs-route-hmr-removals.test.ts`: "vite: an inline pending + component hoisted before a renamed lowercase component renders it"; `known-bugs-route-hmr.test.ts`: "a lowercase + function component split into two chunks renders with the module state they share"; "a lowercase function component + shared with the loader renders with the module state it shares"; "a lowercase function component that is also the + unsplit pendingComponent renders as both"; "a destructured binding that the loader, the split component and the + unsplit pendingComponent share works and is created once"; "a lowercase component created by a call that the loader, the + split component and the unsplit pendingComponent share is created once". +- **A removed split option's module stays in Vite's graph and is compiled as CommonJS.** SPEC J2.13, J3.3. + `integration/known-bugs-route-hmr-removals.test.ts`: "vite: an edit that removes a split option the page loaded + applies in place without errors". +- **Route HMR keeps the previous component for React Refresh to patch**, also without a Refresh runtime and after a + rename. SPEC J3.3. `integration/known-bugs-route-hmr-removals.test.ts`: "rsbuild without React Refresh: an edit of the + route component shows in place (autoCodeSplitting: %s)"; `integration/known-bugs-route-hmr.test.ts`: "renaming the + route component shows the renamed component in place (autoCodeSplitting: %s)". +- **The HMR code reads the route through the identifier `Route`.** SPEC J3.1. + `integration/known-bugs-route-hmr-removals.test.ts`: "a route exported under another local name is hot-updated in + place". +- **Solid and Vue split components get a new lazy component on every update.** SPEC J3.2. + `integration/known-bugs-route-hmr.test.ts`: "$bundler: an edit of a split $target route shows in place, keeping the + split component". +- **Vite: the accept call is on an alias (`const hot = import.meta.hot`)**, so the module is no HMR boundary and the + page reloads. SPEC J3.1, G10. `integration/known-bugs-route-hmr.test.ts`: "vite: an edit of an unsplit Vue route shows + in place"; "vite: an edit of a React .ts route module shows its new loader data in place (autoCodeSplitting: %s)"; + "vite: an edit of a route component in an app without @vitejs/plugin-react shows in place (autoCodeSplitting: %s)". +- **Rsbuild: an unsplit Solid route keeps rendering the old component**, the root route too (always unsplit). SPEC + J3.3, J3.5. `integration/known-bugs-route-hmr.test.ts`: "rsbuild: an edit of an unsplit Solid route shows its new + component in place"; "rsbuild: an edit of a Solid root route shows its new component in place (autoCodeSplitting: + %s)". +- **Rsbuild: an edit of a split loader only never reaches the page** (the route module did not change). SPEC J3.3. + `integration/known-bugs-route-hmr.test.ts`: "rsbuild: an edit of a split loader (codeSplitGroupings: %s) shows its + data in place". +- **With options in a variable, the HMR transform declares the component binding after the object that reads it.** + SPEC G1. `known-bugs-route-hmr.test.ts`: "route options in a variable ($name) evaluate to a route with a component". + +## J4 Start environment separation (86 pins: 66 below, 20 in S1–S7) + +Paths under `start-plugin-core/tests/` unless noted. + +- **A `.validator()` link on a stored builder, or wrapped in `as`/`satisfies`, is not stripped from the client** + (the chain walk stops at the identifier). SPEC J4.1, J4.8, J4.12. `createServerFn/caller-dead-code.test.ts`: "when + the validator link is wrapped in a $name expression"; "when the validator link is on a builder stored in a variable + ($name)"; `integration/start-build-env-separation.test.ts`: "$construct: its server code is not in the client bundle, + and runs in the SSR build"; `start-compiler-factories.test.ts`: "the client strips a validator link$middleware wrapped + in $name"; "the client strips a validator link of a builder stored in a variable". +- **An isomorphic fn whose link is stored, wrapped or passed through a helper loses that implementation.** SPEC J4.9. + `integration/start-build-env-separation.test.ts`: "an isomorphic fn whose $name is stored in a variable runs its + implementation in each build"; `start-compiler-factories.test.ts`: "each output keeps its implementation of an + isomorphic fn whose $name is stored in a variable"; "each output keeps its implementation of an isomorphic fn with a + wrapped chain link: %s"; `known-bugs-start-compiler.test.ts`: "each output keeps its implementation of an isomorphic + fn whose chain passes through a helper function". +- **A factory callee wrapped in `as any` is not resolved.** SPEC J4.5. `start-compiler-factories.test.ts`: "each output + keeps its implementation of $shape with the callee in $name". +- **Builders are traced through identifiers and member expressions only**: namespace members, a re-exported Start + namespace, a builder returned by a call or passed through a helper, `wrap(wrap(...))`, a library function creating + server fns. SPEC J4.5, J4.12. `known-bugs-start-compiler.test.ts`: "client builds compile a builder read from a + namespace import"; "client builds compile factories of a re-exported Start namespace"; "client builds compile a + builder returned by a function of $name"; "client builds compile a server fn whose builder passes through a helper + function"; `createServerFn/declaration-sites.test.ts`: "with %s imported, a server fn wrapped in two calls works like + an unwrapped one"; `integration/known-bugs-start-compiler.test.ts`: "a server fn created by a library function: the + handler is not in the client bundle, or the build fails clearly". Fix: the client has no server code, or the build + fails at the call. +- **The bundler plugins choose modules by their text** (a factory name, `.handler(`, `` block is parsed as TSX** (the parser is chosen from the id without its query). + SPEC §2.1. `integration/known-bugs-start-compiler-vue-sfc.test.ts`: "build: a server fn in a `, + ...app('import.meta.hot'), + }, + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('text v1 other v1') + expect(page.loads()).toBe(1) + + await server.write({ 'text.js': `export const text = 'text v2'\n` }) + await page.waitForText('text v2 other v1') + expect(page.loads()).toBe(1) + + await server.write({ 'other.js': `export const other = 'other v2'\n` }) + await page.waitForText('text v2 other v2') + await expect.poll(() => page.loads()).toBe(2) + }, + timeout, +) + +test( + 'rsbuild: the page shows an accepted update in place, and reloads for one nothing accepts', + async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + browser: true, + entry: 'main.js', + config: { html: { mountId: 'app' } }, + files: app('import.meta.webpackHot'), + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('text v1 other v1') + expect(page.loads()).toBe(1) + + await server.edit({ 'text.js': `export const text = 'text v2'\n` }) + await page.waitForText('text v2 other v1') + expect(page.loads()).toBe(1) + + await server.edit({ 'other.js': `export const other = 'other v2'\n` }) + await page.waitForText('text v2 other v2') + await expect.poll(() => page.loads()).toBe(2) + }, + timeout, +) + +// The page's console has only the app's output. The harness reads Rsbuild's +// logger without raising `logLevel`, to which Rsbuild ties the HMR client's +// log level by default: at `warn`, the client prints each compile's +// warnings (and its failed connection attempts) in the page. +test( + 'rsbuild: Rsbuild’s HMR client prints nothing in the page', + async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + browser: true, + entry: 'main.js', + config: { html: { mountId: 'app' } }, + files: app('import.meta.webpackHot'), + plugins: [ + { + name: 'compile-warner', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.thisCompilation.tap( + 'compile-warner', + (compilation) => { + compilation.warnings.push( + new compiler.webpack.WebpackError( + 'MARK_COMPILE_WARNING', + ), + ) + }, + ) + }, + }) + }) + }, + }, + ], + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('text v1 other v1') + // The client applied an update in place: it was connected, and got the + // first compile's warnings before + await server.edit({ 'text.js': `export const text = 'text v2'\n` }) + await page.waitForText('text v2 other v1') + expect(page.loads()).toBe(1) + expect(page.console).toEqual([]) + expect(page.errors).toEqual([]) + // The harness's channel has the warning + expect( + server.diagnostics.some(({ text }) => + text.includes('MARK_COMPILE_WARNING'), + ), + ).toBe(true) + }, + timeout, +) + +test('a page given its document shows it at its URL, and an init script runs before the page’s own code, on every load', async () => { + // No server listens there: the document is the one given. + const url = 'http://127.0.0.1:9/page' + const page = await openPage(url, { + registerCleanup: onTestFinished, + initScript: `window.initRan = (window.initRan ?? 0) + 1`, + html: `
`, + }) + expect(await page.text('#app')).toBe(`MARK_DOCUMENT ${url}`) + expect(await page.page.evaluate('window.appSaw')).toBe(1) + await page.page.reload() + expect(await page.page.evaluate('[window.appSaw, window.initRan]')).toEqual([ + 1, 1, + ]) +}) + +// The run pages serve every run of a test process, so a +// script that never settles must fail its run within the bound and leave +// its page (or a new one) to the next run. +test('a run whose script never settles fails within its bound, and the next run gets a page', async () => { + const started = Date.now() + await expect( + runInPage({ + pageUrl: 'about:blank', + script: 'await new Promise(() => {})', + timeout: 1000, + }), + ).rejects.toThrow(/did not settle within 1000 ms/) + expect(Date.now() - started).toBeLessThan(10_000) + expect( + (await runInPage({ pageUrl: 'about:blank', script: 'return 1 + 1' })) + .result, + ).toBe(2) +}) + +// What a test process opens in its browser is bounded (Chromium fails +// requests under too many pages), and runs of concurrent tests do not share +// a document. +test('concurrent runs each hold a page of their own, at most runPageLimit at once, each on a fresh document', async () => { + let active = 0 + let most = 0 + const server = createServer((request, response) => { + if (request.url === '/page') { + response.setHeader('content-type', 'text/html') + response.end('

page

') + return + } + active++ + most = Math.max(most, active) + setTimeout(() => { + active-- + response.end('held') + }, 300) + }) + await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve)) + onTestFinished( + () => new Promise((resolve) => server.close(() => resolve())), + ) + const url = `http://127.0.0.1:${(server.address() as AddressInfo).port}/` + const runs = await Promise.all( + Array.from({ length: runPageLimit + 2 }, (_, index) => + runInPage<{ earlier: unknown; held: string }>({ + pageUrl: `${url}page`, + script: `const earlier = window.__earlierRun ?? null +window.__earlierRun = ${index} +// (a URL of its own: the browser's HTTP cache makes requests of the same +// URL wait for each other) +return { earlier, held: await (await fetch('/hold?run=${index}')).text() }`, + }), + ), + ) + expect(runs.map((run) => run.result)).toEqual( + runs.map(() => ({ earlier: null, held: 'held' })), + ) + expect(most).toBeGreaterThan(1) + expect(most).toBeLessThanOrEqual(runPageLimit) +}) + +// A run returns once its page left the run's document, so what the dev +// server sends next (a full reload after the test's edit) reaches no page a +// later run gets. When the page left only after the run returned, such a +// reload, started while the page was on its way to `about:blank`, outlived +// that navigation and interrupted the next run's navigation (under load). +test('a run returns once its page left the run’s document: a message the dev server sends next reaches no page', async () => { + let answers = 0 + const host = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + client: true, + plugins: [ + { + name: 'control:answers', + configureServer(server) { + server.middlewares.use('/__answer', (_request, response) => { + answers++ + response.end() + }) + }, + }, + ], + files: { + 'main.js': `export const value = 'MARK_VALUE' +import.meta.hot.on('control:probe', () => { + navigator.sendBeacon('/__answer') +}) +`, + }, + }) + for (let round = 0; round < 5; round++) { + const run = await host.runClient('/main.js', 'return module.value') + expect(run.result).toBe('MARK_VALUE') + host.dev.vite.environments.client.hot.send({ + type: 'custom', + event: 'control:probe', + }) + // A page still on the run's document gets the message within a moment + await new Promise((resolve) => setTimeout(resolve, 300)) + expect(answers).toBe(0) + // and a full reload sent then reaches no later run + host.dev.vite.environments.client.hot.send({ type: 'full-reload' }) + const later = await host.runClient<{ value: string; loads: number }>( + '/main.js', + `await new Promise((resolve) => setTimeout(resolve, 200)) +return { value: module.value, loads: performance.getEntriesByType('navigation').length }`, + ) + expect(later.result).toEqual({ value: 'MARK_VALUE', loads: 1 }) + } +}) + +test('openPage keeps at most openPageLimit pages open: one more waits until one closes', async () => { + const pages = await Promise.all( + Array.from({ length: openPageLimit }, () => + openPage('about:blank', { registerCleanup: onTestFinished }), + ), + ) + let opened = false + const next = openPage('about:blank', { registerCleanup: onTestFinished }) + void next.then(() => { + opened = true + }) + await new Promise((resolve) => setTimeout(resolve, 500)) + expect(opened).toBe(false) + await pages[0]!.close() + await next + expect(opened).toBe(true) +}) diff --git a/packages/compiler-test-utils/tests/integration/budget-reporter.test.ts b/packages/compiler-test-utils/tests/integration/budget-reporter.test.ts new file mode 100644 index 0000000000..d4c927c7db --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/budget-reporter.test.ts @@ -0,0 +1,153 @@ +/** + * Controls of the budget reporter (budget-reporter.ts) on real Vitest runs + * (the Vitest CLI in a child process, on a fixture package that has this + * package's budgets): a run in which a test file failed to load is not a + * measurement, so strict mode fails it as invalid and report-only mode says + * its times are not a measurement; a run whose files all pass is a + * measurement. + */ +import { execFile } from 'node:child_process' +import { mkdtemp, rm, writeFile } from 'node:fs/promises' +import { createRequire } from 'node:module' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, test } from 'vitest' +import type { TestContext } from 'vitest' + +const reporter = path.join( + path.dirname(fileURLToPath(import.meta.url)), + '../../src/budget-reporter.ts', +) +const vitestCli = path.join( + path.dirname(createRequire(import.meta.url).resolve('vitest/package.json')), + 'vitest.mjs', +) + +const passingFile = `test('passes', () => {})\n` +// A file that fails to load, like a test importing a helper that is missing +const brokenFile = `import './missing-helper.js'\n\ntest('never runs', () => {})\n` + +/** + * Runs a whole tier (every file of the fixture) at the budgets' worker count + * with the Vitest CLI; resolves with its exit code and output. `context` + * is the calling test's: a concurrent test's cleanup must be its own (the + * global `onTestFinished` may register it on another running test, which + * then removes the fixture while this run reads it). + */ +async function runTier( + context: Pick, + files: Record, + budgets: 'strict' | 'report-only', + projectName = 'unit', +) { + const root = await mkdtemp(path.join(tmpdir(), 'budget-reporter-')) + context.onTestFinished(() => rm(root, { recursive: true, force: true })) + await writeFile( + path.join(root, 'package.json'), + JSON.stringify({ name: '@tanstack/compiler-test-utils', type: 'module' }), + ) + await writeFile( + path.join(root, 'vitest.config.mjs'), + `export default { test: { name: ${JSON.stringify(projectName)}, globals: true, watch: false, reporters: ['default', ${JSON.stringify(reporter)}] } }\n`, + ) + for (const [name, code] of Object.entries(files)) { + await writeFile(path.join(root, name), code) + } + // The child is a Vitest run of its own, not a worker of this one + const env = Object.fromEntries( + Object.entries(process.env).filter(([key]) => !key.startsWith('VITEST')), + ) + delete env.COMPILER_TEST_BUDGETS + if (budgets === 'strict') { + env.COMPILER_TEST_BUDGETS = 'strict' + } + env.NO_COLOR = '1' + delete env.FORCE_COLOR + return new Promise<{ exitCode: number; output: string }>((resolve) => { + execFile( + process.execPath, + [vitestCli, 'run', '--root', root, '--maxWorkers=4'], + { cwd: root, env, timeout: 25_000 }, + (error, stdout, stderr) => { + resolve({ + exitCode: error ? ((error.code as number | undefined) ?? 1) : 0, + output: `${stdout}\n${stderr}`, + }) + }, + ) + }) +} + +test.concurrent( + 'strict mode fails a run in which a test file failed to load, as an invalid measurement', + async (context) => { + const { exitCode, output } = await runTier( + context, + { 'passing.test.js': passingFile, 'broken.test.js': brokenFile }, + 'strict', + ) + expect(output).toContain('Test budget (strict') + expect(output).toMatch( + /Test budget \(strict\): not a valid measurement \(test files failed: broken\.test\.js\)/, + ) + expect(output).not.toContain('Test budget (strict): passed') + expect(exitCode).toBe(1) + }, + 30_000, +) + +test.concurrent( + 'report-only mode says the times of such a run are not a measurement', + async (context) => { + const { output } = await runTier( + context, + { 'passing.test.js': passingFile, 'broken.test.js': brokenFile }, + 'report-only', + ) + expect(output).toContain('Test budget (report only') + expect(output).toMatch( + /not a measurement \(test files failed: broken\.test\.js\)/, + ) + }, + 30_000, +) + +test.concurrent( + 'a run whose files all pass is a measurement', + async (context) => { + const { output } = await runTier( + context, + { 'passing.test.js': passingFile }, + 'strict', + ) + // The reporter ran and judged the time (pass or over a limit: the time + // depends on the machine), without calling the run invalid + expect(output).toContain('Test budget (strict') + expect(output).toContain('@tanstack/compiler-test-utils unit:') + expect(output).not.toContain('not a valid measurement') + }, + 30_000, +) + +test('a project named integration-* (e.g. integration-pages) is the slow tier', async (context) => { + const { output } = await runTier( + context, + { 'pages.test.js': passingFile }, + 'report-only', + 'integration-pages', + ) + expect(output).toContain('@tanstack/compiler-test-utils integration:') + expect(output).not.toContain('@tanstack/compiler-test-utils unit:') +}, 30_000) + +test('noncompiler coverage does not consume compiler acceptance budgets', async (context) => { + const { exitCode, output } = await runTier( + context, + { 'runtime.test.js': passingFile }, + 'strict', + 'noncompiler', + ) + expect(exitCode).toBe(0) + expect(output).not.toContain('Test budget (strict') +}, 30_000) diff --git a/packages/compiler-test-utils/tests/integration/build-harness.test.ts b/packages/compiler-test-utils/tests/integration/build-harness.test.ts new file mode 100644 index 0000000000..b57594d398 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/build-harness.test.ts @@ -0,0 +1,572 @@ +/** + * Control tests of the real-build harness (build-harness.ts): for each + * bundler, the harness reports eager and lazy placement correctly, `run()` + * executes SSR output in Node and client output in a real browser, and + * side-effect hints reach the bundler. + */ +import { existsSync } from 'node:fs' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, onTestFinished, test } from 'vitest' +import { + bundleApp as bundleAppIn, + bundlers, + createApp, + describeBuild, + originalFrameOf, +} from '../../src/build-harness' +import { findDiagnostics } from '../../src/diagnostics' +import type { + BundleOptions, + BundlerPlugins, + Placement, +} from '../../src/build-harness' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +/** Builds a one-off app (`bundleApp`) in this directory, without a plugin. */ +function bundleApp( + options: Omit & { plugins?: BundlerPlugins }, +) { + return bundleAppIn({ + dir: testsDir, + registerCleanup: onTestFinished, + ...options, + }) +} + +/** + * The entry imports `./eager` statically and `./lazy` on demand, and never + * uses the `unused` export of `./eager`. + */ +const dynamicImportApp = { + 'entry.ts': `import { eager } from './eager' +export const value = eager() +export async function load() { + const { lazy } = await import('./lazy') + return lazy() +} +`, + 'eager.ts': `export function eager() { + return 'MARK_EAGER' +} +export function unused() { + return 'MARK_UNUSED' +} +`, + 'lazy.ts': `export function lazy() { + return 'MARK_LAZY' +} +`, +} + +describe.each(bundlers)('%s', (bundler) => { + test.each(['ssr', 'client'] as const)( + 'reports static imports as eager and dynamic imports as lazy, and runs the output (%s)', + async (env) => { + const app = await bundleApp({ bundler, env, files: dynamicImportApp }) + expect(app.eager).toContain(app.entry.fileName) + expect(app.lazy).not.toHaveLength(0) + expect({ + eager: app.where('MARK_EAGER'), + lazy: app.where('MARK_LAZY'), + unused: app.where('MARK_UNUSED'), + }).toEqual({ eager: 'eager', lazy: 'lazy', unused: 'nowhere' }) + const lazyChunk = app.locate('MARK_LAZY').lazy[0] + expect( + app.chunks.some((chunk) => chunk.dynamicImports.includes(lazyChunk!)), + ).toBe(true) + + const run = await app.run(`console.log('ran') +return [entry.value, await entry.load()]`) + expect(run.result).toEqual(['MARK_EAGER', 'MARK_LAZY']) + expect(run.logs).toEqual(['ran']) + expect(run.html).toBe( + env === 'client' ? '
' : undefined, + ) + }, + timeout, + ) + + test('emits source maps naming the source files', async () => { + const app = await bundleApp({ + bundler, + files: dynamicImportApp, + sourcemap: true, + }) + const lazyChunk = app.chunks.find( + (chunk) => chunk.fileName === app.locate('MARK_LAZY').lazy[0], + ) + expect( + lazyChunk?.map?.sources.map((source) => path.basename(source)), + ).toContain('lazy.ts') + }) + + test('maps a frame of an error stack through the source map of its chunk', async () => { + const app = await bundleApp({ + bundler, + files: { + 'entry.ts': `export async function load() { + const { fail } = await import('./failing') + return fail() +} +`, + // The TypeScript-only lines before the throw shift it: a map that + // skips the TypeScript transform points at the wrong line. + 'failing.ts': `interface Failure { + message: string + code: number +} +type Reason = Failure['message'] +export function fail(reason: Reason = 'MARK_FAIL'): string { + // MARK_FAIL throws on line 8 + throw new Error(reason) +} +`, + }, + sourcemap: true, + }) + const { result } = await app.run( + `try { await entry.load() } catch (error) { return error.stack }`, + ) + const frame = originalFrameOf(app, result as string) + expect(frame && { file: frame.file, line: frame.line }).toEqual({ + file: 'failing.ts', + line: 8, + }) + }) + + // `(value: T) => value` and `input` only parse as TypeScript + // without JSX, which is how every bundler reads a `.ts` file. + test('compiles the TypeScript-only syntax of a .ts module', async () => { + const app = await bundleApp({ + bundler, + files: { + 'entry.ts': `const identity = (value: T): T => value +export function read(input: unknown) { + return identity(input + 1) +} +`, + }, + }) + expect((await app.run('return entry.read(1)')).result).toBe(2) + }) + + test('builds an app with a symlinked module', async () => { + const app = await bundleApp({ + bundler, + files: { + 'entry.ts': `export { linked } from './linked'\n`, + 'real/linked.ts': `export const linked = 'MARK_LINKED'\n`, + }, + symlinks: { 'linked.ts': 'real/linked.ts' }, + }) + expect((await app.run('return entry.linked')).result).toBe('MARK_LINKED') + }) + + test('reports a build error through the bundler', async () => { + await expect( + bundleApp({ + bundler, + files: { 'entry.ts': `import { missing } from './missing'\nmissing()` }, + }), + ).rejects.toMatchObject({ + name: 'BuildError', + bundler, + errors: expect.arrayContaining([ + expect.stringMatching(/resolve ["']\.\/missing["']/), + ]), + }) + }) +}) + +/** + * A plugin of `bundler` that warns through the bundler's own reporting + * (`MARK_PLUGIN_WARNING`) and, except esbuild's, prints a warning and an + * error on the console while the build runs; the build succeeds. (esbuild + * calls plugins from callbacks of its long-lived service, and the harness + * does not attribute their console output to the build reliably: in this + * file's run it reached no build. A known limit of the capture, which + * router-plugin's console control leaves out for esbuild too.) + */ +const reportingPlugins: BundlerPlugins = { + vite: () => ({ + name: 'reports', + buildStart(this: { warn: (message: string) => void }) { + this.warn('MARK_PLUGIN_WARNING') + console.warn('MARK_CONSOLE_WARNING') + console.error('MARK_CONSOLE_ERROR') + }, + }), + esbuild: () => ({ + name: 'reports', + setup(build: { + onStart: (callback: () => { warnings: Array<{ text: string }> }) => void + }) { + build.onStart(() => { + return { warnings: [{ text: 'MARK_PLUGIN_WARNING' }] } + }) + }, + }), + ...Object.fromEntries( + (['webpack', 'rspack'] as const).map((bundler) => [ + bundler, + () => ({ + apply(compiler: { + hooks: { + thisCompilation: { + tap: ( + name: string, + callback: (compilation: { warnings: Array }) => void, + ) => void + } + } + }) { + compiler.hooks.thisCompilation.tap('reports', (compilation) => { + compilation.warnings.push(new Error('MARK_PLUGIN_WARNING')) + console.warn('MARK_CONSOLE_WARNING') + console.error('MARK_CONSOLE_ERROR') + }) + }, + }), + ]), + ), +} + +/** The markers of `diagnostics`, sorted. */ +const markersOf = (diagnostics: Array<{ text: string }>) => + diagnostics.flatMap(({ text }) => text.match(/MARK_\w+/g) ?? []).sort() + +// Severity is part of a report (SPEC §5.7: a clause that says "warn" and +// allows no refusal asks for a warning): the result keeps it on both +// channels, as a dev server's channel does. +test.each(bundlers)( + '%s: the reports of a build that succeeds keep their severity', + async (bundler) => { + const app = await bundleApp({ + bundler, + files: { 'entry.ts': `export const value = 1\n` }, + plugins: reportingPlugins, + }) + expect(app.warnings).toContainEqual( + expect.objectContaining({ + severity: 'warning', + text: expect.stringContaining('MARK_PLUGIN_WARNING'), + }), + ) + const printsToConsole = bundler !== 'esbuild' + if (printsToConsole) { + expect(app.consoleMessages).toEqual( + expect.arrayContaining([ + expect.objectContaining({ + severity: 'warning', + text: expect.stringContaining('MARK_CONSOLE_WARNING'), + }), + expect.objectContaining({ + severity: 'error', + text: expect.stringContaining('MARK_CONSOLE_ERROR'), + }), + ]), + ) + } + const reported = [...app.warnings, ...app.consoleMessages] + expect({ + warning: markersOf(findDiagnostics(reported, { severity: 'warning' })), + error: markersOf(findDiagnostics(reported, { severity: 'error' })), + }).toEqual( + printsToConsole + ? { + warning: ['MARK_CONSOLE_WARNING', 'MARK_PLUGIN_WARNING'], + error: ['MARK_CONSOLE_ERROR'], + } + : { warning: ['MARK_PLUGIN_WARNING'], error: [] }, + ) + }, + timeout, +) + +// Vite's logger: an error logged by a build that does not fail is a report +// of that build, an error, not a warning. +test('vite: an error logged by a build that succeeds is reported as an error', async () => { + const app = await bundleApp({ + bundler: 'vite', + files: { 'entry.ts': `export const value = 1\n` }, + plugins: { + vite: () => ({ + name: 'logs-an-error', + configResolved(config: { logger: { error: (text: string) => void } }) { + config.logger.error('MARK_LOGGED_ERROR') + }, + }), + }, + }) + expect( + findDiagnostics(app.warnings, { severity: 'error' }).map( + ({ text }) => text, + ), + ).toEqual([expect.stringContaining('MARK_LOGGED_ERROR')]) +}) + +// Like `vite build`, which minifies client builds but not SSR builds. +test('a Vite production build minifies the client, not SSR', async () => { + const files = { + 'entry.ts': `export function read() { + const keepThisLocalName = { value: 'MARK_LOCAL' } + keepThisLocalName.value += '!' + return keepThisLocalName.value +} +`, + } + const ssr = await bundleApp({ bundler: 'vite', env: 'ssr', files }) + const client = await bundleApp({ bundler: 'vite', env: 'client', files }) + expect([ + ssr.where('keepThisLocalName'), + client.where('keepThisLocalName'), + ]).toEqual(['eager', 'nowhere']) + expect((await ssr.run('return entry.read()')).result).toBe('MARK_LOCAL!') +}) + +test('NODE_ENV is the mode during a build, or unset with nodeEnv: null', async () => { + const seen: Record = {} + for (const nodeEnv of [undefined, null] as const) { + await bundleAppIn({ + dir: testsDir, + registerCleanup: onTestFinished, + bundler: 'vite', + files: { 'entry.ts': `export const value = 1\n` }, + nodeEnv, + plugins: { + vite: () => { + seen[String(nodeEnv)] = process.env.NODE_ENV + return { name: 'record-node-env' } + }, + }, + }) + } + expect(seen).toEqual({ undefined: 'production', null: undefined }) +}) + +test.each(['webpack', 'rspack'] as const)( + '%s: rebuildAfter describes the output of the rebuild after the edit', + async (bundler) => { + const app = await bundleApp({ + bundler, + files: { 'entry.ts': `export const value = 'v1'\n` }, + rebuildAfter: { 'entry.ts': `export const value = 'v2'\n` }, + }) + expect((await app.run('return entry.value')).result).toBe('v2') + }, + timeout, +) + +describe('side-effect hints', () => { + /** `./effects` is imported for an export the entry never uses. */ + const unusedModuleApp = { + 'entry.ts': `import { used } from './lib' +export const value = used() +`, + 'lib.ts': `export { used } from './used' +export { unused } from './effects' +`, + 'used.ts': `export function used() { + return 'used' +} +`, + 'effects.ts': `;(globalThis as any).effects = ['MARK_EFFECT'] +export function unused() { + return 'unused' +} +`, + } + + test.each(bundlers)( + '"sideEffects": false in package.json drops a module whose exports are unused (%s)', + async (bundler) => { + const placements: Record = {} + for (const sideEffects of [undefined, false]) { + const app = await bundleApp({ + bundler, + files: unusedModuleApp, + sideEffects, + }) + placements[String(sideEffects)] = app.where('MARK_EFFECT') + } + expect(placements).toEqual({ undefined: 'eager', false: 'nowhere' }) + }, + timeout, + ) + + /** + * Unused bindings initialised by calls to a side-effectful function, with + * and without purity annotations. + */ + const annotatedCallsApp = { + 'entry.ts': `import { used } from './lib' +export const value = used() +`, + 'lib.ts': `function record(label: string) { + ;(globalThis as any).recorded = [...((globalThis as any).recorded ?? []), label] + return label +} +/* #__NO_SIDE_EFFECTS__ */ +function recordAnnotated(label: string) { + ;(globalThis as any).recorded = [...((globalThis as any).recorded ?? []), label] + return label +} +export function used() { + return 'used' +} +export const plain = record('MARK_PLAIN') +export const pure = /* @__PURE__ */ record('MARK_PURE') +export const noSideEffects = recordAnnotated('MARK_NO_SIDE_EFFECTS') +`, + } + + // What each bundler drops in a production build. webpack and Rspack drop + // unused code inside a kept module only when minifying. + test.each(bundlers)( + '/* @__PURE__ */ and #__NO_SIDE_EFFECTS__ let an unused call be dropped (%s)', + async (bundler) => { + const app = await bundleApp({ bundler, files: annotatedCallsApp }) + expect({ + plain: app.where('MARK_PLAIN'), + pure: app.where('MARK_PURE'), + noSideEffects: app.where('MARK_NO_SIDE_EFFECTS'), + }).toEqual({ plain: 'eager', pure: 'nowhere', noSideEffects: 'nowhere' }) + }, + timeout, + ) +}) + +describe('client runs in the browser', () => { + /** Describes classic script chunks written to an app's `dist`. */ + async function classicBuild(files: Record) { + const app = await createApp({ + dir: testsDir, + registerCleanup: onTestFinished, + files: Object.fromEntries( + Object.entries(files).map(([file, code]) => [`dist/${file}`, code]), + ), + }) + return describeBuild({ + bundler: 'rspack', + env: 'client', + mode: 'development', + esModules: false, + root: app.root, + outDir: path.join(app.root, 'dist'), + chunks: [ + { + fileName: 'static/index.js', + isEntry: true, + imports: ['static/vendor.js'], + dynamicImports: [], + }, + { + fileName: 'static/vendor.js', + isEntry: false, + imports: ['static/index.js'], + dynamicImports: [], + }, + ], + warnings: [], + consoleMessages: [], + duration: 0, + dispose: app.dispose, + entryGlobal: '__entry', + }) + } + + test('a classic script entry loads with the chunks of its group, and the page is /', async () => { + const build = await classicBuild({ + 'static/vendor.js': `var vendorValue = 'MARK_VENDOR'\n`, + 'static/index.js': `globalThis.__entry = { read: () => [vendorValue, this === window, location.pathname] }\n`, + }) + expect((await build.run('return entry.read()')).result).toEqual([ + 'MARK_VENDOR', + true, + '/', + ]) + }) + + test('an error the page does not catch fails the run', async () => { + const build = await classicBuild({ + 'static/vendor.js': '', + 'static/index.js': `globalThis.__entry = {} +setTimeout(() => { throw new Error('MARK_UNCAUGHT') }) +`, + }) + await expect( + build.run('await new Promise((resolve) => setTimeout(resolve, 50))'), + ).rejects.toThrow(/MARK_UNCAUGHT/) + }) +}) + +describe('registerCleanup', () => { + test('receives the dispose() that removes the app directory', async () => { + const cleanups: Array<() => Promise> = [] + const app = await createApp({ + dir: testsDir, + files: { 'entry.ts': `export const value = 1\n` }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + expect(cleanups).toEqual([app.dispose]) + expect(existsSync(app.root)).toBe(true) + await cleanups[0]!() + expect(existsSync(app.root)).toBe(false) + }) + + test('without it, the app stays until dispose()', async () => { + const app = await createApp({ + dir: testsDir, + files: { 'entry.ts': `export const value = 1\n` }, + }) + try { + expect(existsSync(app.root)).toBe(true) + } finally { + await app.dispose() + } + expect(existsSync(app.root)).toBe(false) + }) +}) + +test.each(['webpack', 'rspack'] as const)( + '%s: concurrent native loaders keep console messages in their own builds', + async (bundler) => { + const build = () => + bundleApp({ + files: { + 'entry.js': 'export const value = 1', + 'warning-loader.cjs': `module.exports = function(code) { console.warn(this.resourcePath + ' MARK_LOADER_WARNING'); return code }`, + }, + bundler, + env: 'ssr', + entry: 'entry.js', + configure(options) { + const rules = (options.module as { rules: Array }).rules + rules.push({ + test: /\.js$/, + loader: path.join(String(options.context), 'warning-loader.cjs'), + }) + }, + }) + const [first, second] = await Promise.all([build(), build()]) + for (const [app, other] of [ + [first, second], + [second, first], + ] as const) { + expect( + app.consoleMessages.some( + ({ text }) => + text.includes(app.root) && text.includes('MARK_LOADER_WARNING'), + ), + ).toBe(true) + expect( + app.consoleMessages.some(({ text }) => text.includes(other.root)), + ).toBe(false) + } + }, + timeout, +) diff --git a/packages/compiler-test-utils/tests/integration/global-trap.test.ts b/packages/compiler-test-utils/tests/integration/global-trap.test.ts new file mode 100644 index 0000000000..096aae17a5 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/global-trap.test.ts @@ -0,0 +1,97 @@ +/** + * Control tests of the global trap (global-trap.ts) in a real Chromium page: + * every way page code touches a trapped global is recorded. The former + * traps (accessors alone) did not record own-property probes + * (`hasOwnProperty`, `Object.hasOwn`, ...); an `in` probe cannot be + * recorded in a browser, so the code it guards is (it runs, as the + * accessor makes the probe true). + */ +import { expect, onTestFinished, test } from 'vitest' +import { openPage } from '../../src/browser' +import { globalTrapSource } from '../../src/global-trap' + +const timeout = 30_000 + +/** A page whose init script traps `$Trapped$` (`window.touches()`). */ +async function trappedPage() { + return openPage('http://trap.invalid/', { + registerCleanup: onTestFinished, + html: '
', + initScript: `Object.defineProperty(window, 'touches', { + value: ${globalTrapSource({ names: '["$Trapped$"]' })}, +})`, + }) +} + +test.each([ + ['a read', `window.$Trapped$`, ['read $Trapped$']], + ['a write', `window.$Trapped$ = 1`, ['write $Trapped$']], + [ + 'code an `in` probe guards', + `if ('$Trapped$' in window) { window.$Trapped$?.() }`, + ['read $Trapped$'], + ], + ['`typeof` of the bare name', `typeof $Trapped$`, ['read $Trapped$']], + ['a call of the bare name', `$Trapped$()`, ['read $Trapped$']], + ['hasOwnProperty', `window.hasOwnProperty('$Trapped$')`, ['probe $Trapped$']], + [ + 'Object.prototype.hasOwnProperty.call', + `Object.prototype.hasOwnProperty.call(globalThis, '$Trapped$')`, + ['probe $Trapped$'], + ], + ['Object.hasOwn', `Object.hasOwn(window, '$Trapped$')`, ['probe $Trapped$']], + [ + 'propertyIsEnumerable', + `window.propertyIsEnumerable('$Trapped$')`, + ['probe $Trapped$'], + ], + [ + 'getOwnPropertyDescriptor', + `Object.getOwnPropertyDescriptor(window, '$Trapped$')`, + ['probe $Trapped$'], + ], + ['Reflect.has', `Reflect.has(window, '$Trapped$')`, ['probe $Trapped$']], + [ + 'a definition', + `Object.defineProperty(window, '$Trapped$', { value: 1, configurable: true })`, + ['define $Trapped$', 'redefined $Trapped$'], + ], + ['a deletion', `delete window.$Trapped$`, ['redefined $Trapped$']], +])( + '%s is recorded', + async (_, code, expected) => { + const page = await trappedPage() + const touched = await page.page.evaluate(`(() => { + try { ${code} } catch {} + return window.touches() +})()`) + expect(touched).toEqual(expected) + }, + timeout, +) + +test( + 'other names, other objects and the probes of other names record nothing', + async () => { + const page = await trappedPage() + const seen = await page.page.evaluate(`(() => { + window.other = 1 + const element = document.getElementById('app') + element.expando = 2 + const plain = { $Trapped$: 3 } + return { + values: [ + window.other, + element.expando, + Object.hasOwn(window, 'other'), + window.hasOwnProperty('other'), + Object.hasOwn(plain, '$Trapped$'), + Object.getOwnPropertyDescriptor(plain, '$Trapped$').value, + ], + touched: window.touches(), + } +})()`) + expect(seen).toEqual({ values: [1, 2, true, true, true, 3], touched: [] }) + }, + timeout, +) diff --git a/packages/compiler-test-utils/tests/integration/hmr-sync.test.ts b/packages/compiler-test-utils/tests/integration/hmr-sync.test.ts new file mode 100644 index 0000000000..b8a4687a78 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/hmr-sync.test.ts @@ -0,0 +1,153 @@ +/** + * Control tests of `settlePage` (hmr-sync.ts) on the Vite dev-server harness + * in `browser` mode: once it resolves, the page has handled every message + * the server sent before it. An update a module accepts has been applied + * (the page shows it at once, without waiting), and an update nothing + * accepts has reloaded the page (its load count tells), whether the page's + * code imports the sync module or the page imports it on every load + * (`hmrSyncInitScript`); and an update whose accept callback invalidates it + * (as a refresh runtime does when it cannot apply one) has had the reload + * that the page's `invalidate()` asked the server for, also when what the + * page sends reaches the server late. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { openPage } from '../../src/browser' +import { createDevServer } from '../../src/dev-server' +import { + hmrSyncInitScript, + hmrSyncModule, + settlePage, + trackRequests, +} from '../../src/hmr-sync' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +/** + * An entry that shows the texts of `text.js` and `other.js` and applies + * updates of `text.js` itself; nothing accepts the updates of `other.js`. + * With `sync`, it imports the sync module itself. + */ +const app = (sync: boolean) => ({ + 'index.html': `
`, + 'hmr-sync.ts': hmrSyncModule, + 'main.js': `${sync ? `import './hmr-sync.ts'\n` : ''}import { text } from './text.js' +import { other } from './other.js' +const show = (value) => { + document.getElementById('app').textContent = value + ' ' + other +} +show(text) +import.meta.hot.accept('./text.js', (updated) => show(updated.text)) +`, + 'text.js': `export const text = 'text v1'\n`, + 'other.js': `export const other = 'other v1'\n`, +}) + +test.for([ + { name: 'the app imports the sync module', sync: true }, + { name: 'the page imports it on every load', sync: false }, +])( + 'once settled, an accepted update shows in place and one nothing accepts has reloaded the page ($name)', + { timeout }, + async ({ sync }) => { + const server = await createDevServer({ + dir: testsDir, + prefix: '.hmr-sync-', + registerCleanup: onTestFinished, + browser: true, + files: app(sync), + // The edited modules come late (a slow transform): the page handles + // the update, or loads again, a while after the server sent it + plugins: [ + { + name: 'slow-edited-modules', + async transform(code, id) { + if (/(text|other)\.js$/.test(id) && code.includes('v2')) { + await new Promise((resolve) => setTimeout(resolve, 500)) + } + return null + }, + }, + ], + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + ...(sync ? {} : { initScript: hmrSyncInitScript('/hmr-sync.ts') }), + }) + const inFlight = trackRequests(page) + await page.waitForText('text v1 other v1') + await settlePage(server, page, inFlight) + + await server.edit({ 'text.js': `export const text = 'text v2'\n` }) + await settlePage(server, page, inFlight) + expect({ text: await page.text('#app'), loads: page.loads() }).toEqual({ + text: 'text v2 other v1', + loads: 1, + }) + + await server.edit({ 'other.js': `export const other = 'other v2'\n` }) + await settlePage(server, page, inFlight) + expect({ text: await page.text('#app'), loads: page.loads() }).toEqual({ + text: 'text v2 other v2', + loads: 2, + }) + }, +) + +test( + 'once settled, an update whose accept callback invalidates it has reloaded the page, also when the page reaches the server late', + { timeout }, + async () => { + const server = await createDevServer({ + dir: testsDir, + prefix: '.hmr-sync-', + registerCleanup: onTestFinished, + browser: true, + files: { + 'index.html': `
`, + 'hmr-sync.ts': hmrSyncModule, + // A module that accepts its own update, then gives up on it (Vite + // propagates the update to its importer, which accepts nothing: a + // full reload) + 'main.js': `import './hmr-sync.ts' +import { text } from './text.js' +document.getElementById('app').textContent = text +`, + 'text.js': `export const text = 'text v1' +import.meta.hot.accept(() => import.meta.hot.invalidate('cannot apply')) +`, + }, + }) + const page = await openPage('about:blank', { + registerCleanup: onTestFinished, + }) + // What the page sends over its HMR WebSocket reaches the server 400 ms + // late (a busy server or a slow link); what the server sends is not held + await page.page.context().routeWebSocket(/./, (ws) => { + const upstream = ws.connectToServer() + ws.onMessage((message) => { + setTimeout(() => upstream.send(message), 400) + }) + upstream.onMessage((message) => ws.send(message)) + }) + await page.page.goto(server.url!) + const inFlight = trackRequests(page) + await page.waitForText('text v1') + await settlePage(server, page, inFlight) + const loads = page.loads() + + await server.edit({ + 'text.js': `export const text = 'text v2' +import.meta.hot.accept(() => import.meta.hot.invalidate('cannot apply')) +`, + }) + await settlePage(server, page, inFlight) + expect({ + text: await page.text('#app'), + reloads: page.loads() - loads, + }).toEqual({ text: 'text v2', reloads: 1 }) + }, +) diff --git a/packages/compiler-test-utils/tests/integration/native-hook-capture.test.ts b/packages/compiler-test-utils/tests/integration/native-hook-capture.test.ts new file mode 100644 index 0000000000..8771dfab90 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/native-hook-capture.test.ts @@ -0,0 +1,299 @@ +/** + * Controls of the console capture (`console-hook.ts`) for output printed + * from native bundler callbacks: Rolldown calls a Vite build's plugin hooks, + * and Rspack its compiler and compilation hooks, from native code, where + * Node's async context is not propagated. What a compiler prints there is + * a diagnostic like any other (SPEC §5.7: the channel is free), so: + * - the hosts' and the build environment's merged channels receive it, and + * a "nothing reported" check sees it; + * - with two apps at once, each channel receives what names its app, and + * output naming neither reaches both, marked `shared` (the owner is + * unknown), never silently. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { createBuilder } from 'vite' +import { expect, onTestFinished, test } from 'vitest' +import { createApp, withBuildEnvironment } from '../../src/build-harness' +import { expectNoProblems } from '../../src/diagnostic-channel' +import { createPluginHost } from '../../src/plugin-host' +import { createRsbuildPluginHost } from '../../src/rsbuild-plugin-host' +import type { ChannelDiagnostic } from '../../src/diagnostic-channel' +import type { RsbuildPlugin, Rspack } from '@rsbuild/core' +import type { Plugin } from 'vite' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +const marked = (texts: Array) => + texts.filter((text) => text.includes('MARK_NATIVE')) + +/** Warns through the console from a module hook and a bundle hook. */ +function consoleWarner(): Plugin { + return { + name: 'console-warner', + transform(_code, id) { + if (id.includes('/src/')) { + console.warn(`MARK_NATIVE transform ${path.basename(id)}`) + } + return null + }, + generateBundle() { + console.warn('MARK_NATIVE generateBundle') + }, + } +} + +const viteFiles = { + 'index.html': `
`, + 'src/main.ts': `export const value = 1\n`, +} + +test( + 'vite build: console output of Rolldown-called hooks is in the build diagnostics', + async () => { + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: viteFiles, + plugins: [consoleWarner()], + serve: false, + }) + const build = await app.build() + // "Nothing reported" sees build-time output + expect(() => expectNoProblems(build.diagnostics)).toThrow(/MARK_NATIVE/) + expect(marked(build.diagnostics.map(({ text }) => text))).toEqual( + expect.arrayContaining([ + 'MARK_NATIVE transform main.ts', + 'MARK_NATIVE generateBundle', + ]), + ) + // One build at a time: its owner is known + expect(build.diagnostics.filter(({ shared }) => shared)).toEqual([]) + }, + timeout, +) + +test( + 'withBuildEnvironment: a Vite build’s console output and default-logger warnings are in its messages', + async () => { + const app = await createApp({ + dir: testsDir, + registerCleanup: onTestFinished, + files: viteFiles, + }) + const messages: Array = [] + await withBuildEnvironment('production', messages, async () => { + const builder = await createBuilder({ + root: app.root, + configFile: false, + logLevel: 'warn', + plugins: [ + consoleWarner(), + { + name: 'context-warner', + transform(_code, id) { + if (id.includes('/src/')) { + this.warn(`MARK_NATIVE this.warn ${path.basename(id)}`) + } + return null + }, + } satisfies Plugin, + ], + }) + await builder.buildApp() + }) + const reported = marked(messages.map(({ text }) => text)) + expect(reported).toEqual( + expect.arrayContaining([ + 'MARK_NATIVE transform main.ts', + 'MARK_NATIVE generateBundle', + ]), + ) + expect( + reported.some((text) => text.includes('MARK_NATIVE this.warn main.ts')), + ).toBe(true) + }, + timeout, +) + +/** Warns through the console from Rspack compilation and compiler hooks. */ +function rspackWarner(): RsbuildPlugin { + return { + name: 'rspack-warner', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.thisCompilation.tap( + 'rspack-warner', + (compilation) => { + compilation.hooks.processAssets.tap( + { name: 'rspack-warner', stage: 0 }, + () => { + console.warn('MARK_NATIVE processAssets') + }, + ) + }, + ) + compiler.hooks.done.tap('rspack-warner', () => { + console.warn('MARK_NATIVE done') + }) + }, + }) + }) + }, + } +} + +test.each(['dev', 'build'] as const)( + 'rsbuild %s: console output of Rspack compiler and compilation hooks is in the diagnostics', + async (mode) => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': 'export const value = 1\n' }, + serve: mode === 'dev', + plugins: [rspackWarner()], + }) + const diagnostics = + mode === 'dev' ? host.diagnostics : (await host.build()).diagnostics + // "Nothing reported" sees build-time output + expect(() => expectNoProblems(diagnostics)).toThrow(/MARK_NATIVE/) + expect(marked(diagnostics.map(({ text }) => text))).toEqual( + expect.arrayContaining(['MARK_NATIVE processAssets', 'MARK_NATIVE done']), + ) + expect(diagnostics.filter(({ shared }) => shared)).toEqual([]) + }, + timeout, +) + +/** Resolves once `count` callers wait on it: work that overlaps for sure. */ +function barrier(count: number) { + let arrived = 0 + let release!: () => void + const all = new Promise((resolve) => { + release = resolve + }) + return () => { + arrived++ + if (arrived === count) { + release() + } + return all + } +} + +/** + * Two apps at once (`start` builds or serves one and returns its root and + * diagnostics): each channel has the native-callback output naming its own + * app and none naming the other's; output naming neither reaches both, + * marked `shared`. + */ +async function expectSeparated( + start: ( + meet: () => Promise, + ) => Promise<{ root: string; diagnostics: Array }>, +) { + const meet = barrier(2) + const apps = await Promise.all([start(meet), start(meet)]) + for (const [app, other] of [ + [apps[0], apps[1]], + [apps[1], apps[0]], + ] as const) { + const texts = app.diagnostics.map(({ text }) => text) + expect(texts.some((text) => text.includes(`MARK_OWNED ${app.root}`))).toBe( + true, + ) + expect(texts.some((text) => text.includes(other.root))).toBe(false) + const unowned = app.diagnostics.filter(({ text }) => + text.includes('MARK_UNOWNED'), + ) + expect(unowned.length).toBeGreaterThan(0) + expect(unowned.every(({ shared }) => shared)).toBe(true) + expect( + app.diagnostics.filter( + ({ text, shared }) => shared && !text.includes('MARK_UNOWNED'), + ), + ).toEqual([]) + } +} + +test( + 'vite build: concurrent builds keep native-hook output naming their app, and share output naming neither', + async () => { + await expectSeparated(async (meet) => { + let root = '' + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: viteFiles, + serve: false, + plugins: [ + { + name: 'owned-warner', + configResolved(config) { + root = config.root + }, + async generateBundle() { + await meet() + console.warn(`MARK_OWNED ${root}/src/main.ts`) + console.warn('MARK_UNOWNED generateBundle') + }, + } satisfies Plugin, + ], + }) + return { root: app.root, diagnostics: (await app.build()).diagnostics } + }) + }, + timeout, +) + +test.each(['dev', 'build'] as const)( + 'rsbuild %s: concurrent apps keep native-hook output naming their app, and share output naming neither', + async (mode) => { + await expectSeparated(async (meet) => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': 'export const value = 1\n' }, + serve: mode === 'dev', + plugins: [ + { + name: 'owned-warner', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.thisCompilation.tap( + 'owned-warner', + (compilation) => { + compilation.hooks.processAssets.tapPromise( + { name: 'owned-warner', stage: 0 }, + async () => { + await meet() + console.warn( + `MARK_OWNED ${compiler.context}/src/entry.ts`, + ) + console.warn('MARK_UNOWNED processAssets') + }, + ) + }, + ) + }, + }) + }) + }, + }, + ], + }) + return { + root: host.root, + diagnostics: + mode === 'dev' ? host.diagnostics : (await host.build()).diagnostics, + } + }) + }, + timeout, +) diff --git a/packages/compiler-test-utils/tests/integration/oracles.test.ts b/packages/compiler-test-utils/tests/integration/oracles.test.ts new file mode 100644 index 0000000000..3498d2d780 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/oracles.test.ts @@ -0,0 +1,104 @@ +/** + * The diagnostic and source-map oracles on real bundler output: every + * bundler's build error for a broken module names the file and its line + * (whatever the bundler's format), and a throw executed in a built, + * source-mapped chunk resolves through its stack to the line of the throw. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, onTestFinished, test } from 'vitest' +import { bundleApp as bundleAppIn, bundlers } from '../../src/build-harness' +import { + captureThrow, + expectDiagnostic, + mentionsFile, +} from '../../src/diagnostics' +import { traceStack } from '../../src/source-maps' +import type { BundleOptions } from '../../src/build-harness' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +function bundleApp(options: Omit) { + return bundleAppIn({ + dir: testsDir, + registerCleanup: onTestFinished, + ...options, + }) +} + +// One unexpected token, so every parser reports the same position: line 2, +// column 26 (1-based), the `*`. +const broken = `export const ok = 1 +export const value = 1 + * 2 +export const after = 3 +` + +const failing = `interface Failure { + message: string +} +type Reason = Failure['message'] +export function fail(reason: Reason = 'MARK_FAIL'): string { + throw new Error(reason) +} +` + +describe.each(bundlers)('%s', (bundler) => { + test( + 'a build error names the broken file and its line', + async () => { + const diagnostics = await captureThrow(() => + bundleApp({ + bundler, + files: { + 'entry.ts': `export { value } from './src/broken'\n`, + 'src/broken.ts': broken, + }, + }), + ) + expectDiagnostic(diagnostics, { + severity: 'error', + file: 'src/broken.ts', + position: { line: 2, column: 26 }, + }) + }, + timeout, + ) + + test( + 'a throw in a built chunk resolves through its stack to the line of the throw', + async () => { + const app = await bundleApp({ + bundler, + files: { + 'entry.ts': `export async function load() { + const { fail } = await import('./src/failing') + return fail() +} +`, + 'src/failing.ts': failing, + }, + sourcemap: true, + }) + const { result: stack } = await app.run( + `try { await entry.load() } catch (error) { return error.stack }`, + ) + expect(stack).toContain('MARK_FAIL') + const frames = traceStack(stack as string, (location) => { + const file = location.startsWith('file:') + ? fileURLToPath(location) + : location + return app.chunks.find( + (chunk) => path.join(app.outDir, chunk.fileName) === file, + )?.map as never + }) + const resolved = frames.find((frame) => frame.original) + expect(resolved?.original?.line).toBe(6) + expect(mentionsFile(resolved!.original!.source, 'src/failing.ts')).toBe( + true, + ) + }, + timeout, + ) +}) diff --git a/packages/compiler-test-utils/tests/integration/plugin-host.test.ts b/packages/compiler-test-utils/tests/integration/plugin-host.test.ts new file mode 100644 index 0000000000..e6a60f26aa --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/plugin-host.test.ts @@ -0,0 +1,232 @@ +/** + * Controls of the public in-process plugin host (plugin-host.ts), slow + * tier: client code runs in the shared Chromium page with the real Vite + * client (a real hot context, real ES module linking), and `vite build` + * runs the same public plugins, with each environment's chunks and the + * build's merged diagnostics. + */ +import diagnosticsChannel from 'node:diagnostics_channel' +import { appendFile } from 'node:fs/promises' +import net from 'node:net' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { expectDiagnostic } from '../../src/diagnostics' +import { HostBuildError, createPluginHost } from '../../src/plugin-host' +import type { Plugin } from 'vite' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +/** Rewrites `__MARK__` in the app's modules; warns through `this.warn`. */ +const userPlugin: Plugin = { + name: 'user-plugin', + transform(code, id) { + if (!id.includes('/src/') || !code.includes('__MARK__')) { + return null + } + this.warn(`rewrote a marker in ${id}`) + return code.replaceAll('__MARK__', 'MARKED') + }, +} + +const files = { + 'index.html': `
`, + 'src/main.ts': `import { label } from './label' +export const render = () => { + document.getElementById('root')!.textContent = label + return document.body.innerHTML +} +render() +export const hot = () => ({ + hot: typeof import.meta.hot, + data: typeof import.meta.hot?.data, +}) +`, + 'src/label.ts': `export const label = '__MARK__ label'\n`, + 'src/missing.ts': `import { absent } from './label' +export const read = () => absent +`, +} + +test( + 'client code runs in the shared page: rendered by the module, with the real hot context, and a missing import throws', + async () => { + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [userPlugin], + client: true, + }) + const started = performance.now() + const rendered = await app.runClient( + '/src/main.ts', + 'return module.render().trim()', + ) + const first = performance.now() - started + expect(rendered.result).toBe('
MARKED label
') + expect(rendered.errors).toEqual([]) + + // The real Vite client: `import.meta.hot` with its `data` + const again = performance.now() + expect( + (await app.runClient('/src/main.ts', 'return module.hot()')).result, + ).toEqual({ hot: 'object', data: 'object' }) + const second = performance.now() - again + + await expect(app.runClient('/src/missing.ts')).rejects.toThrow( + /does not provide an export named 'absent'/, + ) + // The page is reused: a later run costs a page load, not a browser + // (the dev server's channel records the test's console too) + if (process.env.PLUGIN_HOST_TIMINGS) { + await appendFile( + process.env.PLUGIN_HOST_TIMINGS, + `page runs: first ${first.toFixed(0)} ms, next ${second.toFixed(0)} ms\n`, + ) + } + }, + timeout, +) + +// Vite keeps a full reload sent while no client is +// connected and hands it to the next client that connects. Between two +// `runClient` runs no page is connected, so the next run's page would +// reload under its run; a client host keeps an idle HMR client connected +// instead. The probe connects as the next page's Vite client would, and +// reads everything the server sends it up to a marker sent after it +// connected (a held message is sent right after `connected`, before it). +test( + 'a full reload sent while no page runs is not handed to the next page that connects', + async () => { + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [], + client: true, + }) + // No page of this host is open (as between two runs once the shared page + // moved on to another host or app): an edit's full reload now + app.dev.vite.ws.send({ type: 'full-reload', path: '*' }) + + const url = new URL(app.dev.url!) + url.protocol = 'ws:' + url.searchParams.set('token', app.dev.vite.config.webSocketToken) + const probe = new WebSocket(url, 'vite-hmr') + onTestFinished(() => probe.close()) + const received: Array<{ type: string; event?: string }> = [] + await new Promise((resolve, reject) => { + probe.addEventListener('error', () => reject(new Error('no connection'))) + probe.addEventListener('message', (event) => { + const message = JSON.parse(String(event.data)) + received.push(message) + if (message.type === 'connected') { + app.dev.vite.ws.send({ type: 'custom', event: 'probe:end' }) + } + if (message.event === 'probe:end') { + resolve() + } + }) + }) + expect(received.map(({ type }) => type)).toEqual(['connected', 'custom']) + }, + timeout, +) + +// Under heavy load, a test worker's event loop can stay +// blocked (other tests' synchronous work) right when the idle HMR client +// connects at host start. A client of this process must still reach the +// server: Node's address-family selection gives a connection attempt +// `getDefaultAutoSelectFamilyAttemptTimeout()` on the event loop's clock, +// so a client of a name with two addresses, of which the server listens on +// one, abandoned the connection the kernel had made and was refused at the +// other ("no HMR connection"). The block runs once each attempt's timer is +// set, as a busy worker's would. +test( + 'a client host starts while the event loop is blocked past the attempt timeout of address-family selection', + async () => { + const blockFor = net.getDefaultAutoSelectFamilyAttemptTimeout() + 300 + const attempts: Array = [] + const onSocket = (message: unknown) => { + const { socket } = message as { socket: net.Socket } + socket.once('connectionAttempt', (address: string, port: number) => { + attempts.push(`${address}:${port}`) + queueMicrotask(() => { + const end = performance.now() + blockFor + while (performance.now() < end) { + // a worker busy with synchronous work + } + }) + }) + } + diagnosticsChannel.subscribe('net.client.socket', onSocket) + let app + try { + app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [], + client: true, + }) + } finally { + diagnosticsChannel.unsubscribe('net.client.socket', onSocket) + } + // The idle client went through the blocked attempt, to the server + const port = new URL(app.dev.url!).port + expect(attempts.some((attempt) => attempt.endsWith(`:${port}`))).toBe(true) + }, + timeout, +) + +test( + 'vite build runs the same public plugins; chunks, describe() and diagnostics', + async () => { + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [userPlugin], + serve: false, + }) + const build = await app.build() + const client = build.environments.client! + expect(client.chunks.some((chunk) => chunk.code.includes('MARKED'))).toBe( + true, + ) + // The plugin's warning, through Vite's logger, in the merged channel + expectDiagnostic(build.diagnostics, { + severity: 'warning', + file: 'src/label.ts', + root: app.root, + }) + const described = await build.describe('client') + expect(described.where('MARKED')).toBe('eager') + }, + timeout, +) + +test( + 'a failed build rejects with its error and what it reported', + async () => { + const app = await createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { ...files, 'src/label.ts': `export const label = (` }, + plugins: [userPlugin], + serve: false, + }) + const error = await app.build().catch((thrown: unknown) => thrown) + expect(error).toBeInstanceOf(HostBuildError) + expectDiagnostic(error, { + severity: 'error', + file: 'src/label.ts', + root: app.root, + position: { line: 1 }, + }) + }, + timeout, +) diff --git a/packages/compiler-test-utils/tests/integration/rsbuild-dev-server.test.ts b/packages/compiler-test-utils/tests/integration/rsbuild-dev-server.test.ts new file mode 100644 index 0000000000..0c8d519794 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/rsbuild-dev-server.test.ts @@ -0,0 +1,588 @@ +/** + * Control tests of the Rsbuild dev-server harness (rsbuild-dev-server.ts): + * `edit()` waits for the rebuild of the edited modules, `settle()` for the + * compiles of every write (plugins' included), and `outputs()` returns what + * the environment emits afterwards. + */ +import { watch } from 'node:fs' +import { readFile, stat, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { createRsbuildDevServer } from '../../src/rsbuild-dev-server' +import type { RsbuildPlugin, Rspack } from '@rsbuild/core' +import type { FSWatcher } from 'node:fs' + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +test('rebuilds the edited module and emits the edit', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + }) + const joined = async () => Object.values(await server.outputs()).join('\n') + expect(await joined()).toContain('MARK_V1') + + await server.edit({ 'src/leaf.ts': `export const leaf = 'MARK_V2'\n` }) + + expect(server.rebuilt).toContain('src/leaf.ts') + expect(await joined()).toContain('MARK_V2') + expect(await joined()).not.toContain('MARK_V1') +}, 30_000) + +// The watcher may start the compile of an edit before its writes finish +// (on a loaded machine, before the harness even sees the write done): the +// wait must still end with that compile, which started after the module's +// write. Here a large file nothing imports, which the test accepts no +// compile for, keeps the writes going after the module's. +test('a compile that starts before the writes of the edit finish ends the wait', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + }) + + await server.edit( + { + 'src/leaf.ts': `export const leaf = 'MARK_V2'\n`, + 'notes/large.txt': 'x'.repeat(64 * 1024 * 1024), + }, + { accept: (relative) => relative === 'notes/large.txt' }, + ) + + expect(server.rebuilt).toContain('src/leaf.ts') + expect(Object.values(await server.outputs()).join('\n')).toContain('MARK_V2') +}, 30_000) + +// `stop()` ends the server and its watcher but keeps the app, so a test can +// edit it afterwards; `close()` removes it. +test('stop() stops the server and keeps the app until close()', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + }) + await server.stop() + const leaf = path.join(server.root, 'src/leaf.ts') + await writeFile(leaf, `export const leaf = 'MARK_V2'\n`) + expect(await readFile(leaf, 'utf8')).toContain('MARK_V2') + await server.close() + await expect(readFile(leaf, 'utf8')).rejects.toThrow() +}, 30_000) + +// Rsbuild's default: each compile after an edit emits hot-update chunks with +// the edited modules, which a connected browser applies. +test.each([true, false])( + 'hmr: %s, an edit emits hot-update chunks with the edit only with hmr, and outputs() leaves them out', + async (hmr) => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + hmr, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + }) + + await server.edit({ 'src/leaf.ts': `export const leaf = 'MARK_V2'\n` }) + + const updates = Object.values(await server.hotUpdates()).join('\n') + expect(updates.includes('MARK_V2')).toBe(hmr) + const outputs = await server.outputs() + expect( + Object.keys(outputs).filter((file) => file.includes('hot-update')), + ).toEqual([]) + expect(Object.values(outputs).join('\n')).toContain('MARK_V2') + }, + 30_000, +) + +test('a compile a plugin makes fail rejects the wait with its error, without waiting for the timeout', async () => { + let compile = 0 + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + compileTimeout: 20_000, + files: { 'src/entry.ts': `console.log('MARK_V1')\n` }, + plugins: [ + { + name: 'fails-the-second-compile', + setup(api) { + api.processAssets({ stage: 'summarize' }, () => { + compile++ + if (compile === 2) { + throw new Error('MARK_PLUGIN_FAILURE') + } + }) + }, + }, + ], + }) + const started = Date.now() + await expect( + server.edit({ 'src/entry.ts': `console.log('MARK_V2')\n` }), + ).rejects.toThrow(/Rsbuild failed to compile[\s\S]*MARK_PLUGIN_FAILURE/) + expect(Date.now() - started).toBeLessThan(10_000) +}, 30_000) + +/** + * A plugin like a route generator: at the start of each compile, it writes + * `src/generated.ts` from `src/source.ts` (`rewrite`: with new contents each + * time, a plugin that never settles). + */ +function generator(rewrite = false): RsbuildPlugin { + let count = 0 + return { + name: 'generator', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.watchRun.tapPromise('generator', async () => { + const root = compiler.context + const source = await readFile( + path.join(root, 'src/source.ts'), + 'utf8', + ) + const version = /'(V\d)'/.exec(source)![1] + const code = rewrite + ? `export const generated = ${++count}\n` + : `export const generated = 'MARK_GENERATED_${version}'\n` + const file = path.join(root, 'src/generated.ts') + if ((await readFile(file, 'utf8')) !== code) { + await writeFile(file, code) + } + }) + }, + }) + }) + }, + } +} + +const generatedApp = { + 'src/entry.ts': `import { generated } from './generated' +import { source } from './source' +console.log(generated, source) +`, + 'src/source.ts': `export const source = 'V1'\n`, + 'src/generated.ts': `export const generated = 'MARK_GENERATED_V1'\n`, +} + +test('settle() waits for the compiles of the files a plugin writes in a compile', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: generatedApp, + plugins: [generator()], + }) + await server.write({ 'src/source.ts': `export const source = 'V2'\n` }) + await server.settle() + + const outputs = Object.values(await server.outputs()).join('\n') + expect(outputs).toContain('MARK_GENERATED_V2') + expect(outputs).not.toContain('MARK_GENERATED_V1') +}, 30_000) + +test('settle() waits for a compile that started after each written file, unless accept() takes it', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': `console.log('MARK_V1')\n` }, + }) + await server.write({ 'notes.txt': 'unread' }) + await expect(server.settle({ timeout: 1_000 })).rejects.toThrow( + /no compile started after the write of notes\.txt/, + ) + await server.settle({ accept: (relative) => relative === 'notes.txt' }) + + await server.write({ 'src/lazy.ts': `export const lazy = 'MARK_LAZY'\n` }) + await server.write({ + 'src/entry.ts': `import('./lazy').then(console.log)\n`, + }) + await server.settle() + expect(Object.values(await server.outputs()).join('\n')).toContain( + 'MARK_LAZY', + ) +}, 30_000) + +test('settle() rejects at its bound while a plugin writes a file the compiles read on each compile', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: generatedApp, + plugins: [generator(true)], + }) + await server.write({ 'src/source.ts': `export const source = 'V2'\n` }) + await expect(server.settle({ timeout: 3_000 })).rejects.toThrow( + /did not settle within 3000 ms/, + ) +}, 30_000) + +// A plugin may watch an original source itself and hand +// Rspack a module built from it, so the source is in no compile's +// dependencies. The edit's outcome is still awaited: the plugin's own +// watcher invalidates the compiler, and the compile that follows the write +// ends the wait. (The old wait required every written file to be a +// dependency of the compile and timed out here.) +test('edit() and settle() wait for the compile a plugin-owned watcher starts', async () => { + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { text } from './virtual'\nconsole.log(text)\n`, + 'src/virtual.ts': `export const text = 'placeholder'\n`, + 'content/source.txt': 'MARK_SOURCE_V1', + // Reads the original source without registering it as a dependency + 'loader.cjs': `const { readFileSync } = require('node:fs') +const path = require('node:path') +module.exports = function () { + const source = readFileSync(path.join(this.rootContext, 'content/source.txt'), 'utf8') + return 'export const text = ' + JSON.stringify(source) + '\\n' +} +`, + }, + plugins: [ownWatcher()], + }) + const joined = async () => Object.values(await server.outputs()).join('\n') + expect(await joined()).toContain('MARK_SOURCE_V1') + + await server.edit({ 'content/source.txt': 'MARK_SOURCE_V2' }) + expect(await joined()).toContain('MARK_SOURCE_V2') + + await server.write({ 'content/source.txt': 'MARK_SOURCE_V3' }) + await server.settle() + expect(await joined()).toContain('MARK_SOURCE_V3') +}, 30_000) + +/** + * Builds `src/virtual.ts` from `content/source.txt` (`loader.cjs`) and + * watches that source with a watcher of its own: on each change of it, it + * invalidates the compiler with the module it builds from it. + */ +function ownWatcher(): RsbuildPlugin { + return { + name: 'own-watcher', + setup(api) { + api.modifyRspackConfig((config) => { + config.module.rules = [ + ...(config.module.rules ?? []), + { + test: /virtual\.ts$/, + use: [{ loader: path.join(api.context.rootPath, 'loader.cjs') }], + }, + ] + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + let watcher: FSWatcher | undefined + compiler.hooks.afterDone.tap('own-watcher', () => { + // The plugin tells Rspack which module of its own changed + watcher ??= watch(path.join(compiler.context, 'content'), () => + compiler.watching?.invalidateWithChangesAndRemovals( + new Set([path.join(compiler.context, 'src/virtual.ts')]), + ), + ) + }) + compiler.hooks.watchClose.tap('own-watcher', () => watcher?.close()) + }, + }) + }) + }, + } +} + +// A plugin that reports a problem once (Start's import protection with +// `log: 'once'`) reports it in the first compile that sees it; a dev server +// compiles again on its own, so the diagnostics of every compile are kept. +test('diagnostics keeps the reports of every compile; errors and warnings hold the last compile', async () => { + let compile = 0 + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': `console.log('MARK_V1')\n` }, + plugins: [ + { + name: 'reports-once', + setup(api) { + api.processAssets({ stage: 'report' }, ({ compilation }) => { + compile++ + if (compile === 1) { + compilation.warnings.push( + new Error('MARK_WARNING_FIRST') as never, + ) + compilation.errors.push(new Error('MARK_ERROR_FIRST') as never) + } + }) + }, + }, + ], + }) + const texts = (diagnostics: Array<{ severity: string; text: string }>) => + diagnostics.map(({ severity, text }) => `${severity}: ${text}`) + expect(texts(server.diagnostics)).toEqual([ + expect.stringMatching(/^error: [\s\S]*MARK_ERROR_FIRST/), + expect.stringMatching(/^warning: [\s\S]*MARK_WARNING_FIRST/), + ]) + + const since = server.diagnostics.length + await server.edit({ 'src/entry.ts': `console.log('MARK_V2')\n` }) + + expect(server.errors).toEqual([]) + expect(server.warnings).toEqual([]) + expect(texts(server.diagnostics).slice(0, 2)).toEqual([ + expect.stringMatching(/^error: [\s\S]*MARK_ERROR_FIRST/), + expect.stringMatching(/^warning: [\s\S]*MARK_WARNING_FIRST/), + ]) + expect(server.diagnostics.slice(since)).toEqual([]) +}, 30_000) + +/** An environment compiler, with the app files its last compile read. */ +interface Captured { + compiler: Rspack.Compiler + read: Array +} + +/** + * A plugin that gives the test the environment compilers and, from each + * compile's `done`, the app files (relative to `root`) it read. + */ +function captureCompilers(into: Array, root: string): RsbuildPlugin { + return { + name: 'capture-compilers', + setup(api) { + api.onAfterCreateCompiler(({ compiler }) => { + for (const environmentCompiler of 'compilers' in compiler + ? compiler.compilers + : [compiler]) { + const captured: Captured = { compiler: environmentCompiler, read: [] } + into.push(captured) + environmentCompiler.hooks.done.tap( + 'capture-compilers', + ({ compilation }) => { + captured.read = [...compilation.fileDependencies] + .filter((file) => file.startsWith(root + path.sep)) + .map((file) => path.relative(root, file)) + }, + ) + } + }) + }, + } +} + +/** + * What a captured compiler's watcher knows (watchpack's time entries, + * through Rspack's public `watching.watcher` and `watchFileSystem.watcher`). + */ +function watchedBy({ compiler, read }: Captured) { + const attached = !!(compiler as { watching?: { watcher?: unknown } }).watching + ?.watcher + const watcher = ( + compiler.watchFileSystem as + | { watcher?: { getTimeInfoEntries: () => Map } } + | undefined + )?.watcher + return { + name: compiler.name, + attached, + known: new Set(watcher ? watcher.getTimeInfoEntries().keys() : []), + read, + } +} + +// Rspack attaches its watcher on the tick after the first compile, and +// watchpack then scans the app's directories; a file deleted before that is +// never reported (oracle/KNOWN-BUGS.md, "Upstream issues"). The start +// resolves only once the watcher knows every app file the compile read. +test('the start resolves once the watcher knows every app file the compile read', async () => { + const compilers: Array = [] + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + plugins: ({ root }) => [captureCompilers(compilers, root)], + }) + const client = watchedBy(compilers[0]!) + expect(client.attached).toBe(true) + expect(client.read).toEqual( + expect.arrayContaining(['src/entry.ts', 'src/leaf.ts']), + ) + for (const file of client.read) { + expect(client.known.has(path.join(server.root, file))).toBe(true) + } +}, 30_000) + +// One compiler may watch for another: Rspack's RSC coordinator makes the +// server compiler watch the client compiler's files and ignores everything +// in the client's own watcher. The start must still resolve, with every +// file known to a watcher, when a compiler's watcher ignores everything. +test('the start resolves with a compiler whose watcher ignores every file, while another watches them', async () => { + const compilers: Array = [] + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + compileTimeout: 10_000, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + config: { + environments: { web: {}, node: { output: { target: 'node' } } }, + }, + plugins: ({ root }) => [ + captureCompilers(compilers, root), + { + name: 'ignore-all-in-node', + setup(api) { + api.modifyRspackConfig((config, { environment }) => { + if (environment.name === 'node') { + config.watchOptions = { + ...config.watchOptions, + ignored: () => true, + } + } + }) + }, + }, + ], + }) + const watched = compilers.map(watchedBy) + const node = watched.find((w) => w.name === 'node')! + const web = watched.find((w) => w.name === 'web')! + expect(watched.map((w) => w.attached)).toEqual([true, true]) + expect(node.known.size).toBe(0) + expect(node.read).toEqual( + expect.arrayContaining(['src/entry.ts', 'src/leaf.ts']), + ) + for (const file of node.read) { + expect(web.known.has(path.join(server.root, file))).toBe(true) + } +}, 30_000) + +// A user starts the dev server on files that are already on disk. Files +// written a moment before the first compile fall within the accuracy +// watchpack allows for modification times (up to 2 s), so its first scan +// would report them changed and Rspack would start a second compile by +// itself, during a test's first edit. +test("the app's initial files predate the first compile beyond the watcher's accuracy", async () => { + let firstCompile: number | undefined + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + plugins: [ + { + name: 'first-compile', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.watchRun.tap('first-compile', () => { + firstCompile ??= Date.now() + }) + }, + }) + }) + }, + }, + ], + }) + expect(firstCompile).toBeDefined() + for (const file of ['package.json', 'src/entry.ts', 'src/leaf.ts']) { + const { mtimeMs } = await stat(path.join(server.root, file)) + expect(mtimeMs + 2000, file).toBeLessThan(firstCompile!) + } +}, 30_000) + +// A compile that started before an edit's write does not compile it, even +// if it names the edited file (here for an earlier change of it): `edit()` +// waits for a compile that started once the file held the edit. A plugin +// holds that earlier compile in `watchRun` until the edit began. +test('a compile that started before the write of an edit does not end its wait', async () => { + let hold: { held: () => void; release: Promise } | undefined + /** The contents of `src/leaf.ts` when each compile started; then `done`. */ + const compiles: Array<{ leaf: string; done: boolean }> = [] + const server = await createRsbuildDevServer({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { + 'src/entry.ts': `import { leaf } from './leaf'\nconsole.log(leaf)\n`, + 'src/leaf.ts': `export const leaf = 'MARK_V1'\n`, + }, + plugins: [ + { + name: 'holds-a-compile', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + const leaf = path.join(compiler.context, 'src/leaf.ts') + compiler.hooks.watchRun.tapPromise( + { name: 'holds-a-compile', stage: -2000 }, + async () => { + const current = hold + hold = undefined + compiles.push({ + leaf: await readFile(leaf, 'utf8'), + done: false, + }) + if (current) { + current.held() + await current.release + } + }, + ) + compiler.hooks.done.tap('holds-a-compile', () => { + compiles.at(-1)!.done = true + }) + }, + }) + }) + }, + }, + ], + }) + let release = () => {} + const held = new Promise((resolve) => { + hold = { + held: resolve, + release: new Promise((resolveRelease) => { + release = resolveRelease + }), + } + }) + // A change of the file the watcher reports: a compile naming it starts + // and waits in `watchRun` + await writeFile( + path.join(server.root, 'src/leaf.ts'), + `export const leaf = 'MARK_V2'\n`, + ) + await held + const editing = server.edit({ + 'src/leaf.ts': `export const leaf = 'MARK_V3'\n`, + }) + release() + await editing + + expect( + compiles.some(({ leaf, done }) => leaf.includes('MARK_V3') && done), + ).toBe(true) + expect(Object.values(await server.outputs()).join('\n')).toContain('MARK_V3') +}, 30_000) diff --git a/packages/compiler-test-utils/tests/integration/rsbuild-plugin-host.test.ts b/packages/compiler-test-utils/tests/integration/rsbuild-plugin-host.test.ts new file mode 100644 index 0000000000..3f0790ea13 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/rsbuild-plugin-host.test.ts @@ -0,0 +1,279 @@ +/** + * Controls of the Rsbuild plugin host (rsbuild-plugin-host.ts): the public + * Rsbuild plugins run through Rsbuild's JavaScript API in process. Server + * code loads through Rsbuild's own `loadBundle`, client code runs in the + * shared Chromium page, edits settle on their outcome, the production build + * returns each environment's output with its dangling-name evidence, and a + * plugin's console warning lands in the same channel as the compilation's + * and Rsbuild's logger's, each compilation report once. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { describeBuild } from '../../src/build-harness' +import { problems } from '../../src/diagnostic-channel' +import { expectDiagnostic } from '../../src/diagnostics' +import { + RsbuildHostBuildError, + createRsbuildPluginHost, +} from '../../src/rsbuild-plugin-host' +import type { RsbuildPlugin, Rspack } from '@rsbuild/core' + +const timeout = 60_000 + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +/** Rewrites `__MARK__` (a loader of its own) and warns through the console. */ +function userPlugin(): RsbuildPlugin { + return { + name: 'user-plugin', + setup(api) { + api.transform({ test: /\.ts$/ }, ({ code, resourcePath }) => { + if (!code.includes('__MARK__')) { + return code + } + console.warn(`[user-plugin] rewrote a marker in ${resourcePath}`) + return code.replaceAll('__MARK__', 'MARKED') + }) + }, + } +} + +const files = { + 'src/entry.ts': `import { label } from './label' +const shown = document.createElement('div') +shown.id = 'shown' +shown.textContent = label +document.body.append(shown) +`, + 'src/server.ts': `import { label } from './label' +export const read = () => label +`, + 'src/label.ts': `export const label = '__MARK__ v1'\n`, +} + +const environments = { + web: { source: { entry: { index: './src/entry.ts' } } }, + node: { + source: { entry: { index: './src/server.ts' } }, + // CommonJS: Rsbuild's `loadBundle` runs an ES module bundle only with + // Node's `--experimental-vm-modules` + output: { target: 'node' as const, module: false }, + }, +} + +test( + 'dev: server code through loadBundle, client code in the page, an edit, merged diagnostics', + async () => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [userPlugin()], + config: { environments }, + client: true, + }) + const server = await host.loadServer<{ read: () => string }>('node') + expect(server.read()).toBe('MARKED v1') + expect( + ( + await host.runClient( + `return document.getElementById('shown').textContent`, + ) + ).result, + ).toBe('MARKED v1') + // The plugin warned through the console: the server's channel has it + expectDiagnostic(host.diagnostics, { + severity: 'warning', + file: 'src/label.ts', + root: host.root, + }) + + await host.edit({ 'src/label.ts': `export const label = '__MARK__ v2'\n` }) + expect((await host.loadServer<{ read: () => string }>('node')).read()).toBe( + 'MARKED v2', + ) + }, + timeout, +) + +test( + 'build: each environment output, and the production client evidence for the dangling-name check', + async () => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [userPlugin()], + config: { environments }, + serve: false, + }) + const build = await host.build() + expect(Object.keys(build.environments).sort()).toEqual(['node', 'web']) + expect(Object.values(build.environments.web!.files).join('\n')).toContain( + 'MARKED v1', + ) + expect(build.parsedModules.web!.modules.size).toBeGreaterThan(0) + expectDiagnostic(build.diagnostics, { + severity: 'warning', + file: 'src/label.ts', + root: host.root, + }) + // The output passes the dangling-name check with that evidence + const web = build.environments.web! + const entry = Object.keys(web.files).find((file) => file.includes('index'))! + await describeBuild({ + bundler: 'rspack', + env: 'client', + mode: 'production', + esModules: false, + root: host.root, + outDir: web.distPath, + chunks: [ + { fileName: entry, isEntry: true, imports: [], dynamicImports: [] }, + ], + parsedModules: build.parsedModules.web, + warnings: [], + consoleMessages: [], + duration: 0, + dispose: async () => {}, + }) + }, + timeout, +) + +test.each(['dev', 'build'] as const)( + 'the %s host records warnings through Rsbuild’s logger', + async (mode) => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': 'export const value = 1' }, + serve: mode === 'dev', + plugins: [ + { + name: 'logger-control', + setup(api) { + api.onBeforeEnvironmentCompile(() => { + api.logger.warn('src/entry.ts: logger control warning') + }) + }, + }, + ], + }) + const diagnostics = + mode === 'dev' ? host.diagnostics : (await host.build()).diagnostics + expectDiagnostic(diagnostics, { + severity: 'warning', + file: 'src/entry.ts', + }) + }, + timeout, +) + +test( + 'concurrent Rsbuild apps retain their own native-loader diagnostics', + async () => { + const start = () => + createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': "export const value = '__MARK__'" }, + plugins: [userPlugin()], + }) + const [first, second] = await Promise.all([start(), start()]) + await Promise.all([ + first.edit({ 'src/entry.ts': "export const value = '__MARK__ edited'" }), + second.edit({ 'src/entry.ts': "export const value = '__MARK__ edited'" }), + ]) + for (const [app, other] of [ + [first, second], + [second, first], + ] as const) { + expectDiagnostic(app.diagnostics, { + severity: 'warning', + file: 'src/entry.ts', + root: app.root, + }) + expect( + app.diagnostics.some(({ text }) => text.includes(other.root)), + ).toBe(false) + } + }, + timeout, +) + +/** + * Adds a compilation warning or error naming the entry (`processAssets`), + * as a compiler reporting through the compilation does. + */ +function compilationReporter(severity: 'warning' | 'error'): RsbuildPlugin { + return { + name: 'compilation-reporter', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push({ + apply(compiler: Rspack.Compiler) { + compiler.hooks.thisCompilation.tap( + 'compilation-reporter', + (compilation) => { + compilation.hooks.processAssets.tap( + { name: 'compilation-reporter', stage: 0 }, + () => { + const report = new compiler.webpack.WebpackError( + `MARK_COMPILATION ${severity}: ${path.join(compiler.context, 'src/entry.ts')} is reported`, + ) + if (severity === 'error') { + compilation.errors.push(report) + } else { + compilation.warnings.push(report) + } + }, + ) + }, + ) + }, + }) + }) + }, + } +} + +// Rsbuild's logger prints each compile's report again (and a status line +// for a compile that failed); the channel records the report once, from +// the compilation. +test.each([ + ['dev', 'warning'], + ['dev', 'error'], + ['build', 'warning'], + ['build', 'error'], +] as const)( + 'the %s host records a compilation %s once', + async (mode, severity) => { + const host = await createRsbuildPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files: { 'src/entry.ts': 'export const value = 1' }, + serve: mode === 'dev', + plugins: [compilationReporter(severity)], + }) + const diagnostics = + mode === 'dev' + ? host.diagnostics + : await host.build().then( + (build) => build.diagnostics, + (error: unknown) => { + expect(error).toBeInstanceOf(RsbuildHostBuildError) + return (error as RsbuildHostBuildError).diagnostics + }, + ) + expectDiagnostic(diagnostics, { + severity, + file: 'src/entry.ts', + root: host.root, + times: 1, + }) + expect(problems(diagnostics)).toHaveLength(1) + }, + timeout, +) diff --git a/packages/compiler-test-utils/tests/integration/run-node.test.ts b/packages/compiler-test-utils/tests/integration/run-node.test.ts new file mode 100644 index 0000000000..d9ab5834f4 --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/run-node.test.ts @@ -0,0 +1,110 @@ +/** + * Control tests of run-node.ts: a program run in a child Node process gives + * its output, fails fast past its timeout, and never outlives the process + * that started it (a test worker killed on a timeout must not leave it + * spinning). + */ +import { spawn } from 'node:child_process' +import { mkdtemp, readFile, rm } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { runNodeProgram } from '../../src/run-node' + +const runNodeModule = pathToFileURL( + path.join( + path.dirname(fileURLToPath(import.meta.url)), + '../../src/run-node.ts', + ), +).href + +/** Whether a process is running. */ +function isRunning(pid: number) { + try { + process.kill(pid, 0) + return true + } catch { + return false + } +} + +/** Polls `read` every 50 ms until it returns a value, for `within` ms. */ +async function poll( + read: () => Promise, + what: string, + within = 10_000, +): Promise { + const deadline = Date.now() + within + for (;;) { + const value = await read() + if (value !== undefined) { + return value + } + if (Date.now() > deadline) { + throw new Error(`${what} within ${within} ms`) + } + await new Promise((resolve) => setTimeout(resolve, 50)) + } +} + +test('gives the output of the program', async () => { + const { stdout } = await runNodeProgram(`process.stdout.write(String(6 * 7))`) + expect(stdout).toBe('42') +}) + +test('a program that runs past its timeout is killed, and the run says so', async () => { + const started = Date.now() + await expect( + runNodeProgram(`while (true) {}`, { timeout: 500 }), + ).rejects.toThrow('the program did not finish within 500 ms') + expect(Date.now() - started).toBeLessThan(10_000) +}, 20_000) + +test('a program stuck in a synchronous loop dies with the process that started it', async () => { + const dir = await mkdtemp(path.join(tmpdir(), 'run-node-')) + const pidFile = path.join(dir, 'pid') + const program = `import { writeFileSync } from 'node:fs' +writeFileSync(${JSON.stringify(pidFile)}, String(process.pid)) +while (true) {} +` + // The process that starts the program, killed like a test worker on a + // timeout (SIGKILL: no exit handler runs) + const starter = spawn( + process.execPath, + [ + '--input-type=module', + '--eval', + `import { runNodeProgram } from ${JSON.stringify(runNodeModule)} +runNodeProgram(${JSON.stringify(program)}, { timeout: 120_000 }).catch(() => {}) +`, + ], + { stdio: 'ignore' }, + ) + onTestFinished(async () => { + starter.kill('SIGKILL') + await rm(dir, { recursive: true, force: true }) + }) + const pid = await poll( + () => + readFile(pidFile, 'utf8').then( + (text) => (text ? Number(text) : undefined), + () => undefined, + ), + 'the program did not start', + ) + onTestFinished(() => { + if (isRunning(pid)) { + process.kill(pid, 'SIGKILL') + } + }) + expect(isRunning(pid)).toBe(true) + + starter.kill('SIGKILL') + + await poll( + () => Promise.resolve(isRunning(pid) ? undefined : true), + 'the program still runs after the process that started it was killed', + ) + expect(isRunning(pid)).toBe(false) +}, 30_000) diff --git a/packages/compiler-test-utils/tests/integration/workspace-packages.test.ts b/packages/compiler-test-utils/tests/integration/workspace-packages.test.ts new file mode 100644 index 0000000000..66110b1c4c --- /dev/null +++ b/packages/compiler-test-utils/tests/integration/workspace-packages.test.ts @@ -0,0 +1,49 @@ +/** + * Control tests of workspace-packages.ts: a test app gets a built workspace + * package through a link in its `node_modules`, and asking for a package + * that is no workspace package fails with its name. + */ +import { mkdtemp, rm, writeFile } from 'node:fs/promises' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { pathToFileURL } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { + linkWorkspacePackages, + workspacePackage, + workspacePackageLinks, +} from '../../src/workspace-packages' + +// `@tanstack/history` is built by this project's `test:integration` target +// (package.json `nx.targets`); nothing in this package depends on it. +const name = '@tanstack/history' + +test('a workspace package is its directory under packages/, with its build', () => { + const root = workspacePackage(name) + expect(path.basename(root)).toBe('history') + expect(workspacePackageLinks([name])).toEqual({ + [`node_modules/${name}`]: root, + }) +}) + +test('a name that is no workspace package is refused by name', () => { + expect(() => workspacePackage('@tanstack/no-such-package')).toThrow( + '@tanstack/no-such-package', + ) +}) + +test('an app resolves a linked workspace package like an installed one', async () => { + const root = await mkdtemp(path.join(tmpdir(), 'workspace-packages-')) + onTestFinished(() => rm(root, { recursive: true, force: true })) + await linkWorkspacePackages(root, [name]) + await writeFile( + path.join(root, 'main.mjs'), + `import { createMemoryHistory } from '${name}' +export const location = createMemoryHistory({ initialEntries: ['/linked'] }).location.pathname +`, + ) + const { location } = (await import( + /* @vite-ignore */ pathToFileURL(path.join(root, 'main.mjs')).href + )) as { location: string } + expect(location).toBe('/linked') +}) diff --git a/packages/compiler-test-utils/tests/outcome.test.ts b/packages/compiler-test-utils/tests/outcome.test.ts new file mode 100644 index 0000000000..2062026cfb --- /dev/null +++ b/packages/compiler-test-utils/tests/outcome.test.ts @@ -0,0 +1,130 @@ +/** + * Controls of the edit completion by outcome (outcome.ts): the wait + * ends once the outcome holds with the hosts quiet, however many steps the + * edit took and however late after the first one it shows; it fails at + * its one bound, or at once on a problem. The old page wait failed a + * correct two-phase update 500 ms after the first applied update. + */ +import { describe, expect, test } from 'vitest' +import { waitForOutcome } from '../src/outcome' + +const sleep = (ms: number) => + new Promise((resolve) => setTimeout(resolve, ms)) + +describe('waitForOutcome', () => { + test('a two-phase update whose outcome shows late (after 600 ms) completes', async () => { + let shows = false + // First phase: something applied, nothing to see yet; second phase + // shows the edit + setTimeout(() => { + shows = true + }, 600) + await waitForOutcome({ + timeout: 5_000, + applied: () => shows, + describe: () => 'two phases', + }) + expect(shows).toBe(true) + }) + + test('waits while the hosts have work in flight, even once the outcome shows', async () => { + let inFlight = 3 + const quietChecks: Array = [] + await waitForOutcome({ + timeout: 5_000, + applied: () => true, + quiet: () => { + quietChecks.push(inFlight) + if (inFlight > 0) { + inFlight-- + return false + } + return true + }, + describe: () => 'in flight', + }) + expect(inFlight).toBe(0) + // Quiet twice in a row ends it + expect(quietChecks.slice(-2)).toEqual([0, 0]) + }) + + test('an outcome that flips back before the second check is not settled', async () => { + const seen: Array = [] + let calls = 0 + await waitForOutcome({ + timeout: 5_000, + applied: () => { + calls++ + // true, then false once (a reload blanks the page), then true + const value = calls !== 2 + seen.push(value) + return value + }, + describe: () => 'flip', + }) + expect(seen).toContain(false) + }) + + test('fails at its one bound with what it saw', async () => { + await expect( + waitForOutcome({ + timeout: 200, + applied: () => false, + describe: () => 'the page shows "v1"', + }), + ).rejects.toThrow(/within 200 ms\n.*the page shows "v1"/) + }) + + test('failWhenQuietFor: hosts quiet without the outcome end the wait after that long, not at the bound', async () => { + const started = Date.now() + await expect( + waitForOutcome({ + timeout: 10_000, + failWhenQuietFor: 300, + applied: () => false, + quiet: () => true, + describe: () => 'the page shows "v1"', + }), + ).rejects.toThrow( + /final state without its outcome.*300 ms\n.*the page shows "v1"/s, + ) + const elapsed = Date.now() - started + expect(elapsed).toBeGreaterThanOrEqual(300) + expect(elapsed).toBeLessThan(5_000) + }) + + test('failWhenQuietFor: work in flight restarts the quiet time; an outcome that shows then completes', async () => { + const started = Date.now() + let checks = 0 + await waitForOutcome({ + timeout: 10_000, + failWhenQuietFor: 300, + // Quiet, but busy again every 200 ms (each step of a slow edit), until + // the outcome shows after 1 s + quiet: () => { + checks++ + return (Date.now() - started) % 200 > 60 + }, + applied: () => Date.now() - started > 1_000, + describe: () => 'steps', + }) + expect(Date.now() - started).toBeGreaterThan(1_000) + expect(checks).toBeGreaterThan(5) + }) + + test('a problem ends the wait at once', async () => { + const started = Date.now() + await expect( + waitForOutcome({ + timeout: 5_000, + applied: async () => { + await sleep(5) + return false + }, + problems: () => ['Uncaught ReferenceError: x is not defined'], + describe: () => 'problem', + }), + ).rejects.toThrow(/the edit failed: Uncaught ReferenceError/) + expect(Date.now() - started).toBeLessThan(1_000) + }) +}) diff --git a/packages/compiler-test-utils/tests/plugin-host.test.ts b/packages/compiler-test-utils/tests/plugin-host.test.ts new file mode 100644 index 0000000000..9d32300334 --- /dev/null +++ b/packages/compiler-test-utils/tests/plugin-host.test.ts @@ -0,0 +1,145 @@ +/** + * Controls of the public in-process plugin host (plugin-host.ts), fast + * tier: the plugins a user configures run in a real Vite dev server + * (middleware mode) on an app on disk, and the host hands the test what a + * user gets, by resolved module, not by spelling: + * - server code evaluates through the environment's module runner; a module + * reached through different specifiers (relative, root-absolute, through a + * plugin's virtual module) is one instance; + * - an edit settles and the next evaluation sees it; + * - what a plugin reports on any channel is in `diagnostics`. + * The plugins here stand for any public plugin: nothing in the host knows + * them (no hook placement, id or query). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { expect, onTestFinished, test } from 'vitest' +import { expectNoProblems, problems } from '../src/diagnostic-channel' +import { expectDiagnostic } from '../src/diagnostics' +import { createPluginHost } from '../src/plugin-host' +import type { Plugin } from 'vite' + +const testsDir = path.dirname(fileURLToPath(import.meta.url)) + +/** + * A plugin as a user configures one: serves `virtual:counter` (a module + * that re-exports the app's counter through a root-absolute specifier) and + * rewrites `__MARK__` in the app's modules. + */ +function userPlugin(options: { warn?: 'console' | 'context' } = {}): Plugin { + return { + name: 'user-plugin', + resolveId(id) { + return id === 'virtual:counter' ? '\0virtual:counter' : null + }, + load(id) { + return id === '\0virtual:counter' + ? `export { count, increment } from '/src/counter.ts'\n` + : null + }, + transform(code, id) { + if (!id.includes('/src/') || !code.includes('__MARK__')) { + return null + } + if (options.warn === 'console') { + console.warn(`[user-plugin] rewrote a marker in ${id}`) + } else if (options.warn === 'context') { + this.warn(`rewrote a marker in ${id}`) + } + return code.replaceAll('__MARK__', 'MARKED') + }, + } +} + +const files = { + 'src/counter.ts': `export let count = 0 +export const increment = () => ++count +`, + 'src/server.ts': `import { increment } from './counter' +import { count, increment as viaVirtual } from 'virtual:counter' +import { count as viaRoot } from '/src/counter.ts' +export const marker = '__MARK__' +export const run = () => { + increment() + viaVirtual() + return { count, viaRoot } +} +`, +} + +async function host(warn?: 'console' | 'context') { + return createPluginHost({ + dir: testsDir, + registerCleanup: onTestFinished, + files, + plugins: [userPlugin({ warn })], + }) +} + +test('server code runs through the module runner; a module is one instance whatever the specifier', async () => { + const app = await host() + const server = await app.importServer('/src/server.ts') + expect(server.marker).toBe('MARKED') + // Two increments through two spellings, read through a third: one module + expect(server.run()).toEqual({ count: 2, viaRoot: 2 }) + expect(await app.transform('/src/server.ts', 'ssr')).toContain('MARKED') +}) + +test('an edit settles; the next evaluation runs the edited module', async () => { + const app = await host() + expect((await app.importServer('/src/server.ts')).marker).toBe('MARKED') + await app.edit({ + 'src/server.ts': `export const marker = 'edited __MARK__'\n`, + }) + expect((await app.importServer('/src/server.ts')).marker).toBe( + 'edited MARKED', + ) +}) + +test.each(['console', 'context'] as const)( + 'a plugin warning through %s is in the merged diagnostics', + async (warn) => { + const app = await host(warn) + const since = app.diagnostics.length + await app.importServer('/src/server.ts') + const reported = app.diagnostics.slice(since) + expectDiagnostic(problems(reported), { + severity: 'warning', + file: 'src/server.ts', + root: app.root, + }) + expect(() => expectNoProblems(reported)).toThrow() + // The dev server's text log reads the same channels + expect(app.dev.logs.some((log) => log.includes('rewrote a marker'))).toBe( + true, + ) + }, +) + +test('nothing reported: a quiet plugin leaves no problem on any channel', async () => { + const app = await host() + await app.importServer('/src/server.ts') + expectNoProblems(app.diagnostics) +}) + +test('two live apps keep console diagnostics scoped to their own work', async () => { + const [first, second] = await Promise.all([host('console'), host('console')]) + await Promise.all([ + first.importServer('/src/server.ts'), + second.importServer('/src/server.ts'), + ]) + for (const [app, other] of [ + [first, second], + [second, first], + ]) { + expectDiagnostic(app!.diagnostics, { + severity: 'warning', + file: 'src/server.ts', + root: app!.root, + times: 1, + }) + expect( + app!.diagnostics.some(({ text }) => text.includes(other!.root)), + ).toBe(false) + } +}) diff --git a/packages/compiler-test-utils/tests/source-maps.test.ts b/packages/compiler-test-utils/tests/source-maps.test.ts new file mode 100644 index 0000000000..aa51a758fa --- /dev/null +++ b/packages/compiler-test-utils/tests/source-maps.test.ts @@ -0,0 +1,188 @@ +/** + * Controls of the source-map helpers (source-maps.ts) on maps real + * transforms emit (Oxc through Vite, esbuild): positions resolve through + * `@jridgewell/trace-mapping`, executed throws resolve through their + * stack, tokens are found by parsing whatever the printing, and CRLF + * sources count lines like editors. + */ +import vm from 'node:vm' +import * as esbuild from 'esbuild' +import { transformWithOxc } from 'vite' +import { describe, expect, test } from 'vitest' +import { + expectMapsTo, + findNodes, + inlineSourceMap, + offsetAt, + originalPositionOf, + originalPositions, + positionAt, + tokenOffsets, + traceStack, +} from '../src/source-maps' + +// TypeScript-only lines before the throw shift it: a map that skips the +// type erasure points at the wrong line. +const source = `interface Failure { + message: string +} +type Reason = Failure['message'] +export function fail(reason: Reason = 'MARK_FAIL'): string { + throw new Error(reason) +} +` +const throwLine = 6 + +describe('positions', () => { + test('positionAt and offsetAt count every JavaScript line terminator', () => { + const code = 'a\r\nb\rc\u2028d\u2029e\nf' + expect(positionAt(code, code.indexOf('e'))).toEqual({ line: 5, column: 0 }) + expect(positionAt(code, code.indexOf('f'))).toEqual({ line: 6, column: 0 }) + for (const char of 'abcdef') { + const offset = code.indexOf(char) + expect(offsetAt(code, positionAt(code, offset))).toBe(offset) + } + }) + + test('tokens are found by parsing, whatever the quotes or spacing', () => { + const code = `const a = "box"; const b = 'box'; const c = \`box\`; box(); throw a` + expect(tokenOffsets(code, { string: 'box' })).toHaveLength(3) + expect(tokenOffsets(code, { identifier: 'box' })).toEqual([ + code.indexOf('box()'), + ]) + expect(tokenOffsets(code, { throw: true })).toEqual([code.indexOf('throw')]) + expect( + findNodes(code, (node) => node.type === 'CallExpression'), + ).toHaveLength(1) + }) +}) + +describe.each([ + { + name: 'Oxc (Vite)', + transform: async (code: string, file: string) => { + const result = await transformWithOxc(code, file, { + lang: 'ts', + sourcemap: true, + }) + return { code: result.code, map: result.map! } + }, + }, + { + name: 'esbuild', + transform: async (code: string, file: string) => { + const result = await esbuild.transform(code, { + loader: 'ts', + format: 'cjs', + sourcefile: file, + sourcemap: 'external', + }) + return { code: result.code, map: JSON.parse(result.map) } + }, + }, +])('$name maps', ({ transform }) => { + test('a generated token resolves to the original line and column', async () => { + const { code, map } = await transform(source, '/app/src/fail.ts') + const generated = positionAt(code, tokenOffsets(code, { throw: true })[0]!) + const original = expectMapsTo(map, generated, { + file: 'src/fail.ts', + root: '/app', + line: throwLine, + column: positionAt(source, tokenOffsets(source, { throw: true })[0]!) + .column, + }) + expect(original.source).toContain('fail.ts') + expect( + originalPositions(map).some((position) => position.line === throwLine), + ).toBe(true) + }) + + test('an executed throw resolves through its stack', async () => { + const { code, map } = await transform( + `${source}fail()\n`, + '/app/src/fail.ts', + ) + const location = '/generated/fail.js' + let stack = '' + try { + vm.runInThisContext( + `(function (exports, module) {${code.replace(/^export /gm, '')}\n})({}, {})`, + { filename: location }, + ) + } catch (error) { + stack = (error as Error).stack! + } + expect(stack).toContain('MARK_FAIL') + const frames = traceStack(stack, (file) => + file === location ? map : undefined, + ) + expect(frames[0]).toMatchObject({ + location, + original: { line: throwLine }, + }) + expect(frames[0]!.original!.source).toContain('fail.ts') + }) + + test('a wrong line or file fails', async () => { + const { code, map } = await transform(source, '/app/src/fail.ts') + const generated = positionAt(code, tokenOffsets(code, { throw: true })[0]!) + expect(() => + expectMapsTo(map, generated, { file: 'src/fail.ts', line: 1 }), + ).toThrow() + expect(() => + expectMapsTo(map, generated, { file: 'src/other.ts', line: throwLine }), + ).toThrow() + }) +}) + +// A dev server names a module's source relative to the module (`fail.ts` +// for `/src/fail.ts`): the source map specification resolves it against +// the map's URL. The name alone does not name `src/fail.ts` (SPEC §5.7). +test('a source relative to its module names the file once resolved against the module', async () => { + const { code, map } = await transformWithOxc(source, '/app/src/fail.ts', { + lang: 'ts', + sourcemap: true, + }) + const relative = { ...map!, sources: ['fail.ts'] } + const generated = positionAt(code, tokenOffsets(code, { throw: true })[0]!) + const expected = { file: 'src/fail.ts', root: '/app', line: throwLine } + expectMapsTo(relative, generated, { + ...expected, + mapUrl: '/app/src/fail.ts?v=1', + }) + expectMapsTo(relative, generated, { + ...expected, + mapUrl: 'file:///app/src/fail.ts', + }) + expect(() => expectMapsTo(relative, generated, expected)).toThrow() + expect(() => + expectMapsTo(relative, generated, { + ...expected, + mapUrl: '/app/lib/fail.js', + }), + ).toThrow() +}) + +test('a CRLF source maps to the lines an editor shows', async () => { + const crlf = source.replaceAll('\n', '\r\n') + const { code, map } = await transformWithOxc(crlf, '/app/src/fail.ts', { + lang: 'ts', + sourcemap: true, + }) + const generated = positionAt(code, tokenOffsets(code, { throw: true })[0]!) + expectMapsTo(map!, generated, { file: 'src/fail.ts', line: throwLine }) +}) + +test('inlineSourceMap reads a data URL map, and nothing else', async () => { + const { code, map } = await transformWithOxc(source, '/app/src/fail.ts', { + lang: 'ts', + sourcemap: true, + }) + const inline = `${code}\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(map)).toString('base64')}\n` + expect(inlineSourceMap(inline)).toEqual(JSON.parse(JSON.stringify(map))) + expect(inlineSourceMap(code)).toBeUndefined() + const generated = positionAt(code, tokenOffsets(code, { throw: true })[0]!) + expect(originalPositionOf(inlineSourceMap(inline)!, generated)?.line).toBe( + throwLine, + ) +}) diff --git a/packages/compiler-test-utils/tsconfig.json b/packages/compiler-test-utils/tsconfig.json new file mode 100644 index 0000000000..843889b7fd --- /dev/null +++ b/packages/compiler-test-utils/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "include": ["src", "tests", "vite.config.ts"], + "compilerOptions": { + "target": "esnext", + "types": ["node"] + } +} diff --git a/packages/compiler-test-utils/vite.config.ts b/packages/compiler-test-utils/vite.config.ts new file mode 100644 index 0000000000..4aef98b495 --- /dev/null +++ b/packages/compiler-test-utils/vite.config.ts @@ -0,0 +1,51 @@ +import path from 'node:path' +import os from 'node:os' +import { configDefaults, defineConfig } from 'vitest/config' +import packageJson from './package.json' + +// Under Vitest: Node's compile cache for the test workers and the child +// Node runs they start (the harness passes this environment on). No outcome +// change; less time compiling the bundlers, jsdom and the built apps again. +if (process.env.VITEST) { + process.env.NODE_COMPILE_CACHE ??= path.join( + os.tmpdir(), + 'node-compile-cache', + ) +} + +export default defineConfig({ + test: { + name: packageJson.name, + dir: './tests', + watch: false, + // At most 4 test processes per Vitest run: each + // runs real bundlers, dev servers and its own browser, and Nx runs several + // packages' tiers at once. More workers add swap and load flakes, not + // speed. `--maxWorkers` on the command line still overrides it. + maxWorkers: 4, + reporters: ['default', '@tanstack/compiler-test-utils/budget-reporter'], + globalSetup: ['./src/run-directory.ts'], + projects: [ + { + // Fast tier (`test:unit`): in process; a Vite dev server in + // middleware mode is allowed. + extends: true, + test: { + name: 'unit', + exclude: [...configDefaults.exclude, 'integration/**'], + }, + }, + { + // Slow tier (`test:integration`): the harness self-tests that run + // real builds, Rsbuild dev servers, child Node runs and browsers. + extends: true, + test: { + name: 'integration', + include: ['integration/**/*.test.ts'], + testTimeout: 30_000, + hookTimeout: 30_000, + }, + }, + ], + }, +}) diff --git a/packages/react-router-devtools/CHANGELOG.md b/packages/react-router-devtools/CHANGELOG.md index f74de5f187..963524b66d 100644 --- a/packages/react-router-devtools/CHANGELOG.md +++ b/packages/react-router-devtools/CHANGELOG.md @@ -1,12 +1,5 @@ # @tanstack/react-router-devtools -## 1.167.3 - -### Patch Changes - -- Updated dependencies [[`bbf9b75`](https://github.com/TanStack/router/commit/bbf9b75808d8eee497a6dd1663f0cf08426512e0)]: - - @tanstack/router-devtools-core@1.168.3 - ## 1.167.2 ### Patch Changes diff --git a/packages/react-router-devtools/package.json b/packages/react-router-devtools/package.json index 969371a6a6..fd750b4c2b 100644 --- a/packages/react-router-devtools/package.json +++ b/packages/react-router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-router-devtools", - "version": "1.167.3", + "version": "1.167.2", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/react-router/CHANGELOG.md b/packages/react-router/CHANGELOG.md index 7e1e2f1a62..71b131e2d8 100644 --- a/packages/react-router/CHANGELOG.md +++ b/packages/react-router/CHANGELOG.md @@ -1,16 +1,5 @@ # @tanstack/react-router -## 1.170.46 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/#`) instead of relative file links that break once packages are installed. - -- [#8671](https://github.com/TanStack/router/pull/8671) [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398) - Publish the `@tanstack/react-router` agent skills (`react-router`, `compositions/router-query`, `lifecycle/migrate-from-react-router`), which were missing from the package's `files` list. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - ## 1.170.45 ### Patch Changes diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 9a61d5af25..62e3c8a4bb 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-router", - "version": "1.170.46", + "version": "1.170.45", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/react-start-client/CHANGELOG.md b/packages/react-start-client/CHANGELOG.md index 1cb31dea24..a44c4f947b 100644 --- a/packages/react-start-client/CHANGELOG.md +++ b/packages/react-start-client/CHANGELOG.md @@ -1,20 +1,5 @@ # @tanstack/react-start-client -## 1.168.45 - -### Patch Changes - -- [#8653](https://github.com/TanStack/router/pull/8653) [`d66a84b`](https://github.com/TanStack/router/commit/d66a84ba0a74ffd03e22b57ccd90796274c96244) - fix: a `visible()` boundary keeps its server HTML when the intersection arrives while React waits to replay the boundary's render - -## 1.168.44 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398)]: - - @tanstack/react-router@1.170.46 - - @tanstack/router-core@1.171.39 - - @tanstack/start-client-core@1.170.39 - ## 1.168.43 ### Patch Changes diff --git a/packages/react-start-client/package.json b/packages/react-start-client/package.json index b919d47b92..f5adcee1ff 100644 --- a/packages/react-start-client/package.json +++ b/packages/react-start-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-start-client", - "version": "1.168.45", + "version": "1.168.43", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/react-start-client/src/hydration/visible.tsx b/packages/react-start-client/src/hydration/visible.tsx index b295d77462..e274285cb8 100644 --- a/packages/react-start-client/src/hydration/visible.tsx +++ b/packages/react-start-client/src/hydration/visible.tsx @@ -26,22 +26,20 @@ function HydrationBoundary(props: { o?: () => void children?: React.ReactNode }) { - // Above the gate: a replay after `use` suspended can find the gate open and - // skip `use`, and only `use` leaves the replay's dispatcher, which rejects a - // hook the first attempt did not reach. - const { o } = props + const { g, o } = props + + if (!g.r) { + if (!reactUse) { + throw g.p + } + + reactUse(g.p) + } + React.useEffect(() => { o?.() }, [o]) - if (!props.g.r) { - if (!reactUse) { - throw props.g.p - } - - reactUse(props.g.p) - } - return props.children as React.JSX.Element } diff --git a/packages/react-start-client/src/tests/Hydrate.test.tsx b/packages/react-start-client/src/tests/Hydrate.test.tsx index 0e7abe502a..0d0ce1faad 100644 --- a/packages/react-start-client/src/tests/Hydrate.test.tsx +++ b/packages/react-start-client/src/tests/Hydrate.test.tsx @@ -12,14 +12,7 @@ import { import { afterEach, describe, expect, it, vi } from 'vitest' import { hydrateIdAttribute } from '@tanstack/start-client-core/hydration/constants' import { Hydrate } from '../Hydrate' -import { - condition, - idle, - interaction, - load, - never, - visible, -} from '../hydration' +import { condition, idle, interaction, load, never } from '../hydration' import type { HydrateProps, HydrationPrefetchStrategy } from '../Hydrate' const InternalHydrate = Hydrate as React.ComponentType< @@ -680,84 +673,4 @@ describe('Hydrate', () => { await unmountHydratedRoot(root, container) } }) - - // `visible()` reads its gate's mutable flag during render (`if (!g.r) use(g.p)`). - // React replays a component that suspended in `use` with its re-render - // dispatcher, and only `use` switches away from it: when the intersection - // arrives while React waits to replay, the flag is true, the replay skips - // `use`, and a hook after it would throw "Update hook called on initial render" - // (#467 in production). React would then discard the boundary's server HTML. - // Which task the intersection lands in is the browser's choice, so this runs - // it in each of the tasks around the boundary's first hydration attempt. - it('hydrates a visible boundary whichever task the intersection arrives in', async () => { - const actEnvironment = globalThis as { - IS_REACT_ACT_ENVIRONMENT?: boolean - } - const wasActEnvironment = actEnvironment.IS_REACT_ACT_ENVIRONMENT - actEnvironment.IS_REACT_ACT_ENVIRONMENT = false - const nextTask = () => new Promise((resolve) => setImmediate(resolve)) - const app = (onHydrated?: () => void) => ( - fallback

} - onHydrated={onHydrated} - > -

child

-
- ) - vi.stubGlobal('window', undefined) - const html = renderToString(app()) - vi.unstubAllGlobals() - const failed: Array<{ tasks: number; errors: Array }> = [] - try { - for (let tasks = 0; tasks < 12; tasks++) { - vi.stubGlobal( - 'IntersectionObserver', - class { - constructor(private notify: IntersectionObserverCallback) {} - observe() { - void (async () => { - for (let task = 0; task < tasks; task++) { - await nextTask() - } - this.notify( - [{ isIntersecting: true } as IntersectionObserverEntry], - this as unknown as IntersectionObserver, - ) - })() - } - disconnect() {} - }, - ) - const container = document.createElement('div') - document.body.append(container) - container.innerHTML = html - const errors: Array = [] - const hydrated = new Promise((resolve) => { - const root = hydrateRoot( - container, - app(() => { - resolve() - setImmediate(() => { - root.unmount() - container.remove() - }) - }), - { - onRecoverableError: (error) => { - errors.push(String((error as Error).cause ?? error)) - }, - }, - ) - }) - await hydrated - if (errors.length > 0) { - failed.push({ tasks, errors }) - } - } - } finally { - actEnvironment.IS_REACT_ACT_ENVIRONMENT = wasActEnvironment - } - expect(failed).toEqual([]) - }) }) diff --git a/packages/react-start-rsc/AGENTS.md b/packages/react-start-rsc/AGENTS.md new file mode 100644 index 0000000000..de0712d09d --- /dev/null +++ b/packages/react-start-rsc/AGENTS.md @@ -0,0 +1,5 @@ +# React Start RSC + +- Tests run in two tiers. `test:unit` is reserved for fast compiler acceptance (currently empty). `test:noncompiler` runs main's RSC runtime and type tests (57 tests, at main's paths in `tests/`, listed in `tests/noncompiler-tests.json`, unchanged from main) in jsdom; `test:types` and `test:eslint` check `tests/integration/` only, as main does not type-check or lint them. `test:integration` (slow tier) runs `tests/integration/**`: real Start apps with RSC on Vite and Rsbuild dev servers and builds, and real browser pages; its Nx target builds `@tanstack/react-start` first. Run integration, noncompiler, types and eslint before handing back. +- To run one test file or `-t` filter quickly, the slow-tier load gate and the test budgets: [compiler-test-utils/AGENTS.md](../compiler-test-utils/AGENTS.md). +- What these tests are, the spec they cite (`J4.12`, `G3`, `§5.7`) and the known bugs: [compiler-test-utils/oracle/README.md](../compiler-test-utils/oracle/README.md). diff --git a/packages/react-start-rsc/CHANGELOG.md b/packages/react-start-rsc/CHANGELOG.md index fae6bcabee..99f7b51c0e 100644 --- a/packages/react-start-rsc/CHANGELOG.md +++ b/packages/react-start-rsc/CHANGELOG.md @@ -1,31 +1,5 @@ # @tanstack/react-start-rsc -## 0.1.67 - -### Patch Changes - -- Updated dependencies [[`3f22686`](https://github.com/TanStack/router/commit/3f226869e0af211ff7f1de5d7343e43462dbb101), [`559c7de`](https://github.com/TanStack/router/commit/559c7ded6e2a6eeda3f91c80d8c03f4cfeb9a206)]: - - @tanstack/start-plugin-core@1.171.57 - -## 0.1.66 - -### Patch Changes - -- Updated dependencies [[`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69), [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c), [`c5320d7`](https://github.com/TanStack/router/commit/c5320d7ca23eca82d720ac5629d2bad5cf7d9b02), [`545a8d3`](https://github.com/TanStack/router/commit/545a8d3790989ca502153c3292c6b1e8063257f4), [`da8c28c`](https://github.com/TanStack/router/commit/da8c28c498230a5730ce75b2693baeeb3ef68ac1)]: - - @tanstack/router-utils@1.163.0 - - @tanstack/start-plugin-core@1.171.56 - -## 0.1.65 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398), [`ed55775`](https://github.com/TanStack/router/commit/ed5577593a749b8c7193cc7b5d945fd084bfac2f), [`63a886d`](https://github.com/TanStack/router/commit/63a886da9040c4b039ea3bf5b3a841771375cddb), [`d9b07e8`](https://github.com/TanStack/router/commit/d9b07e8d3b724cdbfac0aa2fba4c1f7a3a241100)]: - - @tanstack/react-router@1.170.46 - - @tanstack/router-core@1.171.39 - - @tanstack/start-client-core@1.170.39 - - @tanstack/start-plugin-core@1.171.55 - - @tanstack/start-storage-context@1.167.41 - ## 0.1.64 ### Patch Changes diff --git a/packages/react-start-rsc/package.json b/packages/react-start-rsc/package.json index 40b1847068..f41e00d798 100644 --- a/packages/react-start-rsc/package.json +++ b/packages/react-start-rsc/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-start-rsc", - "version": "0.1.67", + "version": "0.1.64", "description": "React Server Components support for TanStack Start", "author": "Tanner Linsley", "license": "MIT", @@ -24,19 +24,58 @@ ], "scripts": { "clean": "rimraf ./dist && rimraf ./coverage", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "vitest", - "test:unit:dev": "vitest --watch", - "test:eslint": "eslint ./src", + "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit && pnpm test:integration && pnpm test:noncompiler", + "test:unit": "vitest --project unit --passWithNoTests", + "test:unit:dev": "vitest --project unit --watch", + "test:integration": "vitest --project integration", + "test:eslint": "eslint ./src ./tests/integration", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", - "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", - "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", - "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js", - "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js", - "test:types:ts60": "tsc6", - "test:types:ts70": "tsc", + "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js && node ../../node_modules/typescript56/lib/tsc.js -p tests", + "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js && node ../../node_modules/typescript57/lib/tsc.js -p tests", + "test:types:ts58": "node ../../node_modules/typescript58/lib/tsc.js && node ../../node_modules/typescript58/lib/tsc.js -p tests", + "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js && node ../../node_modules/typescript59/lib/tsc.js -p tests", + "test:types:ts60": "tsc6 && tsc6 -p tests", + "test:types:ts70": "tsc && tsc -p tests", "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "vite build" + "build": "vite build", + "test:noncompiler": "vitest --project noncompiler" + }, + "nx": { + "targets": { + "test:unit": { + "dependsOn": [ + "^build", + { + "projects": [ + "@tanstack/react-start-client" + ], + "target": "build" + } + ] + }, + "test:integration": { + "dependsOn": [ + "^build", + { + "projects": [ + "@tanstack/react-start" + ], + "target": "build" + } + ] + }, + "test:noncompiler": { + "dependsOn": [ + "^build", + { + "projects": [ + "@tanstack/react-start-client" + ], + "target": "build" + } + ] + } + } }, "type": "module", "types": "dist/esm/src/index.d.ts", @@ -107,11 +146,13 @@ "pathe": "catalog:" }, "devDependencies": { + "@rsbuild/plugin-react": "^2.0.0", "@rspack/core": "2.2.7", "@testing-library/react": "catalog:", "@vitejs/plugin-react": "catalog:", - "@vitejs/plugin-rsc": "^0.5.39", - "react-server-dom-rspack": "^0.1.1", + "@vitejs/plugin-rsc": "^0.5.37", + "react-server-dom-rspack": "^0.0.2", + "@tanstack/compiler-test-utils": "workspace:*", "@tanstack/vite-config": "catalog:", "vitest": "catalog:", "jsdom": "catalog:", @@ -127,10 +168,10 @@ }, "peerDependencies": { "@rspack/core": ">=2.0.0-0", - "@vitejs/plugin-rsc": ">=0.5.38", + "@vitejs/plugin-rsc": ">=0.5.30", "react": ">=18.0.0 || >=19.0.0", "react-dom": ">=18.0.0 || >=19.0.0", - "react-server-dom-rspack": ">=0.1.1" + "react-server-dom-rspack": ">=0.0.2" }, "peerDependenciesMeta": { "@rspack/core": { diff --git a/packages/react-start-rsc/tests/integration/rsc-app.ts b/packages/react-start-rsc/tests/integration/rsc-app.ts new file mode 100644 index 0000000000..a5b911935e --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-app.ts @@ -0,0 +1,614 @@ +/** + * Real React Start apps with RSC enabled, for tests of what the RSC CSS + * transform and Start's RSC wiring do end to end: a Vite dev server + * (`startRscDevServer`) runs the app the way `vite dev` does, with the built + * `@tanstack/react-start` (`tanstackStart({ rsc: { enabled: true } })` of its + * `plugin/vite` entry, linked into the app's `node_modules`), Vite's own RSC + * plugin (`@vitejs/plugin-rsc`, the three environments `client`, `ssr` and + * `rsc`) and `@vitejs/plugin-react`. With `browser`, a real page + * (`@tanstack/compiler-test-utils/browser`) loads the app over HTTP through + * Start's own dev server middleware (SSR), Vite's HMR client and React + * Refresh; Vite's own watcher reports the test's file edits (`write()`). + * + * The temporary apps stand in for apps in this directory + * (`@tanstack/compiler-test-utils/app-directory`): their bare imports (`react`, + * `@tanstack/react-router`, `@vitejs/plugin-rsc`, ...) resolve to this + * package's dependencies, as in an installed app. `@tanstack/react-start` + * is not one of them (it depends on this package), so the built workspace + * package is linked (`workspacePackageLinks`); the `test:integration` Nx + * target depends on its `build`. + */ +import { createRequire } from 'node:module' +import path from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import react from '@vitejs/plugin-react' +import rsc from '@vitejs/plugin-rsc' +import { pluginReact } from '@rsbuild/plugin-react' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { + createApp, + pluginNames, + withBuildEnvironment, +} from '@tanstack/compiler-test-utils/build-harness' +import { createBuilder, mergeConfig, preview } from 'vite' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { onTestFinished } from 'vitest' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { + DevServer, + DevServerOptions, +} from '@tanstack/compiler-test-utils/dev-server' +import type { + RsbuildDevServer, + RsbuildDevServerOptions, +} from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +/** + * Node's own `import()`, outside Vitest's module runner (as + * start-plugin-core's `start-compose-app.ts` uses it): a plugin loaded with + * it imports the built server bundle as Node does. + */ +const nativeImport = createRequire(import.meta.url)( + '../../../compiler-test-utils/src/native-import.cjs', +) as (specifier: string) => Promise> + +/** + * Resolve the installed public export with Node, independent of dist + * layout; with `native`, loaded by Node itself (`nativeImport`). + */ +async function tanstackStartPlugin( + bundler: 'vite' | 'rsbuild', + native = false, +): Promise<(options?: Record) => unknown> { + const app = await createApp({ + dir: harnessDir, + prefix: '.rsc-plugin-import-', + files: { + 'plugin.mjs': `export { tanstackStart } from '@tanstack/react-start/plugin/${bundler}'`, + }, + symlinks: workspacePackageLinks(['@tanstack/react-start']), + }) + try { + const url = pathToFileURL(path.join(app.root, 'plugin.mjs')).href + return ( + native ? await nativeImport(url) : await import(/* @vite-ignore */ url) + ).tanstackStart + } finally { + await app.dispose() + } +} + +/** + * The files every app has unless it brings its own: Start's router entry + * (the real router over the generated route tree) and a root route that + * renders the document with Start's `HeadContent` and `Scripts`, so pages + * hydrate and load the client. + */ +export const rscAppFiles = { + 'src/router.tsx': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export function getRouter() { + return createRouter({ routeTree }) +} +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + + + + + +
+ {hydrated ? 'hydrated' : 'hydrating'} + + + + ) +} +`, +} + +export interface RscDevServerOptions extends Omit< + DevServerOptions, + 'dir' | 'plugins' +> { + /** Start's plugin options (`tanstackStart(options)`), `rsc` enabled. */ + start?: Record +} + +/** + * Starts a Vite dev server on a React Start app with RSC enabled, of + * `files` over `rscAppFiles`. Without `browser`, the server runs in + * middleware mode (Vite's watcher still reports `write()`s, which + * `settle()` waits for); the `rsc` environment is runnable + * (`server.import(url, 'rsc')` runs a module in the provider). + */ +export async function startRscDevServer( + options: RscDevServerOptions, +): Promise { + const { files, start, config, ...devServerOptions } = options + const tanstackStart = await tanstackStartPlugin('vite') + return createDevServer({ + dir: harnessDir, + prefix: '.rsc-dev-server-', + registerCleanup: onTestFinished, + ...devServerOptions, + files: { ...rscAppFiles, ...files }, + // An app may also import this package directly (`@tanstack/react-start-rsc`). + symlinks: { + ...workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + ...devServerOptions.symlinks, + }, + config: mergeConfig( + { + // Start serves the pages (SSR through its dev middleware), not + // Vite's SPA fallback. + appType: 'custom', + // Pre-bundled up front, as Vite does once a page discovers them + // (the dependencies of Start's client RPC and of the Flight decoder, + // which the browser imports on the first server function call and + // the first decode): a discovery mid-test re-optimises and reloads + // the page. + optimizeDeps: { + include: [ + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + '@tanstack/react-start > @tanstack/start-server-core > cookie-es', + '@vitejs/plugin-rsc/vendor/react-server-dom/client.browser', + ], + }, + }, + config ?? {}, + ), + plugins: [ + tanstackStart({ ...start, rsc: { enabled: true } }) as never, + rsc(), + react(), + ], + }) +} + +export interface RscPreviewServer { + /** The app root. */ + root: string + /** The URL Start's preview server listens on. */ + url: string + /** What the build logged (warnings and errors). */ + messages: Array +} + +/** + * Builds a React Start app with RSC enabled, of `files` over `rscAppFiles`, + * for production as `vite build` does (the `client`, `ssr` and `rsc` + * environments, `buildApp()`), and serves the build with `vite preview` + * (Start's own preview server runs the built server entry). The test + * process runs with `NODE_ENV=production` until the cleanup, as `vite + * preview` does, so the server's React matches the client's. + */ +export async function startRscPreviewServer(options: { + files: Record + start?: Record + config?: Record + registerCleanup?: (cleanup: () => Promise) => void +}): Promise { + const registerCleanup = options.registerCleanup ?? onTestFinished + const tanstackStart = await tanstackStartPlugin('vite') + const app = await createApp({ + dir: harnessDir, + prefix: '.rsc-preview-server-', + registerCleanup, + files: { ...rscAppFiles, ...options.files }, + symlinks: workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + }) + const config = () => + mergeConfig( + { + root: app.root, + configFile: false, + logLevel: 'warn', + plugins: [ + tanstackStart({ ...options.start, rsc: { enabled: true } }), + rsc(), + react(), + ], + }, + options.config ?? {}, + ) + const reported: Array = [] + await withBuildEnvironment('production', reported, async () => { + const builder = await createBuilder(config()) + await builder.buildApp() + }) + const messages = reported.map(({ text }) => text) + const nodeEnv = process.env.NODE_ENV + process.env.NODE_ENV = 'production' + const server = await preview({ + ...config(), + // Vite's default port: the server binds the next free port itself + // (`port: 0` makes Vite 8 probe a port and bind it after, which another + // process can take meanwhile). + preview: { host: '127.0.0.1' }, + }) + registerCleanup(async () => { + await server.close() + process.env.NODE_ENV = nodeEnv + }) + const url = server.resolvedUrls?.local[0] + if (!url) { + throw new Error('the preview server does not listen') + } + return { root: app.root, url, messages } +} + +/** What `startRscRsbuildPreviewServer` uses of Rsbuild's JavaScript API. */ +interface RsbuildApi { + createRsbuild: (options: { + cwd: string + rsbuildConfig: Record + }) => Promise<{ + build: () => Promise<{ close: () => Promise }> + preview: (options?: { getPortSilently?: boolean }) => Promise<{ + urls: Array + server: { close: () => Promise } + }> + }> +} + +/** + * Rsbuild's JavaScript API: the copy the shared Rsbuild harness runs + * (a dependency of `@tanstack/compiler-test-utils`, which this package's + * tests do not declare themselves). + */ +async function rsbuildApi(): Promise { + const harness = createRequire(import.meta.url).resolve( + '@tanstack/compiler-test-utils/rsbuild-dev-server', + ) + const rsbuild = createRequire(harness).resolve('@rsbuild/core') + return (await import( + /* @vite-ignore */ pathToFileURL(rsbuild).href + )) as RsbuildApi +} + +/** + * Builds a React Start app with RSC enabled, of `files` over `rscAppFiles`, + * for production as `rsbuild build` does in the app's directory (the + * built `@tanstack/react-start/plugin/rsbuild` and `@rsbuild/plugin-react`, + * as for `startRscRsbuildDevServer`), and serves the build as `rsbuild + * preview` does (Start's own middleware runs the built server entry). The + * test process runs with `NODE_ENV=production` until the cleanup, as for + * `startRscPreviewServer`. `errors`: what the build reported as errors. + */ +export async function startRscRsbuildPreviewServer(options: { + files: Record + start?: Record + registerCleanup?: (cleanup: () => Promise) => void +}): Promise }> { + const registerCleanup = options.registerCleanup ?? onTestFinished + // Loaded by Node: Start's preview middleware imports the built server + // bundle, which Node runs, not Vitest's module runner + const tanstackStart = await tanstackStartPlugin('rsbuild', true) + const { createRsbuild } = await rsbuildApi() + const app = await createApp({ + dir: harnessDir, + prefix: '.rsc-rsbuild-preview-server-', + registerCleanup, + files: { ...rscAppFiles, ...options.files }, + symlinks: workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + }) + const reported: Array = [] + const cwd = process.cwd() + const nodeEnv = process.env.NODE_ENV + // In the app's directory, as `rsbuild build` and `rsbuild preview` run + process.chdir(app.root) + try { + // The app's `rsbuild.config.ts`, for `rsbuild build` and then for + // `rsbuild preview` (each command configures the app anew) + const rsbuild = () => + createRsbuild({ + cwd: app.root, + rsbuildConfig: { + logLevel: 'silent', + plugins: [ + pluginReact(), + tanstackStart({ + ...options.start, + rsc: { enabled: true }, + }) as never, + ], + // Start serves the pages, not an HTML template + tools: { htmlPlugin: false }, + server: { host: '127.0.0.1' }, + // Absolute: Start's preview middleware imports the server build + // from the output directory, which it resolves against the + // process's working directory when the first request comes + output: { distPath: { root: path.join(app.root, 'dist') } }, + }, + }) + await withBuildEnvironment('production', reported, async () => { + const built = await (await rsbuild()).build() + await built.close() + }) + process.env.NODE_ENV = 'production' + const { server, urls } = await ( + await rsbuild() + ).preview({ getPortSilently: true }) + registerCleanup(async () => { + await server.close() + process.env.NODE_ENV = nodeEnv + }) + const url = urls[0] + if (!url) { + throw new Error('the preview server does not listen') + } + return { + root: app.root, + url, + messages: reported.map(({ text }) => text), + errors: reported + .filter(({ severity }) => severity === 'error') + .map(({ text }) => text), + } + } finally { + process.chdir(cwd) + } +} + +export interface RscRsbuildDevServerOptions extends Omit< + RsbuildDevServerOptions, + 'dir' | 'plugins' | 'entry' +> { + /** Start's plugin options (`tanstackStart(options)`), `rsc` enabled. */ + start?: Record + /** + * Runs the server with the app root as the working directory, as + * `rsbuild dev` in the app does (default `true`). With `false`, the test + * process's directory stays (`rsbuild dev --root ` from elsewhere). + */ + inAppDirectory?: boolean +} + +/** + * Starts an Rsbuild dev server on a React Start app with RSC enabled, of + * `files` over `rscAppFiles`, with the built `@tanstack/react-start/plugin/ + * rsbuild` (Start's client and SSR environments, its default entries, the + * RSC layer and `react-server-dom-rspack`) and `@rsbuild/plugin-react`, as + * an Rsbuild React app lists them (unless `config.plugins` has it, e.g. + * with other options). With `browser`, Start's own dev middleware serves + * the pages (SSR) and Rsbuild's HMR client runs in the page. + */ +export async function startRscRsbuildDevServer( + options: RscRsbuildDevServerOptions, +): Promise { + const { + files, + start, + config, + inAppDirectory = true, + ...devServerOptions + } = options + const tanstackStart = await tanstackStartPlugin('rsbuild') + const cwd = process.cwd() + try { + return await createRsbuildDevServer({ + dir: harnessDir, + prefix: '.rsc-rsbuild-dev-server-', + registerCleanup: onTestFinished, + ...devServerOptions, + // Start's plugin defines the entries of its environments (the harness + // default is overridden by its client entry of the same name). + entry: 'src/router.tsx', + files: { ...rscAppFiles, ...files }, + symlinks: { + ...workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + ...devServerOptions.symlinks, + }, + config: { + ...config, + tools: { + // Start serves the pages, not an HTML template + htmlPlugin: false, + ...config?.tools, + }, + }, + plugins: [ + ...(pluginNames(config?.plugins).includes('rsbuild:react') + ? [] + : [pluginReact()]), + { + name: 'rsc-app:working-directory', + setup(api) { + if (inAppDirectory) { + process.chdir(api.context.rootPath) + } + }, + }, + tanstackStart({ ...start, rsc: { enabled: true } }) as never, + ], + }) + } finally { + process.chdir(cwd) + } +} + +/** The HTTP requests of a page in flight, and when that last changed. */ +interface Network { + pending: Set + changed: number +} + +const networks = new WeakMap() + +/** + * Opens `pathname` of a dev server with `browser` in a real page, closed + * when the current test finishes unless `registerCleanup` says otherwise. + * The page's requests from then on are tracked for `settledValue`. + */ +export async function openRscPage( + server: Pick, + pathname: string, + options: { registerCleanup?: (cleanup: () => Promise) => void } = {}, +): Promise { + if (!server.url) { + throw new Error('the dev server does not listen: start it with `browser`') + } + const page = await openPage(new URL(pathname, server.url).href, { + registerCleanup: options.registerCleanup ?? onTestFinished, + }) + const network: Network = { pending: new Set(), changed: Date.now() } + page.page.on('request', (request) => { + network.pending.add(request) + network.changed = Date.now() + }) + const done = (request: unknown) => { + if (network.pending.delete(request)) { + network.changed = Date.now() + } + } + page.page.on('requestfinished', done) + page.page.on('requestfailed', done) + networks.set(page, network) + return page +} + +/** + * Reads `read()` until `accept` takes its value, or until the page's + * network has settled (no request in flight for `quiet` ms, default 500) + * and one more read still does not: then whatever the page will show + * without another request, e.g. a stylesheet that never arrives. Gives up + * after `timeout` ms (default 15 000). Gives the last value read; the test + * asserts on it. For pages of `openRscPage`. + */ +export async function settledValue( + page: BrowserPage, + read: () => Promise, + accept: (value: T) => boolean, + { quiet = 500, timeout = 15_000 } = {}, +): Promise { + const network = networks.get(page) + if (!network) { + throw new Error('settledValue needs a page of openRscPage') + } + const deadline = Date.now() + timeout + for (;;) { + const settled = + network.pending.size === 0 && Date.now() - network.changed >= quiet + let value: T | undefined + let readable = true + try { + value = await read() + } catch (error) { + // The page is (re)loading + readable = false + if (Date.now() > deadline) { + throw error + } + } + if (readable && (accept(value as T) || settled || Date.now() > deadline)) { + return value as T + } + await new Promise((resolve) => setTimeout(resolve, 50)) + } +} + +/** + * Waits until the app hydrated in the page (the root route of `rscAppFiles` + * shows it through the router's `useHydrated()`): only then does the page + * run the client, e.g. its HMR listeners. + */ +export function waitForHydration(page: BrowserPage): Promise { + return page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) +} + +/** + * Waits until Start's development-only stylesheet of the server-rendered + * page (`/@tanstack-start/styles.css`, which prevents a flash of unstyled + * content before hydration and which the client removes once it hydrated) + * is gone, so that the computed styles come from what the client loaded. + */ +export async function devStylesGone(page: BrowserPage): Promise { + await page.page.waitForFunction( + () => + document.querySelector('link[href*="/@tanstack-start/styles.css"]') === + null, + undefined, + { timeout: 15_000 }, + ) +} + +/** + * The computed value of a CSS `property` of the first element matching + * `selector` in the page, as the browser resolves it (colours as + * `rgb(r, g, b)`). + */ +export function computedStyle( + page: BrowserPage, + selector: string, + property: string, +): Promise { + return page.page + .locator(selector) + .first() + .evaluate( + (element, name) => getComputedStyle(element).getPropertyValue(name), + property, + ) +} + +/** + * Waits until the computed `property` of `selector` is `expected`, for at + * most `timeout` ms (default 15 000): a hot update applies asynchronously. + * Throws with the current value, the page's errors and console otherwise. + */ +export async function waitForStyle( + page: BrowserPage, + selector: string, + property: string, + expected: string, + timeout = 15_000, +): Promise { + const deadline = Date.now() + timeout + let current = '' + for (;;) { + try { + current = await computedStyle(page, selector, property) + } catch { + // The page is reloading + current = '' + } + if (current === expected) { + return + } + if (Date.now() > deadline) { + throw new Error( + [ + `${selector}'s ${property} did not become ${expected} within ${timeout} ms`, + `it is: ${JSON.stringify(current)}`, + `page loads: ${page.loads()}`, + `errors:\n${page.errors.join('\n') || '(none)'}`, + `console:\n${page.console.join('\n') || '(none)'}`, + ].join('\n'), + ) + } + await new Promise((resolve) => setTimeout(resolve, 50)) + } +} diff --git a/packages/react-start-rsc/tests/integration/rsc-css-app.ts b/packages/react-start-rsc/tests/integration/rsc-css-app.ts new file mode 100644 index 0000000000..7fa2f43a9e --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-app.ts @@ -0,0 +1,347 @@ +/** + * The RSC CSS suites (SPEC J7) on a Vite dev server (`rsc-app.ts`): a React + * Start app whose page shows one section per row. Each row is a module + * (`src/rows/.tsx`) with a server function that renders a server + * component with an RSC helper; the page's loader calls the server + * functions of the rows the page renders, and the page decodes the Flight + * stream of the `renderToReadableStream` rows in the browser. A test reads + * its row's section: the server component's content and the computed styles + * of its CSS. + * + * Rows do not affect each other: each has its own CSS module (scoped class + * names of its own, so a stylesheet one row receives does not style + * another's component), its own error boundary, and its loader result is + * settled on its own (a server function that throws shows in its section + * only). + * + * Mechanism is free (SPEC §5): how the CSS travels (`loadCss`, envelopes, + * link precedence) is never asserted, only that the component is styled. + */ +import { afterAll, beforeAll } from 'vitest' +import { + computedStyle, + devStylesGone, + openRscPage, + settledValue, + startRscDevServer, + waitForHydration, +} from './rsc-app' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +/** A row's `Card` background (its CSS module). */ +export const CARD_BACKGROUND = 'rgb(254, 243, 199)' +/** A row's `Badge` background (its CSS module). */ +export const BADGE_BACKGROUND = 'rgb(224, 242, 254)' +/** `src/global.css` colour (`.plain`). */ +export const GLOBAL_COLOR = 'rgb(1, 2, 3)' + +/** + * How the page consumes what the row's server function returns: + * `renderable` renders it (`renderServerComponent`); `composite` renders it + * through `CompositeComponent` with a `children` slot; `flight` decodes the + * Flight stream the server function answers with + * (`renderToReadableStream`) in the browser, and renders the decoded tree + * (or its validated `card` and scalar sibling, for a plain-data model); `value` prints it as JSON. + */ +export type Consumer = 'renderable' | 'composite' | 'flight' | 'model' | 'value' + +export interface Row { + /** Module name (`src/rows/.tsx`) and section of the row. */ + key: string + /** Import declarations of the row's module. */ + imports: string + /** Body of the server function's handler (returns the value). */ + body: string + consumer: Consumer + /** Exercise a JavaScript provider module instead of TypeScript. */ + jsx?: boolean + /** Runtime input sent through the real server-function protocol. */ + input?: boolean +} + +/** + * The local server components a row's module uses (`Card`, `Badge`), with + * the row's own CSS module. Only those: a component nothing uses would stay + * in the client's module with its stylesheet. Local, not exported: Vite's + * RSC plugin delivers the CSS of an exported component by itself, so only a + * local component shows what Start's transform does. + */ +function localComponents(row: Row): string { + const card = row.body.includes('Card') + const badge = row.body.includes('Badge') + if (!card && !badge) { + return '' + } + return `import styles from './${row.key}.module.css' +${ + card + ? `function Card({ children }${row.jsx ? '' : ': { children?: React.ReactNode }'}) { + return
MARK_CARD{children}
+} +` + : '' +}${ + badge + ? `function Badge() { + return MARK_BADGE +} +` + : '' + }` +} + +/** The module of a row: `render`, its server function. */ +function rowModule(row: Row): string { + return `import { createServerFn } from '@tanstack/react-start' +${row.imports}${localComponents(row)} +const flight = (stream${row.jsx ? '' : ': ReadableStream'}, evaluations = 0) => + new Response(stream, { headers: { 'Content-Type': 'text/x-component', 'X-Evaluations': String(evaluations) } }) +export const render = createServerFn().validator((data${row.jsx ? '' : ': unknown'}) => data).handler(async ({ data }) => { +${row.body} +}) +` +} + +/** The section of a row in the page. */ +function section(row: Row, index: number): string { + const result = `data.r${index}` + const content = { + renderable: `{(value) => value}`, + composite: `{(value) => ( + + MARK_SLOT + + )}`, + flight: ``, + model: ``, + value: `{(value) =>
{JSON.stringify(value)}
}
`, + }[row.consumer] + return `
+ ${content} +
` +} + +/** + * The page (`/`): the loader calls the server function of every row but + * the `flight` ones (which the page calls from the browser), each result + * settled on its own. + */ +function pageRoute(rows: Array): string { + const loaded = rows + .map((row, index) => ({ row, index })) + .filter(({ row }) => row.consumer !== 'flight' && row.consumer !== 'model') + return `import { createFileRoute } from '@tanstack/react-router' +import { CompositeComponent, createFromFetch } from '@tanstack/react-start/rsc' +import { Component, Suspense, useEffect, useState } from 'react' +${rows.map((row, index) => `import { render as render${index} } from '../rows/${row.key}'`).join('\n')} +${rows.map((row, index) => `const call${index} = () => render${index}(${row.input === undefined ? '' : `{ data: ${row.input} }`})`).join('\n')} + +type Result = { value: any } | { error: string } +const settle = (promise: Promise): Promise => + promise.then( + (value) => ({ value }), + (error) => ({ error: String(error) }), + ) + +export const Route = createFileRoute('/')({ + loader: async () => { + const [${loaded.map(({ index }) => `r${index}`).join(', ')}] = await Promise.all([ +${loaded.map(({ index }) => ` settle(call${index}()),`).join('\n')} + ]) + return { ${loaded.map(({ index }) => `r${index}`).join(', ')} } + }, + component: Page, +}) + +function Failed({ error }: { error: string }) { + return

ERROR {error}

+} + +class Boundary extends Component<{ children: React.ReactNode }, { error?: string }> { + state: { error?: string } = {} + static getDerivedStateFromError(error: unknown) { + return { error: String(error) } + } + render() { + return this.state.error ? : this.props.children + } +} + +function Settled({ result, children }: { result: Result; children: (value: any) => React.ReactNode }) { + return 'error' in result ? : <>{children(result.value)} +} + +// One call per row, however often React mounts its section. +const decoded = new Map>() +function Flight({ render, model = false }: { render: () => Promise; model?: boolean }) { + const [decodedTree, setDecodedTree] = useState<{ value: unknown } | null>(null) + const [error, setError] = useState('') + const [evaluations, setEvaluations] = useState('') + useEffect(() => { + let tree = decoded.get(render) + if (!tree) { + tree = createFromFetch(render().then((response) => { + setEvaluations(response.headers.get('X-Evaluations') ?? '') + return response + })) + decoded.set(render, tree) + } + tree.then((value) => setDecodedTree({ value }), (reason) => setError(String(reason))) + }, []) + if (error) { + return + } + const tree = decodedTree?.value + if (model) { + if (!tree || typeof tree !== 'object' || !('card' in tree) || !('label' in tree) || tree.label !== 'MARK_MODEL') { + return decodedTree === null ? null : + } + return <>{tree.label as string}{tree.card as React.ReactNode} + } + return <>{tree as React.ReactNode} +} + +function Page() { + const data = Route.useLoaderData() + return ( +
+${rows.map(section).join('\n')} +
+ ) +} +` +} + +/** Import of `renderToReadableStream` (named, `@tanstack/react-start/rsc`). */ +export const streamImport = `import { renderToReadableStream } from '@tanstack/react-start/rsc'\n` +/** Import of `renderServerComponent` (named, `@tanstack/react-start/rsc`). */ +export const renderableImport = `import { renderServerComponent } from '@tanstack/react-start/rsc'\n` + +export interface RscCssApp { + /** The shared dev server. */ + server: () => DevServer + /** The page, once every section shows something and the page hydrated. */ + page: () => BrowserPage + /** The text of a row's section. */ + text: (row: Row) => Promise + /** + * The computed `property` of `selector` in a row's section once it is + * `expected`, or once the page's network has settled without it (a + * stylesheet loads asynchronously; a page whose requests are all done has + * every stylesheet it will get). `missing` if the section has no such + * element. + */ + style: ( + row: Row, + selector: string, + property: string, + expected: string, + ) => Promise + /** + * The URLs of the client environment's module of a row and of what it + * imports, outside `node_modules` and Vite's own modules. + */ + clientModules: (row: Row) => Promise> +} + +/** + * In `beforeAll`: starts the dev server of an app with the page of `rows` + * (and `files`) and opens the page; stops both in `afterAll`. + */ +export function rscCssApp(options: { + rows: Array + files?: Record + config?: Record +}): RscCssApp { + let server: DevServer | undefined + let page: BrowserPage | undefined + const cleanups: Array<() => Promise> = [] + const registerCleanup = (cleanup: () => Promise) => { + cleanups.push(cleanup) + } + + beforeAll(async () => { + server = await startRscDevServer({ + browser: true, + registerCleanup, + files: { + 'src/global.css': `.plain { color: rgb(1, 2, 3); }\n`, + ...options.files, + ...Object.fromEntries( + options.rows.flatMap((row) => [ + [`src/rows/${row.key}.${row.jsx ? 'jsx' : 'tsx'}`, rowModule(row)], + [ + `src/rows/${row.key}.module.css`, + // The row in the content: Vite's scoped class names hash the + // stylesheet's content, not its path. + `/* ${row.key} */\n.card { background: #fef3c7; }\n.badge { background: #e0f2fe; }\n`, + ], + ]), + ), + 'src/routes/index.tsx': pageRoute(options.rows), + }, + config: options.config, + }) + page = await openRscPage(server, '/', { registerCleanup }) + await page.page.waitForFunction( + () => + [...document.querySelectorAll('section[data-row]')].every( + (element) => + element.textContent !== '' || + element.querySelector('[data-flight-ready="true"]') !== null, + ), + undefined, + { timeout: 30_000 }, + ) + await waitForHydration(page) + await devStylesGone(page) + }) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + const started = (value: T | undefined): T => { + if (!value) { + throw new Error('the app did not start') + } + return value + } + const inRow = (row: Row, selector = '') => + `section[data-row="${row.key}"] ${selector}`.trim() + + return { + server: () => started(server), + page: () => started(page), + text: async (row) => + (await started(page).page.locator(inRow(row)).textContent()) ?? '', + style: async (row, selector, property, expected) => { + const current = started(page) + return settledValue( + current, + async () => + (await current.page.locator(inRow(row, selector)).count()) === 0 + ? 'missing' + : computedStyle(current, inRow(row, selector), property), + (value) => value === expected, + ) + }, + clientModules: async (row) => + Object.keys( + await started(server).load( + `/src/rows/${row.key}.${row.jsx ? 'jsx' : 'tsx'}`, + { + environment: 'client', + skip: /\/node_modules\/|^\/@(vite|react-refresh)\b/, + }, + ), + ), + } +} + +/** The client module URLs that are stylesheets or `src/plain`. */ +export function stylesheetsOf(urls: Array): Array { + return urls.filter((url) => /\.css\b|\/src\/plain/.test(url)) +} diff --git a/packages/react-start-rsc/tests/integration/rsc-css-diagnostics.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-diagnostics.test.ts new file mode 100644 index 0000000000..8e68733454 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-diagnostics.test.ts @@ -0,0 +1,51 @@ +import { expect, test } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { startRscDevServer, startRscRsbuildDevServer } from './rsc-app' + +const files = { + 'src/stream.tsx': `import { createServerFn } from '@tanstack/react-start' +import { renderToReadableStream } from '@tanstack/react-start/rsc' +import styles from './stream.module.css' +function Card() { return
MARK_STREAM
} +export const render = createServerFn().handler(async () => { + const node = + const args = [node] as const + const first = renderToReadableStream(node) + const second = renderToReadableStream(...args) + await Promise.all([new Response(first).text(), new Response(second).text()]) + return 'MARK_STREAMS_RENDERED' +}) +`, + 'src/stream.module.css': '.card { color: red }', + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { render } from '../stream' +export const Route = createFileRoute('/')({ + loader: () => render(), + component: () =>
{Route.useLoaderData()}
, +}) +`, +} + +// J7.3, G5: the real RSC integration currently skips identifier and +// spread arguments silently. Two calls in one file require one warning naming the file. +// G5 requires positions on errors, not on this warning; wording/channel are free. +test.fails.each(['vite', 'rsbuild'] as const)( + '%s dev warns about the CSS limitation once per source file, naming it', + async (bundler) => { + const server = await ( + bundler === 'vite' ? startRscDevServer : startRscRsbuildDevServer + )({ + files, + browser: true, + }) + const response = await fetch(server.url!) + expect(response.ok).toBe(true) + expect(await response.text()).toContain('MARK_STREAMS_RENDERED') + expectDiagnostic(server.diagnostics, { + severity: 'warning', + file: 'src/stream.tsx', + root: server.root, + times: 1, + }) + }, +) diff --git a/packages/react-start-rsc/tests/integration/rsc-css-hmr-rsbuild.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-hmr-rsbuild.test.ts new file mode 100644 index 0000000000..bf7204e462 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-hmr-rsbuild.test.ts @@ -0,0 +1,33 @@ +import { expect, test } from 'vitest' +import { startRscRsbuildDevServer, waitForStyle } from './rsc-app' +import { CARD_BACKGROUND, appFiles, rows, show } from './rsc-css-rsbuild-app' + +// SPEC J7.5 on Rsbuild: editing a server component's CSS updates the open +// page's effective styles without a full reload. +test("Rsbuild: editing a server component's CSS updates the page without a full reload", async () => { + const styles = (background: string) => + `.card { background: ${background}; }\n` + const server = await startRscRsbuildDevServer({ + browser: true, + files: { ...appFiles, 'src/card.module.css': styles('#fef3c7') }, + }) + const page = await show(server, rows[1]!.path) + await waitForStyle( + page, + '[data-testid=card]', + 'background-color', + CARD_BACKGROUND, + 5_000, + ) + + await server.edit({ 'src/card.module.css': styles('#e0f2fe') }) + expect(server.errors).toEqual([]) + await waitForStyle( + page, + '[data-testid=card]', + 'background-color', + 'rgb(224, 242, 254)', + ) + expect(page.loads()).toBe(1) + expect(page.errors).toEqual([]) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-css-hmr.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-hmr.test.ts new file mode 100644 index 0000000000..93ad5c4f5d --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-hmr.test.ts @@ -0,0 +1,73 @@ +/** + * RSC CSS hot updates (SPEC J7.5) on Vite dev (`rsc-app.ts`): editing the + * CSS of a server component updates the open page's effective styles, the + * last edit wins, and removing a rule or the import removes its effect, all + * without a full reload. The Rsbuild counterpart is in + * rsc-css-rsbuild.test.ts. + */ +import { expect, test } from 'vitest' +import { + openRscPage, + startRscDevServer, + waitForHydration, + waitForStyle, +} from './rsc-app' + +const card = ( + css: boolean, +) => `${css ? `import styles from './card.module.css'\n` : ''} +export function Card() { + return
MARK_CARD
+} +` +const route = `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { renderServerComponent } from '@tanstack/react-start/rsc' +import { Card } from '../card' +const render = createServerFn().handler(() => renderServerComponent()) +export const Route = createFileRoute('/')({ + loader: () => render(), + component: () =>
{Route.useLoaderData()}
, +}) +` +const styles = (background: string) => `.card { background: ${background}; }\n` + +test("editing a server component's CSS updates the page without a full reload", async () => { + const server = await startRscDevServer({ + browser: true, + files: { + 'src/card.module.css': styles('#fef3c7'), + 'src/card.tsx': card(true), + 'src/routes/index.tsx': route, + }, + }) + const page = await openRscPage(server, '/') + await page.waitForText('MARK_CARD') + const background = (expected: string) => + waitForStyle(page, '[data-testid=card]', 'background-color', expected) + await background('rgb(254, 243, 199)') + + await waitForHydration(page) + + // A new value + await server.write({ 'src/card.module.css': styles('#e0f2fe') }) + await background('rgb(224, 242, 254)') + + // Twice in a row: the last edit wins, nothing stale stays effective + await server.write({ 'src/card.module.css': styles('#fef3c7') }) + await server.write({ 'src/card.module.css': styles('rgb(1, 2, 3)') }) + await background('rgb(1, 2, 3)') + + // The rule removed + await server.write({ 'src/card.module.css': `.other { color: red; }\n` }) + await background('rgba(0, 0, 0, 0)') + + // The rule back, then the import removed + await server.write({ 'src/card.module.css': styles('#fef3c7') }) + await background('rgb(254, 243, 199)') + await server.write({ 'src/card.tsx': card(false) }) + await background('rgba(0, 0, 0, 0)') + + expect(page.loads()).toBe(1) + expect(page.errors).toEqual([]) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-css-matrix.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-matrix.test.ts new file mode 100644 index 0000000000..2affddbd63 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-matrix.test.ts @@ -0,0 +1,108 @@ +/** + * RSC CSS delivery (SPEC J7.2, J7.3) through the real transport on Vite + * dev (`rsc-css-app.ts`): every RSC helper through every import form + * (named, renamed, namespace) of both module names styles the server + * component it renders. + */ +import { describe, expect, test } from 'vitest' +import { CARD_BACKGROUND, rscCssApp, stylesheetsOf } from './rsc-css-app' +import type { Row } from './rsc-css-app' + +const apis = [ + { + api: 'renderServerComponent', + consumer: 'renderable' as const, + call: (callee: string, node: string) => `return ${callee}(${node})`, + }, + { + api: 'createCompositeComponent', + consumer: 'composite' as const, + call: (callee: string, node: string) => + `return ${callee}((props) => <>{${node}}{props.children})`, + }, + { + api: 'renderToReadableStream', + consumer: 'flight' as const, + call: (callee: string, node: string) => `return flight(${callee}(${node}))`, + }, +] + +const importForms = [ + { + form: 'a named import', + key: 'named', + declaration: (api: string, from: string) => + `import { ${api} } from '${from}'\n`, + callee: (api: string) => api, + }, + { + form: 'a renamed import', + key: 'renamed', + declaration: (api: string, from: string) => + `import { ${api} as rsc } from '${from}'\n`, + callee: () => 'rsc', + }, + { + form: 'a namespace import', + key: 'namespace', + declaration: (_api: string, from: string) => + `import * as RSC from '${from}'\n`, + callee: (api: string) => `RSC.${api}`, + }, +] + +const modules = [ + { from: '@tanstack/react-start/rsc', key: 'start' }, + { from: '@tanstack/react-start-rsc', key: 'rsc' }, +] + +/** Every API through every import form of both module names. */ +const matrix = importForms.flatMap((form) => + modules.flatMap(({ from, key }) => + apis.map((api) => ({ + ...form, + ...api, + from, + row: { + key: `${form.key}-${key}-${api.consumer}`, + imports: form.declaration(api.api, from), + body: api.call(form.callee(api.api), ''), + consumer: api.consumer, + } satisfies Row, + })), + ), +) + +describe('RSC helpers by import form (Vite dev)', () => { + const app = rscCssApp({ rows: matrix.map(({ row }) => row) }) + + test.each(matrix)( + '$api through $form of $from styles the server component', + async ({ row, consumer }) => { + expect( + await app.style( + row, + '[data-testid=card]', + 'background-color', + CARD_BACKGROUND, + ), + ).toBe(CARD_BACKGROUND) + // The server component renders unchanged; a composite's slot renders + // after it (J7.4: injection changes nothing else). + expect(await app.text(row)).toBe( + consumer === 'composite' ? 'MARK_CARDMARK_SLOT' : 'MARK_CARD', + ) + }, + ) + + // J4.12, and the control of the rows above: the client never loads a + // stylesheet of a row's module itself (the handler, and so the render + // call and the local component, are absent), so a styled section shows + // the CSS the RSC payload delivered. + test.each(matrix)( + "the client's module of $api through $form of $from loads no stylesheet", + async ({ row }) => { + expect(stylesheetsOf(await app.clientModules(row))).toEqual([]) + }, + ) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-app.ts b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-app.ts new file mode 100644 index 0000000000..286f30b797 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-app.ts @@ -0,0 +1,260 @@ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + computedStyle, + openRscPage, + startRscRsbuildDevServer, + startRscRsbuildPreviewServer, + waitForHydration, + waitForStyle, +} from './rsc-app' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' + +/** `card.module.css` background. */ +export const CARD_BACKGROUND = 'rgb(254, 243, 199)' +/** `helperCard.module.css` background. */ +export const HELPER_CARD_BACKGROUND = 'rgb(224, 242, 254)' + +/** + * A route whose server function renders a local server component with a + * CSS module through `api`; `consumer` is how the page renders the result. + */ +const route = ( + path: string, + imports: string, + body: string, + page: string, +) => `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +${imports} +import styles from '../card.module.css' +function Card({ children }: { children?: React.ReactNode }) { + return
MARK_CARD{children}
+} +const flight = (stream: ReadableStream) => + new Response(stream, { headers: { 'Content-Type': 'text/x-component' } }) +export const render = createServerFn().handler(async () => { +${body} +}) +export const Route = createFileRoute('${path}')({ +${path === '/flight' ? '' : ' loader: () => render(),\n'} component: Page, +}) +${page} +` + +export const rows = [ + { + api: 'renderToReadableStream', + path: '/flight', + file: route( + '/flight', + `import { createFromFetch, renderToReadableStream } from '@tanstack/react-start/rsc' +import { useEffect, useState } from 'react'`, + ` return flight(renderToReadableStream())`, + `function Page() { + const [tree, setTree] = useState(null) + useEffect(() => { + createFromFetch(render()).then(setTree) + }, []) + return
{tree as React.ReactNode}
+}`, + ), + }, + { + api: 'renderServerComponent', + path: '/renderable', + file: route( + '/renderable', + `import { renderServerComponent } from '@tanstack/react-start/rsc'`, + ` return renderServerComponent()`, + `function Page() { + return
{Route.useLoaderData()}
+}`, + ), + }, + { + api: 'createCompositeComponent', + path: '/composite', + file: route( + '/composite', + `import { CompositeComponent, createCompositeComponent } from '@tanstack/react-start/rsc'`, + ` return createCompositeComponent((props) => {props.children})`, + `function Page() { + return ( +
+ + MARK_SLOT + +
+ ) +}`, + ), + }, +] + +/** + * A route whose server function calls a helper module that renders a local + * server component with its own CSS module through `renderServerComponent`. + */ +export const helperRow = { + path: '/helper', + marker: 'MARK_HELPER', + files: { + 'src/helperCard.module.css': `.card { background: #e0f2fe; }\n`, + 'src/renderHelperCard.tsx': `import { renderServerComponent } from '@tanstack/react-start/rsc' +import styles from './helperCard.module.css' +function HelperCard() { + return
MARK_HELPER
+} +export function renderHelperCard() { + return renderServerComponent() +} +`, + 'src/routes/helper.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { renderHelperCard } from '../renderHelperCard' +export const render = createServerFn().handler(async () => { + return renderHelperCard() +}) +export const Route = createFileRoute('/helper')({ + loader: () => render(), + component: Page, +}) +function Page() { + return
{Route.useLoaderData()}
+} +`, + }, +} + +export const appFiles = { + 'src/routes/control.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { render as flight } from './flight' +import { render as renderable } from './renderable' +import { render as composite } from './composite' +export const Route = createFileRoute('/control')({ component: Control }) +function Control() { + return
+} +`, + 'src/card.module.css': `.card { background: #fef3c7; }\n`, + ...Object.fromEntries( + rows.map((row) => [`src/routes${row.path}.tsx`, row.file]), + ), + ...helperRow.files, +} + +/** Opens `path` and waits for the server component (`marker`) and hydration. */ +export async function show( + server: Pick, + path: string, + marker = 'MARK_CARD', +): Promise { + const page = await openRscPage(server, path) + await page.waitForText(marker) + await waitForHydration(page) + return page +} + +/** + * The rows of rsc-css-rsbuild.test.ts (`dev`: an Rsbuild dev server) and + * rsc-css-rsbuild-build.test.ts (`build`: a production build served by + * `rsbuild preview`), one file per mode so the two run in parallel. + */ +export function describeRscCssRows(mode: 'dev' | 'build') { + describe(`RSC CSS through the real transport (Rsbuild ${mode})`, () => { + let server: Pick + const cleanups: Array<() => Promise> = [] + + beforeAll(async () => { + const registerCleanup = (cleanup: () => Promise) => { + cleanups.push(cleanup) + } + server = + mode === 'dev' + ? await startRscRsbuildDevServer({ + browser: true, + registerCleanup, + files: appFiles, + }) + : await startRscRsbuildPreviewServer({ + registerCleanup, + files: appFiles, + }) + }) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + test('loading only the client callers does not supply the server stylesheet', async () => { + const page = await openRscPage(server, '/control') + await page.waitForText('caller', { selector: '[data-testid=control]' }) + await waitForHydration(page) + const css = await page.page.evaluate(() => + [...document.styleSheets] + .flatMap((sheet) => { + try { + return [...sheet.cssRules].map((rule) => rule.cssText) + } catch { + return [] + } + }) + .join('\n'), + ) + expect(css).not.toMatch(/254, 243, 199|#fef3c7/i) + expect(page.errors).toEqual([]) + }) + + test.each(rows)( + '$api in a server function module styles the server component', + async ({ path }) => { + expect(server.errors).toEqual([]) + const page = await show(server, path) + await waitForStyle( + page, + '[data-testid=card]', + 'background-color', + CARD_BACKGROUND, + 5_000, + ) + expect( + await computedStyle(page, '[data-testid=card]', 'background-color'), + ).toBe(CARD_BACKGROUND) + expect(page.errors).toEqual([]) + }, + ) + + // Bug: on Rsbuild, the RSC CSS transform only rewrites server function + // provider modules (`serverFnProviderOnly: true`, react-start + // src/plugin/rsbuild.ts; react-start-rsc src/plugin/rscCssTransform.ts), so + // a render call in a helper module that a server function calls gets no CSS. + // Impact: the server component renders unstyled; Vite styles it + // (rsc-css.test.ts, "two render helpers in one module each carry their + // component CSS"). + // Source: SPEC J7.1, J7.2 (CSS is delivered wherever the render executes). + test.fails( + 'a render call in a helper module styles the server component', + async () => { + expect(server.errors).toEqual([]) + const page = await show(server, helperRow.path, helperRow.marker) + await waitForStyle( + page, + '[data-testid=helper-card]', + 'background-color', + HELPER_CARD_BACKGROUND, + 5_000, + ) + expect( + await computedStyle( + page, + '[data-testid=helper-card]', + 'background-color', + ), + ).toBe(HELPER_CARD_BACKGROUND) + expect(page.errors).toEqual([]) + }, + ) + }) +} diff --git a/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-build.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-build.test.ts new file mode 100644 index 0000000000..f58b12fe7a --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-build.test.ts @@ -0,0 +1,9 @@ +/** + * The rows of rsc-css-rsbuild.test.ts (RSC CSS delivery, SPEC J7, through + * the real transport on Rsbuild) in an Rsbuild production build served by + * `rsbuild preview` (`rsc-app.ts`). The rows: `describeRscCssRows` + * (rsc-css-rsbuild-app.ts). + */ +import { describeRscCssRows } from './rsc-css-rsbuild-app' + +describeRscCssRows('build') diff --git a/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-root.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-root.test.ts new file mode 100644 index 0000000000..ba37614243 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild-root.test.ts @@ -0,0 +1,26 @@ +import { expect, test } from 'vitest' +import { startRscRsbuildDevServer } from './rsc-app' +import { appFiles, rows, show } from './rsc-css-rsbuild-app' + +// SPEC J4.16: discovery and wiring use the configured root, not the process +// working directory. +// Bug: Start's Rsbuild plugin writes its virtual modules (serialization +// adapters, RSC decode) under `/node_modules/.virtual` +// (rsbuild/virtual-modules.ts `virtualPath`, with `resolvedStartConfig.root` +// still empty at setup), where the app's `@tanstack/react-start` does not +// resolve when the process runs elsewhere (`rsbuild dev --root ` from +// a monorepo root). +// Impact: the dev server (and build) fails with "Module not found". +test.fails( + 'Rsbuild: the app compiles when the process does not run in the app directory', + async () => { + const server = await startRscRsbuildDevServer({ + browser: true, + inAppDirectory: false, + files: appFiles, + }) + expect(server.errors).toEqual([]) + const page = await show(server, rows[0]!.path) + expect(page.errors).toEqual([]) + }, +) diff --git a/packages/react-start-rsc/tests/integration/rsc-css-rsbuild.test.ts b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild.test.ts new file mode 100644 index 0000000000..e85cbffd23 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css-rsbuild.test.ts @@ -0,0 +1,14 @@ +/** + * RSC CSS delivery (SPEC J7) through the real transport on Rsbuild: a React + * Start app with RSC enabled on an Rsbuild dev server (`rsc-app.ts`, Start's + * RSC layer with `react-server-dom-rspack`), whose server functions render + * server components with the RSC helpers, and a real page that shows what + * the browser makes of the Flight payload, including a render call in a + * helper module the server function calls. The Vite counterpart, with the + * whole matrix, is rsc-css.test.ts; the production build: + * rsc-css-rsbuild-build.test.ts. The rows: `describeRscCssRows` + * (rsc-css-rsbuild-app.ts). + */ +import { describeRscCssRows } from './rsc-css-rsbuild-app' + +describeRscCssRows('dev') diff --git a/packages/react-start-rsc/tests/integration/rsc-css.test.ts b/packages/react-start-rsc/tests/integration/rsc-css.test.ts new file mode 100644 index 0000000000..12f394c4ca --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-css.test.ts @@ -0,0 +1,580 @@ +/** + * RSC CSS delivery (SPEC J7.2–J7.4) through the real transport on Vite dev + * (`rsc-css-app.ts`): argument shapes of the RSC helpers, a render call in a + * helper module, undocumented inputs that must not break, look-alikes that + * must stay untouched (SPEC G15) and forms that are not recognised but must + * still work. The import forms are in rsc-css-matrix.test.ts, CSS edits in + * rsc-css-hmr.test.ts. + */ +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { + BADGE_BACKGROUND, + CARD_BACKGROUND, + GLOBAL_COLOR, + renderableImport, + rscCssApp, + streamImport, + stylesheetsOf, +} from './rsc-css-app' +import { + computedStyle, + openRscPage, + settledValue, + waitForHydration, +} from './rsc-app' +import type { Row } from './rsc-css-app' + +const rows = { + // Both calls in one helper module deliver CSS. + helperA: { + key: 'helper-a', + imports: `import { renderA } from '../pair'\n`, + body: 'return renderA()', + consumer: 'renderable', + }, + helperB: { + key: 'helper-b', + imports: `import { renderB } from '../pair'\n`, + body: 'return renderB()', + consumer: 'renderable', + }, + // A .jsx provider is an equally supported input. + javascript: { + key: 'javascript', + imports: renderableImport, + body: 'return renderServerComponent()', + consumer: 'renderable', + jsx: true, + }, + // A fragment root with children from two components. + fragmentRenderable: { + key: 'fragment-renderable', + imports: renderableImport, + body: `return renderServerComponent(<>)`, + consumer: 'renderable', + }, + fragmentComposite: { + key: 'fragment-composite', + imports: `import { createCompositeComponent } from '@tanstack/react-start/rsc'\n`, + body: `return createCompositeComponent(() => <>)`, + consumer: 'composite', + }, + fragmentFlight: { + key: 'fragment-flight', + imports: streamImport, + body: `return flight(renderToReadableStream(<>))`, + consumer: 'flight', + }, + // A render call in a helper module the server function calls, with a + // global stylesheet. + globalCss: { + key: 'global-css', + imports: `import { renderPlain } from '../plain'\n`, + body: `return renderPlain()`, + consumer: 'renderable', + }, + parenthesised: { + key: 'parenthesised', + imports: streamImport, + body: `return flight(renderToReadableStream(()))`, + consumer: 'flight', + }, + asserted: { + key: 'asserted', + imports: streamImport, + body: `return flight(renderToReadableStream( as any))`, + consumer: 'flight', + }, + identifier: { + key: 'identifier', + imports: streamImport, + body: `const node = + return flight(renderToReadableStream(node))`, + consumer: 'flight', + }, + spread: { + key: 'spread', + imports: streamImport, + body: `const args = [] as const + return flight(renderToReadableStream(...args))`, + consumer: 'flight', + }, + ternary: { + key: 'ternary', + imports: streamImport, + body: `let evaluations = 0 + const stream = renderToReadableStream((++evaluations, data) ? : ) + return flight(stream, evaluations)`, + input: true, + consumer: 'flight', + }, + logicalAnd: { + key: 'logical-and', + imports: streamImport, + body: `let evaluations = 0 + const stream = renderToReadableStream((++evaluations, data) && ) + return flight(stream, evaluations)`, + input: true, + consumer: 'flight', + }, + ternaryFalse: { + key: 'ternary-false', + imports: streamImport, + body: `let evaluations = 0 + const stream = renderToReadableStream((++evaluations, data) ? : ) + return flight(stream, evaluations)`, + input: false, + consumer: 'flight', + }, + logicalFalse: { + key: 'logical-false', + imports: streamImport, + body: `let evaluations = 0 + const stream = renderToReadableStream((++evaluations, data) && ) + return flight(stream, evaluations)`, + input: false, + consumer: 'flight', + }, + options: { + key: 'options', + imports: streamImport, + body: `function Boom(): never { + throw new Error('MARK_BOOM') + } + let digest = '' + const stream = renderToReadableStream(, { + onError: (error: Error) => { + digest = 'MARK_DIGEST:' + error.message + return digest + }, + }) + const text = await new Response(stream).text() + return { digest, streamCarriesDigest: text.includes('MARK_DIGEST') }`, + consumer: 'value', + }, + plainModel: { + key: 'plain-model', + imports: streamImport, + body: `return flight(renderToReadableStream({ card: , label: 'MARK_MODEL' }))`, + consumer: 'model', + }, + blockComment: { + key: 'block-comment', + imports: streamImport, + body: `return flight(renderToReadableStream(/* the card */ ))`, + consumer: 'flight', + }, + lineComment: { + key: 'line-comment', + imports: streamImport, + body: `return flight(renderToReadableStream( + // the card + , + ))`, + consumer: 'flight', + }, + chained: { + key: 'chained', + imports: renderableImport, + body: `return renderServerComponent().then((value) => value)`, + consumer: 'renderable', + }, + // Look-alikes (SPEC G15): a foreign package's helper of the same name, a + // local shadowing the import, and a local shadowing the namespace get + // exactly the user's arguments. + foreignNamespace: { + key: 'foreign-namespace', + imports: `import * as RSC from 'other-rsc'\n`, + body: `const effects: Array = [] + return RSC.renderServerComponent(original-child)`, + consumer: 'value', + }, + foreignArguments: { + key: 'foreign-arguments', + imports: `import * as RSC from 'other-rsc'\n`, + body: `const effects: Array = [] + return RSC.renderServerComponent(original-child, (effects.push('first'), 'first'), (effects.push('second'), 2), effects)`, + consumer: 'value', + }, + shadowed: { + key: 'shadowed', + imports: renderableImport, + body: `const effects: Array = [] + const renderServerComponent = (...args) => ({ arity: args.length, label: args[0].props['data-label'], children: args[0].props.children, scalars: args.slice(1, 3), effects: [...effects] }) + return renderServerComponent(original-child)`, + consumer: 'value', + }, + shadowedArguments: { + key: 'shadowed-arguments', + imports: renderableImport, + body: `const effects: Array = [] + const renderServerComponent = (...args) => ({ arity: args.length, label: args[0].props['data-label'], children: args[0].props.children, scalars: args.slice(1, 3), effects: [...effects] }) + return renderServerComponent(original-child, (effects.push('first'), 'first'), (effects.push('second'), 2), effects)`, + consumer: 'value', + }, + shadowedNamespace: { + key: 'shadowed-namespace', + imports: `import * as RSC from '@tanstack/react-start/rsc'\n`, + body: `const effects: Array = [] + const RSC = { + renderServerComponent: (...args) => ({ arity: args.length, label: args[0].props['data-label'], children: args[0].props.children, scalars: args.slice(1, 3), effects: [...effects] }), + } + return RSC.renderServerComponent(original-child)`, + consumer: 'value', + }, + shadowedNamespaceArguments: { + key: 'shadowed-namespace-arguments', + imports: `import * as RSC from '@tanstack/react-start/rsc'\n`, + body: `const effects: Array = [] + const RSC = { + renderServerComponent: (...args) => ({ arity: args.length, label: args[0].props['data-label'], children: args[0].props.children, scalars: args.slice(1, 3), effects: [...effects] }), + } + return RSC.renderServerComponent(original-child, (effects.push('first'), 'first'), (effects.push('second'), 2), effects)`, + consumer: 'value', + }, + // Not recognised forms (J7.2: variables, wrappers and project re-exports + // of the helpers): CSS is not required, but the call must still work. + reexported: { + key: 'reexported', + imports: `import { renderThing } from '../render'\n`, + body: `return renderThing()`, + consumer: 'renderable', + }, + wrapper: { + key: 'wrapper', + imports: `import { wrap } from '../wrap'\n`, + body: `return wrap()`, + consumer: 'renderable', + }, + variable: { + key: 'variable', + imports: renderableImport, + body: `const render = renderServerComponent + return render()`, + consumer: 'renderable', + }, +} satisfies Record + +describe.concurrent('RSC CSS through the real transport (Vite dev)', () => { + const app = rscCssApp({ + rows: Object.values(rows), + files: { + ...Object.fromEntries( + ['a', 'b'].map((name) => [ + `src/routes/pair-${name}.tsx`, + `import { createFileRoute } from '@tanstack/react-router' +import { render } from '../rows/helper-${name}' +export const Route = createFileRoute('/pair-${name}')({ + loader: () => render(), + component: () =>
{Route.useLoaderData()}
, +}) +`, + ]), + ), + 'src/pair.module.css': `.a { background: #fef3c7; } .b { background: #e0f2fe; }\n`, + 'src/pair.tsx': `import { renderServerComponent } from '@tanstack/react-start/rsc' +import styles from './pair.module.css' +function A() { return
MARK_A
} +function B() { return
MARK_B
} +export function renderA() { return renderServerComponent() } +export function renderB() { return renderServerComponent() } +`, + 'src/plain.tsx': `import { renderServerComponent } from '@tanstack/react-start/rsc' +import './global.css' +export function renderPlain() { + return renderServerComponent(

MARK_PLAIN

) +} +`, + 'src/render.ts': `export { renderServerComponent as renderThing } from '@tanstack/react-start/rsc'\n`, + 'src/wrap.tsx': `import { renderServerComponent } from '@tanstack/react-start/rsc' +export const wrap = (node: React.ReactNode) => renderServerComponent(node) +`, + 'node_modules/other-rsc/package.json': JSON.stringify({ + name: 'other-rsc', + type: 'module', + exports: './index.js', + }), + 'node_modules/other-rsc/index.js': `export const renderServerComponent = (...args) => ({ arity: args.length, label: args[0].props['data-label'], children: args[0].props.children, scalars: args.slice(1, 3), effects: [...args[0].props['data-effects']] })\n`, + }, + // The app's own package (a look-alike row), pre-bundled like the rest. + config: { optimizeDeps: { include: ['other-rsc'] } }, + }) + + test('two render helpers in one module each carry their component CSS', async ({ + onTestFinished, + }) => { + // Separate browser contexts/results: renderA's stylesheet must not mask + // renderB missing its own delivery, even though both helpers share CSS. + for (const [name, marker, selector, expected] of [ + ['a', 'MARK_A', '[data-testid=card]', CARD_BACKGROUND], + ['b', 'MARK_B', '[data-testid=badge]', BADGE_BACKGROUND], + ] as const) { + const page = await openRscPage(app.server(), `/pair-${name}`, { + registerCleanup: onTestFinished, + }) + await page.waitForText(marker, { selector: 'main' }) + await waitForHydration(page) + expect( + await settledValue( + page, + () => computedStyle(page, selector, 'background-color'), + (value) => value === expected, + ), + ).toBe(expected) + expect(page.errors).toEqual([]) + } + }) + + test('a JavaScript provider carries its stylesheet with the RSC payload', async () => { + expect(await app.text(rows.javascript)).toBe('MARK_CARD') + expect( + await app.style( + rows.javascript, + '[data-testid=card]', + 'background-color', + CARD_BACKGROUND, + ), + ).toBe(CARD_BACKGROUND) + }) + + const cardBackground = (row: Row) => + app.style(row, '[data-testid=card]', 'background-color', CARD_BACKGROUND) + + // A JSX fragment root must get the CSS of every child, + // like an element root. + test.each([ + { name: 'renderServerComponent', row: rows.fragmentRenderable }, + { name: 'createCompositeComponent', row: rows.fragmentComposite }, + { name: 'renderToReadableStream', row: rows.fragmentFlight }, + ])('$name with a fragment root styles every child', async ({ row }) => { + expect({ + card: await cardBackground(row), + badge: await app.style( + row, + '[data-testid=badge]', + 'background-color', + BADGE_BACKGROUND, + ), + }).toEqual({ card: CARD_BACKGROUND, badge: BADGE_BACKGROUND }) + }) + + test('a render call in a helper module, with a global stylesheet, styles the server component', async () => { + expect( + await app.style( + rows.globalCss, + '[data-testid=plain]', + 'color', + GLOBAL_COLOR, + ), + ).toBe(GLOBAL_COLOR) + }) + + test.each([ + { wrapped: '()', row: rows.parenthesised }, + { wrapped: ' as any', row: rows.asserted }, + ])('renderToReadableStream($wrapped) styles the stream', async ({ row }) => { + expect(await cardBackground(row)).toBe(CARD_BACKGROUND) + expect(await app.text(row)).toBe('MARK_CARD') + }) + + // Arguments the transform cannot see the JSX of are left as they are: + // the stream still renders (CSS not required; dev warnings below). + test.each([ + { name: 'an identifier', row: rows.identifier }, + { name: 'a spread', row: rows.spread }, + ])('renderToReadableStream with $name still renders', async ({ row }) => { + expect(await app.text(row)).toBe('MARK_CARD') + }) + + // Bug: the transform only wraps an argument that is JSX itself, not a + // conditional or logical expression whose branches are all JSX, which is + // as safe to wrap. + // Impact: a stream of a conditionally chosen element has no CSS, so its + // styles never arrive. + // Source: SPEC J7.3. + test.fails.each([ + { argument: 'flag ? : ', row: rows.ternary }, + { argument: 'flag && ', row: rows.logicalAnd }, + ])('renderToReadableStream($argument) styles the stream', async ({ row }) => { + expect(await cardBackground(row)).toBe(CARD_BACKGROUND) + }) + + // Selection/effects are separate from the known missing-CSS goal above: + // a false result must never become a card or hide a transport error. + test.each([ + { row: rows.ternary, text: 'MARK_CARD' }, + { row: rows.ternaryFalse, text: 'MARK_BADGE' }, + { row: rows.logicalAnd, text: 'MARK_CARD' }, + { row: rows.logicalFalse, text: '' }, + ])( + 'conditional stream $row.key selects its runtime input and evaluates it once', + async ({ row, text }) => { + expect(await app.text(row)).toBe(text) + const selected = await app + .page() + .page.locator( + `section[data-row="${row.key}"] [data-testid=card], section[data-row="${row.key}"] [data-testid=badge]`, + ) + .evaluateAll((elements) => + elements.map((element) => element.getAttribute('data-testid')), + ) + expect(selected).toEqual( + text === 'MARK_CARD' + ? ['card'] + : text === 'MARK_BADGE' + ? ['badge'] + : [], + ) + expect( + await app + .page() + .page.locator(`section[data-row="${row.key}"] [data-evaluations]`) + .getAttribute('data-evaluations'), + ).toBe('1') + }, + ) + + // Bug: the alternate JSX branch has no CSS, just like the consequent + // (SPEC J7.3). + // Source: react-start-rsc src/plugin/rscCssTransform.ts:93: a conditional + // argument is not top-level JSX (`isTopLevelJsx`, 116-119, unwraps only + // parentheses and TS wrappers), so the transform skips the call and never + // wraps either branch with the CSS fragment (`createCssFragment`). + // Impact: choosing false renders the badge without its stylesheet. + test.fails( + 'a false ternary stream carries its selected badge CSS', + async () => { + expect( + await app.style( + rows.ternaryFalse, + '[data-testid=badge]', + 'background-color', + BADGE_BACKGROUND, + ), + ).toBe(BADGE_BACKGROUND) + }, + ) + + // The second `options` argument is undocumented (React Start's public + // type is `renderToReadableStream(node)`; `options` is typed only under + // the react-server condition). It must not break: the options reach + // React's renderer (its `onError` runs and its digest is in the stream). + // CSS is not required (SPEC J7.3). + test('renderToReadableStream(, options) renders with the options', async () => { + expect(JSON.parse(await app.text(rows.options))).toEqual({ + digest: 'MARK_DIGEST:MARK_BOOM', + streamCarriesDigest: true, + }) + }) + + // A plain-data model (`{ card: }`) is undocumented too: it must + // not break, and the model reaches the client. Neither CSS for its + // elements nor a warning is required, nor their absence (SPEC §2.2, + // J7.3). + test('renderToReadableStream with a plain-data model streams the model', async () => { + expect(await app.text(rows.plainModel)).toBe('MARK_MODELMARK_CARD') + }) + + // Bug: the transform silently skips a `renderToReadableStream` argument it + // cannot see the JSX of (a variable, a spread). + // Impact: the stream has no CSS, so its styles never arrive, and nothing + // tells the developer. + // Source: SPEC J7.3: warn in dev only. + test.fails.each([ + { name: 'an identifier', row: rows.identifier }, + { name: 'a spread', row: rows.spread }, + ])( + 'dev: renderToReadableStream with $name warns, naming the file', + ({ row }) => { + const server = app.server() + expectDiagnostic(server.diagnostics, { + severity: 'warning', + times: 1, + file: path.join('src/rows', `${row.key}.tsx`), + root: server.root, + }) + }, + ) + + test.each([ + { name: 'a foreign namespace', row: rows.foreignNamespace }, + { name: 'a shadowing local', row: rows.shadowed }, + { name: 'a local shadowing the namespace', row: rows.shadowedNamespace }, + { + name: 'a foreign namespace with scalar arguments', + row: rows.foreignArguments, + }, + { + name: 'a shadowing local with scalar arguments', + row: rows.shadowedArguments, + }, + { + name: 'a shadowed namespace with scalar arguments', + row: rows.shadowedNamespaceArguments, + }, + ])( + 'a look-alike helper of $name gets exactly the arguments the code passes', + async ({ row }) => { + const multiple = row.body.includes("effects.push('first')") + expect(JSON.parse(await app.text(row))).toEqual({ + arity: multiple ? 4 : 1, + label: 'original', + children: 'original-child', + scalars: multiple ? ['first', 2] : [], + effects: multiple ? ['element', 'first', 'second'] : ['element'], + }) + }, + ) + + test.each([ + { name: 'a project re-export', row: rows.reexported }, + { name: 'a project wrapper', row: rows.wrapper }, + { name: 'a variable', row: rows.variable }, + ])('renderServerComponent through $name still renders', async ({ row }) => { + expect(await app.text(row)).toBe('MARK_CARD') + }) + + // J4.12, and the control of the rows above: the client never loads a + // stylesheet of a row's module itself (the handler, and so the render + // call and the local components, are absent), so a styled section shows + // the CSS the RSC payload delivered. + test.each(Object.values(rows))( + "the client's module of row $key loads no stylesheet", + async (row) => { + expect(stylesheetsOf(await app.clientModules(row))).toEqual([]) + }, + ) + + describe('known bugs', () => { + // Bug: a comment before the JSX argument of `renderToReadableStream` is + // moved into the generated CSS fragment, where it becomes JSX text. + // Impact: the comment is rendered into the RSC payload as visible text. + test.fails.each([ + { name: 'a block comment', row: rows.blockComment }, + { name: 'a line comment', row: rows.lineComment }, + ])( + 'renderToReadableStream does not render $name before the JSX argument', + async ({ row }) => { + expect(await app.text(row)).toBe('MARK_CARD') + expect(await cardBackground(row)).toBe(CARD_BACKGROUND) + }, + ) + + // Bug: a call whose result is immediately member-called + // (`renderServerComponent(...).then()`) is recorded as the inner call of + // a method chain and never visited as a candidate itself. The root cause + // is shared with the other Start factories (e.g. a + // `createServerOnlyFn(...).bind()`); this is its only pin. + // Source: start-plugin-core/src/start-compiler/compiler.ts, candidate + // detection ("inner call in a chain"). + // Impact: the server component renders without its CSS. + test.fails( + 'renderServerComponent styles the server component when its result is chained', + async () => { + expect(await cardBackground(rows.chained)).toBe(CARD_BACKGROUND) + }, + ) + }) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-build.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-build.test.ts new file mode 100644 index 0000000000..2676b4343d --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-build.test.ts @@ -0,0 +1,438 @@ +/** + * A production build of a React Start app with RSC enabled on Vite + * (`rsc-app.ts`: `buildApp()` of the `client`, `ssr` and `rsc` + * environments, served by Start's preview server) in a real page: which + * entry of a dependency each environment runs (SPEC J4.3, J4.16, J4.12), + * env-only fns a server fn handler calls (J4.10), and the CSS of server + * components rendered with each RSC helper, in a server fn's module or in a + * helper module it calls (SPEC J7.2, J7.3). The dev counterparts are + * rsc-start-dev.test.ts and rsc-css-matrix.test.ts. + */ +import { readFile, readdir } from 'node:fs/promises' +import path from 'node:path' +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + computedStyle, + openRscPage, + settledValue, + startRscPreviewServer, + waitForHydration, +} from './rsc-app' +import { HELPER_CARD_BACKGROUND, helperRow } from './rsc-css-rsbuild-app' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { RscPreviewServer } from './rsc-app' + +/** A dependency whose entry differs by export condition. */ +const envMarkerPackage = { + 'node_modules/env-marker/package.json': JSON.stringify({ + name: 'env-marker', + type: 'module', + exports: { + '.': { + 'react-server': './react-server.js', + browser: './browser.js', + default: './default.js', + }, + }, + }), + // Counts its initialisations in the server process. + 'node_modules/env-marker/react-server.js': `globalThis.__envMarkerInits = (globalThis.__envMarkerInits ?? 0) + 1 +export const where = () => 'MARK_REACT_SERVER:' + globalThis.__envMarkerInits +`, + 'node_modules/env-marker/browser.js': `export const where = () => 'MARK_BROWSER'\n`, + 'node_modules/env-marker/default.js': `export const where = () => 'MARK_DEFAULT'\n`, +} + +/** A module whose server fn renders a local `Card` with `api`. */ +const cssRow = (key: string, imports: string, body: string) => ({ + [`src/rows/${key}.tsx`]: `import { createServerFn } from '@tanstack/react-start' +${imports} +import styles from './${key}.module.css' +function Card({ children }: { children?: React.ReactNode }) { + return
MARK_CARD{children}
+} +export const render = createServerFn().handler(async () => { + ${body} +}) +`, + // The row in the content: scoped class names hash the content + [`src/rows/${key}.module.css`]: `/* ${key} */\n.card { background: #fef3c7; }\n`, +}) + +const CARD_BACKGROUND = 'rgb(254, 243, 199)' + +const files = { + ...envMarkerPackage, + // A server fn that calls a helper module rendering a server component + // with its own CSS module (rsc-css-rsbuild-app.ts) + ...helperRow.files, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { where } from 'env-marker' +export const greet = createServerFn().handler(() => where()) +`, + 'src/routes/env.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { where } from 'env-marker' +import { greet } from '../fns' +export const Route = createFileRoute('/env')({ + loader: async () => ({ own: where(), provider: await greet() }), + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + const [called, setCalled] = useState('') + const [browser, setBrowser] = useState('') + return ( +
+

ssr {data.own} provider {data.provider}

+

called {called}

+

browser {browser}

+ + +
+ ) +} +`, + ...cssRow( + 'renderable', + `import { renderServerComponent } from '@tanstack/react-start/rsc'`, + `return renderServerComponent()`, + ), + ...cssRow( + 'composite', + `import { createCompositeComponent } from '@tanstack/react-start/rsc'`, + `return createCompositeComponent((props) => {props.children})`, + ), + ...cssRow( + 'flight', + `import { renderToReadableStream } from '@tanstack/react-start/rsc'`, + `return new Response(renderToReadableStream(), { + headers: { 'Content-Type': 'text/x-component' }, + })`, + ), + ...cssRow( + 'identifier', + `import { renderToReadableStream } from '@tanstack/react-start/rsc'`, + `const node = + return new Response(renderToReadableStream(node), { headers: { 'Content-Type': 'text/x-component' } })`, + ), + ...cssRow( + 'spread', + `import { renderToReadableStream } from '@tanstack/react-start/rsc'`, + `const args = [] as const + return new Response(renderToReadableStream(...args), { headers: { 'Content-Type': 'text/x-component' } })`, + ), + // A server fn whose only importer is a `'use client'` component that a + // server component renders. + 'src/client-ref/update.ts': `import { createServerFn } from '@tanstack/react-start' +export const update = createServerFn({ method: 'POST' }).handler(() => 'MARK_UPDATED') +`, + 'src/client-ref/Counter.tsx': `'use client' +import { useState } from 'react' +import { update } from './update' +export function Counter() { + const [result, setResult] = useState('') + return ( + + ) +} +`, + 'src/client-ref/page.tsx': `import { createServerFn } from '@tanstack/react-start' +import { renderServerComponent } from '@tanstack/react-start/rsc' +import { Counter } from './Counter' +export const getPage = createServerFn().handler(() => renderServerComponent(
server
)) +`, + 'src/routes/client-ref.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { getPage } from '../client-ref/page' +export const Route = createFileRoute('/client-ref')({ + loader: async () => ({ tree: await getPage() }), + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return
{data.tree}
+} +`, + // A server fn module whose source names only createServerFn: its handler + // calls env-only fns that a project module re-exports under other names. + 'src/aliased/env.ts': `export { createServerOnlyFn as makeServerOnly, createClientOnlyFn as makeClientOnly } from '@tanstack/react-start' +`, + 'src/aliased/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { makeClientOnly, makeServerOnly } from './env' +const readSecret = makeServerOnly(() => 'MARK_ALIASED_SERVER_ONLY') +const readBrowser = makeClientOnly(() => 'MARK_ALIASED_CLIENT_ONLY') +export const readAliased = createServerFn().handler(() => { + let clientOnly = 'threw' + try { + clientOnly = readBrowser() + } catch {} + return 'server-only ' + readSecret() + ' client-only ' + clientOnly +}) +`, + 'src/routes/aliased.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { readAliased } from '../aliased/fns' +export const Route = createFileRoute('/aliased')({ + loader: () => readAliased(), + component: Page, +}) +function Page() { + const [called, setCalled] = useState('') + return ( +
+

loaded {Route.useLoaderData()}

+

called {called}

+ +
+ ) +} +`, + 'src/routes/control.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { render as renderable } from '../rows/renderable' +import { render as composite } from '../rows/composite' +import { render as flight } from '../rows/flight' +export const Route = createFileRoute('/control')({ component: Control }) +function Control() { + return
+} +`, + 'src/routes/css.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { CompositeComponent, createFromFetch } from '@tanstack/react-start/rsc' +import { useEffect, useState } from 'react' +import { render as renderable } from '../rows/renderable' +import { render as composite } from '../rows/composite' +import { render as flight } from '../rows/flight' +import { render as identifier } from '../rows/identifier' +import { render as spread } from '../rows/spread' +export const Route = createFileRoute('/css')({ + loader: async () => ({ renderable: await renderable(), composite: await composite() }), + component: Page, +}) +function Flight({ render = flight }: { render?: typeof flight }) { + const [tree, setTree] = useState(null) + useEffect(() => { + createFromFetch(render()).then(setTree) + }, []) + return <>{tree as React.ReactNode} +} +function Page() { + const data = Route.useLoaderData() + return ( +
+
{data.renderable}
+
+ + MARK_SLOT + +
+
+
+
+
+ ) +} +`, +} + +/** The files of `dir`, recursively. */ +async function filesOf(dir: string): Promise> { + const entries = await readdir(dir, { recursive: true, withFileTypes: true }) + return entries + .filter((entry) => entry.isFile()) + .map((entry) => path.join(entry.parentPath, entry.name)) +} + +describe('Vite production build with RSC', () => { + let server: RscPreviewServer + const cleanups: Array<() => Promise> = [] + + beforeAll(async () => { + server = await startRscPreviewServer({ + files, + config: { + // Bundled into the provider like Start's own packages are: the + // `rsc` build otherwise leaves a dependency external, and Node + // imports it at run time with its own conditions, not + // `react-server` (@vitejs/plugin-rsc, upstream). + environments: { rsc: { resolve: { noExternal: ['env-marker'] } } }, + // Output size is not under test + build: { minify: false }, + }, + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + }) + }) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + const open = async (pathname: string): Promise => { + const page = await openRscPage(server, pathname, { + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + }) + return page + } + + // J4.3, J4.16, J4.12: the provider runs the handler with `react-server` + // and initialises the package once, whether SSR or the browser calls it; + // SSR's own code gets `default`, the browser `browser`; no client file of + // the build has another environment's entry. + test('each environment runs its own entry of a dependency; the provider runs the handler', async () => { + const page = await open('/env') + await page.waitForText('ssr MARK_DEFAULT provider MARK_REACT_SERVER:1', { + selector: '[data-testid=label]', + }) + await waitForHydration(page) + await page.page.locator('[data-testid=call]').click() + await page.waitForText('called MARK_REACT_SERVER:1', { + selector: '[data-testid=called]', + }) + await page.page.locator('[data-testid=where]').click() + await page.waitForText('browser MARK_BROWSER', { + selector: '[data-testid=browser]', + }) + const client = await Promise.all( + (await filesOf(path.join(server.root, 'dist/client'))).map((file) => + readFile(file, 'utf8'), + ), + ) + expect({ + browser: client.some((code) => code.includes('MARK_BROWSER')), + server: client.some((code) => + /MARK_REACT_SERVER|MARK_DEFAULT/.test(code), + ), + }).toEqual({ browser: true, server: false }) + expect(page.errors).toEqual([]) + }) + + // SPEC J4.10, J4.12, G11 (the Start compiler composed with the RSC CSS + // transform): in the provider, the handler's env-only fns, reached + // through renamed re-exports of a module whose source names only + // createServerFn, are compiled: the server-only one runs, the client-only + // one throws, whether SSR or the browser calls the server fn; the + // server-only body is not in any client file. + test('a server fn handler compiles env-only fns of renamed re-exports in the provider', async () => { + const expected = 'server-only MARK_ALIASED_SERVER_ONLY client-only threw' + const page = await open('/aliased') + await page.waitForText(`loaded ${expected}`, { + selector: '[data-testid=loaded]', + }) + await waitForHydration(page) + await page.page.locator('[data-testid=call]').click() + await page.waitForText(`called ${expected}`, { + selector: '[data-testid=called]', + }) + const client = await Promise.all( + (await filesOf(path.join(server.root, 'dist/client'))).map((file) => + readFile(file, 'utf8'), + ), + ) + expect( + client.some((code) => code.includes('MARK_ALIASED_SERVER_ONLY')), + ).toBe(false) + expect(page.errors).toEqual([]) + }) + + // SPEC J4.2: a server fn the client references is registered and runs + // when called by id, also when its only importer is a `'use client'` + // component that reaches the browser through a server component. + // Bug: the server-fn manifest of the build has no entry for it (the + // provider build never processes a module only a client reference + // imports), so the call answers 500 ("Server function info not found"). + // Impact: a server fn imported only by a client component of a server + // component cannot be called in production (#7943). + test.fails( + "a server fn only a 'use client' component of a server component imports runs when clicked", + async () => { + const page = await open('/client-ref') + await page.page.locator('[data-testid=counter]').waitFor() + await waitForHydration(page) + await page.page.locator('[data-testid=counter]').click() + expect( + await settledValue( + page, + () => page.text('[data-testid=counter]'), + (text) => text.includes('MARK_UPDATED'), + ), + ).toBe('counter MARK_UPDATED') + }, + ) + + test('loading the client callers without an RSC result supplies no server CSS', async () => { + const page = await open('/control') + await page.waitForText('caller', { selector: '[data-testid=control]' }) + await waitForHydration(page) + const css = await page.page.evaluate(() => + [...document.styleSheets] + .flatMap((sheet) => { + try { + return [...sheet.cssRules].map((rule) => rule.cssText) + } catch { + return [] + } + }) + .join('\n'), + ) + expect(css).not.toMatch(/254, 243, 199|#fef3c7/i) + expect(page.errors).toEqual([]) + }) + + test.each(['identifier', 'spread'])( + 'production %s stream still renders without development warnings', + async (row) => { + const page = await open('/css') + await page.waitForText('MARK_CARD', { + selector: `section[data-row=${row}]`, + }) + await waitForHydration(page) + expect( + [...server.messages, ...page.console].filter((message) => + /renderToReadableStream/.test(message), + ), + ).toEqual([]) + expect(page.errors).toEqual([]) + }, + ) + + // SPEC J7.1, J7.2: the CSS is delivered wherever the render runs, here in + // a helper module the server fn calls (the dev twin: rsc-css.test.ts). + test('a render call in a helper module styles the server component', async () => { + const page = await open(helperRow.path) + const selector = '[data-testid=helper-card]' + await page.page.locator(selector).waitFor() + await waitForHydration(page) + expect( + await settledValue( + page, + () => computedStyle(page, selector, 'background-color'), + (value) => value === HELPER_CARD_BACKGROUND, + ), + ).toBe(HELPER_CARD_BACKGROUND) + expect(page.errors).toEqual([]) + }) + + test.each(['renderable', 'composite', 'flight'])( + 'the %s row styles its server component', + async (row) => { + const page = await open('/css') + const selector = `section[data-row=${row}] [data-testid=card]` + await page.page.locator(selector).waitFor() + await waitForHydration(page) + expect( + await settledValue( + page, + () => computedStyle(page, selector, 'background-color'), + (value) => value === CARD_BACKGROUND, + ), + ).toBe(CARD_BACKGROUND) + expect(page.errors).toEqual([]) + }, + ) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-client-module.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-client-module.test.ts new file mode 100644 index 0000000000..254da03573 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-client-module.test.ts @@ -0,0 +1,53 @@ +import { describe, expect, test } from 'vitest' +import { + openRscPage, + settledValue, + startRscDevServer, + waitForHydration, +} from './rsc-app' + +describe('Vite dev: a separate RSC provider', () => { + // SPEC J4.2 / #7943: a server function declared in a `'use client'` + // module runs on the server when the client calls it. + // Bug: the provider module (`?tss-serverfn-split`) keeps the `'use client'` + // directive of its source module, so the RSC bundler turns the provider's + // exports into client references and the handler is not there to run. + // Impact: a server fn co-located with a client component cannot be called. + // Source: the compile-level pin in start-plugin-core + // tests/known-bugs-start-compiler.test.ts. + test.fails( + "a server function of a 'use client' module runs on the server", + async () => { + const server = await startRscDevServer({ + browser: true, + files: { + 'src/widget.tsx': `'use client' +import { useState } from 'react' +import { createServerFn } from '@tanstack/react-start' +const getData = createServerFn().handler(() => 'MARK_WIDGET_DATA') +export function Widget() { + const [data, setData] = useState('') + return +} +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { Widget } from '../widget' +export const Route = createFileRoute('/')({ component: () =>
}) +`, + }, + }) + const browser = await openRscPage(server, '/') + await browser.waitForText('widget') + await waitForHydration(browser) + await browser.page.locator('[data-testid=widget]').click() + // The answer, or what the page shows once its requests are done + expect( + await settledValue( + browser, + () => browser.text('[data-testid=widget]'), + (text) => text.includes('MARK_WIDGET_DATA'), + ), + ).toBe('widget MARK_WIDGET_DATA') + }, + ) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-dev.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-dev.test.ts new file mode 100644 index 0000000000..f70685df23 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-dev.test.ts @@ -0,0 +1,98 @@ +/** + * Start with a separate server function provider (SPEC J4.2, J4.3, J4.16): + * a React Start app with RSC enabled on a Vite dev server (`rsc-app.ts`), + * where the `rsc` environment runs the handlers, SSR forwards its calls to + * it, and a real page calls them from the browser. Outcomes only: what the + * page shows, what a call by id answers, what the browser loaded. Edits + * are in rsc-start-hmr.test.ts. + */ +import { describe, expect, test } from 'vitest' +import { openRscPage, startRscDevServer, waitForHydration } from './rsc-app' +import { callFromPage, envMarkerPackage } from './rsc-start-page' + +describe('Vite dev: a separate RSC provider', () => { + // J4.3, J4.16: SSR (the loader during the page render) and a client call + // both run the handler in the provider, with its module-resolution + // conditions (`react-server`), and the provider initialises the package + // once; SSR's own code gets the `default` entry and the browser's the + // `browser` entry, and no client script has another environment's entry. + test('each environment runs its own entry of a dependency; the provider runs the handler, whether SSR or the browser calls it', async () => { + const server = await startRscDevServer({ + browser: true, + config: { + // Bundled into the provider like Start's own packages are + // (`environments.rsc.resolve.noExternal`): in dev, Vite's module + // runner imports an externalised dependency natively, with Node's + // conditions, not the environment's. + environments: { rsc: { resolve: { noExternal: ['env-marker'] } } }, + // The page imports it too: pre-bundled up front, as Vite does once + // a page discovers it. + optimizeDeps: { include: ['env-marker'] }, + }, + files: { + ...envMarkerPackage, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { where } from 'env-marker' +export const greet = createServerFn().handler(() => where()) +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { where } from 'env-marker' +import { greet } from '../fns' +export const Route = createFileRoute('/')({ + loader: async () => ({ own: where(), provider: await greet() }), + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + const [called, setCalled] = useState('') + const [browser, setBrowser] = useState('') + return ( +
+

ssr {data.own} provider {data.provider}

+

called {called}

+

browser {browser}

+ + +
+ ) +} +`, + }, + }) + const browser = await openRscPage(server, '/') + await browser.waitForText('ssr MARK_DEFAULT provider MARK_REACT_SERVER:1', { + selector: '[data-testid=label]', + }) + await waitForHydration(browser) + await callFromPage(browser, 'called MARK_REACT_SERVER:1') + await browser.page.locator('[data-testid=where]').click() + await browser.waitForText('browser MARK_BROWSER', { + selector: '[data-testid=browser]', + }) + + // What the browser loaded as code (not the server fn answers) + const scripts = await browser.page.evaluate(() => + performance + .getEntriesByType('resource') + .filter( + (entry) => + !['fetch', 'xmlhttprequest'].includes( + (entry as PerformanceResourceTiming).initiatorType, + ), + ) + .map((entry) => new URL(entry.name).pathname), + ) + const leaks: Array = [] + for (const script of scripts) { + const { body } = await server.fetch(script) + if (/MARK_REACT_SERVER|MARK_DEFAULT/.test(body)) { + leaks.push(script) + } + } + // The check covers the dependency's browser entry + expect(scripts.some((script) => script.includes('env-marker'))).toBe(true) + expect(leaks).toEqual([]) + expect(browser.errors).toEqual([]) + }) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-hmr-page.ts b/packages/react-start-rsc/tests/integration/rsc-start-hmr-page.ts new file mode 100644 index 0000000000..c796987981 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-hmr-page.ts @@ -0,0 +1,31 @@ +/** + * `/`: a server fn whose handler returns `handler`, the loader and the page + * calling it, the page's text `text` and a counter (component state). The + * call button shows `text` and the answer, so a call from an edited + * component is told apart from the answer the kept state shows. + */ +export const route = ( + handler: string, + text: string, +) => `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +const getLabel = createServerFn().handler(() => '${handler}') +export const Route = createFileRoute('/')({ + loader: () => getLabel(), + component: Page, +}) +function Page() { + const label = Route.useLoaderData() + const [called, setCalled] = useState('') + const [count, setCount] = useState(0) + return ( +
+

${text} {label}

+

called {called}

+ + +
+ ) +} +` diff --git a/packages/react-start-rsc/tests/integration/rsc-start-hmr-rsbuild.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-hmr-rsbuild.test.ts new file mode 100644 index 0000000000..3921d08de5 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-hmr-rsbuild.test.ts @@ -0,0 +1,60 @@ +import { pluginReact } from '@rsbuild/plugin-react' +import { describe, expect, test } from 'vitest' +import { + openRscPage, + startRscRsbuildDevServer, + waitForHydration, +} from './rsc-app' +import { callFromPage } from './rsc-start-page' +import { route } from './rsc-start-hmr-page' + +describe('Rsbuild dev: edits with a separate RSC provider (SPEC J3.6)', () => { + // The Vite test above on Start's Rsbuild RSC layer, with React Refresh + // from `@rsbuild/plugin-react`, in the same order in one session: editing + // the handler makes the next call run the new code and the client output + // never has it; editing the component then hot-updates the page, keeping + // its state; no full reload either way, and the server fn still answers. + // Source: #7618 (SPEC J3.6). + test('a handler edit reaches the next call and a component edit hot-updates, keeping the state, without a full reload', async () => { + const server = await startRscRsbuildDevServer({ + browser: true, + hmr: true, + config: { plugins: [pluginReact()] }, + files: { 'src/routes/index.tsx': route('MARK_HANDLER_V1', 'Page v1') }, + }) + expect(server.errors).toEqual([]) + const browser = await openRscPage(server, '/') + await browser.waitForText('Page v1 MARK_HANDLER_V1') + await waitForHydration(browser) + await browser.page.locator('[data-testid=count]').click() + await browser.page.locator('[data-testid=count]').click() + await browser.waitForText('count 2') + await callFromPage(browser, 'called Page v1 MARK_HANDLER_V1') + + // The handler + await server.edit({ + 'src/routes/index.tsx': route('MARK_HANDLER_V2', 'Page v1'), + }) + expect(server.errors).toEqual([]) + await callFromPage(browser, 'called Page v1 MARK_HANDLER_V2') + expect(browser.loads()).toBe(1) + // The client's output of the route never has the handler (J4.12) + const client = [ + ...Object.values(await server.outputs('client')), + ...Object.values(await server.hotUpdates('client')), + ].join('\n') + expect(client).not.toContain('MARK_HANDLER_V2') + + // The component + await server.edit({ + 'src/routes/index.tsx': route('MARK_HANDLER_V2', 'Page v2'), + }) + expect(server.errors).toEqual([]) + await browser.waitForText('Page v2', { selector: '[data-testid=text]' }) + expect(await browser.text('[data-testid=count]')).toBe('count 2') + await callFromPage(browser, 'called Page v2 MARK_HANDLER_V2') + + expect(browser.loads()).toBe(1) + expect(browser.errors).toEqual([]) + }) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-hmr.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-hmr.test.ts new file mode 100644 index 0000000000..d95248772b --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-hmr.test.ts @@ -0,0 +1,68 @@ +/** + * Edits with a separate server function provider (SPEC J3.6): a + * React Start app with RSC enabled on a Vite dev server, or on an Rsbuild + * dev server with React Refresh from `@rsbuild/plugin-react` (`rsc-app.ts`), + * a route module that also declares the server function its loader and page + * call, and a real page. Outcomes only: what the page shows, what the next + * call answers, whether the page reloaded. A handler edit that also changes + * what the loader shows on Rsbuild is in rsc-start-rsbuild.test.ts. + */ +import { describe, expect, test } from 'vitest' +import { describeHmr } from '@tanstack/compiler-test-utils/dev-server' +import { openRscPage, startRscDevServer, waitForHydration } from './rsc-app' +import { callFromPage } from './rsc-start-page' +import { route } from './rsc-start-hmr-page' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +/** The HMR messages telling the client to reload the page. */ +const fullReloads = (server: DevServer) => + describeHmr( + server.hmr.filter( + (message) => + message.environment === 'client' && message.type === 'full-reload', + ), + ) + +describe('Vite dev: edits with a separate RSC provider (SPEC J3.6)', () => { + // A route module that also declares a server function: editing the + // handler makes the next call run the new code; editing the component + // hot-updates the page, keeping its state, and the server fn still + // answers; no full reload either way (SPEC J3.6, G10). + // Source: #7618. + test('a handler edit reaches the next call and a component edit hot-updates, without a full reload', async () => { + const server = await startRscDevServer({ + browser: true, + files: { 'src/routes/index.tsx': route('MARK_HANDLER_V1', 'Page v1') }, + }) + const browser = await openRscPage(server, '/') + await browser.waitForText('Page v1 MARK_HANDLER_V1') + await waitForHydration(browser) + await browser.page.locator('[data-testid=count]').click() + await browser.page.locator('[data-testid=count]').click() + await browser.waitForText('count 2') + await callFromPage(browser, 'called Page v1 MARK_HANDLER_V1') + + // The handler + await server.write({ + 'src/routes/index.tsx': route('MARK_HANDLER_V2', 'Page v1'), + }) + await callFromPage(browser, 'called Page v1 MARK_HANDLER_V2') + expect(fullReloads(server)).toEqual([]) + // The client's module of the route never has the handler (J4.12) + expect( + await server.transform('/src/routes/index.tsx', 'client'), + ).not.toContain('MARK_HANDLER_V2') + + // The component + await server.write({ + 'src/routes/index.tsx': route('MARK_HANDLER_V2', 'Page v2'), + }) + await browser.waitForText('Page v2', { selector: '[data-testid=text]' }) + expect(await browser.text('[data-testid=count]')).toBe('count 2') + await callFromPage(browser, 'called Page v2 MARK_HANDLER_V2') + + expect(browser.loads()).toBe(1) + expect(fullReloads(server)).toEqual([]) + expect(browser.errors).toEqual([]) + }) +}) diff --git a/packages/react-start-rsc/tests/integration/rsc-start-page.ts b/packages/react-start-rsc/tests/integration/rsc-start-page.ts new file mode 100644 index 0000000000..7ccdbd34c8 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-page.ts @@ -0,0 +1,32 @@ +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' + +/** + * A dependency whose entry differs by export condition: the environment a + * handler runs in shows in what it imports. + */ +export const envMarkerPackage = { + 'node_modules/env-marker/package.json': JSON.stringify({ + name: 'env-marker', + type: 'module', + exports: { + '.': { + 'react-server': './react-server.js', + browser: './browser.js', + default: './default.js', + }, + }, + }), + // Counts its initialisations (all environments of a Vite dev server run + // in the test process). + 'node_modules/env-marker/react-server.js': `globalThis.__envMarkerInits = (globalThis.__envMarkerInits ?? 0) + 1 +export const where = () => 'MARK_REACT_SERVER:' + globalThis.__envMarkerInits +`, + 'node_modules/env-marker/browser.js': `export const where = () => 'MARK_BROWSER'\n`, + 'node_modules/env-marker/default.js': `export const where = () => 'MARK_DEFAULT'\n`, +} + +/** Clicks the page's call button and waits for the answer. */ +export async function callFromPage(browser: BrowserPage, expected: string) { + await browser.page.locator('[data-testid=call]').click() + await browser.waitForText(expected, { selector: '[data-testid=called]' }) +} diff --git a/packages/react-start-rsc/tests/integration/rsc-start-rsbuild.test.ts b/packages/react-start-rsc/tests/integration/rsc-start-rsbuild.test.ts new file mode 100644 index 0000000000..994d96bbf9 --- /dev/null +++ b/packages/react-start-rsc/tests/integration/rsc-start-rsbuild.test.ts @@ -0,0 +1,173 @@ +/** + * Start with RSC on Rsbuild (`rsc-app.ts`: Start's Rsbuild plugin, its RSC + * layer and `react-server-dom-rspack`): which entry of a dependency each + * environment runs (SPEC J4.3, J4.16), and an edit of a route module that + * declares the server function its loader and page call (SPEC J3.6). The + * Vite counterparts are rsc-start-dev.test.ts and rsc-start-hmr.test.ts. + * + * A component edit keeping state (the other half of J3.6, with React + * Refresh from `@rsbuild/plugin-react`) is in rsc-start-hmr.test.ts. + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + openRscPage, + startRscRsbuildDevServer, + waitForHydration, +} from './rsc-app' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +/** A dependency whose entry differs by export condition. */ +const envMarkerPackage = { + 'node_modules/env-marker/package.json': JSON.stringify({ + name: 'env-marker', + type: 'module', + exports: { + '.': { + 'react-server': './react-server.js', + browser: './browser.js', + default: './default.js', + }, + }, + }), + // Counts its initialisations in the server process. + 'node_modules/env-marker/react-server.js': `globalThis.__envMarkerInits = (globalThis.__envMarkerInits ?? 0) + 1 +export const where = () => 'MARK_REACT_SERVER:' + globalThis.__envMarkerInits +`, + 'node_modules/env-marker/browser.js': `export const where = () => 'MARK_BROWSER'\n`, + 'node_modules/env-marker/default.js': `export const where = () => 'MARK_DEFAULT'\n`, +} + +/** + * `/edit`: a server fn whose handler returns `MARK_HANDLER_*`, the loader + * and the page calling it, and the page's label `MARK_LABEL_*`. + */ +const editRoute = ( + version: string, +) => `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +const greet = createServerFn().handler(async () => 'MARK_HANDLER_${version}') +export const Route = createFileRoute('/edit')({ + loader: () => greet(), + component: Page, +}) +function Page() { + const label = Route.useLoaderData() + const [called, setCalled] = useState('') + return ( +
+

MARK_LABEL_${version} {label}

+

called {called}

+ +
+ ) +} +` + +/** Clicks the page's call button and waits for the answer. */ +async function callFromPage(page: BrowserPage, expected: string) { + await page.page.locator('[data-testid=call]').click() + await page.waitForText(expected, { selector: '[data-testid=called]' }) +} + +describe('Rsbuild dev with RSC', () => { + let server: RsbuildDevServer + const cleanups: Array<() => Promise> = [] + + beforeAll(async () => { + server = await startRscRsbuildDevServer({ + browser: true, + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + files: { + ...envMarkerPackage, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { where } from 'env-marker' +export const greet = createServerFn().handler(() => where()) +`, + 'src/routes/env.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { where } from 'env-marker' +import { greet } from '../fns' +export const Route = createFileRoute('/env')({ + loader: async () => ({ own: where(), provider: await greet() }), + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + const [called, setCalled] = useState('') + const [browser, setBrowser] = useState('') + return ( +
+

ssr {data.own} provider {data.provider}

+

called {called}

+

browser {browser}

+ + +
+ ) +} +`, + 'src/routes/edit.tsx': editRoute('V1'), + }, + }) + }) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + // J4.3, J4.16: the provider runs the handler with `react-server` and + // initialises the package once, whether SSR or the browser calls it; SSR's + // own code gets `default`, the browser `browser`, and the client output + // has no other environment's entry. + test('each environment runs its own entry of a dependency; the provider runs the handler', async () => { + expect(server.errors).toEqual([]) + const page = await openRscPage(server, '/env') + await page.waitForText('ssr MARK_DEFAULT provider MARK_REACT_SERVER:1', { + selector: '[data-testid=label]', + }) + await waitForHydration(page) + await callFromPage(page, 'called MARK_REACT_SERVER:1') + await page.page.locator('[data-testid=where]').click() + await page.waitForText('browser MARK_BROWSER', { + selector: '[data-testid=browser]', + }) + const client = Object.values(await server.outputs('client')).join('\n') + expect({ + browser: client.includes('MARK_BROWSER'), + server: /MARK_REACT_SERVER|MARK_DEFAULT/.test(client), + }).toEqual({ browser: true, server: false }) + expect(page.errors).toEqual([]) + }) + + // J3.6 (#7618) on Rsbuild's RSC layer: after an edit of + // the handler of a route module's server fn, the page applies the hot + // update (its loader runs the new handler) and the next call runs it, + // without a full reload; the client's hot update never has the handler. + test('a handler edit reaches the loader and the next call, without a full reload', async () => { + const page = await openRscPage(server, '/edit') + await page.waitForText('MARK_LABEL_V1 MARK_HANDLER_V1', { + selector: '[data-testid=label]', + }) + await waitForHydration(page) + await callFromPage(page, 'called MARK_HANDLER_V1') + + await server.edit({ 'src/routes/edit.tsx': editRoute('V2') }) + expect(server.errors).toEqual([]) + await page.waitForText('MARK_HANDLER_V2', { + selector: '[data-testid=label]', + }) + await callFromPage(page, 'called MARK_HANDLER_V2') + expect(page.loads()).toBe(1) + const update = Object.values(await server.hotUpdates('client')).join('\n') + expect({ + label: update.includes('MARK_LABEL_V2'), + handler: update.includes('MARK_HANDLER_V2'), + }).toEqual({ label: true, handler: false }) + expect(page.errors).toEqual([]) + }) +}) diff --git a/packages/react-start-rsc/tests/noncompiler-tests.json b/packages/react-start-rsc/tests/noncompiler-tests.json new file mode 100644 index 0000000000..58b94ac648 --- /dev/null +++ b/packages/react-start-rsc/tests/noncompiler-tests.json @@ -0,0 +1,10 @@ +[ + "ClientSlot.test.tsx", + "CompositeComponent.types.test-d.tsx", + "ReplayableStream.test.ts", + "ServerComponent.test.tsx", + "SlotContext.test.tsx", + "createRscProxy.test.tsx", + "createServerComponent.test-d.tsx", + "renderServerComponent.types.test-d.tsx" +] diff --git a/packages/react-start-rsc/tests/rscCssTransform.test.tsx b/packages/react-start-rsc/tests/rscCssTransform.test.tsx deleted file mode 100644 index afc4686e94..0000000000 --- a/packages/react-start-rsc/tests/rscCssTransform.test.tsx +++ /dev/null @@ -1,215 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - StartCompiler, - detectKindsInCode, - getLookupKindsForEnv, -} from '../../start-plugin-core/src/start-compiler/compiler' -import { getLookupConfigurationsForEnv } from '../../start-plugin-core/src/start-compiler/config' -import { createRscCssCompilerTransforms } from '../src/plugin/rscCssTransform' -import type { StartCompilerImportTransform } from '../../start-plugin-core/src/types' - -const TSS_SERVERFN_SPLIT_PARAM = 'tss-serverfn-split' - -async function compileWithRscCssTransform(opts: { - code: string - id?: string | undefined - loadCssExpression?: string | undefined - serverFnProviderOnly?: boolean | undefined -}) { - const compilerTransforms = createRscCssCompilerTransforms({ - loadCssExpression: - opts.loadCssExpression ?? 'import.meta.viteRsc.loadCss()', - serverFnProviderOnly: opts.serverFnProviderOnly, - }) - - const compiler = new StartCompiler({ - env: 'server', - envName: 'rsc', - root: '/test', - framework: 'react', - providerEnvName: 'rsc', - mode: 'build', - lookupKinds: getLookupKindsForEnv('server', { compilerTransforms }), - lookupConfigurations: getLookupConfigurationsForEnv('server', 'react', { - compilerTransforms, - }), - compilerTransforms, - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (id) => id, - }) - - const result = await compiler.compile({ - id: opts.id ?? '/test/src/route.tsx', - code: opts.code, - detectedKinds: detectKindsInCode(opts.code, 'server', { - compilerTransforms, - }), - }) - - return result?.code ?? null -} - -describe('RSC CSS compiler transforms', () => { - test('injects Vite CSS resources into all supported RSC render APIs', async () => { - const code = await compileWithRscCssTransform({ - code: ` - import { - createCompositeComponent, - renderServerComponent, - renderToReadableStream, - } from '@tanstack/react-start/rsc' - - export const renderable = renderServerComponent() - export const composite = createCompositeComponent(() => ({ - Card: , - })) - export const stream = renderToReadableStream() - `, - }) - - expect(code).toMatchInlineSnapshot(` - "import { createCompositeComponent, renderServerComponent, renderToReadableStream } from '@tanstack/react-start/rsc'; - export const renderable = renderServerComponent(, { - __tanstackStartRscCss: import.meta.viteRsc.loadCss() - }); - export const composite = createCompositeComponent(() => ({ - Card: - }), { - __tanstackStartRscCss: import.meta.viteRsc.loadCss() - }); - export const stream = renderToReadableStream(<>{import.meta.viteRsc.loadCss()});" - `) - }) - - test('does not rewrite calls outside the transform constraints', async () => { - const code = await compileWithRscCssTransform({ - code: ` - import { - renderServerComponent, - renderToReadableStream, - } from '@tanstack/react-start/rsc' - - const node = - export const existingOptions = renderServerComponent(, { - alreadyConfigured: true, - }) - export const nonJsxStream = renderToReadableStream(node) - `, - }) - - expect(code).toMatchInlineSnapshot(` - "import { renderServerComponent, renderToReadableStream } from '@tanstack/react-start/rsc'; - const node = ; - export const existingOptions = renderServerComponent(, { - alreadyConfigured: true - }); - export const nonJsxStream = renderToReadableStream(node);" - `) - }) - - test('honors provider-only transforms for Rsbuild', async () => { - const source = ` - import { renderServerComponent } from '@tanstack/react-start/rsc' - - export const renderable = renderServerComponent() - ` - - const callerCode = await compileWithRscCssTransform({ - code: source, - loadCssExpression: 'import.meta.rspackRsc.loadCss()', - serverFnProviderOnly: true, - }) - - const providerCode = await compileWithRscCssTransform({ - code: source, - id: `/test/src/route.tsx?${TSS_SERVERFN_SPLIT_PARAM}`, - loadCssExpression: 'import.meta.rspackRsc.loadCss()', - serverFnProviderOnly: true, - }) - - expect({ callerCode, providerCode }).toMatchInlineSnapshot(` - { - "callerCode": "import { renderServerComponent } from '@tanstack/react-start/rsc'; - export const renderable = renderServerComponent();", - "providerCode": "import { renderServerComponent } from '@tanstack/react-start/rsc'; - export const renderable = renderServerComponent(, { - __tanstackStartRscCss: import.meta.rspackRsc.loadCss() - });", - } - `) - }) - - test('detects transform imports without enabling them outside server builds', () => { - const compilerTransforms: Array = - createRscCssCompilerTransforms({ - loadCssExpression: 'import.meta.viteRsc.loadCss()', - }) - - const code = ` - import { renderServerComponent } from '@tanstack/react-start/rsc' - export const renderable = renderServerComponent() - ` - - expect(detectKindsInCode(code, 'server', { compilerTransforms })) - .toMatchInlineSnapshot(` - Set { - "External:react-rsc-render-server-component-css", - } - `) - expect( - detectKindsInCode(code, 'client', { compilerTransforms }), - ).toMatchInlineSnapshot(`Set {}`) - }) - - test('rewrites render APIs imported from @tanstack/react-start-rsc', async () => { - const code = await compileWithRscCssTransform({ - code: ` - import { renderServerComponent } from '@tanstack/react-start-rsc' - - export const renderable = renderServerComponent() - `, - }) - - expect(code).toContain( - '__tanstackStartRscCss: import.meta.viteRsc.loadCss()', - ) - }) - - test.each([ - { wrapped: '()', bare: '' }, - { wrapped: ' as any', bare: '' }, - { wrapped: '!', bare: '' }, - { wrapped: '(<>) satisfies unknown', bare: '<>' }, - ])( - 'streams $wrapped like the bare JSX it wraps', - async ({ wrapped, bare }) => { - const compileStream = (element: string) => - compileWithRscCssTransform({ - code: ` - import { renderToReadableStream } from '@tanstack/react-start/rsc' - - export const stream = renderToReadableStream(${element}) - `, - }) - - const bareCode = await compileStream(bare) - expect(bareCode).toContain('import.meta.viteRsc.loadCss()') - expect(await compileStream(wrapped)).toBe(bareCode) - }, - ) - - test('does not stream JSX that is not the whole argument', async () => { - const code = await compileWithRscCssTransform({ - code: ` - import { renderToReadableStream } from '@tanstack/react-start/rsc' - - export const conditional = renderToReadableStream(flag ? : ) - export const spread = renderToReadableStream(...args) - `, - }) - - expect(code).toContain('renderToReadableStream(...args)') - expect(code).not.toContain('loadCss') - }) -}) diff --git a/packages/react-start-rsc/tests/tsconfig.json b/packages/react-start-rsc/tests/tsconfig.json new file mode 100644 index 0000000000..2d0e6a5f58 --- /dev/null +++ b/packages/react-start-rsc/tests/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "target": "esnext", + "types": ["node"] + }, + "include": ["integration", "../src/**/*.d.ts"] +} diff --git a/packages/react-start-rsc/vite.config.ts b/packages/react-start-rsc/vite.config.ts index c8dfcf917b..baa544547a 100644 --- a/packages/react-start-rsc/vite.config.ts +++ b/packages/react-start-rsc/vite.config.ts @@ -1,8 +1,23 @@ -import { defineConfig, mergeConfig } from 'vitest/config' +import path from 'node:path' +import os from 'node:os' +import { configDefaults, defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/vite-config' import react from '@vitejs/plugin-react' import { copyFilesPlugin } from '@tanstack/router-utils' import packageJson from './package.json' +// Main's runtime tests (RSC components, streams, the proxy, and the types of +// the public API), at main's paths and unchanged: `test:noncompiler` runs +// them; the compiler projects leave them out. Paths relative to `tests/`. +import noncompilerTests from './tests/noncompiler-tests.json' with { type: 'json' } + +// Under Vitest: Node's compile cache for the test workers. No outcome +// change; less time compiling the bundlers and the built apps again. +if (process.env.VITEST) { + process.env.NODE_COMPILE_CACHE ??= path.join( + os.tmpdir(), + 'node-compile-cache', + ) +} const config = defineConfig({ resolve: { @@ -19,11 +34,62 @@ const config = defineConfig({ }), ], test: { - include: ['**/*.{test-d,test,spec}.?(c|m)[jt]s?(x)'], name: packageJson.name, watch: false, - environment: 'jsdom', - setupFiles: ['./tests/setup.ts'], + // At most 4 test processes per Vitest run: each + // runs real bundlers, dev servers and its own browser, and Nx runs several + // packages' tiers at once. More workers add swap and load flakes, not + // speed. `--maxWorkers` on the command line still overrides it. + maxWorkers: 4, + reporters: ['default', '@tanstack/compiler-test-utils/budget-reporter'], + globalSetup: ['@tanstack/compiler-test-utils/run-directory'], + setupFiles: ['@tanstack/compiler-test-utils/pins-setup'], + projects: [ + { + // Fast compiler acceptance tier; real apps run in integration. + // Runtime coverage is selected by test:noncompiler below. + extends: true, + test: { + name: 'unit', + include: ['**/*.{test,spec}.?(c|m)[jt]s?(x)'], + exclude: [ + ...configDefaults.exclude, + 'tests/integration/**', + ...noncompilerTests.map((file) => `tests/${file}`), + ], + environment: 'jsdom', + setupFiles: ['./tests/setup.ts'], + }, + }, + { + extends: true, + test: { + name: 'noncompiler', + dir: './tests', + include: noncompilerTests, + environment: 'jsdom', + setupFiles: ['./tests/setup.ts'], + }, + }, + { + // Slow tier (`test:integration`): real Start apps with RSC on Vite + // and Rsbuild dev servers and builds, and real browser pages. Its + // Nx target builds `@tanstack/react-start` first. + extends: true, + test: { + name: 'integration', + include: ['tests/integration/**/*.test.ts?(x)'], + environment: 'node', + // The dev servers and their module runners run in the test + // process, and `vite dev` runs with `development`: Vitest's `test` + // would be baked into the served client code (e.g. the RSC HMR + // client is set up under `development` only). + env: { NODE_ENV: 'development' }, + testTimeout: 60_000, + hookTimeout: 60_000, + }, + }, + ], }, }) diff --git a/packages/react-start-server/CHANGELOG.md b/packages/react-start-server/CHANGELOG.md index 86d7854a59..ad9b3012d4 100644 --- a/packages/react-start-server/CHANGELOG.md +++ b/packages/react-start-server/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/react-start-server -## 1.167.52 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398)]: - - @tanstack/react-router@1.170.46 - - @tanstack/router-core@1.171.39 - - @tanstack/start-server-core@1.169.45 - ## 1.167.51 ### Patch Changes diff --git a/packages/react-start-server/package.json b/packages/react-start-server/package.json index a725b70d9c..c423b0f52e 100644 --- a/packages/react-start-server/package.json +++ b/packages/react-start-server/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-start-server", - "version": "1.167.52", + "version": "1.167.51", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/react-start/CHANGELOG.md b/packages/react-start/CHANGELOG.md index 9d6432f985..afa7ee2bc9 100644 --- a/packages/react-start/CHANGELOG.md +++ b/packages/react-start/CHANGELOG.md @@ -1,40 +1,5 @@ # @tanstack/react-start -## 1.169.6 - -### Patch Changes - -- Updated dependencies [[`3f22686`](https://github.com/TanStack/router/commit/3f226869e0af211ff7f1de5d7343e43462dbb101), [`559c7de`](https://github.com/TanStack/router/commit/559c7ded6e2a6eeda3f91c80d8c03f4cfeb9a206)]: - - @tanstack/start-plugin-core@1.171.57 - - @tanstack/react-start-rsc@0.1.67 - -## 1.169.5 - -### Patch Changes - -- [#8863](https://github.com/TanStack/router/pull/8863) [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c) - The Rsbuild plugin keeps the app's `server.compress` setting instead of always setting it to `false`. Compression stays off by default: a compressed streamed page reaches the browser only once the stream ends. The optional `@rsbuild/core` peer is now `^2.0.5`, the first version whose compression keeps SSR response headers intact. - -- Updated dependencies [[`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69), [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c), [`c5320d7`](https://github.com/TanStack/router/commit/c5320d7ca23eca82d720ac5629d2bad5cf7d9b02), [`545a8d3`](https://github.com/TanStack/router/commit/545a8d3790989ca502153c3292c6b1e8063257f4), [`da8c28c`](https://github.com/TanStack/router/commit/da8c28c498230a5730ce75b2693baeeb3ef68ac1), [`d66a84b`](https://github.com/TanStack/router/commit/d66a84ba0a74ffd03e22b57ccd90796274c96244)]: - - @tanstack/router-utils@1.163.0 - - @tanstack/start-plugin-core@1.171.56 - - @tanstack/react-start-client@1.168.45 - - @tanstack/react-start-rsc@0.1.66 - -## 1.169.4 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/#`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398), [`ed55775`](https://github.com/TanStack/router/commit/ed5577593a749b8c7193cc7b5d945fd084bfac2f), [`63a886d`](https://github.com/TanStack/router/commit/63a886da9040c4b039ea3bf5b3a841771375cddb), [`d9b07e8`](https://github.com/TanStack/router/commit/d9b07e8d3b724cdbfac0aa2fba4c1f7a3a241100)]: - - @tanstack/react-router@1.170.46 - - @tanstack/start-client-core@1.170.39 - - @tanstack/start-server-core@1.169.45 - - @tanstack/start-plugin-core@1.171.55 - - @tanstack/react-start-client@1.168.44 - - @tanstack/react-start-rsc@0.1.65 - - @tanstack/react-start-server@1.167.52 - ## 1.169.3 ### Patch Changes diff --git a/packages/react-start/package.json b/packages/react-start/package.json index 6d51a4c6d0..9582e62013 100644 --- a/packages/react-start/package.json +++ b/packages/react-start/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/react-start", - "version": "1.169.6", + "version": "1.169.3", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -171,7 +171,7 @@ "pathe": "catalog:" }, "peerDependencies": { - "@rsbuild/core": "^2.0.5", + "@rsbuild/core": "^2.0.0", "react": ">=18.0.0 || >=19.0.0", "react-dom": ">=18.0.0 || >=19.0.0", "vite": ">=8.0.0" diff --git a/packages/router-cli/CHANGELOG.md b/packages/router-cli/CHANGELOG.md index 67101c3e51..85f6321fde 100644 --- a/packages/router-cli/CHANGELOG.md +++ b/packages/router-cli/CHANGELOG.md @@ -1,23 +1,5 @@ # @tanstack/router-cli -## 1.168.0 - -### Minor Changes - -- [#8855](https://github.com/TanStack/router/pull/8855) [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6) - Require Node `^20.19.0 || >=22.12.0` (was `>=20.19`), so the CommonJS builds can load ESM-only dependencies through `require(esm)`. Node 21 and Node 22.0–22.11 do not enable it by default, so they are no longer supported. - -### Patch Changes - -- Updated dependencies [[`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ad5b3b7`](https://github.com/TanStack/router/commit/ad5b3b7a0990eed7351d672ea6695d341108e0d6)]: - - @tanstack/router-generator@1.168.0 - -## 1.167.46 - -### Patch Changes - -- Updated dependencies []: - - @tanstack/router-generator@1.167.46 - ## 1.167.45 ### Patch Changes diff --git a/packages/router-cli/package.json b/packages/router-cli/package.json index 51a729d79b..39a1958945 100644 --- a/packages/router-cli/package.json +++ b/packages/router-cli/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-cli", - "version": "1.168.0", + "version": "1.167.45", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -63,7 +63,7 @@ "bin/**" ], "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": ">=20.19" }, "dependencies": { "@tanstack/router-generator": "workspace:*", diff --git a/packages/router-core/AGENTS.md b/packages/router-core/AGENTS.md index 7402f0bdfe..b6f0e66911 100644 --- a/packages/router-core/AGENTS.md +++ b/packages/router-core/AGENTS.md @@ -8,5 +8,5 @@ - Backpressure tests are excluded from normal unit runs. For buffering/backpressure changes, run the gated suite below. Its memory case requires exposed GC; bypass Nx cache so a previous run with the gate disabled cannot count as validation. ```sh -RUN_BACKPRESSURE_PERF=1 CI=1 NX_DAEMON=false pnpm nx run-many -p @tanstack/router-core -t test:unit --skipRemoteCache --skipNxCache -- tests/transformStreamBackpressure.perf.test.ts --pool=forks --execArgv=--expose-gc +RUN_BACKPRESSURE_PERF=1 CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-core:test:unit --outputStyle=stream --skipRemoteCache --skipNxCache -- tests/transformStreamBackpressure.perf.test.ts --pool=forks --execArgv=--expose-gc ``` diff --git a/packages/router-core/CHANGELOG.md b/packages/router-core/CHANGELOG.md index b01991e223..1dac820ef4 100644 --- a/packages/router-core/CHANGELOG.md +++ b/packages/router-core/CHANGELOG.md @@ -1,11 +1,5 @@ # @tanstack/router-core -## 1.171.39 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/#`) instead of relative file links that break once packages are installed. - ## 1.171.38 ### Patch Changes diff --git a/packages/router-core/package.json b/packages/router-core/package.json index ed2b794278..45bc69529b 100644 --- a/packages/router-core/package.json +++ b/packages/router-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-core", - "version": "1.171.39", + "version": "1.171.38", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-devtools-core/CHANGELOG.md b/packages/router-devtools-core/CHANGELOG.md index 63eb2961dd..791c877aa9 100644 --- a/packages/router-devtools-core/CHANGELOG.md +++ b/packages/router-devtools-core/CHANGELOG.md @@ -1,11 +1,5 @@ # @tanstack/router-devtools-core -## 1.168.3 - -### Patch Changes - -- [#8888](https://github.com/TanStack/router/pull/8888) [`bbf9b75`](https://github.com/TanStack/router/commit/bbf9b75808d8eee497a6dd1663f0cf08426512e0) - Fix broken styling of the embedded `TanStackRouterDevtoolsPanel` (including inside shadow DOM) by giving the devtools size tokens a `1rem` fallback when `--tsrd-font-size` is not set. - ## 1.168.2 ### Patch Changes diff --git a/packages/router-devtools-core/package.json b/packages/router-devtools-core/package.json index 24db637cc7..722a76e522 100644 --- a/packages/router-devtools-core/package.json +++ b/packages/router-devtools-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-devtools-core", - "version": "1.168.3", + "version": "1.168.2", "description": "Modern and scalable routing for Web applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-devtools-core/src/tokens.ts b/packages/router-devtools-core/src/tokens.ts index 97ed9e4cd9..9d247cf184 100644 --- a/packages/router-devtools-core/src/tokens.ts +++ b/packages/router-devtools-core/src/tokens.ts @@ -161,37 +161,37 @@ export const tokens = { }, font: { size: { - '2xs': 'calc(var(--tsrd-font-size, 1rem) * 0.625)', - xs: 'calc(var(--tsrd-font-size, 1rem) * 0.75)', - sm: 'calc(var(--tsrd-font-size, 1rem) * 0.875)', - md: 'var(--tsrd-font-size, 1rem)', - lg: 'calc(var(--tsrd-font-size, 1rem) * 1.125)', - xl: 'calc(var(--tsrd-font-size, 1rem) * 1.25)', - '2xl': 'calc(var(--tsrd-font-size, 1rem) * 1.5)', - '3xl': 'calc(var(--tsrd-font-size, 1rem) * 1.875)', - '4xl': 'calc(var(--tsrd-font-size, 1rem) * 2.25)', - '5xl': 'calc(var(--tsrd-font-size, 1rem) * 3)', - '6xl': 'calc(var(--tsrd-font-size, 1rem) * 3.75)', - '7xl': 'calc(var(--tsrd-font-size, 1rem) * 4.5)', - '8xl': 'calc(var(--tsrd-font-size, 1rem) * 6)', - '9xl': 'calc(var(--tsrd-font-size, 1rem) * 8)', + '2xs': 'calc(var(--tsrd-font-size) * 0.625)', + xs: 'calc(var(--tsrd-font-size) * 0.75)', + sm: 'calc(var(--tsrd-font-size) * 0.875)', + md: 'var(--tsrd-font-size)', + lg: 'calc(var(--tsrd-font-size) * 1.125)', + xl: 'calc(var(--tsrd-font-size) * 1.25)', + '2xl': 'calc(var(--tsrd-font-size) * 1.5)', + '3xl': 'calc(var(--tsrd-font-size) * 1.875)', + '4xl': 'calc(var(--tsrd-font-size) * 2.25)', + '5xl': 'calc(var(--tsrd-font-size) * 3)', + '6xl': 'calc(var(--tsrd-font-size) * 3.75)', + '7xl': 'calc(var(--tsrd-font-size) * 4.5)', + '8xl': 'calc(var(--tsrd-font-size) * 6)', + '9xl': 'calc(var(--tsrd-font-size) * 8)', }, lineHeight: { - '3xs': 'calc(var(--tsrd-font-size, 1rem) * 0.75)', - '2xs': 'calc(var(--tsrd-font-size, 1rem) * 0.875)', - xs: 'calc(var(--tsrd-font-size, 1rem) * 1)', - sm: 'calc(var(--tsrd-font-size, 1rem) * 1.25)', - md: 'calc(var(--tsrd-font-size, 1rem) * 1.5)', - lg: 'calc(var(--tsrd-font-size, 1rem) * 1.75)', - xl: 'calc(var(--tsrd-font-size, 1rem) * 2)', - '2xl': 'calc(var(--tsrd-font-size, 1rem) * 2.25)', - '3xl': 'calc(var(--tsrd-font-size, 1rem) * 2.5)', - '4xl': 'calc(var(--tsrd-font-size, 1rem) * 2.75)', - '5xl': 'calc(var(--tsrd-font-size, 1rem) * 3)', - '6xl': 'calc(var(--tsrd-font-size, 1rem) * 3.25)', - '7xl': 'calc(var(--tsrd-font-size, 1rem) * 3.5)', - '8xl': 'calc(var(--tsrd-font-size, 1rem) * 3.75)', - '9xl': 'calc(var(--tsrd-font-size, 1rem) * 4)', + '3xs': 'calc(var(--tsrd-font-size) * 0.75)', + '2xs': 'calc(var(--tsrd-font-size) * 0.875)', + xs: 'calc(var(--tsrd-font-size) * 1)', + sm: 'calc(var(--tsrd-font-size) * 1.25)', + md: 'calc(var(--tsrd-font-size) * 1.5)', + lg: 'calc(var(--tsrd-font-size) * 1.75)', + xl: 'calc(var(--tsrd-font-size) * 2)', + '2xl': 'calc(var(--tsrd-font-size) * 2.25)', + '3xl': 'calc(var(--tsrd-font-size) * 2.5)', + '4xl': 'calc(var(--tsrd-font-size) * 2.75)', + '5xl': 'calc(var(--tsrd-font-size) * 3)', + '6xl': 'calc(var(--tsrd-font-size) * 3.25)', + '7xl': 'calc(var(--tsrd-font-size) * 3.5)', + '8xl': 'calc(var(--tsrd-font-size) * 3.75)', + '9xl': 'calc(var(--tsrd-font-size) * 4)', }, weight: { thin: '100', @@ -220,55 +220,55 @@ export const tokens = { border: { radius: { none: '0px', - xs: 'calc(var(--tsrd-font-size, 1rem) * 0.125)', - sm: 'calc(var(--tsrd-font-size, 1rem) * 0.25)', - md: 'calc(var(--tsrd-font-size, 1rem) * 0.375)', - lg: 'calc(var(--tsrd-font-size, 1rem) * 0.5)', - xl: 'calc(var(--tsrd-font-size, 1rem) * 0.75)', - '2xl': 'calc(var(--tsrd-font-size, 1rem) * 1)', - '3xl': 'calc(var(--tsrd-font-size, 1rem) * 1.5)', + xs: 'calc(var(--tsrd-font-size) * 0.125)', + sm: 'calc(var(--tsrd-font-size) * 0.25)', + md: 'calc(var(--tsrd-font-size) * 0.375)', + lg: 'calc(var(--tsrd-font-size) * 0.5)', + xl: 'calc(var(--tsrd-font-size) * 0.75)', + '2xl': 'calc(var(--tsrd-font-size) * 1)', + '3xl': 'calc(var(--tsrd-font-size) * 1.5)', full: '9999px', }, }, size: { 0: '0px', - 0.25: 'calc(var(--tsrd-font-size, 1rem) * 0.0625)', - 0.5: 'calc(var(--tsrd-font-size, 1rem) * 0.125)', - 1: 'calc(var(--tsrd-font-size, 1rem) * 0.25)', - 1.5: 'calc(var(--tsrd-font-size, 1rem) * 0.375)', - 2: 'calc(var(--tsrd-font-size, 1rem) * 0.5)', - 2.5: 'calc(var(--tsrd-font-size, 1rem) * 0.625)', - 3: 'calc(var(--tsrd-font-size, 1rem) * 0.75)', - 3.5: 'calc(var(--tsrd-font-size, 1rem) * 0.875)', - 4: 'calc(var(--tsrd-font-size, 1rem) * 1)', - 4.5: 'calc(var(--tsrd-font-size, 1rem) * 1.125)', - 5: 'calc(var(--tsrd-font-size, 1rem) * 1.25)', - 5.5: 'calc(var(--tsrd-font-size, 1rem) * 1.375)', - 6: 'calc(var(--tsrd-font-size, 1rem) * 1.5)', - 6.5: 'calc(var(--tsrd-font-size, 1rem) * 1.625)', - 7: 'calc(var(--tsrd-font-size, 1rem) * 1.75)', - 8: 'calc(var(--tsrd-font-size, 1rem) * 2)', - 9: 'calc(var(--tsrd-font-size, 1rem) * 2.25)', - 10: 'calc(var(--tsrd-font-size, 1rem) * 2.5)', - 11: 'calc(var(--tsrd-font-size, 1rem) * 2.75)', - 12: 'calc(var(--tsrd-font-size, 1rem) * 3)', - 14: 'calc(var(--tsrd-font-size, 1rem) * 3.5)', - 16: 'calc(var(--tsrd-font-size, 1rem) * 4)', - 20: 'calc(var(--tsrd-font-size, 1rem) * 5)', - 24: 'calc(var(--tsrd-font-size, 1rem) * 6)', - 28: 'calc(var(--tsrd-font-size, 1rem) * 7)', - 32: 'calc(var(--tsrd-font-size, 1rem) * 8)', - 36: 'calc(var(--tsrd-font-size, 1rem) * 9)', - 40: 'calc(var(--tsrd-font-size, 1rem) * 10)', - 44: 'calc(var(--tsrd-font-size, 1rem) * 11)', - 48: 'calc(var(--tsrd-font-size, 1rem) * 12)', - 52: 'calc(var(--tsrd-font-size, 1rem) * 13)', - 56: 'calc(var(--tsrd-font-size, 1rem) * 14)', - 60: 'calc(var(--tsrd-font-size, 1rem) * 15)', - 64: 'calc(var(--tsrd-font-size, 1rem) * 16)', - 72: 'calc(var(--tsrd-font-size, 1rem) * 18)', - 80: 'calc(var(--tsrd-font-size, 1rem) * 20)', - 96: 'calc(var(--tsrd-font-size, 1rem) * 24)', + 0.25: 'calc(var(--tsrd-font-size) * 0.0625)', + 0.5: 'calc(var(--tsrd-font-size) * 0.125)', + 1: 'calc(var(--tsrd-font-size) * 0.25)', + 1.5: 'calc(var(--tsrd-font-size) * 0.375)', + 2: 'calc(var(--tsrd-font-size) * 0.5)', + 2.5: 'calc(var(--tsrd-font-size) * 0.625)', + 3: 'calc(var(--tsrd-font-size) * 0.75)', + 3.5: 'calc(var(--tsrd-font-size) * 0.875)', + 4: 'calc(var(--tsrd-font-size) * 1)', + 4.5: 'calc(var(--tsrd-font-size) * 1.125)', + 5: 'calc(var(--tsrd-font-size) * 1.25)', + 5.5: 'calc(var(--tsrd-font-size) * 1.375)', + 6: 'calc(var(--tsrd-font-size) * 1.5)', + 6.5: 'calc(var(--tsrd-font-size) * 1.625)', + 7: 'calc(var(--tsrd-font-size) * 1.75)', + 8: 'calc(var(--tsrd-font-size) * 2)', + 9: 'calc(var(--tsrd-font-size) * 2.25)', + 10: 'calc(var(--tsrd-font-size) * 2.5)', + 11: 'calc(var(--tsrd-font-size) * 2.75)', + 12: 'calc(var(--tsrd-font-size) * 3)', + 14: 'calc(var(--tsrd-font-size) * 3.5)', + 16: 'calc(var(--tsrd-font-size) * 4)', + 20: 'calc(var(--tsrd-font-size) * 5)', + 24: 'calc(var(--tsrd-font-size) * 6)', + 28: 'calc(var(--tsrd-font-size) * 7)', + 32: 'calc(var(--tsrd-font-size) * 8)', + 36: 'calc(var(--tsrd-font-size) * 9)', + 40: 'calc(var(--tsrd-font-size) * 10)', + 44: 'calc(var(--tsrd-font-size) * 11)', + 48: 'calc(var(--tsrd-font-size) * 12)', + 52: 'calc(var(--tsrd-font-size) * 13)', + 56: 'calc(var(--tsrd-font-size) * 14)', + 60: 'calc(var(--tsrd-font-size) * 15)', + 64: 'calc(var(--tsrd-font-size) * 16)', + 72: 'calc(var(--tsrd-font-size) * 18)', + 80: 'calc(var(--tsrd-font-size) * 20)', + 96: 'calc(var(--tsrd-font-size) * 24)', }, shadow: { xs: (_: string = 'rgb(0 0 0 / 0.1)') => diff --git a/packages/router-devtools/CHANGELOG.md b/packages/router-devtools/CHANGELOG.md index 201d972d6c..3ba014e38f 100644 --- a/packages/router-devtools/CHANGELOG.md +++ b/packages/router-devtools/CHANGELOG.md @@ -1,12 +1,5 @@ # @tanstack/router-devtools -## 1.167.3 - -### Patch Changes - -- Updated dependencies []: - - @tanstack/react-router-devtools@1.167.3 - ## 1.167.2 ### Patch Changes diff --git a/packages/router-devtools/package.json b/packages/router-devtools/package.json index 4158b280d7..2aa446dbab 100644 --- a/packages/router-devtools/package.json +++ b/packages/router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-devtools", - "version": "1.167.3", + "version": "1.167.2", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/router-generator/AGENTS.md b/packages/router-generator/AGENTS.md index 1cc70bf370..abdfc10100 100644 --- a/packages/router-generator/AGENTS.md +++ b/packages/router-generator/AGENTS.md @@ -1,6 +1,8 @@ # Route generator - Preserve the existing `safeFileWrite` path: temporary-file rename, modification-time conflict retry, and post-rename stat. Keep unchanged-write suppression and main/shadow cache rotation; these protect concurrent edits, avoid watcher loops, and discard deleted routes. -- Run the complete `test:unit` target after generator changes. Its runtime phase generates fixture route trees before typechecking their consumers; `test:types` excludes the generator fixtures. -- Add generation cases under `tests/generator//`. Read [`tests/generator.test.ts`](tests/generator.test.ts) for per-case configuration and preprocessing. Change route inputs/configuration or templates, then regenerate route trees and expected snapshots through the test harness. +- Run the complete `test:unit` and `test:integration` targets after generator changes. The fixtures run in copies (no test writes into this package); `test:integration` type-checks the route trees generated there (`tests/integration/fixture-types-*.test.ts`); `test:types` excludes the generator fixtures. +- Add generation cases under `tests/generator//`. Read [`tests/generator.test.ts`](tests/generator.test.ts) for per-case configuration and preprocessing. Change route inputs/configuration or templates; the test harness generates the route trees (no expected snapshots: the tests read the generated tree through a real router, the type checker and the text the documented output options control). - `preprocess()` recreates selected route files for `file-modification*` and `custom-scaffolding`. Edit their templates/configuration/preprocessing when changing those inputs; edits to recreated files are overwritten. +- To run one test file or `-t` filter quickly, the slow-tier load gate and the test budgets: [compiler-test-utils/AGENTS.md](../compiler-test-utils/AGENTS.md). +- What these tests are, the spec they cite (`J4.12`, `G3`, `§5.7`) and the known bugs: [compiler-test-utils/oracle/README.md](../compiler-test-utils/oracle/README.md). diff --git a/packages/router-generator/CHANGELOG.md b/packages/router-generator/CHANGELOG.md index a37550d255..96af3f4ba7 100644 --- a/packages/router-generator/CHANGELOG.md +++ b/packages/router-generator/CHANGELOG.md @@ -1,25 +1,5 @@ # @tanstack/router-generator -## 1.168.0 - -### Minor Changes - -- [#8855](https://github.com/TanStack/router/pull/8855) [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6) - Require Node `^20.19.0 || >=22.12.0` (was `>=20.19`), so the CommonJS builds can load ESM-only dependencies through `require(esm)`. Node 21 and Node 22.0–22.11 do not enable it by default, so they are no longer supported. - -### Patch Changes - -- [#8857](https://github.com/TanStack/router/pull/8857) [`ad5b3b7`](https://github.com/TanStack/router/commit/ad5b3b7a0990eed7351d672ea6695d341108e0d6) - A pathless layout inside a route group (`routes/(group)/_layout.tsx`) or a route group's own layout (`routes/(group)/route.tsx`) is typed with the full path `'/'` in `FileRoutesByPath`, like the router gives it at runtime, instead of `''`. When no index route claims `/`, the layout also appears under `'/'` in `FileRoutesByFullPath` and `FileRoutesByTo`, as a pathless layout outside a group already does. - -- Updated dependencies [[`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69)]: - - @tanstack/router-utils@1.163.0 - -## 1.167.46 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - ## 1.167.45 ### Patch Changes diff --git a/packages/router-generator/eslint.config.js b/packages/router-generator/eslint.config.js index 8ce6ad05fc..a9b4a96a84 100644 --- a/packages/router-generator/eslint.config.js +++ b/packages/router-generator/eslint.config.js @@ -2,4 +2,16 @@ import rootConfig from '../../eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + // The generator's fixture apps (route files, virtual route configs, + // generated and snapshot route trees): inputs and outputs whose bytes the + // tests compare, most outside the TypeScript project (tsconfig.json). + // Their type tests are linted. + ignores: [ + 'tests/generator/**/*.{ts,tsx,js,jsx}', + '!tests/generator/**/*.test-d.ts', + ], + }, +] diff --git a/packages/router-generator/package.json b/packages/router-generator/package.json index e62e105068..e09fa3f9ab 100644 --- a/packages/router-generator/package.json +++ b/packages/router-generator/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-generator", - "version": "1.168.0", + "version": "1.167.45", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -26,7 +26,7 @@ "scripts": { "clean": "rimraf ./dist && rimraf ./coverage", "clean:snapshots": "rimraf **/*snapshot* --glob", - "test:eslint": "eslint ./src", + "test:eslint": "eslint ./src ./tests", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js -p tsconfig.legacy.json", "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js -p tsconfig.legacy.json", @@ -34,7 +34,8 @@ "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js -p tsconfig.legacy.json", "test:types:ts60": "tsc6 -p tsconfig.legacy.json", "test:types:ts70": "tsc -p tsconfig.legacy.json", - "test:unit": "vitest --typecheck false && vitest run --typecheck.only", + "test:unit": "vitest --project unit", + "test:integration": "vitest --project integration", "test:unit:dev": "pnpm run test:unit --watch --hideSkippedTests", "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", "build": "vite build" @@ -62,7 +63,7 @@ "src" ], "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": ">=20.19" }, "dependencies": { "@babel/types": "catalog:", @@ -75,26 +76,24 @@ "zod": "catalog:" }, "devDependencies": { + "@tanstack/compiler-test-utils": "workspace:*", "@tanstack/react-router": "workspace:*", + "@tanstack/vue-router": "workspace:*", "@types/node": ">=20", "@types/react": "catalog:", + "@vitejs/plugin-vue": "^6.0.5", "react": "catalog:", "vite": "catalog:", + "vue": "catalog:", "@tanstack/vite-config": "catalog:", "vitest": "catalog:", "@arethetypeswrong/cli": "catalog:", "publint": "catalog:", - "rimraf": "catalog:" - }, - "nx": { - "targets": { - "test:unit": { - "outputs": [ - "...", - "{projectRoot}/tests/generator/*/routeTree.gen.{ts,js}", - "{projectRoot}/tests/generator/file-modification/routes/*/*.tsx" - ] - } - } + "rimraf": "catalog:", + "@tanstack/solid-router": "workspace:*", + "react-dom": "catalog:", + "solid-js": "catalog:", + "vite-plugin-solid": "catalog:", + "@types/react-dom": "catalog:" } } diff --git a/packages/router-generator/src/utils.ts b/packages/router-generator/src/utils.ts index a3bb4b746c..747980aa7b 100644 --- a/packages/router-generator/src/utils.ts +++ b/packages/router-generator/src/utils.ts @@ -924,10 +924,9 @@ const inferPath = (routeNode: RouteNode): string => { } /** - * The full path with groups and pathless segments removed. A route group's - * layout (e.g. `/(group)/_layout`) strips down to `''`. + * Infers the full path for use by TS */ -const stripFullPath = (routeNode: RouteNode): string => { +export const inferFullPath = (routeNode: RouteNode): string => { const fullPath = removeGroups( removeLayoutSegmentsAndUnderscoresWithEscape( routeNode.routePath, @@ -950,13 +949,6 @@ const stripFullPath = (routeNode: RouteNode): string => { return fullPath.replace(/\/$/, '') } -/** - * Infers the full path for use by TS - */ -export const inferFullPath = (routeNode: RouteNode): string => - // A route group's layout has the router's full path `/` - stripFullPath(routeNode) || '/' - const shouldPreferIndexRoute = ( current: RouteNode, existing: RouteNode, @@ -1120,12 +1112,8 @@ Conflicting files: \n ${emptyPathRoutes throw new Error(errorMessage) } - // A route group's layout keeps its stripped path `''` here, so one without - // child routes yet doesn't conflict with the index route. A childless - // `_auth.tsx` does: the route tree lists the index route first, and the - // router would then match `/` to the layout const routes = _routes.map((d) => { - const inferredFullPath = stripFullPath(d) + const inferredFullPath = inferFullPath(d) return { ...d, inferredFullPath } }) diff --git a/packages/router-generator/tests/app.ts b/packages/router-generator/tests/app.ts new file mode 100644 index 0000000000..ae548e5831 --- /dev/null +++ b/packages/router-generator/tests/app.ts @@ -0,0 +1,117 @@ +/** + * Shared test helper: apps in temporary directories, configured and + * generated like the bundler plugins and the CLI do. + */ +import { + mkdir, + mkdtemp, + readFile, + rm, + utimes, + writeFile, +} from 'node:fs/promises' +import path from 'node:path' +import { onTestFinished } from 'vitest' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { Generator, getConfig } from '../src' +import { recordInputs } from './consumer-inputs' +import type { Config } from '../src' + +/** + * Creates an app in a temporary directory with the given files (paths + * relative to the app root) and returns its root. The directory is removed + * when the test finishes. + */ +export async function createApp(files: Record) { + const root = await mkdtemp(path.join(runDirectory(), 'tsr-app-')) + onTestFinished(() => rm(root, { recursive: true, force: true })) + for (const [file, content] of Object.entries(files)) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), content) + } + recordInputs(root, files) + return root +} + +/** + * The configuration of the app at `root`, read like the bundler plugins do + * (its `tsr.config.json`, then `inlineConfig`), with the default `src/routes` + * directory and `src/routeTree.gen.ts` route tree. Temporary files go to the + * app, on the same filesystem. + */ +export function configOf(root: string, inlineConfig: Partial = {}) { + const config = getConfig( + { + disableLogging: true, + tmpDir: path.join(root, '.tanstack/tmp'), + ...inlineConfig, + }, + root, + ) + recordInputs(root, {}, config.target) + return config +} + +/** Runs a new generator once on the app at `root`. */ +export async function generate( + root: string, + inlineConfig: Partial = {}, +) { + const config = configOf(root, inlineConfig) + await new Generator({ config, root }).run() + return config +} + +/** Reads an app file (path relative to the app root). */ +export function read(root: string, file: string) { + return readFile(path.join(root, file), 'utf8') +} + +let saves = 0 + +/** + * Writes an app file (path relative to the app root) like an editor save: its + * modification time is later than that of any file written before. Returns + * the absolute path, as a file watcher reports it. + */ +export async function save(root: string, file: string, content: string) { + const filePath = path.join(root, file) + await mkdir(path.dirname(filePath), { recursive: true }) + await writeFile(filePath, content) + const savedAt = new Date(Date.now() + 10_000 + ++saves * 1000) + await utimes(filePath, savedAt, savedAt) + recordInputs(root, { [file]: content }) + return filePath +} + +/** A root route file for `target`. */ +export function rootRoute(target: Config['target'] = 'react') { + return `import { createRootRoute } from '@tanstack/${target}-router' + +export const Route = createRootRoute() +` +} + +/** A route file for `target` creating its route with `id` and `options`. */ +export function fileRoute( + id: string, + options = '{}', + target: Config['target'] = 'react', +) { + return `import { createFileRoute } from '@tanstack/${target}-router' + +export const Route = createFileRoute('${id}')(${options}) +` +} + +/** A lazy route file for `target` creating its route with `id`. */ +export function lazyFileRoute( + id: string, + options = '{}', + target: Config['target'] = 'react', +) { + return `import { createLazyFileRoute } from '@tanstack/${target}-router' + +export const Route = createLazyFileRoute('${id}')(${options}) +` +} diff --git a/packages/router-generator/tests/childless-pathless-layout.test.ts b/packages/router-generator/tests/childless-pathless-layout.test.ts deleted file mode 100644 index caef9449bf..0000000000 --- a/packages/router-generator/tests/childless-pathless-layout.test.ts +++ /dev/null @@ -1,107 +0,0 @@ -import fs from 'node:fs/promises' -import os from 'node:os' -import path from 'node:path' -import { afterEach, describe, expect, it, test } from 'vitest' - -import { Generator, getConfig } from '../src' - -let tempDir: string | undefined - -afterEach(async () => { - if (tempDir) { - await fs.rm(tempDir, { recursive: true, force: true }) - tempDir = undefined - } -}) - -function routeSource(id: string) { - if (id === '__root__') { - return `import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute() -` - } - return `import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('${id}')() -` -} - -async function generate(files: Record) { - tempDir = await fs.mkdtemp( - path.join(os.tmpdir(), 'tsr-generator-childless-layout-'), - ) - const routesDirectory = path.join(tempDir, 'routes') - for (const [file, id] of Object.entries(files)) { - const filePath = path.join(routesDirectory, file) - await fs.mkdir(path.dirname(filePath), { recursive: true }) - await fs.writeFile(filePath, routeSource(id)) - } - const generatedRouteTree = path.join(tempDir, 'routeTree.gen.ts') - const generator = new Generator({ - config: getConfig( - { - disableLogging: true, - routesDirectory, - generatedRouteTree, - tmpDir: path.join(tempDir, 'tmp'), - }, - tempDir, - ), - root: tempDir, - }) - await generator.run() - return fs.readFile(generatedRouteTree, 'utf-8') -} - -// A route group's layout without child routes yet next to the index route -// generates, as before route-group layouts were typed with the full path `/`. -describe('a route-group layout without child routes yet next to the index route', () => { - it.each([ - { file: '(group)/_layout.tsx', id: '/(group)/_layout' }, - { file: '(marketing)/route.tsx', id: '/(marketing)' }, - ])('$file is added to the route tree', async ({ file, id }) => { - const routeTree = await generate({ - '__root.tsx': '__root__', - 'index.tsx': '/', - [file]: id, - }) - - expect(routeTree).toContain(`'${id}': typeof`) - }) -}) - -// The route tree lists the index route first, and the router then matches -// `/` to a pathless layout without child routes instead of the index route. -// The generator refuses that pair rather than hide the index route. -test('a pathless layout without child routes yet conflicts with the index route', async () => { - await expect( - generate({ - '__root.tsx': '__root__', - 'index.tsx': '/', - '_auth.tsx': '/_auth', - }), - ).rejects.toThrow( - 'Conflicting configuration paths were found for the following routes: "/", "/".', - ) -}) - -// A pathless layout whose parent directory has no route file of its own -// (`foo/_layout.tsx` without `foo.tsx`) carries that directory's path, so it -// matches `/foo` like any other route there. -describe('a layout without child routes yet that adds a path', () => { - it.each([ - { file: '(group)/foo.tsx', id: '/(group)/foo' }, - { file: 'foo_.tsx', id: '/foo_' }, - ])('conflicts with $file at the same full path', async ({ file, id }) => { - await expect( - generate({ - '__root.tsx': '__root__', - 'foo/_layout.tsx': '/foo/_layout', - [file]: id, - }), - ).rejects.toThrow( - 'Conflicting configuration paths were found for the following routes: "/foo", "/foo".', - ) - }) -}) diff --git a/packages/router-generator/tests/concurrent-write.test.ts b/packages/router-generator/tests/concurrent-write.test.ts deleted file mode 100644 index 6550ad562d..0000000000 --- a/packages/router-generator/tests/concurrent-write.test.ts +++ /dev/null @@ -1,148 +0,0 @@ -import fs from 'node:fs/promises' -import os from 'node:os' -import path from 'node:path' -import { afterEach, describe, expect, it } from 'vitest' - -import { Generator, getConfig } from '../src' - -const rootRouteSource = `import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute() -` - -const postsRouteSource = `import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/posts')({ - component: () => 'posts', -}) -` - -const savedPostsRouteSource = postsRouteSource.replace("'posts'", "'saved'") - -let tempDir: string | undefined - -afterEach(async () => { - if (tempDir) { - await fs.rm(tempDir, { recursive: true, force: true }) - tempDir = undefined - } -}) - -async function readFileWithStat(filePath: string) { - try { - const fileHandle = await fs.open(filePath, 'r') - const stat = await fileHandle.stat({ bigint: true }) - const fileContent = (await fileHandle.readFile()).toString() - await fileHandle.close() - return { stat, fileContent } - } catch (e: any) { - if (e?.code === 'ENOENT') { - return 'file-not-existing' as const - } - throw e - } -} - -describe('generator with concurrent in-place saves', () => { - it.each(['route file read', 'temporary file stat'] as const)( - 'does not scaffold over a route file whose in-place save completes during the %s', - async (completeSaveDuring) => { - tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'tsr-generator-race-')) - const routesDirectory = path.join(tempDir, 'routes') - const tmpDir = path.join(tempDir, 'tmp') - const postsRoutePath = path.join(routesDirectory, 'posts.tsx') - await fs.mkdir(routesDirectory) - await fs.writeFile( - path.join(routesDirectory, '__root.tsx'), - rootRouteSource, - ) - await fs.writeFile(postsRoutePath, postsRouteSource) - - let saveRacesNextRead = false - let completeSave: (() => Promise) | undefined - - const generator = new Generator({ - config: getConfig( - { - disableLogging: true, - routesDirectory, - generatedRouteTree: path.join(tempDir, 'routeTree.gen.ts'), - tmpDir, - }, - tempDir, - ), - root: tempDir, - fs: { - rename: (oldPath, newPath) => fs.rename(oldPath, newPath), - writeFile: (filePath, content) => fs.writeFile(filePath, content), - readFile: async (filePath) => { - // The generator passes route paths with forward slashes, also on - // Windows. - if ( - !saveRacesNextRead || - path.resolve(filePath) !== postsRoutePath - ) { - return readFileWithStat(filePath) - } - saveRacesNextRead = false - - // An editor saving in place truncates the file before writing the - // new content, so the generator can observe an empty route file. - await fs.truncate(postsRoutePath) - const result = await readFileWithStat(postsRoutePath) - if (result === 'file-not-existing') { - throw new Error('expected the route file to exist') - } - - // The save then completes within the same timestamp tick, which is - // common for filesystems with coarse mtime granularity. - completeSave = async () => { - completeSave = undefined - await fs.writeFile(postsRoutePath, savedPostsRouteSource) - const truncatedAt = new Date(Number(result.stat.mtimeMs)) - await fs.utimes(postsRoutePath, truncatedAt, truncatedAt) - } - if (completeSaveDuring === 'route file read') { - await completeSave() - } - - return result - }, - stat: async (filePath) => { - if (completeSave && path.resolve(filePath).startsWith(tmpDir)) { - await completeSave() - } - const stat = await fs.stat(filePath, { bigint: true }) - return { - mtimeMs: stat.mtimeMs, - mode: Number(stat.mode), - uid: Number(stat.uid), - gid: Number(stat.gid), - } - }, - chmod: (filePath, mode) => fs.chmod(filePath, mode), - chown: (filePath, uid, gid) => fs.chown(filePath, uid, gid), - }, - }) - - await generator.run() - - // A first save makes the generator process the route file again, and the - // next save races with that read. - await fs.writeFile( - postsRoutePath, - postsRouteSource.replace("'posts'", "'edited'"), - ) - const editedAt = new Date(Date.now() + 10_000) - await fs.utimes(postsRoutePath, editedAt, editedAt) - saveRacesNextRead = true - await generator.run({ type: 'update', path: postsRoutePath }) - - expect(saveRacesNextRead).toBe(false) - expect(completeSave).toBeUndefined() - await expect(fs.readFile(postsRoutePath, 'utf8')).resolves.toBe( - savedPostsRouteSource, - ) - }, - ) -}) diff --git a/packages/router-generator/tests/config.test.ts b/packages/router-generator/tests/config.test.ts deleted file mode 100644 index 1290920040..0000000000 --- a/packages/router-generator/tests/config.test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { join } from 'node:path' -import { describe, expect, it } from 'vitest' - -import { getConfig } from '../src' - -function makeFolderDir(folder: string) { - return join(process.cwd(), 'tests', 'config', folder) -} - -type TestCases = Array<{ - folder: string -}> - -describe('load config tests', () => { - it.each([ - { - folder: 'json-config', - }, - ] satisfies TestCases)( - 'should load config correctly: $folder', - async ({ folder }) => { - const absPath = makeFolderDir(folder) - const resolvedConfig = getConfig({}, absPath) - expect(resolvedConfig).toEqual( - expect.objectContaining({ - disableLogging: true, - routesDirectory: join(absPath, './configured-routes-path'), - generatedRouteTree: join(absPath, './routeTree.gen.ts'), - }), - ) - }, - ) -}) diff --git a/packages/router-generator/tests/config/json-config/tsr.config.json b/packages/router-generator/tests/config/json-config/tsr.config.json deleted file mode 100644 index ef0d33482e..0000000000 --- a/packages/router-generator/tests/config/json-config/tsr.config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "disableLogging": true, - "routesDirectory": "./configured-routes-path", - "generatedRouteTree": "./routeTree.gen.ts" -} diff --git a/packages/router-generator/tests/consumer-client.ts b/packages/router-generator/tests/consumer-client.ts new file mode 100644 index 0000000000..9ee8f5f7eb --- /dev/null +++ b/packages/router-generator/tests/consumer-client.ts @@ -0,0 +1,132 @@ +/** Generated trees mounted by the real framework and router in Chromium. */ +import { randomUUID } from 'node:crypto' +import { rm, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { createServer } from 'vite' +import { runInPage } from '@tanstack/compiler-test-utils/browser' +import { openDiagnosticChannel } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { inputsOf } from './consumer-inputs' +import type { PluginOption } from 'vite' + +export async function createClientConsumer( + treeFile: string, + framework: string, +) { + const { root } = inputsOf(treeFile) + const entry = path.join( + path.dirname(treeFile), + `.consumer-client-${randomUUID()}.tsx`, + ) + const mount = + framework === 'react' + ? `import { createElement } from 'react' +import { createRoot } from 'react-dom/client' +import { flushSync } from 'react-dom' +const mount = (router, target) => flushSync(() => createRoot(target).render(createElement(runtime.RouterProvider, { router })))` + : framework === 'vue' + ? `import { createApp, h, nextTick } from 'vue' +const mount = async (router, target) => { + createApp({ render: () => h(runtime.RouterProvider, { router }) }).mount(target) + await nextTick() +}` + : `import { render, createComponent } from 'solid-js/web' +const mount = (router, target) => render(() => createComponent(runtime.RouterProvider, { router }), target)` + await writeFile( + entry, + `import { waitForOutcome } from '@tanstack/compiler-test-utils/outcome' +import * as runtime from '@tanstack/${framework}-router' +import { routeTree } from ${JSON.stringify('./' + path.basename(treeFile))} +${mount} +export async function renderAt(url, expectedParagraphs) { + const router = runtime.createRouter({ routeTree, history: runtime.createMemoryHistory({ initialEntries: [url] }) }) + await router.load() + const target = document.getElementById('root') + await mount(router, target) + await waitForOutcome({ + applied: () => JSON.stringify([...target.querySelectorAll('p')].map((element) => element.textContent)) === JSON.stringify(expectedParagraphs), + timeout: 15_000, + describe: () => target.innerHTML, + }) + return target.innerHTML +} +`, + ) + const plugins: Array = [ + { + name: 'generator-consumer:page', + configureServer(server) { + server.middlewares.use(async (request, response, next) => { + if (request.url !== '/__consumer.html') { + next() + return + } + try { + response.setHeader('Content-Type', 'text/html') + response.end( + await server.transformIndexHtml( + '/__consumer.html', + '
', + ), + ) + } catch (error) { + next(error) + } + }) + }, + }, + ] + if (framework === 'vue') { + plugins.push((await import('@vitejs/plugin-vue')).default()) + } + if (framework === 'solid') { + plugins.push((await import('vite-plugin-solid')).default()) + } + const channel = openDiagnosticChannel() + const server = await createServer({ + root, + cacheDir: path.join(root, '.vite-consumer', framework), + configFile: false, + envDir: false, + appType: 'custom', + plugins, + customLogger: channel.viteLogger(), + server: { host: '127.0.0.1', port: 0, watch: null }, + optimizeDeps: { + include: [ + `@tanstack/${framework}-router`, + '@tanstack/compiler-test-utils/outcome', + ...(framework === 'react' + ? ['react', 'react-dom/client', 'react-dom'] + : framework === 'solid' + ? ['solid-js', 'solid-js/web'] + : ['vue']), + ], + }, + }) + await server.listen() + const base = server.resolvedUrls!.local[0]! + return { + async renderAt(url: string, expectedParagraphs: Array) { + const result = await runInPage({ + pageUrl: new URL('/__consumer.html', base).href, + moduleUrl: new URL( + '/' + path.relative(root, entry).replaceAll(path.sep, '/'), + base, + ).href, + script: `return module.renderAt(${JSON.stringify(url)}, ${JSON.stringify(expectedParagraphs)})`, + }) + if (result.errors.length) { + throw new Error(result.errors.join('\n')) + } + return result.result + }, + async close() { + try { + await server.close() + } finally { + channel.close() + await rm(entry, { force: true }) + } + }, + } +} diff --git a/packages/router-generator/tests/consumer-inputs.ts b/packages/router-generator/tests/consumer-inputs.ts new file mode 100644 index 0000000000..af042ee2e3 --- /dev/null +++ b/packages/router-generator/tests/consumer-inputs.ts @@ -0,0 +1,62 @@ +/** Fixture-owned files, recorded before generation; generated support is free. */ +import { existsSync } from 'node:fs' +import { readFile, readdir } from 'node:fs/promises' +import path from 'node:path' + +const apps = new Map< + string, + { files: Record; target: string } +>() + +export function recordInputs( + root: string, + files: Record, + target?: string, +) { + const absolute = path.resolve(root) + const app = apps.get(absolute) ?? { files: {}, target: 'react' } + const inputs = app.files + for (const [file, source] of Object.entries(files)) { + inputs[path.resolve(root, file)] = source + } + app.target = target ?? app.target + apps.set(absolute, app) +} + +export async function recordDirectoryInputs(root: string, excluded: string) { + const files: Record = {} + async function visit(dir: string) { + for (const entry of await readdir(dir, { withFileTypes: true })) { + const file = path.join(dir, entry.name) + if (entry.isDirectory()) { + if (entry.name !== 'node_modules' && !entry.name.startsWith('.')) { + await visit(file) + } + } else if ( + file !== excluded && + /\.(?:[cm]?[jt]sx?|vue)$/.test(file) && + !file.endsWith('.test-d.ts') + ) { + files[path.relative(root, file)] = await readFile(file, 'utf8') + } + } + } + await visit(root) + recordInputs(root, files) +} + +export function inputsOf(file: string) { + const entry = [...apps] + .filter(([root]) => file.startsWith(root + path.sep)) + .sort(([a], [b]) => b.length - a.length)[0] + if (!entry) { + throw new Error(`No fixture inputs recorded for ${file}`) + } + return { + root: entry[0], + target: entry[1].target, + files: Object.fromEntries( + Object.entries(entry[1].files).filter(([input]) => existsSync(input)), + ), + } +} diff --git a/packages/router-generator/tests/crlf-app.ts b/packages/router-generator/tests/crlf-app.ts new file mode 100644 index 0000000000..9c5a6aac06 --- /dev/null +++ b/packages/router-generator/tests/crlf-app.ts @@ -0,0 +1,60 @@ +/** Shared real generation workload: semantic acceptance and byte control. */ +import fs from 'node:fs/promises' +import path, { join } from 'node:path' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { Generator, getConfig } from '../src' +import { recordDirectoryInputs } from './consumer-inputs' +import { observeRouteTree } from './route-tree' + +export const crlfRoutes = { + '__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + component: () => null, +}) +`, + 'posts.$postId.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/posts/$postId')({ + loader: () => 'post', +}) +`, +} + +/** Runs the generator twice on the routes with `newline` line endings. */ +export async function generateCrlf(newline: string) { + const root = await fs.mkdtemp(path.join(runDirectory(), 'tsr-crlf-')) + try { + await fs.mkdir(join(root, 'routes')) + for (const [file, code] of Object.entries(crlfRoutes)) { + await fs.writeFile( + join(root, 'routes', file), + code.replaceAll('\n', newline), + ) + } + const config = getConfig({ + disableLogging: true, + routesDirectory: join(root, 'routes'), + generatedRouteTree: join(root, 'routeTree.gen.ts'), + tmpDir: join(root, '.tanstack/tmp'), + }) + await recordDirectoryInputs(root, config.generatedRouteTree) + const read = async () => ({ + observed: await observeRouteTree(config.generatedRouteTree), + treeBytes: await fs.readFile(config.generatedRouteTree, 'utf8'), + routes: await Promise.all( + Object.keys(crlfRoutes).map((file) => + fs.readFile(join(root, 'routes', file), 'utf8'), + ), + ), + }) + await new Generator({ config, root }).run() + const first = await read() + const observed = await observeRouteTree(config.generatedRouteTree) + await new Generator({ config, root }).run() + return { first, observed, second: await read() } + } finally { + await fs.rm(root, { recursive: true, force: true }) + } +} diff --git a/packages/router-generator/tests/deny-route-group-config.test.ts b/packages/router-generator/tests/deny-route-group-config.test.ts index 7af8ddd69a..8dfa2261b4 100644 --- a/packages/router-generator/tests/deny-route-group-config.test.ts +++ b/packages/router-generator/tests/deny-route-group-config.test.ts @@ -1,71 +1,142 @@ -import { join } from 'node:path' +/** + * A standalone route file named like a route group (`(group).tsx`): route + * groups are documented as directories only (routing/routing-concepts.md + * :627-643, routing/file-naming-conventions.md:15), so this form is + * undocumented and must never fail silently (SPEC §2.2, G5). Three outcomes + * are acceptable: + * + * - a failed run naming the file; + * - a warning or error naming the file, and a route tree the router loads; + * - no diagnostic, and correct routing: the group adds no URL segment, its + * child index and the other pages render at their URLs. + * + * Which route (if any) `(group).tsx` becomes, and whether it wraps the + * group's children, is not documented, so it is not required. No channel is + * required either. Route group directories are tested in + * real-router.test.ts and route-paths.test.ts. + */ +import path from 'node:path' import { describe, expect, it } from 'vitest' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { Generator } from '../src' +import { configOf, createApp, fileRoute, rootRoute } from './app' +import { withRouteTree } from './route-tree' -import { Generator, getConfig } from '../src' -import type { Config } from '../src' - -function makeFolderDir(folder: string) { - return join(process.cwd(), 'tests', 'deny-route-group-config', folder) +/** A route file whose page renders `text`. */ +function page(text: string) { + return fileRoute('/', `{ component: () => ${JSON.stringify(text)} }`) } -function setupConfig( - folder: string, - inlineConfig: Partial> = {}, -) { - const { generatedRouteTree = `/routeTree.gen.ts`, ...rest } = inlineConfig - const dir = makeFolderDir(folder) - - const config = getConfig({ - disableLogging: true, - routesDirectory: dir, - generatedRouteTree: dir + generatedRouteTree, - ...rest, +/** + * Asserts the routing of an app with `about.tsx` and a group index at + * `indexUrl`: no full path names the group, and each page renders at its + * URL. + */ +async function expectGroupRouting(treeFile: string, indexUrl: string) { + await withRouteTree(treeFile, async ({ router, renderAt }) => { + expect( + Object.values(router.routesById) + .map((route) => route.fullPath) + .filter((fullPath) => fullPath.includes('(group)')), + 'the full paths that name the group', + ).toEqual([]) + expect(await renderAt('/about')).toContain('about page') + expect(await renderAt(indexUrl)).toContain('group index page') }) - return config } -type TestCases = Array<{ - folder: string - expectedError: string -}> +/** + * Generates an app with `files` (route files under `src/routes`, besides the + * root route and `about.tsx`). Returns the app, its config, the error of a + * failed run and the console diagnostics. + */ +async function generateApp(files: Record) { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/about.tsx': page('about page'), + ...Object.fromEntries( + Object.entries(files).map(([file, code]) => [`src/routes/${file}`, code]), + ), + }) + const config = configOf(root, { disableLogging: false }) + const { result: error, diagnostics } = await captureDiagnostics(() => + new Generator({ config, root }).run().then( + () => undefined, + (e: unknown) => e as Error, + ), + ) + return { root, config, error, diagnostics } +} -describe('deny-route-group-config throws', () => { +describe('route files named like a route group', () => { const testCases = [ + { name: 'flat-flat', group: '(group).tsx', index: '(group).index.tsx' }, + { name: 'nested-flat', group: '(group).tsx', index: '(group)/index.tsx' }, { - folder: 'flat-flat', - expectedError: - 'A route configuration for a route group was found at `(group).tsx`. This is not supported. Did you mean to use a layout/pathless route instead?', + name: 'flat-nested', + group: 'nested/(group).tsx', + index: 'nested/(group).index.tsx', }, { - folder: 'nested-flat', - expectedError: - 'A route configuration for a route group was found at `(group).tsx`. This is not supported. Did you mean to use a layout/pathless route instead?', - }, - { - folder: 'flat-nested', - expectedError: - 'A route configuration for a route group was found at `nested/(group).tsx`. This is not supported. Did you mean to use a layout/pathless route instead?', - }, - { - folder: 'nested-nested', - expectedError: - 'A route configuration for a route group was found at `nested/(group).tsx`. This is not supported. Did you mean to use a layout/pathless route instead?', + name: 'nested-nested', + group: 'nested/(group).tsx', + index: 'nested/(group)/index.tsx', }, ] - it.each(testCases)( - 'should throw an error for the folder: $folder', - async ({ folder, expectedError }) => { - const config = setupConfig(folder) - const folderRoot = makeFolderDir(folder) - - const generator = new Generator({ config, root: folderRoot }) - try { - await generator.run() - } catch (error) { - expect(error).toBeInstanceOf(Error) - expect((error as Error).message.startsWith(expectedError)).toBeTruthy() + // Bug: the generator rejects a `(group).tsx` route file with an error that + // names the file relative to the routes directory (`(group).tsx`, + // `nested/(group).tsx` for `src/routes/nested/(group).tsx`), neither + // absolute nor project-relative (SPEC G5, §5.7: a diagnostic names the + // file by its absolute or project-relative path); it neither warns with the file's name nor routes + // the app. + // Source: src/filesystem/physical/getRouteNodes.ts (the "route + // configuration for a route group" error interpolates `filePath`, the + // path under `routesDirectory`). + // Impact: the failed run names a path that does not open from the project + // root (`(group).tsx` is `src/routes/(group).tsx`), so the user has to + // guess where the file to rename is. Low: diagnostics only. + it.fails.each(testCases)( + 'a (group).tsx route file is reported by name or routes correctly: $name', + async ({ group, index }) => { + const { root, config, error, diagnostics } = await generateApp({ + [group]: page('group layout'), + [index]: page('group index page'), + }) + const file = path.join('src/routes', group) + if (error) { + expectDiagnostic(error, { file, root }) + return } + const reported = findDiagnostics(diagnostics, { + severity: ['error', 'warning'], + file, + root, + }) + if (reported.length > 0) { + await withRouteTree(config.generatedRouteTree, () => {}) + return + } + await expectGroupRouting( + config.generatedRouteTree, + group.startsWith('nested/') ? '/nested/' : '/', + ) }, ) + + // (control: the routing check accepts the documented group directory) + it('a route group directory routes correctly', async () => { + const { config, error, diagnostics } = await generateApp({ + '(group)/index.tsx': page('group index page'), + }) + expect(error).toBeUndefined() + expect( + diagnostics.filter((diagnostic) => diagnostic.severity !== 'info'), + ).toEqual([]) + await expectGroupRouting(config.generatedRouteTree, '/') + }) }) diff --git a/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).index.tsx b/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).index.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).index.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).tsx b/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-flat/(group).tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-flat/__root.tsx b/packages/router-generator/tests/deny-route-group-config/flat-flat/__root.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-flat/__root.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-flat/about.tsx b/packages/router-generator/tests/deny-route-group-config/flat-flat/about.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-flat/about.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-nested/__root.tsx b/packages/router-generator/tests/deny-route-group-config/flat-nested/__root.tsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/router-generator/tests/deny-route-group-config/flat-nested/about.tsx b/packages/router-generator/tests/deny-route-group-config/flat-nested/about.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-nested/about.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).index.tsx b/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).index.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).index.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).tsx b/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/flat-nested/nested/(group).tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-flat/(group).tsx b/packages/router-generator/tests/deny-route-group-config/nested-flat/(group).tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-flat/(group).tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-flat/(group)/index.tsx b/packages/router-generator/tests/deny-route-group-config/nested-flat/(group)/index.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-flat/(group)/index.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-flat/__root.tsx b/packages/router-generator/tests/deny-route-group-config/nested-flat/__root.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-flat/__root.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-flat/about.tsx b/packages/router-generator/tests/deny-route-group-config/nested-flat/about.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-flat/about.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-nested/__root.tsx b/packages/router-generator/tests/deny-route-group-config/nested-nested/__root.tsx deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/packages/router-generator/tests/deny-route-group-config/nested-nested/about.tsx b/packages/router-generator/tests/deny-route-group-config/nested-nested/about.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-nested/about.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group).tsx b/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group).tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group).tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group)/index.tsx b/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group)/index.tsx deleted file mode 100644 index ab504e42e9..0000000000 --- a/packages/router-generator/tests/deny-route-group-config/nested-nested/nested/(group)/index.tsx +++ /dev/null @@ -1 +0,0 @@ -/** */ diff --git a/packages/router-generator/tests/determinism-app.ts b/packages/router-generator/tests/determinism-app.ts new file mode 100644 index 0000000000..9999ab9819 --- /dev/null +++ b/packages/router-generator/tests/determinism-app.ts @@ -0,0 +1,207 @@ +/** + * The app of the route tree determinism tests (`determinism.test.ts`): its + * route files, a fresh generation at a root, and listing orders of the + * filesystem. + */ +import fs from 'node:fs' +import fsp, { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { syncBuiltinESMExports } from 'node:module' +import { tmpdir } from 'node:os' +import path from 'node:path' +import { expect, onTestFinished, vi } from 'vitest' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + captureDiagnostics, + expectNoProblems, +} from '@tanstack/compiler-test-utils/diagnostic-channel' +import { Generator } from '../src' +import { configOf, fileRoute, lazyFileRoute, rootRoute } from './app' +import { recordInputs } from './consumer-inputs' +import { observeRouteTree } from './route-tree' + +/** + * Route files whose routes tie on everything but their names (siblings of + * the same depth and kind), with index routes, layouts, lazy files and + * params. + */ +export const files: Record = { + 'src/routes/__root.tsx': rootRoute(), + // A required J1.12 diagnostic exercises semantic diagnostic determinism. + 'src/routes/helper.tsx': 'export const helper = 1', + 'src/routes/index.tsx': fileRoute('/wrong'), + 'src/routes/about.tsx': fileRoute('/wrong'), + 'src/routes/posts.tsx': fileRoute('/wrong'), + 'src/routes/posts/index.tsx': fileRoute('/wrong'), + 'src/routes/posts/$postId.tsx': fileRoute('/wrong'), + 'src/routes/posts/$postId.lazy.tsx': lazyFileRoute('/wrong'), + 'src/routes/account/busy-guard.tsx': fileRoute('/wrong'), + 'src/routes/account/beta-features.tsx': fileRoute('/wrong'), + 'src/routes/account/alpha.tsx': fileRoute('/wrong'), + 'src/routes/_auth.tsx': fileRoute('/wrong'), + 'src/routes/_auth/login.tsx': fileRoute('/wrong'), + 'src/routes/_auth/signup.tsx': fileRoute('/wrong'), + 'src/routes/(marketing)/pricing.tsx': fileRoute('/wrong'), + 'src/routes/(marketing)/features.tsx': fileRoute('/wrong'), +} + +/** The app's route files as the tree's directory (`src`) names them. */ +const routeFiles = new Set( + Object.keys(files).map((file) => path.posix.relative('src', file)), +) + +/** An app directory removed when the test finishes. */ +export async function appRoot() { + const root = await mkdtemp(path.join(tmpdir(), 'tsr-determinism-')) + onTestFinished(() => rm(root, { recursive: true, force: true })) + return root +} + +/** + * Writes the app's route files at `root` (anew), runs a new generator, and + * returns the tree it wrote (`tree`, its bytes: for the implementation + * control only), the routes the real router builds from it, and the + * warnings and errors the generator logged. + */ +export async function generateFresh(root: string) { + await rm(path.join(root, 'src'), { recursive: true, force: true }) + for (const [file, content] of Object.entries(files)) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), content) + } + recordInputs(root, files) + const config = configOf(root, { disableLogging: false }) + const { diagnostics } = await captureDiagnostics(() => + new Generator({ config, root }).run(), + ) + const diagnosticContract = { + // (a warning: the run goes on, so no error) + severity: 'warning' as const, + file: 'src/routes/helper.tsx', + root, + } + expectDiagnostic(diagnostics, diagnosticContract) + const reported = findDiagnostics(diagnostics, diagnosticContract) + expectNoProblems( + diagnostics.filter((diagnostic) => !reported.includes(diagnostic)), + ) + return { + tree: await readFile(config.generatedRouteTree, 'utf8'), + routes: await observeRouteTree(config.generatedRouteTree), + // Compare the file reported, not wording, grouping, channel, severity + // labels, or duplicate presentations of the same diagnosis. + diagnostics: [{ file: diagnosticContract.file }], + } +} + +/** + * What a generation means (SPEC J1.5, G4): each route's path, parent and + * route file, the app's route files that load only with it, and the + * warnings and errors of the generation. Not the tree's bytes or generated + * names, nor generated support modules a route's load may evaluate. + */ +export function routeTreeSemantics({ + routes, + diagnostics, +}: Awaited>) { + return { + routes: Object.fromEntries( + Object.entries(routes).map(([id, route]) => [ + id, + { ...route, lazy: route.lazy.filter((file) => routeFiles.has(file)) }, + ]), + ), + diagnostics, + } +} + +/** + * Runs `run` while the filesystem lists directories in another order: + * `fs.promises.readdir`, `fs.readdir` and `fs.readdirSync` return the real + * entries, permuted by `order` (any order is a valid listing; filesystems + * differ: tmpfs lists by name, ext4 by hash). Fails when `run` listed no + * directory through them: the order would not have varied anything. + */ +export async function withListingOrder( + order: (entries: Array) => Array, + run: () => Promise, +) { + let listings = 0 + const permuted = (entries: Array) => { + listings++ + return order(entries) + } + const readdir = fsp.readdir + const readdirCallback = fs.readdir + const readdirSync = fs.readdirSync + const spies = [ + vi + .spyOn(fsp, 'readdir') + .mockImplementation((async (...args: Array) => + permuted( + await (readdir as (...args: Array) => Promise>)( + ...args, + ), + )) as unknown as typeof readdir), + vi.spyOn(fs, 'readdir').mockImplementation(((...args: Array) => { + const done = args.pop() as (error: unknown, entries?: Array) => void + ;(readdirCallback as (...args: Array) => void)( + ...args, + (error: unknown, entries?: Array) => + done(error, entries && permuted(entries)), + ) + }) as unknown as typeof readdirCallback), + vi + .spyOn(fs, 'readdirSync') + .mockImplementation(((...args: Array) => + permuted( + (readdirSync as (...args: Array) => Array)(...args), + )) as unknown as typeof readdirSync), + ] + // (`import * as fsp from 'node:fs/promises'` sees the change only once + // the module's ES exports are synced with its object) + syncBuiltinESMExports() + try { + const result = await run() + expect(listings, 'directories the generation listed').toBeGreaterThan(0) + return result + } finally { + for (const spy of spies) { + spy.mockRestore() + } + syncBuiltinESMExports() + } +} + +/** Valid listings of the same entries: as listed, reversed, rotated by one. */ +export const listingOrders: Array< + (entries: Array) => Array +> = [ + (entries) => entries, + (entries) => [...entries].reverse(), + (entries) => [...entries.slice(1), ...entries.slice(0, 1)], +] + +/** The working directories a generation runs from (`root` is the app's). */ +export const workingDirectories = (root: string) => [ + root, + path.join(root, 'other'), + tmpdir(), +] + +/** + * Runs `run` with `directory` (created if missing) as the working + * directory, restoring the previous one afterwards. + */ +export async function inDirectory(directory: string, run: () => Promise) { + const cwd = process.cwd() + await mkdir(directory, { recursive: true }) + process.chdir(directory) + try { + return await run() + } finally { + process.chdir(cwd) + } +} diff --git a/packages/router-generator/tests/determinism.test.ts b/packages/router-generator/tests/determinism.test.ts new file mode 100644 index 0000000000..ae499ce0c2 --- /dev/null +++ b/packages/router-generator/tests/determinism.test.ts @@ -0,0 +1,48 @@ +/** + * The route tree is deterministic (SPEC J1.5, G4): for the same app and + * configuration, the order in which the filesystem lists the route files + * and the working directory change neither the routes the real router + * builds from the tree (route-tree.ts) nor, for the listing order, the + * generation's warnings and errors. Only incidental order varies here (ctu `expectDeterministic`); + * what is compared is what the tree means (`routeTreeSemantics`): how the + * tree is printed and how siblings are sorted is free. + * + * (The listing order is varied at the filesystem boundary: writing the files + * in another order does not change it on tmpfs, which lists by name, nor on + * ext4, which lists by hash. Another process gives no other input: the + * generator's output depends on no randomness or process state the tests + * could vary.) + */ +import { describe, test } from 'vitest' +import { expectDeterministic } from '@tanstack/compiler-test-utils/determinism' +import { + appRoot, + generateFresh, + inDirectory, + listingOrders, + routeTreeSemantics, + withListingOrder, + workingDirectories, +} from './determinism-app' + +describe('route tree determinism', () => { + test('the order the filesystem lists the route files in does not change the routes', async () => { + const root = await appRoot() + await expectDeterministic( + listingOrders, + (order) => withListingOrder(order, () => generateFresh(root)), + { project: routeTreeSemantics }, + ) + }) + + test('the working directory does not change the routes', async () => { + const root = await appRoot() + await expectDeterministic( + workingDirectories(root), + (directory) => inDirectory(directory, () => generateFresh(root)), + // (the routes only: diagnostics may name files relative to the + // working directory, §5.7) + { project: (generation) => routeTreeSemantics(generation).routes }, + ) + }) +}) diff --git a/packages/router-generator/tests/generator-dev.test.ts b/packages/router-generator/tests/generator-dev.test.ts new file mode 100644 index 0000000000..64667cd8af --- /dev/null +++ b/packages/router-generator/tests/generator-dev.test.ts @@ -0,0 +1,517 @@ +/** + * A generator kept across edits, as the bundler plugins keep one in dev and + * watch mode: each file event (`create`, `update`, `delete`, with the + * absolute path a file watcher reports) is passed to `run()`, and the route + * tree must be the one a fresh generator writes for the app at that point. + * + * These pass the events themselves: a supplement, not watcher coverage. The + * real dev servers' watchers, the live routes and route HMR of created and + * renamed routes are tested in router-plugin + * `tests/integration/{dev-server,rsbuild-dev-server}-{generator,new-routes}.test.ts`. + */ +import { existsSync } from 'node:fs' +import { rm } from 'node:fs/promises' +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { + physical, + rootRoute as virtualRootRoute, + route as virtualRoute, +} from '@tanstack/virtual-file-routes' +import { + diagnosticsOf, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { Generator } from '../src' +import { configOf, createApp, fileRoute, read, rootRoute, save } from './app' +import { expectOnlyOwnedEdits } from './owned-edits' +import { routeIdOf } from './route-id' +import { observeRouteTree, routesOf } from './route-tree' +import type { Config } from '../src' + +/** A generator for the app at `root`, after its first run. */ +async function startGenerator( + root: string, + inlineConfig: Partial = {}, +) { + const config = configOf(root, inlineConfig) + const generator = new Generator({ config, root }) + await generator.run() + return { config, generator } +} + +/** + * The routes the real router builds from the route tree a fresh generator + * writes for the app at `root` (written next to the app's route tree, so + * its imports are the same): ids, full paths, parents, route files and + * lazily loaded files (route-tree.ts `observeRouteTree`). A running + * generator's tree must give the same routes; its text is free (SPEC J1.5, + * §5.5). + */ +async function freshTree(root: string, config: Config) { + const fresh = path.join( + path.dirname(config.generatedRouteTree), + 'fresh.gen.ts', + ) + await new Generator({ + config: { ...config, generatedRouteTree: fresh }, + root, + }).run() + return observeRouteTree(fresh) +} + +/** Deletes an app file (path relative to the app root); returns its path. */ +async function remove(root: string, file: string) { + const filePath = path.join(root, file) + await rm(filePath) + return filePath +} + +describe('route edits', () => { + test('adding a route next to nested routes gives the route tree of a fresh run', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': fileRoute('/posts'), + 'src/routes/posts.$id.tsx': fileRoute('/posts/$id'), + }) + const { config, generator } = await startGenerator(root) + + const about = await save(root, 'src/routes/about.tsx', fileRoute('/about')) + await generator.run({ type: 'create', path: about }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/about': 'routes/about.tsx', + '/posts': 'routes/posts.tsx', + '/posts/$id': 'routes/posts.$id.tsx', + }) + expect(await observeRouteTree(config.generatedRouteTree)).toEqual( + await freshTree(root, config), + ) + }) + + test('deleting a nested route gives the route tree of a fresh run', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': fileRoute('/posts'), + 'src/routes/posts.$id.tsx': fileRoute('/posts/$id'), + 'src/routes/posts.new.tsx': fileRoute('/posts/new'), + }) + const { config, generator } = await startGenerator(root) + + const deleted = await remove(root, 'src/routes/posts.$id.tsx') + await generator.run({ type: 'delete', path: deleted }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts.tsx', + '/posts/new': 'routes/posts.new.tsx', + }) + expect(await observeRouteTree(config.generatedRouteTree)).toEqual( + await freshTree(root, config), + ) + }) + + test('a route deleted after an edit that changed no route leaves the route tree', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/', "{ component: () => 'index' }"), + 'src/routes/bar.tsx': fileRoute('/bar'), + }) + const { config, generator } = await startGenerator(root) + + const index = await save( + root, + 'src/routes/index.tsx', + fileRoute('/', "{ component: () => 'edited' }"), + ) + await generator.run({ type: 'update', path: index }) + const deleted = await remove(root, 'src/routes/bar.tsx') + await generator.run({ type: 'delete', path: deleted }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + }) + }) + + // A failed run and a warning (keeping the last good tree) are both fine, + // if the diagnostic names the file and the place of the problem (SPEC G5, + // §5.7). + test('a route file broken by an edit is reported with its location, and fixing it is processed', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': fileRoute('/posts'), + }) + const { config, generator } = await startGenerator(root) + + const broken = `import { createFileRoute } from '@tanstack/react-router' + +export const Route = (` + const posts = await save(root, 'src/routes/posts.tsx', broken) + const { result: error, diagnostics } = await captureDiagnostics(() => + generator.run({ type: 'update', path: posts }).then( + () => undefined, + (e: unknown) => e, + ), + ) + expectDiagnostic([...diagnosticsOf(error), ...diagnostics], { + severity: ['error', 'warning'], + file: posts, + root, + position: { line: 3 }, + }) + await save(root, 'src/routes/posts.tsx', fileRoute('/wrong')) + await generator.run({ type: 'update', path: posts }) + + const written = await read(root, 'src/routes/posts.tsx') + expectOnlyOwnedEdits(fileRoute('/wrong'), written) + expect(await routeIdOf(written)).toBe('/posts') + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts.tsx', + }) + }) + + // Control: "deleting a nested route gives the route tree of a fresh run" + // above (same harness, deleting a leaf route). + + // Bug: after a layout route file is deleted, its child routes disappear + // from the route tree of a running generator, while a fresh run keeps them + // (under the root route). + // Source: src/generator.ts (route nodes reused from the cache keep the + // `parent` of the run that created them, so the child still points at the + // deleted layout). + // Impact: in dev, deleting `posts.tsx` while keeping `posts.$id.tsx` + // removes `/posts/$id` from the app until the dev server restarts. + test.fails( + 'deleting a layout route keeps its child routes in the route tree', + async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': fileRoute('/posts'), + 'src/routes/posts.$id.tsx': fileRoute('/posts/$id'), + }) + const { config, generator } = await startGenerator(root) + + const deleted = await remove(root, 'src/routes/posts.tsx') + await generator.run({ type: 'delete', path: deleted }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts/$id': 'routes/posts.$id.tsx', + }) + }, + ) +}) + +// A rename or move reaches the generator as a delete and a create event, in +// either order, in one batch (a file watcher reports both before the first +// run completes). +describe.each([ + { + name: 'a top-level route file', + from: 'src/routes/about.tsx', + to: 'src/routes/contact.tsx', + routes: { + '/contact': 'routes/contact.tsx', + '/posts': 'routes/posts.tsx', + '/posts/$id': 'routes/posts.$id.tsx', + }, + id: '/contact', + }, + { + name: 'a child route file to another param name', + from: 'src/routes/posts.$id.tsx', + to: 'src/routes/posts.$postId.tsx', + routes: { + '/about': 'routes/about.tsx', + '/posts': 'routes/posts.tsx', + '/posts/$postId': 'routes/posts.$postId.tsx', + }, + id: '/posts/$postId', + }, + { + name: 'a route file into a directory under its layout', + from: 'src/routes/about.tsx', + to: 'src/routes/posts/about.tsx', + routes: { + '/posts': 'routes/posts.tsx', + '/posts/$id': 'routes/posts.$id.tsx', + '/posts/about': 'routes/posts/about.tsx', + }, + id: '/posts/about', + }, +])('renaming $name', ({ from, to, routes, id }) => { + test.each(['delete', 'create'] as const)( + 'with the %s event first gives the route tree of a fresh run and fixes the route id', + async (first) => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/about.tsx': fileRoute('/about'), + 'src/routes/posts.tsx': fileRoute('/posts'), + 'src/routes/posts.$id.tsx': fileRoute('/posts/$id'), + }) + const { config, generator } = await startGenerator(root) + + const content = await read(root, from) + const created = await save(root, to, content) + const deleted = await remove(root, from) + const events = [ + { type: 'delete' as const, path: deleted }, + { type: 'create' as const, path: created }, + ] + if (first === 'create') { + events.reverse() + } + await Promise.all(events.map((event) => generator.run(event))) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + ...routes, + }) + expect(await routeIdOf(await read(root, to))).toBe(id) + expect(await observeRouteTree(config.generatedRouteTree)).toEqual( + await freshTree(root, config), + ) + }, + ) +}) + +describe('route tree file events', () => { + test.each([ + { name: 'hand-edited', content: '// edited\n' }, + { name: 'corrupted', content: 'export const routeTree = (\n' }, + ])( + 'a $name route tree is regenerated on its update event', + async ({ content }) => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/'), + }) + const { config, generator } = await startGenerator(root) + const generated = await observeRouteTree(config.generatedRouteTree) + + await save(root, 'src/routeTree.gen.ts', content) + await generator.run({ type: 'update', path: config.generatedRouteTree }) + + expect(await observeRouteTree(config.generatedRouteTree)).toEqual( + generated, + ) + }, + ) + + // Control: "a hand-edited route tree is regenerated on its update event" + // above (same harness). + + // Bug: a deleted route tree file is not written again: neither on its + // delete event, nor on the next route change, whose run fails with ENOENT. + // Source: src/generator.ts (the route tree cache still holds the deleted + // file's content, so the write is skipped as unchanged; the next write + // then fails in `safeFileWrite`). + // Impact: in dev, deleting `routeTree.gen.ts` (e.g. `git clean`, a branch + // switch) leaves the app without a route tree until the dev server + // restarts. + test.fails( + 'a deleted route tree is written again on its delete event', + async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/'), + }) + const { config, generator } = await startGenerator(root) + const generated = await observeRouteTree(config.generatedRouteTree) + + await rm(config.generatedRouteTree) + await generator.run({ type: 'delete', path: config.generatedRouteTree }) + + expect(existsSync(config.generatedRouteTree)).toBe(true) + expect(await observeRouteTree(config.generatedRouteTree)).toEqual( + generated, + ) + }, + ) + + test.fails( + 'after the route tree is deleted, adding a route writes the route tree', + async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/'), + }) + const { config, generator } = await startGenerator(root) + + await rm(config.generatedRouteTree) + await generator.run({ type: 'delete', path: config.generatedRouteTree }) + const about = await save( + root, + 'src/routes/about.tsx', + fileRoute('/about'), + ) + await generator.run({ type: 'create', path: about }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + '/about': 'routes/about.tsx', + }) + }, + ) +}) + +describe('events that arrive together', () => { + // A bundler's watcher reports the unchanged route tree (webpack rebuilds + // once after the first build, which wrote it) while the generator's own + // file watcher reports a created route file: both events reach `run()` + // before either run ends. + const createdWith = async (together: boolean) => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/'), + }) + const { config, generator } = await startGenerator(root) + const about = await save(root, 'src/routes/about.tsx', fileRoute('/about')) + const update = { type: 'update', path: config.generatedRouteTree } as const + const create = { type: 'create', path: about } as const + if (together) { + await Promise.all([generator.run(update), generator.run(create)]) + } else { + await generator.run(update) + await generator.run(create) + } + return routesOf(config.generatedRouteTree) + } + const withAbout = { + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + '/about': 'routes/about.tsx', + } + + test('a route created after an update event that changed nothing joins the route tree (control)', async () => { + expect(await createdWith(false)).toEqual(withAbout) + }) + + // Bug: an event that arrives while a run checks events that changed + // nothing is dropped: that run ends without looking at the events queued + // meanwhile, so the created route is not added. + // Source: src/generator.ts `run()` (the early `break` when every event of + // the batch is an unchanged update skips the `while` check of the queue). + // Impact: in webpack's watch mode, a route file created just after the + // first build (when webpack rebuilds for the route tree the generator + // wrote) is neither scaffolded nor routed until another route file + // changes (router-plugin generator-watch-mode.test.ts hit it now and then). + test.fails( + 'a route created while an update event that changed nothing is checked joins the route tree', + async () => { + expect(await createdWith(true)).toEqual(withAbout) + }, + ) +}) + +describe('first runs', () => { + test('a routes directory without a root route fails with the root route file to add', async () => { + const root = await createApp({ + 'src/routes/index.tsx': fileRoute('/'), + }) + await expect( + new Generator({ config: configOf(root), root }).run(), + ).rejects.toThrow('__root.tsx') + }) +}) + +describe('route files outside the routes directory', () => { + // Supplement of router-plugin's real-watcher scenario "a route file + // created, edited and deleted under a physical() mount outside the routes + // directory reaches the live routes". + test('a route file created in a physical() directory outside the routes directory is added', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/features/a/index.tsx': fileRoute('/a/'), + 'src/other/b/index.tsx': fileRoute('/b/'), + }) + const { config, generator } = await startGenerator(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + physical('/a', '../features/a'), + physical('/b', '../other/b'), + ]), + }) + + const created = await save( + root, + 'src/features/a/new.tsx', + fileRoute('/wrong'), + ) + await generator.run({ type: 'create', path: created }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/a/': 'features/a/index.tsx', + '/a/new': 'features/a/new.tsx', + '/b/': 'other/b/index.tsx', + }) + expect(await routeIdOf(await read(root, 'src/features/a/new.tsx'))).toBe( + '/a/new', + ) + }) + + test('a virtual route file outside the routes directory gets its id fixed when edited', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/features/posts.tsx': fileRoute('/posts'), + }) + const { generator } = await startGenerator(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/posts', '../features/posts.tsx'), + ]), + }) + + const posts = await save( + root, + 'src/features/posts.tsx', + fileRoute('/wrong'), + ) + await generator.run({ type: 'update', path: posts }) + + expect(await routeIdOf(await read(root, 'src/features/posts.tsx'))).toBe( + '/posts', + ) + }) + + // Control: the two tests above (same harness, editing route files). + + // Bug: edits to the file `virtualRouteConfig` points to are ignored by a + // running generator: its update event is dropped (the absolute event path + // is compared with the configured relative path), and the config module + // is loaded from jiti's cache anyway. + // Source: src/generator.ts:1639-1644 (isFileRelevantForRouteTreeGeneration), + // src/filesystem/virtual/loadConfigFile.ts (jiti import of the config). + // Impact: in dev, changing the virtual route config has no effect until + // the dev server restarts. + test.fails( + 'editing the virtualRouteConfig file updates the route tree', + async () => { + const routes = (routePath: string) => + `import { rootRoute, route } from '@tanstack/virtual-file-routes' + +export const routes = rootRoute('__root.tsx', [route('${routePath}', 'posts.tsx')]) +` + const root = await createApp({ + 'routes.ts': routes('/posts'), + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': fileRoute('/posts'), + }) + const { config, generator } = await startGenerator(root, { + virtualRouteConfig: './routes.ts', + }) + + const configFile = await save(root, 'routes.ts', routes('/articles')) + await generator.run({ type: 'update', path: configFile }) + + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/articles': 'routes/posts.tsx', + }) + }, + ) +}) diff --git a/packages/router-generator/tests/generator-fixture.ts b/packages/router-generator/tests/generator-fixture.ts new file mode 100644 index 0000000000..0a554e4a14 --- /dev/null +++ b/packages/router-generator/tests/generator-fixture.ts @@ -0,0 +1,334 @@ +/** + * Shared test helper: the generator fixtures (tests/generator/), each + * an app with its own configuration, shared by generator.test.ts (routes) + * and integration/fixture-types-*.test.ts (types). A fixture runs in a copy + * (`copyFixture`): the generator and `prepareFixture` write into the + * fixture's directory. The expected routes are in generator-fixtures.ts. + */ +import { existsSync } from 'node:fs' +import fs from 'node:fs/promises' +import path, { join } from 'node:path' +import { onTestFinished } from 'vitest' +import { + index, + layout, + physical, + rootRoute, + route, +} from '@tanstack/virtual-file-routes' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { getConfig } from '../src' +import { recordInputs } from './consumer-inputs' +import { fixtureRoutes } from './generator-fixtures' +import type { Config } from '../src' + +/** The directory of the fixtures. */ +export const fixturesDir = join(import.meta.dirname, 'generator') + +/** The names of the fixtures. */ +export function fixtureNames() { + return fs.readdir(fixturesDir) +} + +/** The directory of the fixture `name` in this package. */ +export function fixtureDir(name: string) { + return join(fixturesDir, name) +} + +/** + * Copies the fixture `name` (without its generated route trees) to a new + * temporary directory, with this package's `node_modules` for its imports; + * the copy is removed when the test finishes. Returns the copy. + */ +export async function copyFixture(name: string) { + const dir = await fs.mkdtemp( + path.join(runDirectory(), `tsr-fixture-${name}-`), + ) + onTestFinished(() => fs.rm(dir, { recursive: true, force: true })) + await fs.cp(fixtureDir(name), dir, { + recursive: true, + filter: (source) => + path.basename(source) !== 'node_modules' && + !/[\\/]routeTree\.gen\.[jt]s$/.test(source), + }) + await fs.symlink( + path.resolve(import.meta.dirname, '../node_modules'), + join(dir, 'node_modules'), + 'junction', + ) + return dir +} + +/** The custom templates of the custom-scaffolding fixture. */ +export const customTemplates = { + routeTemplate: [ + 'import * as React from "react";\n', + '%%tsrImports%%\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', + ].join(''), + lazyRouteTemplate: [ + 'import React, { useState } from "react";\n', + '%%tsrImports%%\n\n', + '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', + 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', + ].join(''), +} + +/** + * The configuration of the fixture `name` in `dir`: its `tsr.config.json` + * if it has one, its `routes` directory and `routeTree.gen.ts`, and the + * options the fixture is about. + */ +export function fixtureConfig(name: string, dir = fixtureDir(name)): Config { + const configDirectory = existsSync(join(dir, 'tsr.config.json')) + ? dir + : undefined + const config = getConfig( + { + disableLogging: true, + routesDirectory: dir + '/routes', + generatedRouteTree: dir + '/routeTree.gen.ts', + }, + configDirectory, + ) + switch (name) { + case 'append-and-prepend': + config.routeTreeFileHeader = ['// prepend1', '// prepend2'] + config.routeTreeFileFooter = ['// append1', '// append2'] + break + case 'no-formatted-route-tree': + config.enableRouteTreeFormatting = false + break + case 'custom-tokens': + case 'escaped-custom-tokens': + config.indexToken = '_1nd3x' + config.routeToken = '_r0ut3_' + break + case 'virtual': + config.virtualRouteConfig = rootRoute('root.tsx', [ + index('index.tsx'), + route('$lang', [index('pages.tsx')]), + layout('layout.tsx', [ + route('/dashboard', 'db/dashboard.tsx', [ + index('db/dashboard-index.tsx'), + route('/invoices', 'db/dashboard-invoices.tsx', [ + index('db/invoices-index.tsx'), + route('$id', 'db/invoice-detail.tsx'), + ]), + ]), + physical('/hello', 'subtree'), + ]), + ]) + break + case 'virtual-with-escaped-underscore': + // Escaped underscores in physical routes mounted via virtual config: + // originalRoutePath is correctly prefixed when paths are updated. + config.virtualRouteConfig = rootRoute('__root.tsx', [ + index('index.tsx'), + physical('/api', 'physical-routes'), + ]) + break + case 'types-disabled': + config.disableTypes = true + config.generatedRouteTree = dir + `/routeTree.gen.js` + break + case 'custom-scaffolding': + config.customScaffolding = customTemplates + break + case 'routeFileIgnore': + config.routeFileIgnorePattern = 'ignoredPattern' + config.routeFileIgnorePrefix = 'imIgnored' + break + case 'routeFilePrefix': + config.routeFileIgnorePattern = 'ignoredPattern' + config.routeFilePrefix = 'r&' + break + case 'regex-tokens-inline': + // indexToken matches patterns like "index-page", "home-page"; + // routeToken matches patterns like "main-layout", "protected-layout". + config.indexToken = /[a-z]+-page/ + config.routeToken = /[a-z]+-layout/ + break + case 'virtual-sibling-routes': + // Issue #5822: virtual routes respect explicit sibling relationships: + // /posts and /posts/$id stay siblings under the layout, not nested by + // path. + config.virtualRouteConfig = rootRoute('__root.tsx', [ + layout('_main', 'layout.tsx', [ + route('/posts', 'posts.tsx'), + route('/posts/$id', 'post-detail.tsx'), + ]), + ]) + break + case 'virtual-pathless-layout-dotted-filename': + config.virtualRouteConfig = rootRoute('root.route.tsx', [ + index('index.route.tsx'), + layout('pathless.layout.tsx', [route('subpath', 'subpath.route.tsx')]), + ]) + break + case 'virtual-explicit-dotted-paths': + config.virtualRouteConfig = rootRoute('root.tsx', [ + route('direct.path', 'direct.tsx'), + physical('/mounted.path', 'physical-routes'), + ]) + break + case 'virtual-root-sibling-routes': + // Issue #5431: virtual routes that are siblings at the root level are + // not nested by a shared path prefix: /device/$id and + // /device/$id/history/$filename are both children of the root. + config.virtualRouteConfig = rootRoute('__root.tsx', [ + route('/device/$id', 'device/route.tsx'), + route('/device/$id/history/$filename', 'history/route.tsx'), + ]) + break + case 'add-extensions-custom': + config.addExtensions = '.js' + break + case 'virtual-nested-layouts-with-virtual-route': + // Nested layouts with a virtual file-less route in between. + config.virtualRouteConfig = rootRoute('__root.tsx', [ + index('home.tsx'), + layout('first', 'layout/first-layout.tsx', [ + layout('layout/second-layout.tsx', [ + route('route-without-file', [ + route('/layout-a', 'a.tsx'), + route('/layout-b', 'b.tsx'), + ]), + ]), + ]), + ]) + break + default: + break + } + return config +} + +/** + * Prepares the route files the generator edits or scaffolds in a run of + * the fixture `name` in `dir`; returns their contents before the run (path + * relative to the routes directory to content). Route files written by + * earlier runs (gitignored, possibly by an older version of this helper) + * are removed first: a leftover file would be a route of the fixture. + */ +export async function prepareFixture(name: string, dir: string) { + const before: Record = {} + if (name === 'file-modification') { + const routePath = (file: string) => join(dir, 'routes', '(test)', file) + for (const file of await fs.readdir(routePath('.'))) { + if (file.endsWith('.tsx')) { + await fs.rm(routePath(file)) + } + } + const template = await fs.readFile(join(dir, 'template.tsx'), 'utf8') + const files: Record = { + 'foo.bar.tsx': await fs.readFile( + join(dir, 'template-verbose.tsx'), + 'utf8', + ), + 'foo.tsx': template, + 'initiallyLazy.tsx': await fs.readFile( + join(dir, 'template.lazy.tsx'), + 'utf8', + ), + // (a lazy file written with createFileRoute: its options are only + // what a lazy route takes, here a component) + 'bar.lazy.tsx': [ + "import { createFileRoute } from '@tanstack/react-router'", + '', + "export const Route = createFileRoute('/foo/bar')({", + ' component: BarComponent,', + '})', + '', + 'function BarComponent() {', + ' return

Bar from its lazy file

', + '}', + '', + ].join('\n'), + 'double-quotes.tsx': template.replace( + "createFileRoute('/foo/bar')", + 'createFileRoute("/foo/bar")', + ), + // (a template literal id may be replaced or reported, SPEC J1.1: + // route-file-upkeep.test.ts) + 'duplicate-import.tsx': [ + "import { createFileRoute } from '@tanstack/react-router'", + "import * as React from 'react'", + "import { Link, Outlet } from '@tanstack/react-router'", + '', + "export const Route = createFileRoute('/foo/bar')({", + ' component: PostsLayoutComponent,', + '})', + '', + 'function PostsLayoutComponent() {', + ' return (', + ' <>', + ' Home', + ' ', + ' ', + ' )', + '}', + '', + ].join('\n'), + 'initiallyEmpty.tsx': '', + 'initiallyEmpty.lazy.tsx': '', + } + for (const [file, content] of Object.entries(files)) { + await fs.writeFile(routePath(file), content) + before[`(test)/${file}`] = content + } + } else if (name === 'custom-scaffolding') { + for (const file of [ + '__root.tsx', + 'index.tsx', + 'foo.lazy.tsx', + 'api/bar.tsx', + ]) { + await fs.mkdir(path.dirname(join(dir, 'routes', file)), { + recursive: true, + }) + await fs.writeFile(join(dir, 'routes', file), '') + before[file] = '' + } + } + // Only fixture-declared source identities participate. A previous run's + // generated support modules must never become fixture inputs. + const sourceFiles = new Set( + Object.values(fixtureRoutes[name] ?? {}).flatMap(([, , file, ...lazy]) => [ + ...(file ? [file] : []), + ...lazy, + ]), + ) + recordInputs( + dir, + Object.fromEntries( + await Promise.all( + [...sourceFiles].map(async (file) => [ + file, + await fs.readFile(join(dir, file), 'utf8'), + ]), + ), + ), + fixtureConfig(name, dir).target, + ) + return before +} + +/** + * For a fixture whose routes conflict, the route files the generator's error + * must name (its wording is free). + */ +export function conflictingFiles( + name: string, + dir = fixtureDir(name), +): Array | undefined { + const routeFile = (...file: Array) => join(dir, 'routes', ...file) + if (name === 'duplicate-fullPath') { + return [routeFile('index.tsx'), routeFile('_auth', 'index.tsx')] + } + if (name === 'virtual-physical-empty-path-conflict-virtual') { + return [routeFile('about.tsx'), routeFile('merged', 'about.tsx')] + } + return undefined +} diff --git a/packages/router-generator/tests/generator-fixtures.ts b/packages/router-generator/tests/generator-fixtures.ts new file mode 100644 index 0000000000..22b1313ffc --- /dev/null +++ b/packages/router-generator/tests/generator-fixtures.ts @@ -0,0 +1,1035 @@ +/** + * The routes each generator fixture (tests/generator/) gives the real + * router (SPEC J1.4): route id to its full path, its parent route's id + * (null for the root route), the file whose `Route` it is (relative to the + * route tree; null for a route the tree creates, e.g. for a lazy-only + * route file) and then the app files that load only with the route (its + * lazy route file and lazy components). Checked against the file naming + * conventions and virtual route docs (routing/file-naming-conventions.md, + * routing/file-based-routing.md, routing/virtual-file-routes.md, + * guide/code-splitting.md:222-224), not against an emitted tree. + */ +export type FixtureRoute = [ + fullPath: string, + parent: string | null, + file: string | null, + ...lazy: Array, +] + +export const fixtureRoutes: Record> = { + 'add-extensions-custom': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'append-and-prepend': { + '/': ['/', '__root__', 'routes/index.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'custom-scaffolding': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/api/bar': ['/api/bar', '__root__', 'routes/api/bar.tsx'], + '/foo': ['/foo', '__root__', null, 'routes/foo.lazy.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'custom-tokens': { + '/': ['/', '__root__', 'routes/_1nd3x.tsx'], + '/blog': ['/blog', '__root__', 'routes/blog/_r0ut3_.tsx'], + '/blog/': ['/blog/', '/blog', 'routes/blog/_1nd3x.tsx'], + '/blog/$slug': ['/blog/$slug', '/blog', 'routes/blog/$slug.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts/_r0ut3_.tsx'], + '/posts/': ['/posts/', '/posts', 'routes/posts/_1nd3x.tsx'], + '/posts/$postId/': [ + '/posts/$postId/', + '/posts', + 'routes/posts/$postId/_1nd3x.tsx', + ], + '/posts/$postId/deep': [ + '/posts/$postId/deep', + '/posts', + 'routes/posts/$postId/deep.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'dot-escaped': { + '/nested.js': ['/nested.js', '__root__', 'routes/nested[.]js.tsx'], + '/nested.js/double.ext.js': [ + '/nested.js/double.ext.js', + '/nested.js', + 'routes/nested[.]js.double[.]ext[.]js.tsx', + ], + '/nested.js/script.js': [ + '/nested.js/script.js', + '/nested.js', + 'routes/nested[.]js.script[.]js.tsx', + ], + '/script.js': ['/script.js', '__root__', 'routes/script[.]js.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'escaped-custom-tokens': { + '/': ['/', '__root__', 'routes/_1nd3x.tsx'], + '/_1nd3x': ['/_1nd3x', '__root__', 'routes/[_1nd3x].tsx'], + '/blog': ['/blog', '__root__', 'routes/blog._r0ut3_.tsx'], + '/nested/_1nd3x': [ + '/nested/_1nd3x', + '__root__', + 'routes/nested.[_1nd3x].tsx', + ], + '/posts/_r0ut3_': [ + '/posts/_r0ut3_', + '__root__', + 'routes/posts.[_r0ut3_].tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'escaped-special-strings': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/_auth': ['/_auth', '__root__', 'routes/[_]auth.route.tsx'], + '/_layout': ['/_layout', '__root__', 'routes/[_]layout.tsx'], + '/_prefix_middle_suffix': [ + '/_prefix_middle_suffix', + '__root__', + 'routes/[_]prefix[_]middle[_]suffix.tsx', + ], + '/api_v2_users': [ + '/api_v2_users', + '__root__', + 'routes/api[_]v2[_]users.tsx', + ], + '/blog_': ['/blog_', '__root__', 'routes/blog[_].tsx'], + '/foo_bar': ['/foo_bar', '__root__', 'routes/foo[_]bar.tsx'], + '/index': ['/index', '__root__', 'routes/[index].tsx'], + '/lazy': ['/lazy', '__root__', 'routes/[lazy].tsx'], + '/nested/index': ['/nested/index', '__root__', 'routes/nested.[index].tsx'], + '/route': ['/route', '__root__', 'routes/[route].tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'export-variations': { + '/export-separate-from-declaration': [ + '/export-separate-from-declaration', + '__root__', + 'routes/export-separate-from-declaration.tsx', + ], + '/export-with-as': [ + '/export-with-as', + '__root__', + 'routes/export-with-as.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'file-modification': { + '/(test)/bar': ['/bar', '__root__', null, 'routes/(test)/bar.lazy.tsx'], + '/(test)/double-quotes': [ + '/double-quotes', + '__root__', + 'routes/(test)/double-quotes.tsx', + ], + '/(test)/duplicate-import': [ + '/duplicate-import', + '__root__', + 'routes/(test)/duplicate-import.tsx', + ], + '/(test)/foo': ['/foo', '__root__', 'routes/(test)/foo.tsx'], + '/(test)/foo/bar': ['/foo/bar', '/(test)/foo', 'routes/(test)/foo.bar.tsx'], + '/(test)/initiallyEmpty': [ + '/initiallyEmpty', + '__root__', + 'routes/(test)/initiallyEmpty.tsx', + 'routes/(test)/initiallyEmpty.lazy.tsx', + ], + '/(test)/initiallyLazy': [ + '/initiallyLazy', + '__root__', + 'routes/(test)/initiallyLazy.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'flat-route-group': { + '/app': ['/app', '__root__', 'routes/app.tsx'], + '/app/(compras)/compras_/_mas': [ + '/app/compras', + '/app', + 'routes/app.(compras)/compras_._mas.tsx', + ], + '/app/(compras)/compras_/_mas/divisiones': [ + '/app/compras/divisiones', + '/app/(compras)/compras_/_mas', + 'routes/app.(compras)/compras_._mas.divisiones.tsx', + ], + '/app/(compras)/compras_/ordenes': [ + '/app/compras/ordenes', + '/app', + 'routes/app.(compras)/compras_.ordenes.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + flat: { + '/': ['/', '__root__', 'routes/index.tsx'], + '/blog': ['/blog', '__root__', 'routes/blog.route.tsx'], + '/blog/': ['/blog/', '/blog', 'routes/blog.index.tsx'], + '/blog/$slug/': ['/blog/$slug/', '/blog', 'routes/blog.$slug.index.tsx'], + '/blog_/$blogId': [ + '/blog/$blogId', + '__root__', + 'routes/blog_.$blogId.route.tsx', + ], + '/blog_/$blogId/$slug': [ + '/blog/$blogId/$slug', + '/blog_/$blogId', + 'routes/blog_.$blogId.$slug.route.tsx', + ], + '/blog_/$blogId/$slug_/bar': [ + '/blog/$blogId/$slug/bar', + '/blog_/$blogId', + 'routes/blog_.$blogId.$slug_.bar.tsx', + ], + '/blog_/$blogId_/edit': [ + '/blog/$blogId/edit', + '__root__', + 'routes/blog_.$blogId_.edit.tsx', + ], + '/blog_/stats': ['/blog/stats', '__root__', 'routes/blog_.stats.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts.route.tsx'], + '/posts/': ['/posts/', '/posts', 'routes/posts.index.tsx'], + '/posts/$postId/': [ + '/posts/$postId/', + '/posts', + 'routes/posts.$postId.index.tsx', + ], + '/posts/$postId/deep': [ + '/posts/$postId/deep', + '/posts', + 'routes/posts.$postId.deep.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'invalid-param-names': { + '/$123': ['/$123', '__root__', 'routes/$123.tsx'], + '/$user-name': ['/$user-name', '__root__', 'routes/$user-name.tsx'], + '/$validParam': ['/$validParam', '__root__', 'routes/$validParam.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'lazy-multi-slug-params': { + '/sub': ['/sub', '__root__', null, 'routes/sub/route.lazy.tsx'], + '/sub/$a/$b': ['/sub/$a/$b', '/sub', null, 'routes/sub/$a.$b.lazy.tsx'], + '/sub/test': ['/sub/test', '/sub', null, 'routes/sub/test.lazy.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'lazy-only-layout-and-index-in-pathless': { + '/_layout': ['/', '__root__', 'routes/_layout/route.tsx'], + '/_layout/path': [ + '/path', + '/_layout', + null, + 'routes/_layout/path.lazy.tsx', + ], + '/_layout/path/': [ + '/path/', + '/_layout/path', + null, + 'routes/_layout/path.index.lazy.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'lazy-only-layout-and-index': { + '/path': ['/path', '__root__', null, 'routes/path.lazy.tsx'], + '/path/': ['/path/', '/path', null, 'routes/path.index.lazy.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + lazy: { + '/posts': [ + '/posts', + '__root__', + 'routes/posts.route.tsx', + 'routes/posts.route.lazy.tsx', + ], + '/posts/': ['/posts/', '/posts', 'routes/posts.index.tsx'], + '/posts/$postId': ['/posts/$postId', '/posts', 'routes/posts.$postId.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'nested-layouts': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/(folder)/in-folder': [ + '/in-folder', + '__root__', + 'routes/(folder)/in-folder.tsx', + ], + '/_layout-a1': ['/', '__root__', 'routes/_layout-a1.tsx'], + '/_layout-a1/foo': ['/foo', '/_layout-a1', 'routes/_layout-a1/foo.tsx'], + '/_layout-a2': ['/', '__root__', 'routes/_layout-a2.tsx'], + '/_layout-a2/bar': ['/bar', '/_layout-a2', 'routes/_layout-a2/bar.tsx'], + '/foo/_layout-b5': ['/foo', '__root__', 'routes/foo/_layout-b5/route.tsx'], + '/foo/_layout-b5/': [ + '/foo/', + '/foo/_layout-b5', + 'routes/foo/_layout-b5/index.tsx', + ], + '/foo/_layout-b5/$id': [ + '/foo/$id', + '/foo/_layout-b5', + 'routes/foo/_layout-b5/$id.tsx', + ], + '/foo/bar': ['/foo/bar', '__root__', 'routes/foo/bar.tsx'], + '/jested': ['/jested', '__root__', 'routes/jested/route.tsx'], + '/jested/_layout-b3': [ + '/jested', + '/jested', + 'routes/jested/_layout-b3.tsx', + ], + '/jested/_layout-b3/': [ + '/jested/', + '/jested/_layout-b3', + 'routes/jested/_layout-b3/index.tsx', + ], + '/jested/_layout-b3/_layout-c2': [ + '/jested', + '/jested/_layout-b3', + 'routes/jested/_layout-b3/_layout-c2.tsx', + ], + '/jested/_layout-b3/_layout-c2/bar': [ + '/jested/bar', + '/jested/_layout-b3/_layout-c2', + 'routes/jested/_layout-b3/_layout-c2/bar.tsx', + ], + '/jested/_layout-b4': [ + '/jested', + '/jested', + 'routes/jested/_layout-b4.tsx', + ], + '/jested/_layout-b4/foo': [ + '/jested/foo', + '/jested/_layout-b4', + 'routes/jested/_layout-b4/foo.tsx', + ], + '/nested/_layout-b1': [ + '/nested', + '__root__', + 'routes/nested/_layout-b1.tsx', + ], + '/nested/_layout-b1/': [ + '/nested/', + '/nested/_layout-b1', + 'routes/nested/_layout-b1/index.tsx', + ], + '/nested/_layout-b1/_layout-c1': [ + '/nested', + '/nested/_layout-b1', + 'routes/nested/_layout-b1/_layout-c1.tsx', + ], + '/nested/_layout-b1/_layout-c1/bar': [ + '/nested/bar', + '/nested/_layout-b1/_layout-c1', + 'routes/nested/_layout-b1/_layout-c1/bar.tsx', + ], + '/nested/_layout-b2': [ + '/nested', + '__root__', + 'routes/nested/_layout-b2.tsx', + ], + '/nested/_layout-b2/foo': [ + '/nested/foo', + '/nested/_layout-b2', + 'routes/nested/_layout-b2/foo.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'nested-route-groups-with-layouts-before-physical': { + '/(group-a)/_layout-a': ['/', '__root__', 'routes/(group-a)/_layout-a.tsx'], + '/(group-a)/_layout-a/login': [ + '/login', + '/(group-a)/_layout-a', + 'routes/(group-a)/_layout-a/login.tsx', + ], + '/(group-a)/_layout-a/signup': [ + '/signup', + '/(group-a)/_layout-a', + 'routes/(group-a)/_layout-a/signup.tsx', + ], + '/(group-b)/_layout-b': ['/', '__root__', 'routes/(group-b)/_layout-b.tsx'], + '/(group-b)/_layout-b/dashboard': [ + '/dashboard', + '/(group-b)/_layout-b', + 'routes/(group-b)/_layout-b/dashboard.tsx', + ], + '/(group-c)/_layout-c': ['/', '__root__', 'routes/(group-c)/_layout-c.tsx'], + '/(group-c)/_layout-c/': [ + '/', + '/(group-c)/_layout-c', + 'routes/(group-c)/_layout-c/index.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + nested: { + '/': ['/', '__root__', 'routes/index.tsx'], + '/_pathlessLayout': ['/', '__root__', 'routes/_pathlessLayout.tsx'], + '/_pathlessLayout/settings': [ + '/settings', + '/_pathlessLayout', + 'routes/_pathlessLayout/settings.tsx', + ], + '/blog': ['/blog', '__root__', 'routes/blog/route.tsx'], + '/blog/': ['/blog/', '/blog', 'routes/blog/index.tsx'], + '/blog/$slug': ['/blog/$slug', '/blog', 'routes/blog/$slug.tsx'], + '/blog_/$blogId': [ + '/blog/$blogId', + '__root__', + 'routes/blog_/$blogId/route.tsx', + ], + '/blog_/$blogId/$slug': [ + '/blog/$blogId/$slug', + '/blog_/$blogId', + 'routes/blog_/$blogId/$slug/route.tsx', + ], + '/blog_/$blogId/$slug_/bar': [ + '/blog/$blogId/$slug/bar', + '/blog_/$blogId', + 'routes/blog_/$blogId/$slug_/bar.tsx', + ], + '/blog_/$blogId_/edit': [ + '/blog/$blogId/edit', + '__root__', + 'routes/blog_/$blogId_/edit.tsx', + ], + '/blog_/stats': ['/blog/stats', '__root__', 'routes/blog_/stats.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts/route.tsx'], + '/posts/': ['/posts/', '/posts', 'routes/posts/index.tsx'], + '/posts/$postId/': [ + '/posts/$postId/', + '/posts', + 'routes/posts/$postId/index.tsx', + ], + '/posts/$postId/deep': [ + '/posts/$postId/deep', + '/posts', + 'routes/posts/$postId/deep.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'no-duplicate-route-segment': { + '/foo/_layout': ['/foo', '__root__', 'routes/foo/_layout/route.tsx'], + '/foo/_layout/': ['/foo/', '/foo/_layout', 'routes/foo/_layout/index.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'no-formatted-route-tree': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/nested/': ['/nested/', '__root__', 'routes/nested/index.tsx'], + '/nested/child': ['/nested/child', '__root__', 'routes/nested/child.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'numbers-in-path': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/01-example/': ['/01-example/', '__root__', 'routes/01-example/index.tsx'], + '/02/': ['/02/', '__root__', 'routes/02.index.tsx'], + '/03': ['/03', '__root__', 'routes/03.tsx'], + '/about': ['/about', '__root__', 'routes/about.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'only-root': { + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'path-above-route-in-group': { + '/a/$b/(c)': ['/a/$b', '__root__', 'routes/a/$b/(c)/route.tsx'], + '/a/$b/(c)/': ['/a/$b/', '/a/$b/(c)', 'routes/a/$b/(c)/index.tsx'], + '/a/$b/(c)/d/e/': [ + '/a/$b/d/e/', + '/a/$b/(c)', + 'routes/a/$b/(c)/d/e/index.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'pathless-to-index-preference': { + '/livestock/$farmId/medicine': [ + '/livestock/$farmId/medicine', + '__root__', + 'routes/livestock/$farmId/medicine/route.tsx', + ], + '/livestock/$farmId/medicine/': [ + '/livestock/$farmId/medicine/', + '/livestock/$farmId/medicine', + 'routes/livestock/$farmId/medicine/index.tsx', + ], + '/livestock/$farmId/medicine/_form': [ + '/livestock/$farmId/medicine', + '/livestock/$farmId/medicine', + 'routes/livestock/$farmId/medicine/_form.tsx', + ], + '/livestock/$farmId/medicine/_form/new': [ + '/livestock/$farmId/medicine/new', + '/livestock/$farmId/medicine/_form', + 'routes/livestock/$farmId/medicine/_form.new.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'physical-pathless-layout-escaped-underscore': { + '/__layout': ['/', '__root__', 'routes/__layout.tsx'], + '/__layout/_qux': ['/_qux', '/__layout', 'routes/__layout/[_]qux.tsx'], + '/__literal': ['/__literal', '__root__', 'routes/[__literal].tsx'], + '/__root-index/': [ + '/__root-index/', + '__root__', + 'routes/[__root-index]/index.tsx', + ], + '/_foo': ['/_foo', '__root__', 'routes/[_]foo.tsx'], + '/_layout': ['/', '__root__', 'routes/_layout.tsx'], + '/_layout/__double': [ + '/__double', + '/_layout', + 'routes/_layout/[__double].tsx', + ], + '/_layout/__double-index/': [ + '/__double-index/', + '/_layout', + 'routes/_layout/[__double-index]/index.tsx', + ], + '/_layout/__double-index/$id': [ + '/__double-index/$id', + '/_layout', + 'routes/_layout/[__double-index]/$id.tsx', + ], + '/_layout/__nested2': ['/', '/_layout', 'routes/_layout/__nested2.tsx'], + '/_layout/__nested2/_deep': [ + '/_deep', + '/_layout/__nested2', + 'routes/_layout/__nested2/[_]deep.tsx', + ], + '/_layout/_bar': ['/_bar', '/_layout', 'routes/_layout/[_]bar.tsx'], + '/_layout/_nested': ['/', '/_layout', 'routes/_layout/_nested.tsx'], + '/_layout/_nested-index/': [ + '/_nested-index/', + '/_layout', + 'routes/_layout/[_]nested-index/index.tsx', + ], + '/_layout/_nested-index/$id': [ + '/_nested-index/$id', + '/_layout', + 'routes/_layout/[_]nested-index/$id.tsx', + ], + '/_layout/_nested/_baz': [ + '/_baz', + '/_layout/_nested', + 'routes/_layout/_nested/[_]baz.tsx', + ], + '/_layout/_nested/_deep-index/': [ + '/_deep-index/', + '/_layout/_nested', + 'routes/_layout/_nested/[_]deep-index/index.tsx', + ], + '/_layout/nested-trailing_/': [ + '/nested-trailing_/', + '/_layout', + 'routes/_layout/nested-trailing[_]/index.tsx', + ], + '/_root-index/': [ + '/_root-index/', + '__root__', + 'routes/[_]root-index/index.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'prefix-suffix': { + '/wildcard/$': ['/wildcard/$', '__root__', 'routes/wildcard/$.tsx'], + '/wildcard/prefix{$}': [ + '/wildcard/prefix{$}', + '__root__', + 'routes/wildcard/prefix{$}.tsx', + ], + '/wildcard/{$}.suffix': [ + '/wildcard/{$}.suffix', + '__root__', + 'routes/wildcard/{$}[.]suffix.tsx', + ], + '/wildcard/{$}suffix': [ + '/wildcard/{$}suffix', + '__root__', + 'routes/wildcard/{$}suffix.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'regex-tokens-inline': { + '/': ['/', '__root__', 'routes/index-page.tsx'], + '/dashboard': [ + '/dashboard', + '__root__', + 'routes/dashboard.main-layout.tsx', + ], + '/dashboard/': [ + '/dashboard/', + '/dashboard', + 'routes/dashboard.home-page.tsx', + ], + '/dashboard/settings': [ + '/dashboard/settings', + '/dashboard', + 'routes/dashboard.settings.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'regex-tokens-json': { + '/': ['/', '__root__', 'routes/index-page.tsx'], + '/dashboard': [ + '/dashboard', + '__root__', + 'routes/dashboard.main-layout.tsx', + ], + '/dashboard/': [ + '/dashboard/', + '/dashboard', + 'routes/dashboard.home-page.tsx', + ], + '/dashboard/settings': [ + '/dashboard/settings', + '/dashboard', + 'routes/dashboard.settings.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'regex-tokens-plus-json': { + '/': ['/', '__root__', 'routes/+page.tsx'], + '/dashboard': ['/dashboard', '__root__', 'routes/dashboard/+layout.tsx'], + '/dashboard/': ['/dashboard/', '/dashboard', 'routes/dashboard/+page.tsx'], + '/dashboard/settings': [ + '/dashboard/settings', + '/dashboard', + 'routes/dashboard/settings.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'root-export-specifier': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/about': ['/about', '__root__', 'routes/about.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'route-groups': { + '/(bar)/_bar': ['/', '__root__', 'routes/(bar)/_bar.tsx'], + '/(bar)/_bar/hello': [ + '/hello', + '/(bar)/_bar', + 'routes/(bar)/_bar.hello.tsx', + ], + '/(foo)/asdf/(another-group)/_layout': [ + '/asdf', + '__root__', + 'routes/(foo)/asdf/(another-group)/_layout.tsx', + ], + '/(foo)/asdf/(another-group)/_layout/baz': [ + '/asdf/baz', + '/(foo)/asdf/(another-group)/_layout', + 'routes/(foo)/asdf/(another-group)/_layout.baz.tsx', + ], + '/(foo)/asdf/(bar)/$id': [ + '/asdf/$id', + '__root__', + 'routes/(foo)/asdf/(bar)/$id.tsx', + ], + // (the pathless layout of the `(bar)` group's `_layout.*` files; the + // other groups have `_layout` layouts of their own) + '/(foo)/asdf/(bar)/_layout': [ + '/asdf', + '__root__', + 'routes/(foo)/asdf/(bar)/_layout.tsx', + ], + '/(foo)/asdf/(bar)/_layout/about': [ + '/asdf/about', + '/(foo)/asdf/(bar)/_layout', + 'routes/(foo)/asdf/(bar)/_layout.about.tsx', + ], + '/(foo)/asdf/(bar)/_layout/xyz': [ + '/asdf/xyz', + '/(foo)/asdf/(bar)/_layout', + null, + 'routes/(foo)/asdf/(bar)/_layout.xyz.lazy.tsx', + ], + '/(foo)/asdf/_layout': [ + '/asdf', + '__root__', + 'routes/(foo)/asdf/_layout.tsx', + ], + '/(foo)/asdf/_layout/foo': [ + '/asdf/foo', + '/(foo)/asdf/_layout', + 'routes/(foo)/asdf/_layout.foo.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + routeFileIgnore: { + '/': ['/', '__root__', 'routes/index.tsx'], + '/blog': ['/blog', '__root__', 'routes/blog.route.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + routeFilePrefix: { + '/': ['/', '__root__', 'routes/r&index.tsx'], + '/blog': ['/blog', '__root__', 'routes/r&blog.route.tsx'], + __root__: ['/', null, 'routes/r&__root.tsx'], + }, + 'single-level': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'types-disabled': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/posts': ['/posts', '__root__', 'routes/posts.tsx'], + '/posts/$postId': ['/posts/$postId', '/posts', 'routes/posts/$postId.tsx'], + '/users/$userId': [ + '/users/$userId', + '__root__', + 'routes/users.$userId.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-config-file-default-export': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/$lang/': ['/$lang/', '__root__', 'routes/pages.tsx'], + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/dashboard': ['/dashboard', '/_layout', 'routes/db/dashboard.tsx'], + '/_layout/dashboard/': [ + '/dashboard/', + '/_layout/dashboard', + 'routes/db/dashboard-index.tsx', + ], + '/_layout/dashboard/invoices': [ + '/dashboard/invoices', + '/_layout/dashboard', + 'routes/db/dashboard-invoices.tsx', + ], + '/_layout/dashboard/invoices/': [ + '/dashboard/invoices/', + '/_layout/dashboard/invoices', + 'routes/db/invoices-index.tsx', + ], + '/_layout/dashboard/invoices/$id': [ + '/dashboard/invoices/$id', + '/_layout/dashboard/invoices', + 'routes/db/invoice-detail.tsx', + ], + '/_layout/hello/': ['/hello/', '/_layout', 'routes/subtree/index.tsx'], + '/_layout/hello/foo/': [ + '/hello/foo/', + '/_layout', + 'routes/subtree/foo/index.tsx', + ], + '/_layout/hello/foo/$id': [ + '/hello/foo/$id', + '/_layout', + 'routes/subtree/foo/$id.tsx', + ], + __root__: ['/', null, 'routes/root.tsx'], + }, + 'virtual-config-file-named-export': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/$lang/': ['/$lang/', '__root__', 'routes/pages.tsx'], + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/dashboard': ['/dashboard', '/_layout', 'routes/db/dashboard.tsx'], + '/_layout/dashboard/': [ + '/dashboard/', + '/_layout/dashboard', + 'routes/db/dashboard-index.tsx', + ], + '/_layout/dashboard/invoices': [ + '/dashboard/invoices', + '/_layout/dashboard', + 'routes/db/dashboard-invoices.tsx', + ], + '/_layout/dashboard/invoices/': [ + '/dashboard/invoices/', + '/_layout/dashboard/invoices', + 'routes/db/invoices-index.tsx', + ], + '/_layout/dashboard/invoices/$id': [ + '/dashboard/invoices/$id', + '/_layout/dashboard/invoices', + 'routes/db/invoice-detail.tsx', + ], + '/_layout/hello/': ['/hello/', '/_layout', 'routes/subtree/index.tsx'], + '/_layout/hello/foo/': [ + '/hello/foo/', + '/_layout', + 'routes/subtree/foo/index.tsx', + ], + '/_layout/hello/foo/$id': [ + '/hello/foo/$id', + '/_layout', + 'routes/subtree/foo/$id.tsx', + ], + __root__: ['/', null, 'routes/root.tsx'], + }, + 'virtual-config-file-tsconfig-paths': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/$lang/': ['/$lang/', '__root__', 'routes/pages.tsx'], + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/dashboard': ['/dashboard', '/_layout', 'routes/db/dashboard.tsx'], + '/_layout/dashboard/': [ + '/dashboard/', + '/_layout/dashboard', + 'routes/db/dashboard-index.tsx', + ], + '/_layout/dashboard/invoices': [ + '/dashboard/invoices', + '/_layout/dashboard', + 'routes/db/dashboard-invoices.tsx', + ], + '/_layout/dashboard/invoices/': [ + '/dashboard/invoices/', + '/_layout/dashboard/invoices', + 'routes/db/invoices-index.tsx', + ], + '/_layout/dashboard/invoices/$id': [ + '/dashboard/invoices/$id', + '/_layout/dashboard/invoices', + 'routes/db/invoice-detail.tsx', + ], + '/_layout/hello/': ['/hello/', '/_layout', 'routes/subtree/index.tsx'], + '/_layout/hello/foo/': [ + '/hello/foo/', + '/_layout', + 'routes/subtree/foo/index.tsx', + ], + '/_layout/hello/foo/$id': [ + '/hello/foo/$id', + '/_layout', + 'routes/subtree/foo/$id.tsx', + ], + __root__: ['/', null, 'routes/root.tsx'], + }, + 'virtual-explicit-dotted-paths': { + '/direct.path': ['/direct.path', '__root__', 'routes/direct.tsx'], + '/mounted.path/': [ + '/mounted.path/', + '__root__', + 'routes/physical-routes/index.tsx', + ], + __root__: ['/', null, 'routes/root.tsx'], + }, + 'virtual-inside-nested': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/foo/bar': ['/foo/bar', '__root__', 'routes/foo/bar.tsx'], + '/foo/bar/': ['/foo/bar/', '/foo/bar', 'routes/foo/bar/home.tsx'], + '/foo/bar/$id': ['/foo/bar/$id', '/foo/bar', 'routes/foo/bar/details.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-inside-with-escaped-underscore': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/nested/': ['/nested/', '__root__', 'routes/nested/home.tsx'], + '/nested/_auth': ['/nested/_auth', '__root__', 'routes/nested/auth.tsx'], + '/nested/_callback': [ + '/nested/_callback', + '__root__', + 'routes/nested/callback.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-nested-layouts-with-virtual-route': { + '/': ['/', '__root__', 'routes/home.tsx'], + '/_first': ['/', '__root__', 'routes/layout/first-layout.tsx'], + '/_first/_second-layout': [ + '/', + '/_first', + 'routes/layout/second-layout.tsx', + ], + '/_first/_second-layout/route-without-file/layout-a': [ + '/route-without-file/layout-a', + '/_first/_second-layout', + 'routes/a.tsx', + ], + '/_first/_second-layout/route-without-file/layout-b': [ + '/route-without-file/layout-b', + '/_first/_second-layout', + 'routes/b.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-pathless-layout-dotted-filename': { + '/': ['/', '__root__', 'routes/index.route.tsx'], + '/_pathless.layout': ['/', '__root__', 'routes/pathless.layout.tsx'], + '/_pathless.layout/subpath': [ + '/subpath', + '/_pathless.layout', + 'routes/subpath.route.tsx', + ], + __root__: ['/', null, 'routes/root.route.tsx'], + }, + 'virtual-pathless-layout-escaped-underscore': { + '/__double': ['/__double', '__root__', 'routes/double.tsx'], + '/_escaped': ['/_escaped', '__root__', 'routes/escaped.tsx'], + '/_foo': ['/_foo', '__root__', 'routes/foo.tsx'], + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/__double-bar': [ + '/__double-bar', + '/_layout', + 'routes/double-bar.tsx', + ], + '/_layout/__double-index/': [ + '/__double-index/', + '/_layout', + 'routes/double-index.tsx', + ], + '/_layout/__double-index/$id': [ + '/__double-index/$id', + '/_layout', + 'routes/double-id.tsx', + ], + '/_layout/_bar': ['/_bar', '/_layout', 'routes/bar.tsx'], + '/_layout/_escaped-bar': [ + '/_escaped-bar', + '/_layout', + 'routes/escaped-bar.tsx', + ], + '/_layout/_escaped-index/': [ + '/_escaped-index/', + '/_layout', + 'routes/escaped-index.tsx', + ], + '/_layout/_escaped-index/$id': [ + '/_escaped-index/$id', + '/_layout', + 'routes/escaped-id.tsx', + ], + '/_layout/_inner': ['/', '/_layout', 'routes/inner-layout.tsx'], + '/_layout/_inner/_deep-index/': [ + '/_deep-index/', + '/_layout/_inner', + 'routes/deep-index.tsx', + ], + '/_layout/_nested': ['/', '/_layout', 'routes/nested-layout.tsx'], + '/_layout/_nested-index/': [ + '/_nested-index/', + '/_layout', + 'routes/nested-index.tsx', + ], + '/_layout/_nested-index/$id': [ + '/_nested-index/$id', + '/_layout', + 'routes/nested-id.tsx', + ], + '/_layout/_nested/_baz': ['/_baz', '/_layout/_nested', 'routes/baz.tsx'], + '/_layout/trail_/': ['/trail_/', '/_layout', 'routes/trail-index.tsx'], + '/_root-index/': ['/_root-index/', '__root__', 'routes/root-index.tsx'], + '/_root-index/$id': ['/_root-index/$id', '__root__', 'routes/root-id.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-empty-path-merge': { + '/': ['/', '__root__', 'routes/merged/index.tsx'], + '/about': ['/about', '__root__', 'routes/about.tsx'], + '/contact': ['/contact', '__root__', 'routes/merged/contact.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-inside-nested': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/s1/_layout': ['/s1', '__root__', 'subtree/routes/_layout.tsx'], + '/s1/_layout/foo': [ + '/s1/foo', + '/s1/_layout', + 'subtree/foo/routes/route.tsx', + ], + '/s1/_layout/foo/': [ + '/s1/foo/', + '/s1/_layout/foo', + 'subtree/foo/routes/index.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-layout-and-index': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/feature': ['/feature', '__root__', 'routes/feature/route.tsx'], + '/feature/': ['/feature/', '/feature', 'routes/feature/index.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-no-prefix': { + '/': ['/', '__root__', 'routes/merged/index.tsx'], + '/about': ['/about', '__root__', 'routes/about.tsx'], + '/contact': ['/contact', '__root__', 'routes/merged/contact.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-pathless-layout-literal-index': { + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/_nested/': [ + '/_nested/', + '/_layout', + 'routes/physical-routes/[_]nested/index.tsx', + ], + '/_layout/_nested/$id': [ + '/_nested/$id', + '/_layout', + 'routes/physical-routes/[_]nested/$id.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-physical-prefix-escaped-underscore': { + '/_api/': ['/_api/', '__root__', 'routes/physical-routes/index.tsx'], + '/_api/$id': ['/_api/$id', '__root__', 'routes/physical-routes/$id.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-root-sibling-routes': { + '/device/$id': ['/device/$id', '__root__', 'routes/device/route.tsx'], + '/device/$id/history/$filename': [ + '/device/$id/history/$filename', + '__root__', + 'routes/history/route.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-sibling-routes': { + '/_main': ['/', '__root__', 'routes/layout.tsx'], + '/_main/posts': ['/posts', '/_main', 'routes/posts.tsx'], + '/_main/posts/$id': ['/posts/$id', '/_main', 'routes/post-detail.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-subtree-in-escaped-physical-directory': { + '/_area/': ['/_area/', '__root__', 'routes/[_]area/index.tsx'], + '/_area/child': ['/_area/child', '__root__', 'routes/[_]area/child.tsx'], + __root__: ['/', null, 'routes/__root.tsx'], + }, + 'virtual-with-escaped-underscore': { + '/': ['/', '__root__', 'routes/index.tsx'], + '/api/': ['/api/', '__root__', 'routes/physical-routes/index.tsx'], + '/api/_auth': [ + '/api/_auth', + '__root__', + 'routes/physical-routes/[_]auth.route.tsx', + ], + '/api/_hello': [ + '/api/_hello', + '__root__', + 'routes/physical-routes/[_]hello.tsx', + ], + __root__: ['/', null, 'routes/__root.tsx'], + }, + virtual: { + '/': ['/', '__root__', 'routes/index.tsx'], + '/$lang/': ['/$lang/', '__root__', 'routes/pages.tsx'], + '/_layout': ['/', '__root__', 'routes/layout.tsx'], + '/_layout/dashboard': ['/dashboard', '/_layout', 'routes/db/dashboard.tsx'], + '/_layout/dashboard/': [ + '/dashboard/', + '/_layout/dashboard', + 'routes/db/dashboard-index.tsx', + ], + '/_layout/dashboard/invoices': [ + '/dashboard/invoices', + '/_layout/dashboard', + 'routes/db/dashboard-invoices.tsx', + ], + '/_layout/dashboard/invoices/': [ + '/dashboard/invoices/', + '/_layout/dashboard/invoices', + 'routes/db/invoices-index.tsx', + ], + '/_layout/dashboard/invoices/$id': [ + '/dashboard/invoices/$id', + '/_layout/dashboard/invoices', + 'routes/db/invoice-detail.tsx', + ], + '/_layout/hello/': ['/hello/', '/_layout', 'routes/subtree/index.tsx'], + '/_layout/hello/foo/': [ + '/hello/foo/', + '/_layout', + 'routes/subtree/foo/index.tsx', + ], + '/_layout/hello/foo/$id': [ + '/hello/foo/$id', + '/_layout', + 'routes/subtree/foo/$id.tsx', + ], + __root__: ['/', null, 'routes/root.tsx'], + }, +} diff --git a/packages/router-generator/tests/generator-options.test.ts b/packages/router-generator/tests/generator-options.test.ts new file mode 100644 index 0000000000..2a0793fa01 --- /dev/null +++ b/packages/router-generator/tests/generator-options.test.ts @@ -0,0 +1,1063 @@ +/** + * Full generator runs on apps in temporary directories: route files the + * generator fixes or scaffolds, and configuration options, read through + * `getConfig` (and `tsr.config.json`) like the bundler plugins and the CLI do. + */ +import { existsSync } from 'node:fs' +import { + access, + mkdir, + mkdtemp, + readFile, + rm, + stat, + writeFile, +} from 'node:fs/promises' +import os from 'node:os' +import path from 'node:path' +import { parseSync } from 'vite' +import { afterEach, describe, expect, onTestFinished, test, vi } from 'vitest' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { Generator, getConfig } from '../src' +import { recordInputs } from './consumer-inputs' +import { expectOnlyOwnedEdits } from './owned-edits' +import { routeCallOf, routeIdOf } from './route-id' +import { routesOf, urlsOf, withRouteTree } from './route-tree' +import type { Config } from '../src' + +let roots: Array = [] + +afterEach(async () => { + vi.restoreAllMocks() + vi.unstubAllEnvs() + await Promise.all( + roots.map((root) => rm(root, { recursive: true, force: true })), + ) + roots = [] +}) + +/** + * Creates an app in a temporary directory with the given files (paths + * relative to the app root) and returns its root. + */ +async function createApp(files: Record) { + const root = await mkdtemp( + path.join(runDirectory(), 'tsr-generator-options-'), + ) + roots.push(root) + for (const [file, content] of Object.entries(files)) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), content) + } + recordInputs(root, files) + return root +} + +/** + * The configuration of the app at `root`, read like the bundler plugins do + * (its `tsr.config.json`, then `inlineConfig`), with the default `src/routes` + * directory and `src/routeTree.gen.ts` route tree. Temporary files go to the + * app, on the same filesystem. + */ +function configOf(root: string, inlineConfig: Partial = {}) { + const config = getConfig( + { + disableLogging: true, + tmpDir: path.join(root, '.tanstack/tmp'), + ...inlineConfig, + }, + root, + ) + recordInputs(root, {}, config.target) + return config +} + +/** Runs the generator once on the app at `root`. */ +async function generate(root: string, inlineConfig: Partial = {}) { + const config = configOf(root, inlineConfig) + await new Generator({ config, root }).run() + return config +} + +function read(root: string, file: string) { + return readFile(path.join(root, file), 'utf8') +} + +function rootRoute(target: Config['target'] = 'react') { + return `import { createRootRoute } from '@tanstack/${target}-router' + +export const Route = createRootRoute() +` +} + +describe('route files whose id the generator fixes', () => { + const postsRoute = ( + target: Config['target'] = 'react', + ) => `import { createFileRoute } from '@tanstack/${target}-router' + +export const Route = createFileRoute('/old')({ + component: Posts, +}) + +function Posts() { + return

Posts

+} +` + + // (UTF-8 BOMs: outside the compiler tests, SPEC \u00A72.1 selects + // BOM-free sources.) + test.each([ + { + name: 'CRLF line endings', + file: 'posts.tsx', + source: postsRoute().replaceAll('\n', '\r\n'), + }, + { + name: 'quoteStyle double and semicolons, in a file using them', + file: 'posts.tsx', + config: { quoteStyle: 'double', semicolons: true }, + source: `import { createFileRoute } from "@tanstack/react-router"; + +export const Route = createFileRoute("/old")({ + component: Posts, +}); + +function Posts() { + return

Posts

; +} +`, + }, + { + name: 'quoteStyle double and semicolons, in a file not using them', + file: 'posts.tsx', + config: { quoteStyle: 'double', semicolons: true }, + source: postsRoute(), + }, + { + name: 'the solid target', + file: 'posts.tsx', + config: { target: 'solid' }, + source: postsRoute('solid'), + }, + { + name: 'the vue target', + file: 'posts.tsx', + config: { target: 'vue' }, + source: postsRoute('vue'), + }, + { + name: 'a .jsx file', + file: 'posts.jsx', + source: postsRoute(), + }, + { + name: 'a .js file', + file: 'posts.js', + source: `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/old')({ + loader: () => fetch('/api/posts'), +}) +`, + }, + ] satisfies Array<{ + name: string + file: string + source: string + config?: Partial + }>)( + 'only the route id changes in a route file with $name', + async ({ file, source, config }) => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(config?.target), + [`src/routes/${file}`]: source, + }) + const { generatedRouteTree } = await generate(root, config) + + const written = await read(root, `src/routes/${file}`) + // (the quote character of the edited id is free, SPEC J1.2) + expectOnlyOwnedEdits(source, written, file) + expect(routeCallOf(written, file)).toEqual({ + constructor: 'createFileRoute', + id: '/posts', + }) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': `routes/${file}`, + }) + }, + ) + + describe.each(['react', 'solid', 'vue'] as const)('target %s', (target) => { + const routerPackage = `@tanstack/${target}-router` + + test.each([ + { name: 'LF', newline: '\n' }, + { name: 'CRLF', newline: '\r\n' }, + ])( + 'a lazy route file created with createFileRoute gets createLazyFileRoute, with $name', + async ({ newline }) => { + const source = `import { Link, createFileRoute } from '${routerPackage}' + +export const Route = createFileRoute('/posts')({ + component: () => Home, +}) +`.replaceAll('\n', newline) + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(target), + 'src/routes/posts.tsx': `import { createFileRoute } from '${routerPackage}' + +export const Route = createFileRoute('/posts')({ + loader: () => fetch('/api/posts'), +}) +`, + 'src/routes/posts.lazy.tsx': source, + }) + const { generatedRouteTree } = await generate(root, { target }) + + const written = await read(root, 'src/routes/posts.lazy.tsx') + // Only the constructor changes: `Link` stays bound, and the now + // unused `createFileRoute` import may stay or go (SPEC J1.2). + expectOnlyOwnedEdits(source, written) + expect(routeCallOf(written)).toEqual({ + constructor: 'createLazyFileRoute', + id: '/posts', + }) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts.tsx', + }) + }, + ) + + test(`a route file without the route constructor import gets it from ${routerPackage}`, async () => { + const source = `import { Link } from '${routerPackage}' + +export const Route = createFileRoute('/old')({ + component: Link, +}) +` + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(target), + 'src/routes/posts.tsx': source, + }) + await generate(root, { target }) + + const written = await read(root, 'src/routes/posts.tsx') + expect(routeCallOf(written)).toEqual({ + constructor: 'createFileRoute', + id: '/posts', + }) + // (`Link` stays bound: expectOnlyOwnedEdits) + expectOnlyOwnedEdits(source, written) + }) + }) +}) + +describe('empty route files', () => { + // Control for the pin below: an empty .tsx route file. + test('an empty .tsx route file is scaffolded, and the other routes still generate', async () => { + const { written, routes } = await scaffold('posts.tsx') + expect(parseErrors(written, 'posts.tsx')).toEqual([]) + expect(await routeIdOf(written)).toBe('/posts') + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + '/posts': 'routes/posts.tsx', + }) + }) + + // Bug: an empty .ts route file is scaffolded with the route template, which + // renders JSX; the generator then parses the scaffolded file as plain + // TypeScript (no JSX) and the run fails with "Error transforming route + // file". Issue #8480. + // Source: src/generator.ts:1073 (the route template for any script file), + // src/generator.ts:1096 (parse of the scaffolded file). + // Impact: an empty .ts route file breaks route generation for the whole + // app (no route tree update) until the file is renamed or filled in. + test.fails( + 'an empty .ts route file is scaffolded, and the other routes still generate', + async () => { + const { written, routes } = await scaffold('posts.ts') + expect(parseErrors(written, 'posts.ts')).toEqual([]) + expect(await routeIdOf(written)).toBe('/posts') + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + '/posts': 'routes/posts.ts', + }) + }, + ) + + /** + * Runs the generator on an app with an index route and an empty + * `routes/`; returns the scaffolded file and the route tree's routes. + */ + async function scaffold(file: string) { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/')({}) +`, + [`src/routes/${file}`]: '', + }) + const { generatedRouteTree } = await generate(root) + return { + written: await read(root, `src/routes/${file}`), + routes: await routesOf(generatedRouteTree), + } + } + + /** The syntax errors of `code` as a file named `fileName`. */ + function parseErrors(code: string, fileName: string) { + return parseSync(fileName, code).errors.map((error) => error.message) + } +}) + +describe('route files with unusual names and contents', () => { + test('route files with non-ASCII names get routes with their paths', async () => { + const route = `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/old')({}) +` + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/café.tsx': route, + 'src/routes/日本語.tsx': route, + 'src/routes/日本語.$id.tsx': route, + }) + const { generatedRouteTree } = await generate(root) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/café': 'routes/café.tsx', + '/日本語': 'routes/日本語.tsx', + '/日本語/$id': 'routes/日本語.$id.tsx', + }) + for (const [file, id] of [ + ['café.tsx', '/café'], + ['日本語.$id.tsx', '/日本語/$id'], + ] as const) { + const written = await read(root, `src/routes/${file}`) + expectOnlyOwnedEdits(route, written) + expect(routeCallOf(written)).toEqual({ + constructor: 'createFileRoute', + id, + }) + } + }) +}) + +describe('virtual route config in tsr.config.json', () => { + test('a virtual route config object in tsr.config.json generates its routes, and fixes their ids', async () => { + const route = `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/old')({}) +` + const root = await createApp({ + 'tsr.config.json': JSON.stringify({ + virtualRouteConfig: { + type: 'root', + file: 'root.tsx', + children: [ + { type: 'index', file: 'home.tsx' }, + { + type: 'route', + path: '/posts', + file: 'posts/layout.tsx', + children: [ + { type: 'index', file: 'posts/list.tsx' }, + { type: 'route', path: '$postId', file: 'posts/detail.tsx' }, + ], + }, + { + type: 'layout', + id: 'auth', + file: 'auth-layout.tsx', + children: [{ type: 'route', path: '/login', file: 'login.tsx' }], + }, + { type: 'physical', directory: 'legacy', pathPrefix: '/legacy' }, + ], + }, + }), + 'src/routes/root.tsx': rootRoute(), + 'src/routes/home.tsx': route, + 'src/routes/posts/layout.tsx': route, + 'src/routes/posts/list.tsx': route, + 'src/routes/posts/detail.tsx': route, + 'src/routes/auth-layout.tsx': route, + 'src/routes/login.tsx': route, + 'src/routes/legacy/about.tsx': route, + }) + const { generatedRouteTree } = await generate(root) + + const routes = await routesOf(generatedRouteTree) + expect(routes).toEqual({ + __root__: 'routes/root.tsx', + '/': 'routes/home.tsx', + '/posts': 'routes/posts/layout.tsx', + '/posts/': 'routes/posts/list.tsx', + '/posts/$postId': 'routes/posts/detail.tsx', + '/_auth': 'routes/auth-layout.tsx', + '/_auth/login': 'routes/login.tsx', + '/legacy/about': 'routes/legacy/about.tsx', + }) + for (const [id, file] of Object.entries(routes)) { + if (id !== '__root__') { + expect(await routeIdOf(await read(root, `src/${file}`))).toBe(id) + } + } + }) +}) + +describe('route tree options', () => { + /** An app with a root, index, posts and lazy posts route. */ + const app = (ext = 'tsx') => ({ + [`src/routes/__root.${ext}`]: rootRoute(), + [`src/routes/index.${ext}`]: `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/')({}) +`, + [`src/routes/posts.${ext}`]: `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts')({}) +`, + [`src/routes/posts.lazy.${ext}`]: `import { createLazyFileRoute } from '@tanstack/react-router' + +export const Route = createLazyFileRoute('/posts')({}) +`, + }) + + const appRoutes = (ext = 'tsx') => ({ + __root__: `routes/__root.${ext}`, + '/': `routes/index.${ext}`, + '/posts': `routes/posts.${ext}`, + }) + + /** + * The imports of the app's route files in a route tree, static and + * dynamic: route file (relative to the app, without its extension) to + * the specifiers that import it. Imports of other modules (packages, + * generated support modules) are left out: the options are about the + * route files. + */ + async function routeFileImports( + root: string, + treeFile: string, + files: Array, + kinds: Array<'static' | 'dynamic'> = ['static', 'dynamic'], + ) { + return withRouteTree(treeFile, async (tree) => { + const initial = [...tree.imports] + if (kinds.includes('dynamic')) { + for (const route of Object.values(tree.router.routesById)) { + await tree.router.loadRouteChunk(route) + } + } + const withoutExtension = (file: string) => file.replace(/\.[^./]+$/, '') + const imports: Record< + string, + Array<{ specifier: string; importer: string }> + > = Object.fromEntries(files.map((file) => [withoutExtension(file), []])) + for (const edge of kinds.includes('dynamic') ? tree.imports : initial) { + const file = withoutExtension( + path.relative(root, edge.file).replaceAll(path.sep, '/'), + ) + imports[file]?.push(edge) + } + return imports + }) + } + + /** The route files of `app()`. */ + const appFiles = (ext = 'tsx') => + Object.keys(app(ext)).filter((file) => file.startsWith('src/routes/')) + + test.each([ + { config: {}, quote: "'", semicolons: false }, + { config: { quoteStyle: 'double' }, quote: '"', semicolons: false }, + { config: { semicolons: true }, quote: "'", semicolons: true }, + { + config: { quoteStyle: 'double', semicolons: true }, + quote: '"', + semicolons: true, + }, + ] satisfies Array<{ + config: Partial + quote: string + semicolons: boolean + }>)( + 'the route tree follows the quoteStyle and semicolons options: $config', + async ({ config, quote, semicolons }) => { + const root = await createApp(app()) + const { generatedRouteTree } = await generate(root, config) + + const code = await readFile(generatedRouteTree, 'utf8') + const { program, errors } = parseSync('routeTree.gen.ts', code) + expect(errors).toEqual([]) + // The quotes of the string literals without quote characters in them + // (a printer may quote the others either way to avoid escapes). + const quotes = new Set() + const visit = (node: unknown) => { + if (Array.isArray(node)) { + node.forEach(visit) + } else if (node && typeof node === 'object') { + const { type, value, raw } = node as Record + if ( + type === 'Literal' && + typeof value === 'string' && + !/["']/.test(value) + ) { + quotes.add(String(raw)[0]!) + } + Object.values(node).forEach(visit) + } + } + visit(program) + expect([...quotes]).toEqual([quote]) + const statements = program.body.filter( + (statement) => + statement.type === 'ImportDeclaration' || + statement.type === 'VariableDeclaration' || + (statement.type === 'ExportNamedDeclaration' && + statement.declaration?.type === 'VariableDeclaration'), + ) + expect(statements.length).toBeGreaterThan(0) + for (const statement of statements) { + expect(code.slice(statement.start, statement.end).endsWith(';')).toBe( + semicolons, + ) + } + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }, + ) + + test('addExtensions true imports the route files by their file names', async () => { + const root = await createApp(app()) + const { generatedRouteTree } = await generate(root, { + addExtensions: true, + }) + + const imports = await routeFileImports(root, generatedRouteTree, appFiles()) + for (const [file, specifiers] of Object.entries(imports)) { + expect(specifiers.length, file).toBeGreaterThan(0) + for (const { specifier, importer } of specifiers) { + expect(specifier).toMatch(/\.tsx$/) + expect( + existsSync(path.resolve(path.dirname(importer), specifier)), + ).toBe(true) + } + } + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }) + + test.each(['js', '.js'])( + 'addExtensions "%s" in tsr.config.json imports the route files with a .js extension', + async (addExtensions) => { + const root = await createApp({ + ...app(), + 'tsr.config.json': JSON.stringify({ addExtensions }), + }) + const { generatedRouteTree } = await generate(root) + + const imports = await routeFileImports( + root, + generatedRouteTree, + appFiles(), + ) + for (const [file, specifiers] of Object.entries(imports)) { + expect(specifiers.length, file).toBeGreaterThan(0) + for (const { specifier } of specifiers) { + expect(specifier).toMatch(/[^.]\.js$/) + } + } + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }, + ) + + test('disableTypes in tsr.config.json generates a JavaScript route tree', async () => { + const root = await createApp({ + ...app('jsx'), + 'tsr.config.json': JSON.stringify({ + disableTypes: true, + generatedRouteTree: './src/routeTree.gen.ts', + }), + }) + const { generatedRouteTree } = await generate(root) + + expect(generatedRouteTree).toBe(path.join(root, 'src/routeTree.gen.js')) + expect(existsSync(path.join(root, 'src/routeTree.gen.ts'))).toBe(false) + const code = await readFile(generatedRouteTree, 'utf8') + expect(parseSync('routeTree.gen.js', code, { lang: 'js' }).errors).toEqual( + [], + ) + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes('jsx')) + }) + + test('importRoutesUsingAbsolutePaths imports the route files by absolute paths', async () => { + const root = await createApp(app()) + const { generatedRouteTree } = await generate(root, { + importRoutesUsingAbsolutePaths: true, + }) + + // (the static imports of the route files; the lazy file: below) + const imports = await routeFileImports( + root, + generatedRouteTree, + appFiles().filter((file) => !file.includes('.lazy.')), + ['static'], + ) + for (const [file, specifiers] of Object.entries(imports)) { + expect(specifiers.length, file).toBeGreaterThan(0) + for (const { specifier } of specifiers) { + expect(path.isAbsolute(specifier), specifier).toBe(true) + } + } + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }) + + // Bug: with importRoutesUsingAbsolutePaths, the route tree still imports + // lazy route files (and lazy components) by paths relative to itself; + // only the eager route file imports are absolute. + // Source: src/generator.ts (the `.lazy(() => import('./…'))` and + // `lazyRouteComponent(() => import('./…'))` templates ignore the option; + // src/utils.ts `getImportForRouteNode` honours it for static imports). + // Impact: the option holds for eager routes only; whatever needs the + // tree's route imports to be absolute (a tree evaluated from another + // location than the one it was generated for) still gets relative imports + // for every lazy route. + test.fails( + 'importRoutesUsingAbsolutePaths imports the lazy route files by absolute paths too', + async () => { + const root = await createApp(app()) + const { generatedRouteTree } = await generate(root, { + importRoutesUsingAbsolutePaths: true, + }) + + // (static imports of the route files and dynamic ones of the lazy file) + const imports = await routeFileImports( + root, + generatedRouteTree, + appFiles(), + ) + for (const [file, specifiers] of Object.entries(imports)) { + expect(specifiers.length, file).toBeGreaterThan(0) + for (const { specifier } of specifiers) { + expect(path.isAbsolute(specifier), specifier).toBe(true) + } + } + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }, + ) + + test.each([ + { + name: 'a function', + routeTreeFileFooter: () => ['// footer', 'export const footer = 1'], + }, + { + name: 'an array', + routeTreeFileFooter: ['// footer', 'export const footer = 1'], + }, + ])( + 'routeTreeFileFooter as $name ends the route tree with its lines', + async ({ routeTreeFileFooter }) => { + const root = await createApp(app()) + const { generatedRouteTree } = await generate(root, { + routeTreeFileFooter, + }) + + const lines = (await readFile(generatedRouteTree, 'utf8')) + .split('\n') + .filter((line) => line.trim() !== '') + expect(lines.slice(-2)).toEqual(['// footer', 'export const footer = 1']) + expect(await routesOf(generatedRouteTree)).toEqual(appRoutes()) + }, + ) +}) + +describe('ignored route files', () => { + test('with the default routeFileIgnorePrefix, "-" route files and directories are left out of the route tree and untouched', async () => { + const notARoute = `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/old')({}) +` + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/')({}) +`, + 'src/routes/-disabled.tsx': notARoute, + 'src/routes/-components/card.tsx': notARoute, + 'src/routes/-empty.tsx': '', + }) + const { generatedRouteTree } = await generate(root) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + }) + expect(await read(root, 'src/routes/-disabled.tsx')).toBe(notARoute) + expect(await read(root, 'src/routes/-components/card.tsx')).toBe(notARoute) + expect(await read(root, 'src/routes/-empty.tsx')).toBe('') + }) + + // An empty routeFileIgnorePrefix ignores nothing by prefix: a "-" file is + // a route like any other (a generator must not restore the default "-" + // for an empty prefix). + test('with an empty routeFileIgnorePrefix, a "-" route file is a route', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/-health.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/old')({}) +`, + }) + const { generatedRouteTree } = await generate(root, { + routeFileIgnorePrefix: '', + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/-health': 'routes/-health.tsx', + }) + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/-health': '/-health', + }) + }) +}) + +describe.each(['react', 'solid', 'vue'] as const)('the %s target', (target) => { + const routerPackage = `@tanstack/${target}-router` + + test(`the route tree imports its runtime from ${routerPackage}`, async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(target), + // A lazy route without a route file: the route tree creates its route. + 'src/routes/about.lazy.tsx': `import { createLazyFileRoute } from '${routerPackage}' + +export const Route = createLazyFileRoute('/about')({}) +`, + }) + const { generatedRouteTree } = await generate(root, { target }) + + await withRouteTree( + generatedRouteTree, + async ({ router, routerPackage, import: importFile }) => { + expect(router.routeTree).toBeInstanceOf(routerPackage.RootRoute) + const { Route } = await importFile( + path.join(root, 'src/routes/about.lazy.tsx'), + ) + expect(Route).toBeInstanceOf(routerPackage.LazyRoute) + // The route the tree creates itself comes from the target runtime + expect(router.routesById['/about']).toBeInstanceOf(routerPackage.Route) + await router.loadRouteChunk(router.routesById['/about']) + }, + ) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/about': null, + }) + }) +}) + +describe('custom scaffolding', () => { + // The lazy template uses an option a lazy route takes (`component`; + // `staticData` is no option of createLazyFileRoute: tsc TS2353, + // api/router/createLazyFileRouteFunction.md:22-28). + test('customScaffolding in tsr.config.json scaffolds new route and lazy route files', async () => { + const root = await createApp({ + 'tsr.config.json': JSON.stringify({ + customScaffolding: { + routeTemplate: + '%%tsrImports%%\n\n%%tsrExportStart%%{ staticData: { template: "route" } }%%tsrExportEnd%%\n', + lazyRouteTemplate: + '%%tsrImports%%\n\n%%tsrExportStart%%{ component: () => "lazy template" }%%tsrExportEnd%%\n', + }, + }), + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': '', + 'src/routes/about.lazy.tsx': '', + }) + const { generatedRouteTree } = await generate(root) + + for (const [file, constructor, id] of [ + ['posts.tsx', 'createFileRoute', '/posts'], + ['about.lazy.tsx', 'createLazyFileRoute', '/about'], + ]) { + expect(routeCallOf(await read(root, `src/routes/${file}`))).toEqual({ + constructor, + id, + }) + } + await withRouteTree(generatedRouteTree, async ({ router, renderAt }) => { + expect(router.routesById['/posts']!.options.staticData).toEqual({ + template: 'route', + }) + expect(await renderAt('/about')).toContain('lazy template') + }) + }) +}) + +describe('token options', () => { + test('a RegExp indexToken with the default routeToken generates index and layout routes', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts/route.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts')({}) +`, + 'src/routes/posts/page.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts/')({}) +`, + }) + const { generatedRouteTree } = await generate(root, { + indexToken: /^page$/, + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts/route.tsx', + '/posts/': 'routes/posts/page.tsx', + }) + }) +}) + +describe('custom tokens matching longer names', () => { + // The routeToken regex of the docs (file-based-routing.md: "filenames like + // `dashboard.main-layout.tsx` ... would all be recognized as layout + // routes") matches the whole name of a layout file (a generator that read + // every name as bracket-wrapped missed it). + test('a routeToken regex matching whole names makes such a file the layout route of its directory', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts/main-layout.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts')({}) +`, + 'src/routes/posts/index.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts/')({}) +`, + }) + const { generatedRouteTree } = await generate(root, { + routeToken: /[a-z]+-layout/, + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts/main-layout.tsx', + '/posts/': 'routes/posts/index.tsx', + }) + }) + + // A token RegExp keeps its flags' meaning: `\p{L}` needs the `u` flag (a + // generator must not drop it). + test('a Unicode-mode routeToken regex makes a file with a non-ASCII name the layout route of its directory', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts/écran-layout.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts')({}) +`, + 'src/routes/posts/index.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/posts/')({}) +`, + }) + const { generatedRouteTree } = await generate(root, { + routeToken: /\p{L}+-layout/u, + }) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/posts': '/posts', + '/posts/': '/posts/', + }) + expect((await routesOf(generatedRouteTree))['/posts']).toBe( + 'routes/posts/écran-layout.tsx', + ) + }) +}) + +describe('route tree path', () => { + test('the directories of a nested route tree path are created', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + }) + const { generatedRouteTree } = await generate(root, { + generatedRouteTree: './src/generated/deep/routeTree.gen.ts', + }) + + expect(generatedRouteTree).toBe( + path.join(root, 'src/generated/deep/routeTree.gen.ts'), + ) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: '../../routes/__root.tsx', + }) + }) +}) + +describe('logging', () => { + /** + * An app whose run scaffolds a route file (an empty root route) and skips + * one (a route file without a Route export). + */ + const app = () => ({ + 'src/routes/__root.tsx': '', + 'src/routes/helpers.tsx': 'export const helper = 1\n', + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('/')({}) +`, + }) + + // A route file without a Route export is left out with a warning naming it + // (SPEC J1.12, G5); what else the run logs is free. + test('with logging on, a route file without a Route export is left out with a warning naming it', async () => { + const root = await createApp(app()) + const { result: config, diagnostics } = await captureDiagnostics(() => + generate(root, { disableLogging: false }), + ) + + // (a warning: the run goes on, so no error) + expectDiagnostic(diagnostics, { + severity: 'warning', + file: path.join(root, 'src/routes/helpers.tsx'), + root, + }) + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + }) + }) + + // `disableLogging` silences the route generation logging (SPEC J1.12) on + // every console channel, whatever its severity; actionable diagnostics + // about the input stay allowed (G5): here, only ones naming the route + // file without a Route export. + test('with disableLogging, a run that scaffolds and skips route files logs no route generation messages', async () => { + const root = await createApp(app()) + const { result: config, diagnostics } = await captureDiagnostics(() => + generate(root, { disableLogging: true }), + ) + + const actionable = findDiagnostics(diagnostics, { + severity: ['warning', 'error'], + file: path.join(root, 'src/routes/helpers.tsx'), + root, + }) + expect( + diagnostics.filter((diagnostic) => !actionable.includes(diagnostic)), + 'the messages not about the route file without a Route export', + ).toEqual([]) + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/': 'routes/index.tsx', + }) + }) +}) + +/** + * A writable directory on another filesystem than the system's temporary + * directory, which holds the apps of these tests (shared memory, if the host + * has it there). + */ +async function directoryOnAnotherDevice() { + const { dev } = await stat(os.tmpdir()) + const candidate = '/dev/shm' + const found = await stat(candidate).catch(() => undefined) + if ( + !found?.isDirectory() || + found.dev === dev || + (await access(candidate).then( + () => false, + () => true, + )) + ) { + return undefined + } + return candidate +} + +const otherDevice = await directoryOnAnotherDevice() + +describe('tmpDir', () => { + // Bug (SPEC J1.16): with `tmpDir` on another filesystem than the app (e.g. the + // app on a disk and TSR_TMP_DIR on a tmpfs), every publication fails: + // renaming the temporary file onto the route file or the route tree fails + // with EXDEV, and the run fails. The atomic fallback is to write the + // temporary file beside the destination and rename it there (SPEC J1.16); + // a copy over the destination is not atomic (the destination file must be + // replaced, not rewritten in place). Real filesystems only (SPEC §9): a + // host without a second writable filesystem skips the pin. + // Source: src/generator.ts `safeFileWrite` renames from + // `getTempFileName`'s file in `config.tmpDir`. + // Impact: route generation fails until tmpDir is moved to the app's + // filesystem (api/file-based-routing.md `tmpDir` names no such limit). + test + .skipIf(!otherDevice) + .fails( + 'with tmpDir on another filesystem, the route file and the route tree are replaced atomically', + async () => { + const tmpDir = await mkdtemp( + path.join(otherDevice!, 'tsr-generator-tmp-'), + ) + onTestFinished(() => rm(tmpDir, { recursive: true, force: true })) + const postsRoute = (id: string) => + `import { createFileRoute } from '@tanstack/react-router' + +export const Route = createFileRoute('${id}')({ + component: () => 'posts', +}) +` + // A first run, with tmpDir on the app's filesystem; the next one + // rewrites the route file (a wrong id) and the route tree (a new route) + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/posts.tsx': postsRoute('/posts'), + }) + const config = await generate(root) + await writeFile( + path.join(root, 'src/routes/posts.tsx'), + postsRoute('/old'), + ) + await writeFile( + path.join(root, 'src/routes/about.tsx'), + postsRoute('/about'), + ) + recordInputs(root, { 'src/routes/about.tsx': postsRoute('/about') }) + const files = [ + path.join(root, 'src/routes/posts.tsx'), + config.generatedRouteTree, + ] + const inodes = await Promise.all( + files.map(async (file) => (await stat(file)).ino), + ) + + await generate(root, { tmpDir }) + + expect(await routeIdOf(await read(root, 'src/routes/posts.tsx'))).toBe( + '/posts', + ) + expect(await routesOf(config.generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/about': 'routes/about.tsx', + '/posts': 'routes/posts.tsx', + }) + // Replaced by a rename, not rewritten in place or copied over + for (const [index, file] of files.entries()) { + expect((await stat(file)).ino, file).not.toBe(inodes[index]) + } + }, + ) +}) diff --git a/packages/router-generator/tests/generator.test.ts b/packages/router-generator/tests/generator.test.ts index 3e0831fe91..74a858a9ff 100644 --- a/packages/router-generator/tests/generator.test.ts +++ b/packages/router-generator/tests/generator.test.ts @@ -1,466 +1,264 @@ -import { existsSync } from 'node:fs' +/** + * The generator fixtures (tests/generator/, configured in + * generator-fixture.ts): each app's route tree is loaded with the real + * router (route-tree.ts), and its routes (ids, full paths, parents, route + * files and lazily loaded files) must be the ones listed in + * generator-fixtures.ts (SPEC J1.4). Fixtures with conflicting routes must + * fail with an error naming the files (J1.7). Route files the generator + * edits or scaffolds are checked for what the edit may change + * (owned-edits.ts) and for the custom templates. The trees' types are + * checked against the same routes in integration/fixture-types-*.test.ts + * (J1.13). + */ import fs from 'node:fs/promises' -import path, { dirname, join, relative } from 'node:path' +import path, { join } from 'node:path' +import { parseSync } from 'vite' import { describe, expect, it } from 'vitest' - import { - index, - layout, - physical, - rootRoute, - route, -} from '@tanstack/virtual-file-routes' -import { Generator, getConfig, virtualGetRouteNodes } from '../src' + captureThrow, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { Generator } from '../src' +import { + conflictingFiles, + copyFixture, + customTemplates, + fixtureConfig, + fixtureNames, + prepareFixture, +} from './generator-fixture' +import { crlfRoutes, generateCrlf } from './crlf-app' +import { fixtureRoutes } from './generator-fixtures' +import { expectOnlyOwnedEdits } from './owned-edits' +import { routeCallOf } from './route-id' +import { withRouteTree } from './route-tree' +import type { FixtureRoute } from './generator-fixtures' import type { Config } from '../src' -function makeFolderDir(folder: string) { - return join(process.cwd(), 'tests', 'generator', folder) -} - -async function readDir(...paths: Array) { - const folders = await fs.readdir( - join(process.cwd(), 'tests', 'generator', ...paths), - ) - return folders -} - -async function traverseDirectory( - dir: string, - handleFile: (filePath: string) => void | Promise, +/** + * Asserts that `written` applies `template` for the route at `routePath`: + * the template's own statements (here its `react` import and its component + * returning `Hello !`) are in the scaffolded file, which the + * generator may print in the configured style. + */ +function expectTemplateApplied( + template: string, + routePath: string, + written: string, ) { - const files = await fs.readdir(dir, { withFileTypes: true }) - - for (const file of files) { - const filePath = join(dir, file.name) - - if (file.isDirectory()) { - await traverseDirectory(filePath, handleFile) - } else { - await handleFile(filePath) - } - } -} - -function setupConfig( - folder: string, - inlineConfig: Partial> = {}, -) { - const { generatedRouteTree = `/routeTree.gen.ts`, ...rest } = inlineConfig - const dir = makeFolderDir(folder) - - const configFilePath = join(dir, 'tsr.config.json') - const configDirectory = existsSync(configFilePath) ? dir : undefined - - const config = getConfig( - { - disableLogging: true, - routesDirectory: dir + '/routes', - generatedRouteTree: dir + generatedRouteTree, - ...rest, - }, - configDirectory, - ) - return config -} - -async function getRouteTreeFileText(config: Config) { - const location = config.generatedRouteTree - const text = await fs.readFile(location, 'utf-8') - return text -} - -function rewriteConfigByFolderName(folderName: string, config: Config) { - switch (folderName) { - case 'append-and-prepend': - config.routeTreeFileHeader = ['// prepend1', '// prepend2'] - config.routeTreeFileFooter = ['// append1', '// append2'] - break - case 'no-formatted-route-tree': - config.enableRouteTreeFormatting = false - break - case 'custom-tokens': - config.indexToken = '_1nd3x' - config.routeToken = '_r0ut3_' - break - case 'escaped-custom-tokens': - config.indexToken = '_1nd3x' - config.routeToken = '_r0ut3_' - break - case 'virtual': - { - const virtualRouteConfig = rootRoute('root.tsx', [ - index('index.tsx'), - route('$lang', [index('pages.tsx')]), - layout('layout.tsx', [ - route('/dashboard', 'db/dashboard.tsx', [ - index('db/dashboard-index.tsx'), - route('/invoices', 'db/dashboard-invoices.tsx', [ - index('db/invoices-index.tsx'), - route('$id', 'db/invoice-detail.tsx'), - ]), - ]), - physical('/hello', 'subtree'), - ]), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'virtual-with-escaped-underscore': - { - // Test case for escaped underscores in physical routes mounted via virtual config - // This ensures originalRoutePath is correctly prefixed when paths are updated - const virtualRouteConfig = rootRoute('__root.tsx', [ - index('index.tsx'), - physical('/api', 'physical-routes'), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'types-disabled': - config.disableTypes = true - config.generatedRouteTree = - makeFolderDir(folderName) + `/routeTree.gen.js` - break - case 'custom-scaffolding': - config.customScaffolding = { - routeTemplate: [ - 'import * as React from "react";\n', - '%%tsrImports%%\n\n', - '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', - 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', - ].join(''), - lazyRouteTemplate: [ - 'import React, { useState } from "react";\n', - '%%tsrImports%%\n\n', - '%%tsrExportStart%%{\n component: RouteComponent\n }%%tsrExportEnd%%\n\n', - 'function RouteComponent() { return "Hello %%tsrPath%%!" };\n', - ].join(''), - } - break - case 'routeFileIgnore': - config.routeFileIgnorePattern = 'ignoredPattern' - config.routeFileIgnorePrefix = 'imIgnored' - break - case 'routeFilePrefix': - config.routeFileIgnorePattern = 'ignoredPattern' - config.routeFilePrefix = 'r&' - break - case 'regex-tokens-inline': - // Test inline config with RegExp tokens - // indexToken matches patterns like "index-page", "home-page" - // routeToken matches patterns like "main-layout", "protected-layout" - config.indexToken = /[a-z]+-page/ - config.routeToken = /[a-z]+-layout/ - break - case 'virtual-sibling-routes': - { - // Test case for issue #5822: Virtual routes should respect explicit sibling relationships - // Routes /posts and /posts/$id should remain siblings under the layout, - // NOT auto-nested based on path matching - const virtualRouteConfig = rootRoute('__root.tsx', [ - layout('_main', 'layout.tsx', [ - route('/posts', 'posts.tsx'), - route('/posts/$id', 'post-detail.tsx'), - ]), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'virtual-pathless-layout-dotted-filename': - { - const virtualRouteConfig = rootRoute('root.route.tsx', [ - index('index.route.tsx'), - layout('pathless.layout.tsx', [ - route('subpath', 'subpath.route.tsx'), - ]), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'virtual-explicit-dotted-paths': - { - const virtualRouteConfig = rootRoute('root.tsx', [ - route('direct.path', 'direct.tsx'), - physical('/mounted.path', 'physical-routes'), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'virtual-root-sibling-routes': - { - // Test case for issue #5431: Virtual routes that are siblings at the root level - // should NOT be auto-nested based on shared path prefix. - // /device/$id and /device/$id/history/$filename are both children of root, - // NOT parent-child of each other. - const virtualRouteConfig = rootRoute('__root.tsx', [ - route('/device/$id', 'device/route.tsx'), - route('/device/$id/history/$filename', 'history/route.tsx'), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - case 'add-extensions-custom': - config.addExtensions = '.js' - break - case 'virtual-nested-layouts-with-virtual-route': - { - // Test case for nested layouts with a virtual file-less route in between. - const virtualRouteConfig = rootRoute('__root.tsx', [ - index('home.tsx'), - layout('first', 'layout/first-layout.tsx', [ - layout('layout/second-layout.tsx', [ - route('route-without-file', [ - route('/layout-a', 'a.tsx'), - route('/layout-b', 'b.tsx'), - ]), - ]), - ]), - ]) - config.virtualRouteConfig = virtualRouteConfig - } - break - default: - break - } -} - -async function preprocess(folderName: string) { - if (folderName.startsWith('file-modification')) { - const templateVerbosePath = join( - makeFolderDir(folderName), - 'template-verbose.tsx', - ) - const templatePath = join(makeFolderDir(folderName), 'template.tsx') - const lazyTemplatePath = join( - makeFolderDir(folderName), - 'template.lazy.tsx', - ) - - const makeRoutePath = (file: string) => - join(makeFolderDir(folderName), 'routes', '(test)', file) - const makeEmptyFile = async (file: string) => { - const fh = await fs.open(makeRoutePath(file), 'w') - await fh.close() - } - - await fs.copyFile(templateVerbosePath, makeRoutePath('foo.bar.tsx')) - await fs.copyFile(templatePath, makeRoutePath('foo.tsx')) - await fs.copyFile(lazyTemplatePath, makeRoutePath('initiallyLazy.tsx')) - await fs.copyFile(templatePath, makeRoutePath('bar.lazy.tsx')) - await fs.copyFile(templatePath, makeRoutePath('double-quotes.tsx')) - await fs.copyFile(templatePath, makeRoutePath('template-literal.tsx')) - await fs.copyFile(templatePath, makeRoutePath('duplicate-import.tsx')) - await makeEmptyFile('initiallyEmpty.tsx') - await makeEmptyFile('initiallyEmpty.lazy.tsx') - - await fs.writeFile( - makeRoutePath('double-quotes.tsx'), - (await fs.readFile(makeRoutePath('double-quotes.tsx'), 'utf-8')).replace( - "createFileRoute('/foo/bar')", - 'createFileRoute("/foo/bar")', - ), - ) - - await fs.writeFile( - makeRoutePath('template-literal.tsx'), - ( - await fs.readFile(makeRoutePath('template-literal.tsx'), 'utf-8') - ).replace("createFileRoute('/foo/bar')", 'createFileRoute(`/foo/bar`)'), - ) - - await fs.writeFile( - makeRoutePath('duplicate-import.tsx'), - [ - "import { createFileRoute } from '@tanstack/react-router'", - "import * as React from 'react'", - "import { Link, Outlet } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/foo/bar')({", - ' component: PostsLayoutComponent,', - '})', - '', - 'function PostsLayoutComponent() {', - ' return (', - ' <>', - ' Home', - ' ', - ' ', - ' )', - '}', - '', - ].join('\n'), - ) - } else if (folderName === 'custom-scaffolding') { - const makeEmptyFile = async (...file: Array) => { - const filePath = join(makeFolderDir(folderName), 'routes', ...file) - const dir = dirname(filePath) - await fs.mkdir(dir, { recursive: true }) - const fh = await fs.open(filePath, 'w') - await fh.close() - } - - await makeEmptyFile('__root.tsx') - await makeEmptyFile('index.tsx') - await makeEmptyFile('foo.lazy.tsx') - await makeEmptyFile('api', 'bar.tsx') - } -} - -async function postprocess(folderName: string) { - switch (folderName) { - case 'file-modification': { - const routeFiles = await readDir(folderName, 'routes', '(test)') - await Promise.all( - routeFiles - .filter((r) => r.endsWith('.tsx')) - .map(async (routeFile) => { - const text = await fs.readFile( - join(makeFolderDir(folderName), 'routes', '(test)', routeFile), - 'utf-8', - ) - await expect(text).toMatchFileSnapshot( - join('generator', folderName, 'snapshots', routeFile), - ) - }), + const imports = (code: string) => + parseSync('route.tsx', code) + .program.body.filter( + (node) => + node.type === 'ImportDeclaration' && node.source.value === 'react', ) + .flatMap((node) => + node.type === 'ImportDeclaration' + ? node.specifiers.map((specifier) => ({ + kind: specifier.type, + local: specifier.local.name, + imported: + specifier.type === 'ImportSpecifier' + ? specifier.imported.type === 'Identifier' + ? specifier.imported.name + : specifier.imported.value + : undefined, + })) + : [], + ) + expect(imports(written)).toEqual(imports(template.split('%%')[0]!)) + expect(written).toContain(`Hello ${routePath}!`) +} + +/** The route id a route file of the file-modification fixture gets. */ +function fileModificationRoute(file: string) { + const name = path.basename(file).replace(/(\.lazy)?\.tsx$/, '') + return { + constructor: file.endsWith('.lazy.tsx') + ? 'createLazyFileRoute' + : 'createFileRoute', + id: `/(test)/${name.replaceAll('.', '/')}`, + } +} + +/** Fixture-specific checks after the run, beyond the routes. */ +async function postprocess( + name: string, + config: Config, + before: Record, +) { + const routeFile = (file: string) => + fs.readFile(join(config.routesDirectory, file), 'utf8') + switch (name) { + case 'file-modification': { + for (const [file, source] of Object.entries(before)) { + const written = await routeFile(file) + expect(routeCallOf(written), file).toEqual(fileModificationRoute(file)) + if (source !== '') { + expectOnlyOwnedEdits(source, written) + } + } + // (the lazy file switched to createLazyFileRoute gives the page) + await withRouteTree(config.generatedRouteTree, async ({ renderAt }) => { + expect(await renderAt('/bar')).toContain('Bar from its lazy file') + }) break } case 'custom-scaffolding': { - const startDir = join(makeFolderDir(folderName), 'routes') - await traverseDirectory(startDir, async (filePath) => { - const relativePath = relative(startDir, filePath) - if (filePath.endsWith('.tsx')) { - await expect( - await fs.readFile(filePath, 'utf-8'), - ).toMatchFileSnapshot( - join('generator', folderName, 'snapshots', relativePath), - ) + for (const [file, routePath] of [ + ['index.tsx', '/'], + ['api/bar.tsx', '/api/bar'], + ['foo.lazy.tsx', '/foo'], + ] as const) { + expectTemplateApplied( + file.endsWith('.lazy.tsx') + ? customTemplates.lazyRouteTemplate + : customTemplates.routeTemplate, + routePath, + await routeFile(file), + ) + } + // (the scaffolds are routes whose components render) + await withRouteTree(config.generatedRouteTree, async ({ renderAt }) => { + for (const url of ['/', '/api/bar', '/foo']) { + expect(await renderAt(url)).toContain(`Hello ${url}!`) } }) + break + } + case 'route-groups': { + // (the `(bar)` group's pathless layout wraps its children's pages) + await withRouteTree(config.generatedRouteTree, async ({ renderAt }) => { + for (const page of ['about', 'xyz']) { + const html = await renderAt(`/asdf/${page}`) + expect(html).toContain('Hello /(foo)/asdf/(bar)/_layout!') + expect(html).toContain(`Hello /(foo)/asdf/(bar)/_layout/${page}!`) + } + }) + break + } + case 'append-and-prepend': { + // (routeTreeFileHeader / routeTreeFileFooter, api/file-based-routing.md) + const lines = (await fs.readFile(config.generatedRouteTree, 'utf8')) + .split('\n') + .filter((line) => line.trim() !== '') + expect(lines.slice(0, 2)).toEqual(['// prepend1', '// prepend2']) + expect(lines.slice(-2)).toEqual(['// append1', '// append2']) + break } } } -function shouldThrow(folderName: string) { - if (folderName === 'duplicate-fullPath') { - return `Conflicting configuration paths were found for the following routes: "/", "/".` - } - if (folderName === 'virtual-physical-empty-path-conflict-root') { - return 'Invalid route path "" was found.' - } - if (folderName === 'virtual-physical-empty-path-conflict-virtual') { - return `Conflicting configuration paths were found for the following routes: "/about", "/about".` - } - return undefined +/** + * Asserts the routes of the router built from the generated route tree at + * `treeFile` against `expected` (generator-fixtures.ts): each route's full + * path, parent and route file; and, for each route with lazy files, that + * each of them loads only on demand: it is not loaded before the router + * loads the route (`loadRouteChunk`, routes loaded one after the other), it + * is loaded after, and the options of its lazy `Route` are the route's. + * Other modules the demand loads (generated support, shared dependencies) + * are free (SPEC J1.4, §5.3, §5.8). + */ +async function expectFixtureRoutes( + treeFile: string, + expected: Record, +) { + await withRouteTree(treeFile, async (tree) => { + const { router, fileOf, loadedFiles } = tree + expect( + Object.fromEntries( + Object.values(router.routesById).map((route) => [ + route.id, + [route.fullPath, route.parentRoute?.id ?? null, fileOf(route.id)], + ]), + ), + 'the routes of the fixture', + ).toEqual( + Object.fromEntries( + Object.entries(expected).map(([id, [fullPath, parent, file]]) => [ + id, + [fullPath, parent, file], + ]), + ), + ) + const treeDir = path.dirname(await fs.realpath(treeFile)) + for (const [id, [, , , ...lazy]] of Object.entries(expected)) { + if (lazy.length === 0) { + continue + } + const route = router.routesById[id]! + expect( + loadedFiles().filter((file) => lazy.includes(file)), + `the lazy files of ${id} loaded before the route is loaded`, + ).toEqual([]) + await router.loadRouteChunk(route) + expect( + lazy.filter((file) => !loadedFiles().includes(file)), + `the lazy files of ${id} not loaded with the route`, + ).toEqual([]) + for (const file of lazy) { + const { Route } = await tree.import(path.join(treeDir, file)) + if (Route) { + const { id: _id, ...options } = Route.options + for (const [key, value] of Object.entries(options)) { + expect( + route.options[key], + `${id}'s ${key} after loading ${file}`, + ).toBe(value) + } + } + } + } + }) } -describe('generator works', async () => { - const folderNames = await readDir() - - it.each(folderNames)( - 'should wire-up the routes for a "%s" tree', - async (folderName) => { - const folderRoot = makeFolderDir(folderName) - - const config = await setupConfig(folderName) - - rewriteConfigByFolderName(folderName, config) - - await preprocess(folderName) - const generator = new Generator({ config, root: folderRoot }) - const error = shouldThrow(folderName) - if (error) { - try { - await generator.run() - } catch (e) { - expect(e).toBeInstanceOf(Error) - expect((e as Error).message.startsWith(error)).toBeTruthy() +describe('generator fixtures', async () => { + it.each(await fixtureNames())( + 'the "%s" fixture gets its routes', + async (name) => { + // A copy: the generator may edit the fixture's route files + const dir = await copyFixture(name) + // (temporary files on the copy's filesystem) + const config = { + ...fixtureConfig(name, dir), + tmpDir: path.join(dir, 'tmp'), + } + const before = await prepareFixture(name, dir) + const generator = new Generator({ config, root: dir }) + const conflicting = conflictingFiles(name, dir) + if (conflicting) { + const error = await captureThrow(() => generator.run()) + for (const file of conflicting) { + expectDiagnostic(error, { + severity: 'error', + root: dir, + file, + }) } - } else { - await generator.run() - - const generatedRouteTree = await getRouteTreeFileText(config) - - const snapshotPath = `routeTree.snapshot.${config.disableTypes ? 'js' : 'ts'}` - - await expect(generatedRouteTree).toMatchFileSnapshot( - join('generator', folderName, snapshotPath), - ) + return } + await generator.run() - await postprocess(folderName) - }, - ) - - it('physical() mount returns absolute physicalDirectories', async () => { - const folderName = 'virtual-physical-no-prefix' - const dir = makeFolderDir(folderName) - const config = await setupConfig(folderName) - - const { physicalDirectories } = await virtualGetRouteNodes(config, dir, { - indexTokenSegmentRegex: /^(?:index)$/, - routeTokenSegmentRegex: /^(?:route)$/, - }) - - expect(physicalDirectories.length).toBeGreaterThan(0) - physicalDirectories.forEach((physicalDir) => { - expect(path.isAbsolute(physicalDir)).toBe(true) - }) - }) - - it.each(folderNames)( - 'should create directory for routeTree if it does not exist', - async () => { - const folderName = 'only-root' - const folderRoot = makeFolderDir(folderName) - let pathCreated = false - - const config = await setupConfig(folderName) - - rewriteConfigByFolderName(folderName, config) - - await preprocess(folderName) - config.generatedRouteTree = join( - folderRoot, - 'generated', - `/routeTree.gen.ts`, - ) - const generator = new Generator({ config, root: folderRoot }) - - const error = shouldThrow(folderName) - if (error) { - try { - await generator.run() - } catch (e) { - expect(e).toBeInstanceOf(Error) - expect((e as Error).message.startsWith(error)).toBeTruthy() - } - } else { - await generator.run() - - const generatedRouteTree = await getRouteTreeFileText(config) - - await expect(generatedRouteTree).toMatchFileSnapshot( - join( - 'generator', - folderName, - `routeTree.generated.snapshot.${config.disableTypes ? 'js' : 'ts'}`, - ), - ) - - pathCreated = await fs.access(dirname(config.generatedRouteTree)).then( - () => true, - () => false, - ) - - await expect(pathCreated).toBe(true) - } - - await postprocess(folderName) - - if (pathCreated) { - await fs.rm(dirname(config.generatedRouteTree), { recursive: true }) - } + expect(fixtureRoutes[name], 'the routes of the fixture').toBeDefined() + await expectFixtureRoutes(config.generatedRouteTree, fixtureRoutes[name]!) + await postprocess(name, config, before) }, ) }) + +// Windows checkouts with `autocrlf` give route files CRLF line endings: the +// routes are the same as with LF sources, and a second run changes nothing. +// Source: review of #8504. +describe('route files with CRLF line endings', () => { + it('gives the routes of LF sources, and a second run changes nothing', async () => { + const lf = await generateCrlf('\n') + const crlf = await generateCrlf('\r\n') + expect(crlf.observed).toEqual(lf.observed) + expect(crlf.second.observed).toEqual(crlf.first.observed) + expect(crlf.second.routes).toEqual(crlf.first.routes) + // The route files are left as written. + expect(crlf.first.routes).toEqual( + Object.values(crlfRoutes).map((code) => code.replaceAll('\n', '\r\n')), + ) + }) +}) diff --git a/packages/router-generator/tests/generator/add-extensions-custom/routeTree.snapshot.ts b/packages/router-generator/tests/generator/add-extensions-custom/routeTree.snapshot.ts deleted file mode 100644 index 2e6aa9d355..0000000000 --- a/packages/router-generator/tests/generator/add-extensions-custom/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root.js' -import { Route as IndexRouteImport } from './routes/index.js' -import { Route as PostsRouteImport } from './routes/posts.js' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const PostsRoute = PostsRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/posts' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/posts' - id: '__root__' | '/' | '/posts' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - PostsRoute: typeof PostsRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - PostsRoute: PostsRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/add-extensions-custom/routes/__root.tsx b/packages/router-generator/tests/generator/add-extensions-custom/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/add-extensions-custom/routes/__root.tsx +++ b/packages/router-generator/tests/generator/add-extensions-custom/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts b/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts deleted file mode 100644 index 4592b6f51d..0000000000 --- a/packages/router-generator/tests/generator/append-and-prepend/routeTree.snapshot.ts +++ /dev/null @@ -1,61 +0,0 @@ -// prepend1 - -// prepend2 - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' - fileRoutesByTo: FileRoutesByTo - to: '/' - id: '__root__' | '/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() - -// append1 - -// append2 diff --git a/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts b/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts deleted file mode 100644 index 8f0ed564f4..0000000000 --- a/packages/router-generator/tests/generator/custom-scaffolding/routeTree.snapshot.ts +++ /dev/null @@ -1,98 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as ApiBarRouteImport } from './routes/api/bar' - -const FooLazyRouteImport = createFileRoute('/foo')() - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const FooLazyRoute = FooLazyRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => rootRouteImport, -} as any).lazy(() => import('./routes/foo.lazy').then((d) => d.Route)) -const ApiBarRoute = ApiBarRouteImport.update({ - id: '/api/bar', - path: '/api/bar', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/foo': typeof FooLazyRoute - '/api/bar': typeof ApiBarRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/foo': typeof FooLazyRoute - '/api/bar': typeof ApiBarRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/foo': typeof FooLazyRoute - '/api/bar': typeof ApiBarRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/foo' | '/api/bar' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/foo' | '/api/bar' - id: '__root__' | '/' | '/foo' | '/api/bar' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - FooLazyRoute: typeof FooLazyRoute - ApiBarRoute: typeof ApiBarRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/foo': { - id: '/foo' - path: '/foo' - fullPath: '/foo' - preLoaderRoute: typeof FooLazyRouteImport - parentRoute: typeof rootRouteImport - } - '/api/bar': { - id: '/api/bar' - path: '/api/bar' - fullPath: '/api/bar' - preLoaderRoute: typeof ApiBarRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - FooLazyRoute: FooLazyRoute, - ApiBarRoute: ApiBarRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/__root.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshots/__root.tsx deleted file mode 100644 index 3797d7bf8c..0000000000 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/__root.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import * as React from 'react' -import { Outlet, createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: RootComponent, -}) - -function RootComponent() { - return ( - -
Hello "__root"!
- -
- ) -} diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/api/bar.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshots/api/bar.tsx deleted file mode 100644 index 5629cffd8c..0000000000 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/api/bar.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/api/bar')({ - component: RouteComponent, -}) - -function RouteComponent() { - return 'Hello /api/bar!' -} diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/foo.lazy.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshots/foo.lazy.tsx deleted file mode 100644 index 1d5655f893..0000000000 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/foo.lazy.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React, { useState } from 'react' -import { createLazyFileRoute } from '@tanstack/react-router' - -export const Route = createLazyFileRoute('/foo')({ - component: RouteComponent, -}) - -function RouteComponent() { - return 'Hello /foo!' -} diff --git a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/index.tsx b/packages/router-generator/tests/generator/custom-scaffolding/snapshots/index.tsx deleted file mode 100644 index 8b22ea6bb5..0000000000 --- a/packages/router-generator/tests/generator/custom-scaffolding/snapshots/index.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: RouteComponent, -}) - -function RouteComponent() { - return 'Hello /!' -} diff --git a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts b/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts deleted file mode 100644 index fc136dc277..0000000000 --- a/packages/router-generator/tests/generator/custom-tokens/routeTree.snapshot.ts +++ /dev/null @@ -1,226 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as R1nd3xRouteImport } from './routes/_1nd3x' -import { Route as BlogR0ut3RouteImport } from './routes/blog/_r0ut3_' -import { Route as PostsR0ut3RouteImport } from './routes/posts/_r0ut3_' -import { Route as Blog1nd3xRouteImport } from './routes/blog/_1nd3x' -import { Route as BlogSlugRouteImport } from './routes/blog/$slug' -import { Route as Posts1nd3xRouteImport } from './routes/posts/_1nd3x' -import { Route as PostsPostId1nd3xRouteImport } from './routes/posts/$postId/_1nd3x' -import { Route as PostsPostIdDeepRouteImport } from './routes/posts/$postId/deep' - -const R1nd3xRoute = R1nd3xRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BlogR0ut3Route = BlogR0ut3RouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) -const PostsR0ut3Route = PostsR0ut3RouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any) -const Blog1nd3xRoute = Blog1nd3xRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => BlogR0ut3Route, -} as any) -const BlogSlugRoute = BlogSlugRouteImport.update({ - id: '/$slug', - path: '/$slug', - getParentRoute: () => BlogR0ut3Route, -} as any) -const Posts1nd3xRoute = Posts1nd3xRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => PostsR0ut3Route, -} as any) -const PostsPostId1nd3xRoute = PostsPostId1nd3xRouteImport.update({ - id: '/$postId/', - path: '/$postId/', - getParentRoute: () => PostsR0ut3Route, -} as any) -const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ - id: '/$postId/deep', - path: '/$postId/deep', - getParentRoute: () => PostsR0ut3Route, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof R1nd3xRoute - '/blog': typeof BlogR0ut3RouteWithChildren - '/posts': typeof PostsR0ut3RouteWithChildren - '/blog/$slug': typeof BlogSlugRoute - '/blog/': typeof Blog1nd3xRoute - '/posts/': typeof Posts1nd3xRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId/': typeof PostsPostId1nd3xRoute -} -export interface FileRoutesByTo { - '/': typeof R1nd3xRoute - '/blog/$slug': typeof BlogSlugRoute - '/blog': typeof Blog1nd3xRoute - '/posts': typeof Posts1nd3xRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId': typeof PostsPostId1nd3xRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof R1nd3xRoute - '/blog': typeof BlogR0ut3RouteWithChildren - '/posts': typeof PostsR0ut3RouteWithChildren - '/blog/$slug': typeof BlogSlugRoute - '/blog/': typeof Blog1nd3xRoute - '/posts/': typeof Posts1nd3xRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId/': typeof PostsPostId1nd3xRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/blog' - | '/posts' - | '/blog/$slug' - | '/blog/' - | '/posts/' - | '/posts/$postId/deep' - | '/posts/$postId/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/blog/$slug' - | '/blog' - | '/posts' - | '/posts/$postId/deep' - | '/posts/$postId' - id: - | '__root__' - | '/' - | '/blog' - | '/posts' - | '/blog/$slug' - | '/blog/' - | '/posts/' - | '/posts/$postId/deep' - | '/posts/$postId/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - R1nd3xRoute: typeof R1nd3xRoute - BlogR0ut3Route: typeof BlogR0ut3RouteWithChildren - PostsR0ut3Route: typeof PostsR0ut3RouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof R1nd3xRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogR0ut3RouteImport - parentRoute: typeof rootRouteImport - } - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsR0ut3RouteImport - parentRoute: typeof rootRouteImport - } - '/blog/': { - id: '/blog/' - path: '/' - fullPath: '/blog/' - preLoaderRoute: typeof Blog1nd3xRouteImport - parentRoute: typeof BlogR0ut3Route - } - '/blog/$slug': { - id: '/blog/$slug' - path: '/$slug' - fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugRouteImport - parentRoute: typeof BlogR0ut3Route - } - '/posts/': { - id: '/posts/' - path: '/' - fullPath: '/posts/' - preLoaderRoute: typeof Posts1nd3xRouteImport - parentRoute: typeof PostsR0ut3Route - } - '/posts/$postId/': { - id: '/posts/$postId/' - path: '/$postId' - fullPath: '/posts/$postId/' - preLoaderRoute: typeof PostsPostId1nd3xRouteImport - parentRoute: typeof PostsR0ut3Route - } - '/posts/$postId/deep': { - id: '/posts/$postId/deep' - path: '/$postId/deep' - fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepRouteImport - parentRoute: typeof PostsR0ut3Route - } - } -} - -interface BlogR0ut3RouteChildren { - BlogSlugRoute: typeof BlogSlugRoute - Blog1nd3xRoute: typeof Blog1nd3xRoute -} - -const BlogR0ut3RouteChildren: BlogR0ut3RouteChildren = { - BlogSlugRoute: BlogSlugRoute, - Blog1nd3xRoute: Blog1nd3xRoute, -} - -const BlogR0ut3RouteWithChildren = BlogR0ut3Route._addFileChildren( - BlogR0ut3RouteChildren, -) - -interface PostsR0ut3RouteChildren { - Posts1nd3xRoute: typeof Posts1nd3xRoute - PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute - PostsPostId1nd3xRoute: typeof PostsPostId1nd3xRoute -} - -const PostsR0ut3RouteChildren: PostsR0ut3RouteChildren = { - Posts1nd3xRoute: Posts1nd3xRoute, - PostsPostIdDeepRoute: PostsPostIdDeepRoute, - PostsPostId1nd3xRoute: PostsPostId1nd3xRoute, -} - -const PostsR0ut3RouteWithChildren = PostsR0ut3Route._addFileChildren( - PostsR0ut3RouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - R1nd3xRoute: R1nd3xRoute, - BlogR0ut3Route: BlogR0ut3RouteWithChildren, - PostsR0ut3Route: PostsR0ut3RouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts b/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts deleted file mode 100644 index 815dba6590..0000000000 --- a/packages/router-generator/tests/generator/dot-escaped/routeTree.snapshot.ts +++ /dev/null @@ -1,137 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as NestedDotjsRouteImport } from './routes/nested[.]js' -import { Route as ScriptDotjsRouteImport } from './routes/script[.]js' -import { Route as NestedDotjsDoubleDotextDotjsRouteImport } from './routes/nested[.]js.double[.]ext[.]js' -import { Route as NestedDotjsScriptDotjsRouteImport } from './routes/nested[.]js.script[.]js' - -const NestedDotjsRoute = NestedDotjsRouteImport.update({ - id: '/nested.js', - path: '/nested.js', - getParentRoute: () => rootRouteImport, -} as any) -const ScriptDotjsRoute = ScriptDotjsRouteImport.update({ - id: '/script.js', - path: '/script.js', - getParentRoute: () => rootRouteImport, -} as any) -const NestedDotjsDoubleDotextDotjsRoute = - NestedDotjsDoubleDotextDotjsRouteImport.update({ - id: '/double.ext.js', - path: '/double.ext.js', - getParentRoute: () => NestedDotjsRoute, - } as any) -const NestedDotjsScriptDotjsRoute = NestedDotjsScriptDotjsRouteImport.update({ - id: '/script.js', - path: '/script.js', - getParentRoute: () => NestedDotjsRoute, -} as any) - -export interface FileRoutesByFullPath { - '/nested.js': typeof NestedDotjsRouteWithChildren - '/script.js': typeof ScriptDotjsRoute - '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute - '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute -} -export interface FileRoutesByTo { - '/nested.js': typeof NestedDotjsRouteWithChildren - '/script.js': typeof ScriptDotjsRoute - '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute - '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/nested.js': typeof NestedDotjsRouteWithChildren - '/script.js': typeof ScriptDotjsRoute - '/nested.js/double.ext.js': typeof NestedDotjsDoubleDotextDotjsRoute - '/nested.js/script.js': typeof NestedDotjsScriptDotjsRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/nested.js' - | '/script.js' - | '/nested.js/double.ext.js' - | '/nested.js/script.js' - fileRoutesByTo: FileRoutesByTo - to: - | '/nested.js' - | '/script.js' - | '/nested.js/double.ext.js' - | '/nested.js/script.js' - id: - | '__root__' - | '/nested.js' - | '/script.js' - | '/nested.js/double.ext.js' - | '/nested.js/script.js' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - NestedDotjsRoute: typeof NestedDotjsRouteWithChildren - ScriptDotjsRoute: typeof ScriptDotjsRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/nested.js': { - id: '/nested.js' - path: '/nested.js' - fullPath: '/nested.js' - preLoaderRoute: typeof NestedDotjsRouteImport - parentRoute: typeof rootRouteImport - } - '/script.js': { - id: '/script.js' - path: '/script.js' - fullPath: '/script.js' - preLoaderRoute: typeof ScriptDotjsRouteImport - parentRoute: typeof rootRouteImport - } - '/nested.js/double.ext.js': { - id: '/nested.js/double.ext.js' - path: '/double.ext.js' - fullPath: '/nested.js/double.ext.js' - preLoaderRoute: typeof NestedDotjsDoubleDotextDotjsRouteImport - parentRoute: typeof NestedDotjsRoute - } - '/nested.js/script.js': { - id: '/nested.js/script.js' - path: '/script.js' - fullPath: '/nested.js/script.js' - preLoaderRoute: typeof NestedDotjsScriptDotjsRouteImport - parentRoute: typeof NestedDotjsRoute - } - } -} - -interface NestedDotjsRouteChildren { - NestedDotjsDoubleDotextDotjsRoute: typeof NestedDotjsDoubleDotextDotjsRoute - NestedDotjsScriptDotjsRoute: typeof NestedDotjsScriptDotjsRoute -} - -const NestedDotjsRouteChildren: NestedDotjsRouteChildren = { - NestedDotjsDoubleDotextDotjsRoute: NestedDotjsDoubleDotextDotjsRoute, - NestedDotjsScriptDotjsRoute: NestedDotjsScriptDotjsRoute, -} - -const NestedDotjsRouteWithChildren = NestedDotjsRoute._addFileChildren( - NestedDotjsRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - NestedDotjsRoute: NestedDotjsRouteWithChildren, - ScriptDotjsRoute: ScriptDotjsRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx b/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx index ab504e42e9..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx +++ b/packages/router-generator/tests/generator/dot-escaped/routes/__root.tsx @@ -1 +1,3 @@ -/** */ +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/escaped-custom-tokens/routeTree.snapshot.ts b/packages/router-generator/tests/generator/escaped-custom-tokens/routeTree.snapshot.ts deleted file mode 100644 index 69b6a09946..0000000000 --- a/packages/router-generator/tests/generator/escaped-custom-tokens/routeTree.snapshot.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as Char91_1nd3xChar93RouteImport } from './routes/[_1nd3x]' -import { Route as R1nd3xRouteImport } from './routes/_1nd3x' -import { Route as BlogR0ut3RouteImport } from './routes/blog._r0ut3_' -import { Route as NestedChar91_1nd3xChar93RouteImport } from './routes/nested.[_1nd3x]' -import { Route as PostsChar91_r0ut3_Char93RouteImport } from './routes/posts.[_r0ut3_]' - -const Char91_1nd3xChar93Route = Char91_1nd3xChar93RouteImport.update({ - id: '/_1nd3x', - path: '/_1nd3x', - getParentRoute: () => rootRouteImport, -} as any) -const R1nd3xRoute = R1nd3xRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BlogR0ut3Route = BlogR0ut3RouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) -const NestedChar91_1nd3xChar93Route = - NestedChar91_1nd3xChar93RouteImport.update({ - id: '/nested/_1nd3x', - path: '/nested/_1nd3x', - getParentRoute: () => rootRouteImport, - } as any) -const PostsChar91_r0ut3_Char93Route = - PostsChar91_r0ut3_Char93RouteImport.update({ - id: '/posts/_r0ut3_', - path: '/posts/_r0ut3_', - getParentRoute: () => rootRouteImport, - } as any) - -export interface FileRoutesByFullPath { - '/': typeof R1nd3xRoute - '/blog': typeof BlogR0ut3Route - '/_1nd3x': typeof Char91_1nd3xChar93Route - '/nested/_1nd3x': typeof NestedChar91_1nd3xChar93Route - '/posts/_r0ut3_': typeof PostsChar91_r0ut3_Char93Route -} -export interface FileRoutesByTo { - '/': typeof R1nd3xRoute - '/blog': typeof BlogR0ut3Route - '/_1nd3x': typeof Char91_1nd3xChar93Route - '/nested/_1nd3x': typeof NestedChar91_1nd3xChar93Route - '/posts/_r0ut3_': typeof PostsChar91_r0ut3_Char93Route -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof R1nd3xRoute - '/blog': typeof BlogR0ut3Route - '/_1nd3x': typeof Char91_1nd3xChar93Route - '/nested/_1nd3x': typeof NestedChar91_1nd3xChar93Route - '/posts/_r0ut3_': typeof PostsChar91_r0ut3_Char93Route -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/blog' | '/_1nd3x' | '/nested/_1nd3x' | '/posts/_r0ut3_' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/blog' | '/_1nd3x' | '/nested/_1nd3x' | '/posts/_r0ut3_' - id: - '__root__' | '/' | '/blog' | '/_1nd3x' | '/nested/_1nd3x' | '/posts/_r0ut3_' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - R1nd3xRoute: typeof R1nd3xRoute - BlogR0ut3Route: typeof BlogR0ut3Route - Char91_1nd3xChar93Route: typeof Char91_1nd3xChar93Route - NestedChar91_1nd3xChar93Route: typeof NestedChar91_1nd3xChar93Route - PostsChar91_r0ut3_Char93Route: typeof PostsChar91_r0ut3_Char93Route -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_1nd3x': { - id: '/_1nd3x' - path: '/_1nd3x' - fullPath: '/_1nd3x' - preLoaderRoute: typeof Char91_1nd3xChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof R1nd3xRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogR0ut3RouteImport - parentRoute: typeof rootRouteImport - } - '/nested/_1nd3x': { - id: '/nested/_1nd3x' - path: '/nested/_1nd3x' - fullPath: '/nested/_1nd3x' - preLoaderRoute: typeof NestedChar91_1nd3xChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/posts/_r0ut3_': { - id: '/posts/_r0ut3_' - path: '/posts/_r0ut3_' - fullPath: '/posts/_r0ut3_' - preLoaderRoute: typeof PostsChar91_r0ut3_Char93RouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - R1nd3xRoute: R1nd3xRoute, - BlogR0ut3Route: BlogR0ut3Route, - Char91_1nd3xChar93Route: Char91_1nd3xChar93Route, - NestedChar91_1nd3xChar93Route: NestedChar91_1nd3xChar93Route, - PostsChar91_r0ut3_Char93Route: PostsChar91_r0ut3_Char93Route, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/escaped-custom-tokens/routes/__root.tsx b/packages/router-generator/tests/generator/escaped-custom-tokens/routes/__root.tsx index c11ed1e011..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/escaped-custom-tokens/routes/__root.tsx +++ b/packages/router-generator/tests/generator/escaped-custom-tokens/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck +import { createRootRoute } from '@tanstack/react-router' + export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/escaped-special-strings/routeTree.snapshot.ts b/packages/router-generator/tests/generator/escaped-special-strings/routeTree.snapshot.ts deleted file mode 100644 index 2600d0296d..0000000000 --- a/packages/router-generator/tests/generator/escaped-special-strings/routeTree.snapshot.ts +++ /dev/null @@ -1,273 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as Char91indexChar93RouteImport } from './routes/[index]' -import { Route as IndexRouteImport } from './routes/index' -import { Route as AuthRouteRouteImport } from './routes/[_]auth.route' -import { Route as LayoutRouteImport } from './routes/[_]layout' -import { Route as Prefix_middle_suffixRouteImport } from './routes/[_]prefix[_]middle[_]suffix' -import { Route as Api_v2_usersRouteImport } from './routes/api[_]v2[_]users' -import { Route as BlogRouteImport } from './routes/blog[_]' -import { Route as Foo_barRouteImport } from './routes/foo[_]bar' -import { Route as Char91lazyChar93RouteImport } from './routes/[lazy]' -import { Route as Char91routeChar93RouteImport } from './routes/[route]' -import { Route as NestedChar91indexChar93RouteImport } from './routes/nested.[index]' - -const Char91indexChar93Route = Char91indexChar93RouteImport.update({ - id: '/index', - path: '/index', - getParentRoute: () => rootRouteImport, -} as any) -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const AuthRouteRoute = AuthRouteRouteImport.update({ - id: '/_auth', - path: '/_auth', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutRoute = LayoutRouteImport.update({ - id: '/_layout', - path: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const Prefix_middle_suffixRoute = Prefix_middle_suffixRouteImport.update({ - id: '/_prefix_middle_suffix', - path: '/_prefix_middle_suffix', - getParentRoute: () => rootRouteImport, -} as any) -const Api_v2_usersRoute = Api_v2_usersRouteImport.update({ - id: '/api_v2_users', - path: '/api_v2_users', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRoute = BlogRouteImport.update({ - id: '/blog_', - path: '/blog_', - getParentRoute: () => rootRouteImport, -} as any) -const Foo_barRoute = Foo_barRouteImport.update({ - id: '/foo_bar', - path: '/foo_bar', - getParentRoute: () => rootRouteImport, -} as any) -const Char91lazyChar93Route = Char91lazyChar93RouteImport.update({ - id: '/lazy', - path: '/lazy', - getParentRoute: () => rootRouteImport, -} as any) -const Char91routeChar93Route = Char91routeChar93RouteImport.update({ - id: '/route', - path: '/route', - getParentRoute: () => rootRouteImport, -} as any) -const NestedChar91indexChar93Route = NestedChar91indexChar93RouteImport.update({ - id: '/nested/index', - path: '/nested/index', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/_auth': typeof AuthRouteRoute - '/_layout': typeof LayoutRoute - '/_prefix_middle_suffix': typeof Prefix_middle_suffixRoute - '/api_v2_users': typeof Api_v2_usersRoute - '/blog_': typeof BlogRoute - '/foo_bar': typeof Foo_barRoute - '/index': typeof Char91indexChar93Route - '/lazy': typeof Char91lazyChar93Route - '/route': typeof Char91routeChar93Route - '/nested/index': typeof NestedChar91indexChar93Route -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/_auth': typeof AuthRouteRoute - '/_layout': typeof LayoutRoute - '/_prefix_middle_suffix': typeof Prefix_middle_suffixRoute - '/api_v2_users': typeof Api_v2_usersRoute - '/blog_': typeof BlogRoute - '/foo_bar': typeof Foo_barRoute - '/index': typeof Char91indexChar93Route - '/lazy': typeof Char91lazyChar93Route - '/route': typeof Char91routeChar93Route - '/nested/index': typeof NestedChar91indexChar93Route -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/_auth': typeof AuthRouteRoute - '/_layout': typeof LayoutRoute - '/_prefix_middle_suffix': typeof Prefix_middle_suffixRoute - '/api_v2_users': typeof Api_v2_usersRoute - '/blog_': typeof BlogRoute - '/foo_bar': typeof Foo_barRoute - '/index': typeof Char91indexChar93Route - '/lazy': typeof Char91lazyChar93Route - '/route': typeof Char91routeChar93Route - '/nested/index': typeof NestedChar91indexChar93Route -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/_auth' - | '/_layout' - | '/_prefix_middle_suffix' - | '/api_v2_users' - | '/blog_' - | '/foo_bar' - | '/index' - | '/lazy' - | '/route' - | '/nested/index' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/_auth' - | '/_layout' - | '/_prefix_middle_suffix' - | '/api_v2_users' - | '/blog_' - | '/foo_bar' - | '/index' - | '/lazy' - | '/route' - | '/nested/index' - id: - | '__root__' - | '/' - | '/_auth' - | '/_layout' - | '/_prefix_middle_suffix' - | '/api_v2_users' - | '/blog_' - | '/foo_bar' - | '/index' - | '/lazy' - | '/route' - | '/nested/index' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - AuthRouteRoute: typeof AuthRouteRoute - LayoutRoute: typeof LayoutRoute - Prefix_middle_suffixRoute: typeof Prefix_middle_suffixRoute - Api_v2_usersRoute: typeof Api_v2_usersRoute - BlogRoute: typeof BlogRoute - Foo_barRoute: typeof Foo_barRoute - Char91indexChar93Route: typeof Char91indexChar93Route - Char91lazyChar93Route: typeof Char91lazyChar93Route - Char91routeChar93Route: typeof Char91routeChar93Route - NestedChar91indexChar93Route: typeof NestedChar91indexChar93Route -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/index': { - id: '/index' - path: '/index' - fullPath: '/index' - preLoaderRoute: typeof Char91indexChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_auth': { - id: '/_auth' - path: '/_auth' - fullPath: '/_auth' - preLoaderRoute: typeof AuthRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '/_layout' - fullPath: '/_layout' - preLoaderRoute: typeof LayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_prefix_middle_suffix': { - id: '/_prefix_middle_suffix' - path: '/_prefix_middle_suffix' - fullPath: '/_prefix_middle_suffix' - preLoaderRoute: typeof Prefix_middle_suffixRouteImport - parentRoute: typeof rootRouteImport - } - '/api_v2_users': { - id: '/api_v2_users' - path: '/api_v2_users' - fullPath: '/api_v2_users' - preLoaderRoute: typeof Api_v2_usersRouteImport - parentRoute: typeof rootRouteImport - } - '/blog_': { - id: '/blog_' - path: '/blog_' - fullPath: '/blog_' - preLoaderRoute: typeof BlogRouteImport - parentRoute: typeof rootRouteImport - } - '/foo_bar': { - id: '/foo_bar' - path: '/foo_bar' - fullPath: '/foo_bar' - preLoaderRoute: typeof Foo_barRouteImport - parentRoute: typeof rootRouteImport - } - '/lazy': { - id: '/lazy' - path: '/lazy' - fullPath: '/lazy' - preLoaderRoute: typeof Char91lazyChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/route': { - id: '/route' - path: '/route' - fullPath: '/route' - preLoaderRoute: typeof Char91routeChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/nested/index': { - id: '/nested/index' - path: '/nested/index' - fullPath: '/nested/index' - preLoaderRoute: typeof NestedChar91indexChar93RouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - AuthRouteRoute: AuthRouteRoute, - LayoutRoute: LayoutRoute, - Prefix_middle_suffixRoute: Prefix_middle_suffixRoute, - Api_v2_usersRoute: Api_v2_usersRoute, - BlogRoute: BlogRoute, - Foo_barRoute: Foo_barRoute, - Char91indexChar93Route: Char91indexChar93Route, - Char91lazyChar93Route: Char91lazyChar93Route, - Char91routeChar93Route: Char91routeChar93Route, - NestedChar91indexChar93Route: NestedChar91indexChar93Route, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/escaped-special-strings/routes/__root.tsx b/packages/router-generator/tests/generator/escaped-special-strings/routes/__root.tsx index c11ed1e011..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/escaped-special-strings/routes/__root.tsx +++ b/packages/router-generator/tests/generator/escaped-special-strings/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck +import { createRootRoute } from '@tanstack/react-router' + export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/export-variations/routeTree.snapshot.ts b/packages/router-generator/tests/generator/export-variations/routeTree.snapshot.ts deleted file mode 100644 index bb251cc516..0000000000 --- a/packages/router-generator/tests/generator/export-variations/routeTree.snapshot.ts +++ /dev/null @@ -1,78 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as ExportSeparateFromDeclarationRouteImport } from './routes/export-separate-from-declaration' -import { Route as ExportWithAsRouteImport } from './routes/export-with-as' - -const ExportSeparateFromDeclarationRoute = - ExportSeparateFromDeclarationRouteImport.update({ - id: '/export-separate-from-declaration', - path: '/export-separate-from-declaration', - getParentRoute: () => rootRouteImport, - } as any) -const ExportWithAsRoute = ExportWithAsRouteImport.update({ - id: '/export-with-as', - path: '/export-with-as', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/export-separate-from-declaration': typeof ExportSeparateFromDeclarationRoute - '/export-with-as': typeof ExportWithAsRoute -} -export interface FileRoutesByTo { - '/export-separate-from-declaration': typeof ExportSeparateFromDeclarationRoute - '/export-with-as': typeof ExportWithAsRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/export-separate-from-declaration': typeof ExportSeparateFromDeclarationRoute - '/export-with-as': typeof ExportWithAsRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/export-separate-from-declaration' | '/export-with-as' - fileRoutesByTo: FileRoutesByTo - to: '/export-separate-from-declaration' | '/export-with-as' - id: '__root__' | '/export-separate-from-declaration' | '/export-with-as' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - ExportSeparateFromDeclarationRoute: typeof ExportSeparateFromDeclarationRoute - ExportWithAsRoute: typeof ExportWithAsRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/export-separate-from-declaration': { - id: '/export-separate-from-declaration' - path: '/export-separate-from-declaration' - fullPath: '/export-separate-from-declaration' - preLoaderRoute: typeof ExportSeparateFromDeclarationRouteImport - parentRoute: typeof rootRouteImport - } - '/export-with-as': { - id: '/export-with-as' - path: '/export-with-as' - fullPath: '/export-with-as' - preLoaderRoute: typeof ExportWithAsRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - ExportSeparateFromDeclarationRoute: ExportSeparateFromDeclarationRoute, - ExportWithAsRoute: ExportWithAsRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts b/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts deleted file mode 100644 index 7ec8640782..0000000000 --- a/packages/router-generator/tests/generator/file-modification/routeTree.snapshot.ts +++ /dev/null @@ -1,228 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' -import { Route as testDoubleQuotesRouteImport } from './routes/(test)/double-quotes' -import { Route as testDuplicateImportRouteImport } from './routes/(test)/duplicate-import' -import { Route as testFooRouteImport } from './routes/(test)/foo' -import { Route as testInitiallyEmptyRouteImport } from './routes/(test)/initiallyEmpty' -import { Route as testInitiallyLazyRouteImport } from './routes/(test)/initiallyLazy' -import { Route as testTemplateLiteralRouteImport } from './routes/(test)/template-literal' -import { Route as testFooBarRouteImport } from './routes/(test)/foo.bar' - -const testBarLazyRouteImport = createFileRoute('/(test)/bar')() - -const testBarLazyRoute = testBarLazyRouteImport - .update({ - id: '/(test)/bar', - path: '/bar', - getParentRoute: () => rootRouteImport, - } as any) - .lazy(() => import('./routes/(test)/bar.lazy').then((d) => d.Route)) -const testDoubleQuotesRoute = testDoubleQuotesRouteImport.update({ - id: '/(test)/double-quotes', - path: '/double-quotes', - getParentRoute: () => rootRouteImport, -} as any) -const testDuplicateImportRoute = testDuplicateImportRouteImport.update({ - id: '/(test)/duplicate-import', - path: '/duplicate-import', - getParentRoute: () => rootRouteImport, -} as any) -const testFooRoute = testFooRouteImport.update({ - id: '/(test)/foo', - path: '/foo', - getParentRoute: () => rootRouteImport, -} as any) -const testInitiallyEmptyRoute = testInitiallyEmptyRouteImport - .update({ - id: '/(test)/initiallyEmpty', - path: '/initiallyEmpty', - getParentRoute: () => rootRouteImport, - } as any) - .lazy(() => - import('./routes/(test)/initiallyEmpty.lazy').then((d) => d.Route), - ) -const testInitiallyLazyRoute = testInitiallyLazyRouteImport.update({ - id: '/(test)/initiallyLazy', - path: '/initiallyLazy', - getParentRoute: () => rootRouteImport, -} as any) -const testTemplateLiteralRoute = testTemplateLiteralRouteImport.update({ - id: '/(test)/template-literal', - path: '/template-literal', - getParentRoute: () => rootRouteImport, -} as any) -const testFooBarRoute = testFooBarRouteImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => testFooRoute, -} as any) - -export interface FileRoutesByFullPath { - '/double-quotes': typeof testDoubleQuotesRoute - '/duplicate-import': typeof testDuplicateImportRoute - '/foo': typeof testFooRouteWithChildren - '/initiallyEmpty': typeof testInitiallyEmptyRoute - '/initiallyLazy': typeof testInitiallyLazyRoute - '/template-literal': typeof testTemplateLiteralRoute - '/bar': typeof testBarLazyRoute - '/foo/bar': typeof testFooBarRoute -} -export interface FileRoutesByTo { - '/double-quotes': typeof testDoubleQuotesRoute - '/duplicate-import': typeof testDuplicateImportRoute - '/foo': typeof testFooRouteWithChildren - '/initiallyEmpty': typeof testInitiallyEmptyRoute - '/initiallyLazy': typeof testInitiallyLazyRoute - '/template-literal': typeof testTemplateLiteralRoute - '/bar': typeof testBarLazyRoute - '/foo/bar': typeof testFooBarRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/(test)/double-quotes': typeof testDoubleQuotesRoute - '/(test)/duplicate-import': typeof testDuplicateImportRoute - '/(test)/foo': typeof testFooRouteWithChildren - '/(test)/initiallyEmpty': typeof testInitiallyEmptyRoute - '/(test)/initiallyLazy': typeof testInitiallyLazyRoute - '/(test)/template-literal': typeof testTemplateLiteralRoute - '/(test)/bar': typeof testBarLazyRoute - '/(test)/foo/bar': typeof testFooBarRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/double-quotes' - | '/duplicate-import' - | '/foo' - | '/initiallyEmpty' - | '/initiallyLazy' - | '/template-literal' - | '/bar' - | '/foo/bar' - fileRoutesByTo: FileRoutesByTo - to: - | '/double-quotes' - | '/duplicate-import' - | '/foo' - | '/initiallyEmpty' - | '/initiallyLazy' - | '/template-literal' - | '/bar' - | '/foo/bar' - id: - | '__root__' - | '/(test)/double-quotes' - | '/(test)/duplicate-import' - | '/(test)/foo' - | '/(test)/initiallyEmpty' - | '/(test)/initiallyLazy' - | '/(test)/template-literal' - | '/(test)/bar' - | '/(test)/foo/bar' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - testDoubleQuotesRoute: typeof testDoubleQuotesRoute - testDuplicateImportRoute: typeof testDuplicateImportRoute - testFooRoute: typeof testFooRouteWithChildren - testInitiallyEmptyRoute: typeof testInitiallyEmptyRoute - testInitiallyLazyRoute: typeof testInitiallyLazyRoute - testTemplateLiteralRoute: typeof testTemplateLiteralRoute - testBarLazyRoute: typeof testBarLazyRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/(test)/bar': { - id: '/(test)/bar' - path: '/bar' - fullPath: '/bar' - preLoaderRoute: typeof testBarLazyRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/double-quotes': { - id: '/(test)/double-quotes' - path: '/double-quotes' - fullPath: '/double-quotes' - preLoaderRoute: typeof testDoubleQuotesRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/duplicate-import': { - id: '/(test)/duplicate-import' - path: '/duplicate-import' - fullPath: '/duplicate-import' - preLoaderRoute: typeof testDuplicateImportRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/foo': { - id: '/(test)/foo' - path: '/foo' - fullPath: '/foo' - preLoaderRoute: typeof testFooRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/initiallyEmpty': { - id: '/(test)/initiallyEmpty' - path: '/initiallyEmpty' - fullPath: '/initiallyEmpty' - preLoaderRoute: typeof testInitiallyEmptyRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/initiallyLazy': { - id: '/(test)/initiallyLazy' - path: '/initiallyLazy' - fullPath: '/initiallyLazy' - preLoaderRoute: typeof testInitiallyLazyRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/template-literal': { - id: '/(test)/template-literal' - path: '/template-literal' - fullPath: '/template-literal' - preLoaderRoute: typeof testTemplateLiteralRouteImport - parentRoute: typeof rootRouteImport - } - '/(test)/foo/bar': { - id: '/(test)/foo/bar' - path: '/bar' - fullPath: '/foo/bar' - preLoaderRoute: typeof testFooBarRouteImport - parentRoute: typeof testFooRoute - } - } -} - -interface testFooRouteChildren { - testFooBarRoute: typeof testFooBarRoute -} - -const testFooRouteChildren: testFooRouteChildren = { - testFooBarRoute: testFooBarRoute, -} - -const testFooRouteWithChildren = - testFooRoute._addFileChildren(testFooRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - testDoubleQuotesRoute: testDoubleQuotesRoute, - testDuplicateImportRoute: testDuplicateImportRoute, - testFooRoute: testFooRouteWithChildren, - testInitiallyEmptyRoute: testInitiallyEmptyRoute, - testInitiallyLazyRoute: testInitiallyLazyRoute, - testTemplateLiteralRoute: testTemplateLiteralRoute, - testBarLazyRoute: testBarLazyRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/bar.lazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/bar.lazy.tsx deleted file mode 100644 index 24db5929dd..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/bar.lazy.tsx +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-nocheck - -import * as React from 'react' -import { - ErrorComponent, - ErrorComponentProps, - Link, - createLazyFileRoute, -} from '@tanstack/react-router' - -export const Route = createLazyFileRoute('/(test)/bar')({ - loader: async ({ params: { postId } }) => ({ - postId, - title: 'title', - body: 'body', - id: 'id', - }), - errorComponent: PostErrorComponent as any, - notFoundComponent: () => { - return

Post not found

- }, - component: PostComponent, -}) - -export function PostErrorComponent({ error }: ErrorComponentProps) { - return -} - -function PostComponent() { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) -} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/double-quotes.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/double-quotes.tsx deleted file mode 100644 index d03bf88405..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/double-quotes.tsx +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-nocheck - -import * as React from 'react' -import { - ErrorComponent, - ErrorComponentProps, - Link, - createFileRoute, -} from '@tanstack/react-router' - -export const Route = createFileRoute("/(test)/double-quotes")({ - loader: async ({ params: { postId } }) => ({ - postId, - title: 'title', - body: 'body', - id: 'id', - }), - errorComponent: PostErrorComponent as any, - notFoundComponent: () => { - return

Post not found

- }, - component: PostComponent, -}) - -export function PostErrorComponent({ error }: ErrorComponentProps) { - return -} - -function PostComponent() { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) -} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/duplicate-import.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/duplicate-import.tsx deleted file mode 100644 index 6a668f371f..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/duplicate-import.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' -import * as React from 'react' -import { Link, Outlet } from '@tanstack/react-router' - -export const Route = createFileRoute('/(test)/duplicate-import')({ - component: PostsLayoutComponent, -}) - -function PostsLayoutComponent() { - return ( - <> - Home - - - ) -} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/foo.bar.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/foo.bar.tsx deleted file mode 100644 index fbfcc3dde6..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/foo.bar.tsx +++ /dev/null @@ -1,43 +0,0 @@ -// @ts-nocheck - -import * as React from 'react' -import { ErrorComponent, ErrorComponentProps, Link, createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(test)/foo/bar')({ - loader: async ({ params: { postId } }) => ({ - postId, - title: 'title', - body: 'body', - id: 'id', - }), - errorComponent: PostErrorComponent as any, - notFoundComponent: () => { - return

Post not found

- }, - component: PostComponent, -}) - -export function PostErrorComponent({ error }: ErrorComponentProps) { - return -} - -function PostComponent() { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) -} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/foo.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/foo.tsx deleted file mode 100644 index 400df7e122..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/foo.tsx +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-nocheck - -import * as React from 'react' -import { - ErrorComponent, - ErrorComponentProps, - Link, - createFileRoute, -} from '@tanstack/react-router' - -export const Route = createFileRoute('/(test)/foo')({ - loader: async ({ params: { postId } }) => ({ - postId, - title: 'title', - body: 'body', - id: 'id', - }), - errorComponent: PostErrorComponent as any, - notFoundComponent: () => { - return

Post not found

- }, - component: PostComponent, -}) - -export function PostErrorComponent({ error }: ErrorComponentProps) { - return -} - -function PostComponent() { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) -} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.lazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.lazy.tsx deleted file mode 100644 index df27585a6f..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.lazy.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { createLazyFileRoute } from '@tanstack/react-router' - -export const Route = createLazyFileRoute('/(test)/initiallyEmpty')({ - component: RouteComponent, -}) - -function RouteComponent() { - return
Hello "/(test)/initiallyEmpty"!
-} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.tsx deleted file mode 100644 index a7fea80dde..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyEmpty.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/(test)/initiallyEmpty')({ - component: RouteComponent, -}) - -function RouteComponent() { - return
Hello "/(test)/initiallyEmpty"!
-} diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyLazy.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/initiallyLazy.tsx deleted file mode 100644 index b9d388acd0..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/initiallyLazy.tsx +++ /dev/null @@ -1,26 +0,0 @@ -// @ts-nocheck - -import { createFileRoute, Link } from '@tanstack/react-router' - -export const Route = createFileRoute('/(test)/initiallyLazy')({ - component: () => { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) - }, -}) diff --git a/packages/router-generator/tests/generator/file-modification/snapshots/template-literal.tsx b/packages/router-generator/tests/generator/file-modification/snapshots/template-literal.tsx deleted file mode 100644 index 1e31639331..0000000000 --- a/packages/router-generator/tests/generator/file-modification/snapshots/template-literal.tsx +++ /dev/null @@ -1,48 +0,0 @@ -// @ts-nocheck - -import * as React from 'react' -import { - ErrorComponent, - ErrorComponentProps, - Link, - createFileRoute, -} from '@tanstack/react-router' - -export const Route = createFileRoute(`/(test)/template-literal`)({ - loader: async ({ params: { postId } }) => ({ - postId, - title: 'title', - body: 'body', - id: 'id', - }), - errorComponent: PostErrorComponent as any, - notFoundComponent: () => { - return

Post not found

- }, - component: PostComponent, -}) - -export function PostErrorComponent({ error }: ErrorComponentProps) { - return -} - -function PostComponent() { - const post = Route.useLoaderData() - - return ( -
-

{post.title}

-
{post.body}
- - Deep View - -
- ) -} diff --git a/packages/router-generator/tests/generator/flat-route-group/routeTree.snapshot.ts b/packages/router-generator/tests/generator/flat-route-group/routeTree.snapshot.ts deleted file mode 100644 index 542a64a174..0000000000 --- a/packages/router-generator/tests/generator/flat-route-group/routeTree.snapshot.ts +++ /dev/null @@ -1,141 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as AppRouteImport } from './routes/app' -import { Route as AppcomprasCompras_masRouteImport } from './routes/app.(compras)/compras_._mas' -import { Route as AppcomprasComprasOrdenesRouteImport } from './routes/app.(compras)/compras_.ordenes' -import { Route as AppcomprasCompras_masDivisionesRouteImport } from './routes/app.(compras)/compras_._mas.divisiones' - -const AppRoute = AppRouteImport.update({ - id: '/app', - path: '/app', - getParentRoute: () => rootRouteImport, -} as any) -const AppcomprasCompras_masRoute = AppcomprasCompras_masRouteImport.update({ - id: '/(compras)/compras_/_mas', - path: '/compras', - getParentRoute: () => AppRoute, -} as any) -const AppcomprasComprasOrdenesRoute = - AppcomprasComprasOrdenesRouteImport.update({ - id: '/(compras)/compras_/ordenes', - path: '/compras/ordenes', - getParentRoute: () => AppRoute, - } as any) -const AppcomprasCompras_masDivisionesRoute = - AppcomprasCompras_masDivisionesRouteImport.update({ - id: '/divisiones', - path: '/divisiones', - getParentRoute: () => AppcomprasCompras_masRoute, - } as any) - -export interface FileRoutesByFullPath { - '/app': typeof AppRouteWithChildren - '/app/compras': typeof AppcomprasCompras_masRouteWithChildren - '/app/compras/ordenes': typeof AppcomprasComprasOrdenesRoute - '/app/compras/divisiones': typeof AppcomprasCompras_masDivisionesRoute -} -export interface FileRoutesByTo { - '/app': typeof AppRouteWithChildren - '/app/compras': typeof AppcomprasCompras_masRouteWithChildren - '/app/compras/ordenes': typeof AppcomprasComprasOrdenesRoute - '/app/compras/divisiones': typeof AppcomprasCompras_masDivisionesRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/app': typeof AppRouteWithChildren - '/app/(compras)/compras_/_mas': typeof AppcomprasCompras_masRouteWithChildren - '/app/(compras)/compras_/ordenes': typeof AppcomprasComprasOrdenesRoute - '/app/(compras)/compras_/_mas/divisiones': typeof AppcomprasCompras_masDivisionesRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - '/app' | '/app/compras' | '/app/compras/ordenes' | '/app/compras/divisiones' - fileRoutesByTo: FileRoutesByTo - to: - '/app' | '/app/compras' | '/app/compras/ordenes' | '/app/compras/divisiones' - id: - | '__root__' - | '/app' - | '/app/(compras)/compras_/_mas' - | '/app/(compras)/compras_/ordenes' - | '/app/(compras)/compras_/_mas/divisiones' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - AppRoute: typeof AppRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/app': { - id: '/app' - path: '/app' - fullPath: '/app' - preLoaderRoute: typeof AppRouteImport - parentRoute: typeof rootRouteImport - } - '/app/(compras)/compras_/_mas': { - id: '/app/(compras)/compras_/_mas' - path: '/compras' - fullPath: '/app/compras' - preLoaderRoute: typeof AppcomprasCompras_masRouteImport - parentRoute: typeof AppRoute - } - '/app/(compras)/compras_/ordenes': { - id: '/app/(compras)/compras_/ordenes' - path: '/compras/ordenes' - fullPath: '/app/compras/ordenes' - preLoaderRoute: typeof AppcomprasComprasOrdenesRouteImport - parentRoute: typeof AppRoute - } - '/app/(compras)/compras_/_mas/divisiones': { - id: '/app/(compras)/compras_/_mas/divisiones' - path: '/divisiones' - fullPath: '/app/compras/divisiones' - preLoaderRoute: typeof AppcomprasCompras_masDivisionesRouteImport - parentRoute: typeof AppcomprasCompras_masRoute - } - } -} - -interface AppcomprasCompras_masRouteChildren { - AppcomprasCompras_masDivisionesRoute: typeof AppcomprasCompras_masDivisionesRoute -} - -const AppcomprasCompras_masRouteChildren: AppcomprasCompras_masRouteChildren = { - AppcomprasCompras_masDivisionesRoute: AppcomprasCompras_masDivisionesRoute, -} - -const AppcomprasCompras_masRouteWithChildren = - AppcomprasCompras_masRoute._addFileChildren( - AppcomprasCompras_masRouteChildren, - ) - -interface AppRouteChildren { - AppcomprasCompras_masRoute: typeof AppcomprasCompras_masRouteWithChildren - AppcomprasComprasOrdenesRoute: typeof AppcomprasComprasOrdenesRoute -} - -const AppRouteChildren: AppRouteChildren = { - AppcomprasCompras_masRoute: AppcomprasCompras_masRouteWithChildren, - AppcomprasComprasOrdenesRoute: AppcomprasComprasOrdenesRoute, -} - -const AppRouteWithChildren = AppRoute._addFileChildren(AppRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - AppRoute: AppRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/flat-route-group/routes/__root.tsx b/packages/router-generator/tests/generator/flat-route-group/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/flat-route-group/routes/__root.tsx +++ b/packages/router-generator/tests/generator/flat-route-group/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts b/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts deleted file mode 100644 index 923cfc0530..0000000000 --- a/packages/router-generator/tests/generator/flat/routeTree.snapshot.ts +++ /dev/null @@ -1,341 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as BlogRouteRouteImport } from './routes/blog.route' -import { Route as PostsRouteRouteImport } from './routes/posts.route' -import { Route as BlogIndexRouteImport } from './routes/blog.index' -import { Route as BlogBlogIdRouteRouteImport } from './routes/blog_.$blogId.route' -import { Route as BlogStatsRouteImport } from './routes/blog_.stats' -import { Route as PostsIndexRouteImport } from './routes/posts.index' -import { Route as BlogSlugIndexRouteImport } from './routes/blog.$slug.index' -import { Route as BlogBlogIdSlugRouteRouteImport } from './routes/blog_.$blogId.$slug.route' -import { Route as BlogBlogIdEditRouteImport } from './routes/blog_.$blogId_.edit' -import { Route as PostsPostIdIndexRouteImport } from './routes/posts.$postId.index' -import { Route as PostsPostIdDeepRouteImport } from './routes/posts.$postId.deep' -import { Route as BlogBlogIdSlugBarRouteImport } from './routes/blog_.$blogId.$slug_.bar' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRouteRoute = BlogRouteRouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) -const PostsRouteRoute = PostsRouteRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any) -const BlogIndexRoute = BlogIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => BlogRouteRoute, -} as any) -const BlogBlogIdRouteRoute = BlogBlogIdRouteRouteImport.update({ - id: '/blog_/$blogId', - path: '/blog/$blogId', - getParentRoute: () => rootRouteImport, -} as any) -const BlogStatsRoute = BlogStatsRouteImport.update({ - id: '/blog_/stats', - path: '/blog/stats', - getParentRoute: () => rootRouteImport, -} as any) -const PostsIndexRoute = PostsIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => PostsRouteRoute, -} as any) -const BlogSlugIndexRoute = BlogSlugIndexRouteImport.update({ - id: '/$slug/', - path: '/$slug/', - getParentRoute: () => BlogRouteRoute, -} as any) -const BlogBlogIdSlugRouteRoute = BlogBlogIdSlugRouteRouteImport.update({ - id: '/$slug', - path: '/$slug', - getParentRoute: () => BlogBlogIdRouteRoute, -} as any) -const BlogBlogIdEditRoute = BlogBlogIdEditRouteImport.update({ - id: '/blog_/$blogId_/edit', - path: '/blog/$blogId/edit', - getParentRoute: () => rootRouteImport, -} as any) -const PostsPostIdIndexRoute = PostsPostIdIndexRouteImport.update({ - id: '/$postId/', - path: '/$postId/', - getParentRoute: () => PostsRouteRoute, -} as any) -const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ - id: '/$postId/deep', - path: '/$postId/deep', - getParentRoute: () => PostsRouteRoute, -} as any) -const BlogBlogIdSlugBarRoute = BlogBlogIdSlugBarRouteImport.update({ - id: '/$slug_/bar', - path: '/$slug/bar', - getParentRoute: () => BlogBlogIdRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRouteWithChildren - '/posts': typeof PostsRouteRouteWithChildren - '/blog/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/blog/stats': typeof BlogStatsRoute - '/blog/': typeof BlogIndexRoute - '/posts/': typeof PostsIndexRoute - '/blog/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog/$blogId/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/blog/$slug/': typeof BlogSlugIndexRoute - '/posts/$postId/': typeof PostsPostIdIndexRoute - '/blog/$blogId/$slug/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/blog/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/blog/stats': typeof BlogStatsRoute - '/blog': typeof BlogIndexRoute - '/posts': typeof PostsIndexRoute - '/blog/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog/$blogId/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/blog/$slug': typeof BlogSlugIndexRoute - '/posts/$postId': typeof PostsPostIdIndexRoute - '/blog/$blogId/$slug/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/blog': typeof BlogRouteRouteWithChildren - '/posts': typeof PostsRouteRouteWithChildren - '/blog_/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/blog_/stats': typeof BlogStatsRoute - '/blog/': typeof BlogIndexRoute - '/posts/': typeof PostsIndexRoute - '/blog_/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog_/$blogId_/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/blog/$slug/': typeof BlogSlugIndexRoute - '/posts/$postId/': typeof PostsPostIdIndexRoute - '/blog_/$blogId/$slug_/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/blog' - | '/posts' - | '/blog/$blogId' - | '/blog/stats' - | '/blog/' - | '/posts/' - | '/blog/$blogId/$slug' - | '/blog/$blogId/edit' - | '/posts/$postId/deep' - | '/blog/$slug/' - | '/posts/$postId/' - | '/blog/$blogId/$slug/bar' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/blog/$blogId' - | '/blog/stats' - | '/blog' - | '/posts' - | '/blog/$blogId/$slug' - | '/blog/$blogId/edit' - | '/posts/$postId/deep' - | '/blog/$slug' - | '/posts/$postId' - | '/blog/$blogId/$slug/bar' - id: - | '__root__' - | '/' - | '/blog' - | '/posts' - | '/blog_/$blogId' - | '/blog_/stats' - | '/blog/' - | '/posts/' - | '/blog_/$blogId/$slug' - | '/blog_/$blogId_/edit' - | '/posts/$postId/deep' - | '/blog/$slug/' - | '/posts/$postId/' - | '/blog_/$blogId/$slug_/bar' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - BlogRouteRoute: typeof BlogRouteRouteWithChildren - PostsRouteRoute: typeof PostsRouteRouteWithChildren - BlogBlogIdRouteRoute: typeof BlogBlogIdRouteRouteWithChildren - BlogStatsRoute: typeof BlogStatsRoute - BlogBlogIdEditRoute: typeof BlogBlogIdEditRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/blog/': { - id: '/blog/' - path: '/' - fullPath: '/blog/' - preLoaderRoute: typeof BlogIndexRouteImport - parentRoute: typeof BlogRouteRoute - } - '/blog_/$blogId': { - id: '/blog_/$blogId' - path: '/blog/$blogId' - fullPath: '/blog/$blogId' - preLoaderRoute: typeof BlogBlogIdRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/blog_/stats': { - id: '/blog_/stats' - path: '/blog/stats' - fullPath: '/blog/stats' - preLoaderRoute: typeof BlogStatsRouteImport - parentRoute: typeof rootRouteImport - } - '/posts/': { - id: '/posts/' - path: '/' - fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexRouteImport - parentRoute: typeof PostsRouteRoute - } - '/blog/$slug/': { - id: '/blog/$slug/' - path: '/$slug' - fullPath: '/blog/$slug/' - preLoaderRoute: typeof BlogSlugIndexRouteImport - parentRoute: typeof BlogRouteRoute - } - '/blog_/$blogId/$slug': { - id: '/blog_/$blogId/$slug' - path: '/$slug' - fullPath: '/blog/$blogId/$slug' - preLoaderRoute: typeof BlogBlogIdSlugRouteRouteImport - parentRoute: typeof BlogBlogIdRouteRoute - } - '/blog_/$blogId_/edit': { - id: '/blog_/$blogId_/edit' - path: '/blog/$blogId/edit' - fullPath: '/blog/$blogId/edit' - preLoaderRoute: typeof BlogBlogIdEditRouteImport - parentRoute: typeof rootRouteImport - } - '/posts/$postId/': { - id: '/posts/$postId/' - path: '/$postId' - fullPath: '/posts/$postId/' - preLoaderRoute: typeof PostsPostIdIndexRouteImport - parentRoute: typeof PostsRouteRoute - } - '/posts/$postId/deep': { - id: '/posts/$postId/deep' - path: '/$postId/deep' - fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepRouteImport - parentRoute: typeof PostsRouteRoute - } - '/blog_/$blogId/$slug_/bar': { - id: '/blog_/$blogId/$slug_/bar' - path: '/$slug/bar' - fullPath: '/blog/$blogId/$slug/bar' - preLoaderRoute: typeof BlogBlogIdSlugBarRouteImport - parentRoute: typeof BlogBlogIdRouteRoute - } - } -} - -interface BlogRouteRouteChildren { - BlogIndexRoute: typeof BlogIndexRoute - BlogSlugIndexRoute: typeof BlogSlugIndexRoute -} - -const BlogRouteRouteChildren: BlogRouteRouteChildren = { - BlogIndexRoute: BlogIndexRoute, - BlogSlugIndexRoute: BlogSlugIndexRoute, -} - -const BlogRouteRouteWithChildren = BlogRouteRoute._addFileChildren( - BlogRouteRouteChildren, -) - -interface PostsRouteRouteChildren { - PostsIndexRoute: typeof PostsIndexRoute - PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute - PostsPostIdIndexRoute: typeof PostsPostIdIndexRoute -} - -const PostsRouteRouteChildren: PostsRouteRouteChildren = { - PostsIndexRoute: PostsIndexRoute, - PostsPostIdDeepRoute: PostsPostIdDeepRoute, - PostsPostIdIndexRoute: PostsPostIdIndexRoute, -} - -const PostsRouteRouteWithChildren = PostsRouteRoute._addFileChildren( - PostsRouteRouteChildren, -) - -interface BlogBlogIdRouteRouteChildren { - BlogBlogIdSlugRouteRoute: typeof BlogBlogIdSlugRouteRoute - BlogBlogIdSlugBarRoute: typeof BlogBlogIdSlugBarRoute -} - -const BlogBlogIdRouteRouteChildren: BlogBlogIdRouteRouteChildren = { - BlogBlogIdSlugRouteRoute: BlogBlogIdSlugRouteRoute, - BlogBlogIdSlugBarRoute: BlogBlogIdSlugBarRoute, -} - -const BlogBlogIdRouteRouteWithChildren = BlogBlogIdRouteRoute._addFileChildren( - BlogBlogIdRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - BlogRouteRoute: BlogRouteRouteWithChildren, - PostsRouteRoute: PostsRouteRouteWithChildren, - BlogBlogIdRouteRoute: BlogBlogIdRouteRouteWithChildren, - BlogStatsRoute: BlogStatsRoute, - BlogBlogIdEditRoute: BlogBlogIdEditRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/flat/routes/__root.tsx b/packages/router-generator/tests/generator/flat/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/flat/routes/__root.tsx +++ b/packages/router-generator/tests/generator/flat/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/invalid-param-names/routeTree.snapshot.ts b/packages/router-generator/tests/generator/invalid-param-names/routeTree.snapshot.ts deleted file mode 100644 index 9048976e40..0000000000 --- a/packages/router-generator/tests/generator/invalid-param-names/routeTree.snapshot.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as R123RouteImport } from './routes/$123' -import { Route as UserNameRouteImport } from './routes/$user-name' -import { Route as ValidParamRouteImport } from './routes/$validParam' - -const R123Route = R123RouteImport.update({ - id: '/$123', - path: '/$123', - getParentRoute: () => rootRouteImport, -} as any) -const UserNameRoute = UserNameRouteImport.update({ - id: '/$user-name', - path: '/$user-name', - getParentRoute: () => rootRouteImport, -} as any) -const ValidParamRoute = ValidParamRouteImport.update({ - id: '/$validParam', - path: '/$validParam', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/$123': typeof R123Route - '/$user-name': typeof UserNameRoute - '/$validParam': typeof ValidParamRoute -} -export interface FileRoutesByTo { - '/$123': typeof R123Route - '/$user-name': typeof UserNameRoute - '/$validParam': typeof ValidParamRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/$123': typeof R123Route - '/$user-name': typeof UserNameRoute - '/$validParam': typeof ValidParamRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/$123' | '/$user-name' | '/$validParam' - fileRoutesByTo: FileRoutesByTo - to: '/$123' | '/$user-name' | '/$validParam' - id: '__root__' | '/$123' | '/$user-name' | '/$validParam' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - R123Route: typeof R123Route - UserNameRoute: typeof UserNameRoute - ValidParamRoute: typeof ValidParamRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/$123': { - id: '/$123' - path: '/$123' - fullPath: '/$123' - preLoaderRoute: typeof R123RouteImport - parentRoute: typeof rootRouteImport - } - '/$user-name': { - id: '/$user-name' - path: '/$user-name' - fullPath: '/$user-name' - preLoaderRoute: typeof UserNameRouteImport - parentRoute: typeof rootRouteImport - } - '/$validParam': { - id: '/$validParam' - path: '/$validParam' - fullPath: '/$validParam' - preLoaderRoute: typeof ValidParamRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - R123Route: R123Route, - UserNameRoute: UserNameRoute, - ValidParamRoute: ValidParamRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/lazy-multi-slug-params/routeTree.snapshot.ts b/packages/router-generator/tests/generator/lazy-multi-slug-params/routeTree.snapshot.ts deleted file mode 100644 index 6eb3a308bd..0000000000 --- a/packages/router-generator/tests/generator/lazy-multi-slug-params/routeTree.snapshot.ts +++ /dev/null @@ -1,108 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' - -const SubRouteLazyRouteImport = createFileRoute('/sub')() -const SubTestLazyRouteImport = createFileRoute('/sub/test')() -const SubABLazyRouteImport = createFileRoute('/sub/$a/$b')() - -const SubRouteLazyRoute = SubRouteLazyRouteImport.update({ - id: '/sub', - path: '/sub', - getParentRoute: () => rootRouteImport, -} as any).lazy(() => import('./routes/sub/route.lazy').then((d) => d.Route)) -const SubTestLazyRoute = SubTestLazyRouteImport.update({ - id: '/test', - path: '/test', - getParentRoute: () => SubRouteLazyRoute, -} as any).lazy(() => import('./routes/sub/test.lazy').then((d) => d.Route)) -const SubABLazyRoute = SubABLazyRouteImport.update({ - id: '/$a/$b', - path: '/$a/$b', - getParentRoute: () => SubRouteLazyRoute, -} as any).lazy(() => import('./routes/sub/$a.$b.lazy').then((d) => d.Route)) - -export interface FileRoutesByFullPath { - '/sub': typeof SubRouteLazyRouteWithChildren - '/sub/test': typeof SubTestLazyRoute - '/sub/$a/$b': typeof SubABLazyRoute -} -export interface FileRoutesByTo { - '/sub': typeof SubRouteLazyRouteWithChildren - '/sub/test': typeof SubTestLazyRoute - '/sub/$a/$b': typeof SubABLazyRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/sub': typeof SubRouteLazyRouteWithChildren - '/sub/test': typeof SubTestLazyRoute - '/sub/$a/$b': typeof SubABLazyRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/sub' | '/sub/test' | '/sub/$a/$b' - fileRoutesByTo: FileRoutesByTo - to: '/sub' | '/sub/test' | '/sub/$a/$b' - id: '__root__' | '/sub' | '/sub/test' | '/sub/$a/$b' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - SubRouteLazyRoute: typeof SubRouteLazyRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/sub': { - id: '/sub' - path: '/sub' - fullPath: '/sub' - preLoaderRoute: typeof SubRouteLazyRouteImport - parentRoute: typeof rootRouteImport - } - '/sub/test': { - id: '/sub/test' - path: '/test' - fullPath: '/sub/test' - preLoaderRoute: typeof SubTestLazyRouteImport - parentRoute: typeof SubRouteLazyRoute - } - '/sub/$a/$b': { - id: '/sub/$a/$b' - path: '/$a/$b' - fullPath: '/sub/$a/$b' - preLoaderRoute: typeof SubABLazyRouteImport - parentRoute: typeof SubRouteLazyRoute - } - } -} - -interface SubRouteLazyRouteChildren { - SubTestLazyRoute: typeof SubTestLazyRoute - SubABLazyRoute: typeof SubABLazyRoute -} - -const SubRouteLazyRouteChildren: SubRouteLazyRouteChildren = { - SubTestLazyRoute: SubTestLazyRoute, - SubABLazyRoute: SubABLazyRoute, -} - -const SubRouteLazyRouteWithChildren = SubRouteLazyRoute._addFileChildren( - SubRouteLazyRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - SubRouteLazyRoute: SubRouteLazyRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/lazy-only-layout-and-index-in-pathless/routeTree.snapshot.ts b/packages/router-generator/tests/generator/lazy-only-layout-and-index-in-pathless/routeTree.snapshot.ts deleted file mode 100644 index 2de1aa6bb6..0000000000 --- a/packages/router-generator/tests/generator/lazy-only-layout-and-index-in-pathless/routeTree.snapshot.ts +++ /dev/null @@ -1,118 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' -import { Route as LayoutRouteRouteImport } from './routes/_layout/route' - -const LayoutPathLazyRouteImport = createFileRoute('/_layout/path')() -const LayoutPathIndexLazyRouteImport = createFileRoute('/_layout/path/')() - -const LayoutRouteRoute = LayoutRouteRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutPathLazyRoute = LayoutPathLazyRouteImport.update({ - id: '/path', - path: '/path', - getParentRoute: () => LayoutRouteRoute, -} as any).lazy(() => import('./routes/_layout/path.lazy').then((d) => d.Route)) -const LayoutPathIndexLazyRoute = LayoutPathIndexLazyRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => LayoutPathLazyRoute, -} as any).lazy(() => - import('./routes/_layout/path.index.lazy').then((d) => d.Route), -) - -export interface FileRoutesByFullPath { - '/': typeof LayoutRouteRouteWithChildren - '/path': typeof LayoutPathLazyRouteWithChildren - '/path/': typeof LayoutPathIndexLazyRoute -} -export interface FileRoutesByTo { - '/': typeof LayoutRouteRouteWithChildren - '/path': typeof LayoutPathIndexLazyRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/_layout': typeof LayoutRouteRouteWithChildren - '/_layout/path': typeof LayoutPathLazyRouteWithChildren - '/_layout/path/': typeof LayoutPathIndexLazyRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/path' | '/path/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/path' - id: '__root__' | '/_layout' | '/_layout/path' | '/_layout/path/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - LayoutRouteRoute: typeof LayoutRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/path': { - id: '/_layout/path' - path: '/path' - fullPath: '/path' - preLoaderRoute: typeof LayoutPathLazyRouteImport - parentRoute: typeof LayoutRouteRoute - } - '/_layout/path/': { - id: '/_layout/path/' - path: '/' - fullPath: '/path/' - preLoaderRoute: typeof LayoutPathIndexLazyRouteImport - parentRoute: typeof LayoutPathLazyRoute - } - } -} - -interface LayoutPathLazyRouteChildren { - LayoutPathIndexLazyRoute: typeof LayoutPathIndexLazyRoute -} - -const LayoutPathLazyRouteChildren: LayoutPathLazyRouteChildren = { - LayoutPathIndexLazyRoute: LayoutPathIndexLazyRoute, -} - -const LayoutPathLazyRouteWithChildren = LayoutPathLazyRoute._addFileChildren( - LayoutPathLazyRouteChildren, -) - -interface LayoutRouteRouteChildren { - LayoutPathLazyRoute: typeof LayoutPathLazyRouteWithChildren -} - -const LayoutRouteRouteChildren: LayoutRouteRouteChildren = { - LayoutPathLazyRoute: LayoutPathLazyRouteWithChildren, -} - -const LayoutRouteRouteWithChildren = LayoutRouteRoute._addFileChildren( - LayoutRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - LayoutRouteRoute: LayoutRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/lazy-only-layout-and-index/routeTree.snapshot.ts b/packages/router-generator/tests/generator/lazy-only-layout-and-index/routeTree.snapshot.ts deleted file mode 100644 index dd385cf7ac..0000000000 --- a/packages/router-generator/tests/generator/lazy-only-layout-and-index/routeTree.snapshot.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' - -const PathLazyRouteImport = createFileRoute('/path')() -const PathIndexLazyRouteImport = createFileRoute('/path/')() - -const PathLazyRoute = PathLazyRouteImport.update({ - id: '/path', - path: '/path', - getParentRoute: () => rootRouteImport, -} as any).lazy(() => import('./routes/path.lazy').then((d) => d.Route)) -const PathIndexLazyRoute = PathIndexLazyRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => PathLazyRoute, -} as any).lazy(() => import('./routes/path.index.lazy').then((d) => d.Route)) - -export interface FileRoutesByFullPath { - '/path': typeof PathLazyRouteWithChildren - '/path/': typeof PathIndexLazyRoute -} -export interface FileRoutesByTo { - '/path': typeof PathIndexLazyRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/path': typeof PathLazyRouteWithChildren - '/path/': typeof PathIndexLazyRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/path' | '/path/' - fileRoutesByTo: FileRoutesByTo - to: '/path' - id: '__root__' | '/path' | '/path/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - PathLazyRoute: typeof PathLazyRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/path': { - id: '/path' - path: '/path' - fullPath: '/path' - preLoaderRoute: typeof PathLazyRouteImport - parentRoute: typeof rootRouteImport - } - '/path/': { - id: '/path/' - path: '/' - fullPath: '/path/' - preLoaderRoute: typeof PathIndexLazyRouteImport - parentRoute: typeof PathLazyRoute - } - } -} - -interface PathLazyRouteChildren { - PathIndexLazyRoute: typeof PathIndexLazyRoute -} - -const PathLazyRouteChildren: PathLazyRouteChildren = { - PathIndexLazyRoute: PathIndexLazyRoute, -} - -const PathLazyRouteWithChildren = PathLazyRoute._addFileChildren( - PathLazyRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - PathLazyRoute: PathLazyRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/lazy/routeTree.snapshot.ts b/packages/router-generator/tests/generator/lazy/routeTree.snapshot.ts deleted file mode 100644 index ea40f442ad..0000000000 --- a/packages/router-generator/tests/generator/lazy/routeTree.snapshot.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as PostsRouteRouteImport } from './routes/posts.route' -import { Route as PostsIndexRouteImport } from './routes/posts.index' -import { Route as PostsPostIdRouteImport } from './routes/posts.$postId' - -const PostsRouteRoute = PostsRouteRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any).lazy(() => import('./routes/posts.route.lazy').then((d) => d.Route)) -const PostsIndexRoute = PostsIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => PostsRouteRoute, -} as any) -const PostsPostIdRoute = PostsPostIdRouteImport.update({ - id: '/$postId', - path: '/$postId', - getParentRoute: () => PostsRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/posts': typeof PostsRouteRouteWithChildren - '/posts/$postId': typeof PostsPostIdRoute - '/posts/': typeof PostsIndexRoute -} -export interface FileRoutesByTo { - '/posts/$postId': typeof PostsPostIdRoute - '/posts': typeof PostsIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/posts': typeof PostsRouteRouteWithChildren - '/posts/$postId': typeof PostsPostIdRoute - '/posts/': typeof PostsIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/posts' | '/posts/$postId' | '/posts/' - fileRoutesByTo: FileRoutesByTo - to: '/posts/$postId' | '/posts' - id: '__root__' | '/posts' | '/posts/$postId' | '/posts/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - PostsRouteRoute: typeof PostsRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/posts/': { - id: '/posts/' - path: '/' - fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexRouteImport - parentRoute: typeof PostsRouteRoute - } - '/posts/$postId': { - id: '/posts/$postId' - path: '/$postId' - fullPath: '/posts/$postId' - preLoaderRoute: typeof PostsPostIdRouteImport - parentRoute: typeof PostsRouteRoute - } - } -} - -interface PostsRouteRouteChildren { - PostsPostIdRoute: typeof PostsPostIdRoute - PostsIndexRoute: typeof PostsIndexRoute -} - -const PostsRouteRouteChildren: PostsRouteRouteChildren = { - PostsPostIdRoute: PostsPostIdRoute, - PostsIndexRoute: PostsIndexRoute, -} - -const PostsRouteRouteWithChildren = PostsRouteRoute._addFileChildren( - PostsRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - PostsRouteRoute: PostsRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts deleted file mode 100644 index 7fb6ebb0d0..0000000000 --- a/packages/router-generator/tests/generator/nested-layouts/routeTree.snapshot.ts +++ /dev/null @@ -1,586 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as LayoutA1RouteImport } from './routes/_layout-a1' -import { Route as LayoutA2RouteImport } from './routes/_layout-a2' -import { Route as JestedRouteRouteImport } from './routes/jested/route' -import { Route as folderInFolderRouteImport } from './routes/(folder)/in-folder' -import { Route as LayoutA1FooRouteImport } from './routes/_layout-a1/foo' -import { Route as LayoutA2BarRouteImport } from './routes/_layout-a2/bar' -import { Route as FooLayoutB5RouteRouteImport } from './routes/foo/_layout-b5/route' -import { Route as FooBarRouteImport } from './routes/foo/bar' -import { Route as JestedLayoutB3RouteImport } from './routes/jested/_layout-b3' -import { Route as JestedLayoutB4RouteImport } from './routes/jested/_layout-b4' -import { Route as NestedLayoutB1RouteImport } from './routes/nested/_layout-b1' -import { Route as NestedLayoutB2RouteImport } from './routes/nested/_layout-b2' -import { Route as FooLayoutB5IndexRouteImport } from './routes/foo/_layout-b5/index' -import { Route as FooLayoutB5IdRouteImport } from './routes/foo/_layout-b5/$id' -import { Route as JestedLayoutB3IndexRouteImport } from './routes/jested/_layout-b3/index' -import { Route as JestedLayoutB3LayoutC2RouteImport } from './routes/jested/_layout-b3/_layout-c2' -import { Route as JestedLayoutB4FooRouteImport } from './routes/jested/_layout-b4/foo' -import { Route as NestedLayoutB1IndexRouteImport } from './routes/nested/_layout-b1/index' -import { Route as NestedLayoutB1LayoutC1RouteImport } from './routes/nested/_layout-b1/_layout-c1' -import { Route as NestedLayoutB2FooRouteImport } from './routes/nested/_layout-b2/foo' -import { Route as JestedLayoutB3LayoutC2BarRouteImport } from './routes/jested/_layout-b3/_layout-c2/bar' -import { Route as NestedLayoutB1LayoutC1BarRouteImport } from './routes/nested/_layout-b1/_layout-c1/bar' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutA1Route = LayoutA1RouteImport.update({ - id: '/_layout-a1', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutA2Route = LayoutA2RouteImport.update({ - id: '/_layout-a2', - getParentRoute: () => rootRouteImport, -} as any) -const JestedRouteRoute = JestedRouteRouteImport.update({ - id: '/jested', - path: '/jested', - getParentRoute: () => rootRouteImport, -} as any) -const folderInFolderRoute = folderInFolderRouteImport.update({ - id: '/(folder)/in-folder', - path: '/in-folder', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutA1FooRoute = LayoutA1FooRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => LayoutA1Route, -} as any) -const LayoutA2BarRoute = LayoutA2BarRouteImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => LayoutA2Route, -} as any) -const FooLayoutB5RouteRoute = FooLayoutB5RouteRouteImport.update({ - id: '/foo/_layout-b5', - path: '/foo', - getParentRoute: () => rootRouteImport, -} as any) -const FooBarRoute = FooBarRouteImport.update({ - id: '/foo/bar', - path: '/foo/bar', - getParentRoute: () => rootRouteImport, -} as any) -const JestedLayoutB3Route = JestedLayoutB3RouteImport.update({ - id: '/_layout-b3', - getParentRoute: () => JestedRouteRoute, -} as any) -const JestedLayoutB4Route = JestedLayoutB4RouteImport.update({ - id: '/_layout-b4', - getParentRoute: () => JestedRouteRoute, -} as any) -const NestedLayoutB1Route = NestedLayoutB1RouteImport.update({ - id: '/nested/_layout-b1', - path: '/nested', - getParentRoute: () => rootRouteImport, -} as any) -const NestedLayoutB2Route = NestedLayoutB2RouteImport.update({ - id: '/nested/_layout-b2', - path: '/nested', - getParentRoute: () => rootRouteImport, -} as any) -const FooLayoutB5IndexRoute = FooLayoutB5IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => FooLayoutB5RouteRoute, -} as any) -const FooLayoutB5IdRoute = FooLayoutB5IdRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => FooLayoutB5RouteRoute, -} as any) -const JestedLayoutB3IndexRoute = JestedLayoutB3IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => JestedLayoutB3Route, -} as any) -const JestedLayoutB3LayoutC2Route = JestedLayoutB3LayoutC2RouteImport.update({ - id: '/_layout-c2', - getParentRoute: () => JestedLayoutB3Route, -} as any) -const JestedLayoutB4FooRoute = JestedLayoutB4FooRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => JestedLayoutB4Route, -} as any) -const NestedLayoutB1IndexRoute = NestedLayoutB1IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => NestedLayoutB1Route, -} as any) -const NestedLayoutB1LayoutC1Route = NestedLayoutB1LayoutC1RouteImport.update({ - id: '/_layout-c1', - getParentRoute: () => NestedLayoutB1Route, -} as any) -const NestedLayoutB2FooRoute = NestedLayoutB2FooRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => NestedLayoutB2Route, -} as any) -const JestedLayoutB3LayoutC2BarRoute = - JestedLayoutB3LayoutC2BarRouteImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => JestedLayoutB3LayoutC2Route, - } as any) -const NestedLayoutB1LayoutC1BarRoute = - NestedLayoutB1LayoutC1BarRouteImport.update({ - id: '/bar', - path: '/bar', - getParentRoute: () => NestedLayoutB1LayoutC1Route, - } as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/jested': typeof JestedRouteRouteWithChildren - '/foo': typeof LayoutA1FooRoute - '/in-folder': typeof folderInFolderRoute - '/bar': typeof LayoutA2BarRoute - '/foo/bar': typeof FooBarRoute - '/nested': typeof NestedLayoutB1LayoutC1RouteWithChildren - '/foo/$id': typeof FooLayoutB5IdRoute - '/jested/foo': typeof JestedLayoutB4FooRoute - '/nested/foo': typeof NestedLayoutB2FooRoute - '/foo/': typeof FooLayoutB5IndexRoute - '/jested/': typeof JestedLayoutB3IndexRoute - '/nested/': typeof NestedLayoutB1IndexRoute - '/jested/bar': typeof JestedLayoutB3LayoutC2BarRoute - '/nested/bar': typeof NestedLayoutB1LayoutC1BarRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/jested': typeof JestedLayoutB3IndexRoute - '/in-folder': typeof folderInFolderRoute - '/foo': typeof FooLayoutB5IndexRoute - '/bar': typeof LayoutA2BarRoute - '/foo/bar': typeof FooBarRoute - '/nested': typeof NestedLayoutB1IndexRoute - '/foo/$id': typeof FooLayoutB5IdRoute - '/jested/foo': typeof JestedLayoutB4FooRoute - '/nested/foo': typeof NestedLayoutB2FooRoute - '/jested/bar': typeof JestedLayoutB3LayoutC2BarRoute - '/nested/bar': typeof NestedLayoutB1LayoutC1BarRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/jested': typeof JestedRouteRouteWithChildren - '/_layout-a1': typeof LayoutA1RouteWithChildren - '/_layout-a2': typeof LayoutA2RouteWithChildren - '/foo/_layout-b5': typeof FooLayoutB5RouteRouteWithChildren - '/(folder)/in-folder': typeof folderInFolderRoute - '/_layout-a1/foo': typeof LayoutA1FooRoute - '/_layout-a2/bar': typeof LayoutA2BarRoute - '/foo/bar': typeof FooBarRoute - '/jested/_layout-b3': typeof JestedLayoutB3RouteWithChildren - '/jested/_layout-b4': typeof JestedLayoutB4RouteWithChildren - '/nested/_layout-b1': typeof NestedLayoutB1RouteWithChildren - '/nested/_layout-b2': typeof NestedLayoutB2RouteWithChildren - '/foo/_layout-b5/$id': typeof FooLayoutB5IdRoute - '/jested/_layout-b3/_layout-c2': typeof JestedLayoutB3LayoutC2RouteWithChildren - '/jested/_layout-b4/foo': typeof JestedLayoutB4FooRoute - '/nested/_layout-b1/_layout-c1': typeof NestedLayoutB1LayoutC1RouteWithChildren - '/nested/_layout-b2/foo': typeof NestedLayoutB2FooRoute - '/foo/_layout-b5/': typeof FooLayoutB5IndexRoute - '/jested/_layout-b3/': typeof JestedLayoutB3IndexRoute - '/nested/_layout-b1/': typeof NestedLayoutB1IndexRoute - '/jested/_layout-b3/_layout-c2/bar': typeof JestedLayoutB3LayoutC2BarRoute - '/nested/_layout-b1/_layout-c1/bar': typeof NestedLayoutB1LayoutC1BarRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/jested' - | '/foo' - | '/in-folder' - | '/bar' - | '/foo/bar' - | '/nested' - | '/foo/$id' - | '/jested/foo' - | '/nested/foo' - | '/foo/' - | '/jested/' - | '/nested/' - | '/jested/bar' - | '/nested/bar' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/jested' - | '/in-folder' - | '/foo' - | '/bar' - | '/foo/bar' - | '/nested' - | '/foo/$id' - | '/jested/foo' - | '/nested/foo' - | '/jested/bar' - | '/nested/bar' - id: - | '__root__' - | '/' - | '/jested' - | '/_layout-a1' - | '/_layout-a2' - | '/foo/_layout-b5' - | '/(folder)/in-folder' - | '/_layout-a1/foo' - | '/_layout-a2/bar' - | '/foo/bar' - | '/jested/_layout-b3' - | '/jested/_layout-b4' - | '/nested/_layout-b1' - | '/nested/_layout-b2' - | '/foo/_layout-b5/$id' - | '/jested/_layout-b3/_layout-c2' - | '/jested/_layout-b4/foo' - | '/nested/_layout-b1/_layout-c1' - | '/nested/_layout-b2/foo' - | '/foo/_layout-b5/' - | '/jested/_layout-b3/' - | '/nested/_layout-b1/' - | '/jested/_layout-b3/_layout-c2/bar' - | '/nested/_layout-b1/_layout-c1/bar' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - JestedRouteRoute: typeof JestedRouteRouteWithChildren - LayoutA1Route: typeof LayoutA1RouteWithChildren - LayoutA2Route: typeof LayoutA2RouteWithChildren - FooLayoutB5RouteRoute: typeof FooLayoutB5RouteRouteWithChildren - folderInFolderRoute: typeof folderInFolderRoute - FooBarRoute: typeof FooBarRoute - NestedLayoutB1Route: typeof NestedLayoutB1RouteWithChildren - NestedLayoutB2Route: typeof NestedLayoutB2RouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout-a1': { - id: '/_layout-a1' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutA1RouteImport - parentRoute: typeof rootRouteImport - } - '/_layout-a2': { - id: '/_layout-a2' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutA2RouteImport - parentRoute: typeof rootRouteImport - } - '/jested': { - id: '/jested' - path: '/jested' - fullPath: '/jested' - preLoaderRoute: typeof JestedRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/(folder)/in-folder': { - id: '/(folder)/in-folder' - path: '/in-folder' - fullPath: '/in-folder' - preLoaderRoute: typeof folderInFolderRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout-a1/foo': { - id: '/_layout-a1/foo' - path: '/foo' - fullPath: '/foo' - preLoaderRoute: typeof LayoutA1FooRouteImport - parentRoute: typeof LayoutA1Route - } - '/_layout-a2/bar': { - id: '/_layout-a2/bar' - path: '/bar' - fullPath: '/bar' - preLoaderRoute: typeof LayoutA2BarRouteImport - parentRoute: typeof LayoutA2Route - } - '/foo/_layout-b5': { - id: '/foo/_layout-b5' - path: '/foo' - fullPath: '/foo' - preLoaderRoute: typeof FooLayoutB5RouteRouteImport - parentRoute: typeof rootRouteImport - } - '/foo/bar': { - id: '/foo/bar' - path: '/foo/bar' - fullPath: '/foo/bar' - preLoaderRoute: typeof FooBarRouteImport - parentRoute: typeof rootRouteImport - } - '/jested/_layout-b3': { - id: '/jested/_layout-b3' - path: '' - fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB3RouteImport - parentRoute: typeof JestedRouteRoute - } - '/jested/_layout-b4': { - id: '/jested/_layout-b4' - path: '' - fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB4RouteImport - parentRoute: typeof JestedRouteRoute - } - '/nested/_layout-b1': { - id: '/nested/_layout-b1' - path: '/nested' - fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB1RouteImport - parentRoute: typeof rootRouteImport - } - '/nested/_layout-b2': { - id: '/nested/_layout-b2' - path: '/nested' - fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB2RouteImport - parentRoute: typeof rootRouteImport - } - '/foo/_layout-b5/': { - id: '/foo/_layout-b5/' - path: '/' - fullPath: '/foo/' - preLoaderRoute: typeof FooLayoutB5IndexRouteImport - parentRoute: typeof FooLayoutB5RouteRoute - } - '/foo/_layout-b5/$id': { - id: '/foo/_layout-b5/$id' - path: '/$id' - fullPath: '/foo/$id' - preLoaderRoute: typeof FooLayoutB5IdRouteImport - parentRoute: typeof FooLayoutB5RouteRoute - } - '/jested/_layout-b3/': { - id: '/jested/_layout-b3/' - path: '/' - fullPath: '/jested/' - preLoaderRoute: typeof JestedLayoutB3IndexRouteImport - parentRoute: typeof JestedLayoutB3Route - } - '/jested/_layout-b3/_layout-c2': { - id: '/jested/_layout-b3/_layout-c2' - path: '' - fullPath: '/jested' - preLoaderRoute: typeof JestedLayoutB3LayoutC2RouteImport - parentRoute: typeof JestedLayoutB3Route - } - '/jested/_layout-b4/foo': { - id: '/jested/_layout-b4/foo' - path: '/foo' - fullPath: '/jested/foo' - preLoaderRoute: typeof JestedLayoutB4FooRouteImport - parentRoute: typeof JestedLayoutB4Route - } - '/nested/_layout-b1/': { - id: '/nested/_layout-b1/' - path: '/' - fullPath: '/nested/' - preLoaderRoute: typeof NestedLayoutB1IndexRouteImport - parentRoute: typeof NestedLayoutB1Route - } - '/nested/_layout-b1/_layout-c1': { - id: '/nested/_layout-b1/_layout-c1' - path: '' - fullPath: '/nested' - preLoaderRoute: typeof NestedLayoutB1LayoutC1RouteImport - parentRoute: typeof NestedLayoutB1Route - } - '/nested/_layout-b2/foo': { - id: '/nested/_layout-b2/foo' - path: '/foo' - fullPath: '/nested/foo' - preLoaderRoute: typeof NestedLayoutB2FooRouteImport - parentRoute: typeof NestedLayoutB2Route - } - '/jested/_layout-b3/_layout-c2/bar': { - id: '/jested/_layout-b3/_layout-c2/bar' - path: '/bar' - fullPath: '/jested/bar' - preLoaderRoute: typeof JestedLayoutB3LayoutC2BarRouteImport - parentRoute: typeof JestedLayoutB3LayoutC2Route - } - '/nested/_layout-b1/_layout-c1/bar': { - id: '/nested/_layout-b1/_layout-c1/bar' - path: '/bar' - fullPath: '/nested/bar' - preLoaderRoute: typeof NestedLayoutB1LayoutC1BarRouteImport - parentRoute: typeof NestedLayoutB1LayoutC1Route - } - } -} - -interface JestedLayoutB3LayoutC2RouteChildren { - JestedLayoutB3LayoutC2BarRoute: typeof JestedLayoutB3LayoutC2BarRoute -} - -const JestedLayoutB3LayoutC2RouteChildren: JestedLayoutB3LayoutC2RouteChildren = - { - JestedLayoutB3LayoutC2BarRoute: JestedLayoutB3LayoutC2BarRoute, - } - -const JestedLayoutB3LayoutC2RouteWithChildren = - JestedLayoutB3LayoutC2Route._addFileChildren( - JestedLayoutB3LayoutC2RouteChildren, - ) - -interface JestedLayoutB3RouteChildren { - JestedLayoutB3LayoutC2Route: typeof JestedLayoutB3LayoutC2RouteWithChildren - JestedLayoutB3IndexRoute: typeof JestedLayoutB3IndexRoute -} - -const JestedLayoutB3RouteChildren: JestedLayoutB3RouteChildren = { - JestedLayoutB3LayoutC2Route: JestedLayoutB3LayoutC2RouteWithChildren, - JestedLayoutB3IndexRoute: JestedLayoutB3IndexRoute, -} - -const JestedLayoutB3RouteWithChildren = JestedLayoutB3Route._addFileChildren( - JestedLayoutB3RouteChildren, -) - -interface JestedLayoutB4RouteChildren { - JestedLayoutB4FooRoute: typeof JestedLayoutB4FooRoute -} - -const JestedLayoutB4RouteChildren: JestedLayoutB4RouteChildren = { - JestedLayoutB4FooRoute: JestedLayoutB4FooRoute, -} - -const JestedLayoutB4RouteWithChildren = JestedLayoutB4Route._addFileChildren( - JestedLayoutB4RouteChildren, -) - -interface JestedRouteRouteChildren { - JestedLayoutB3Route: typeof JestedLayoutB3RouteWithChildren - JestedLayoutB4Route: typeof JestedLayoutB4RouteWithChildren -} - -const JestedRouteRouteChildren: JestedRouteRouteChildren = { - JestedLayoutB3Route: JestedLayoutB3RouteWithChildren, - JestedLayoutB4Route: JestedLayoutB4RouteWithChildren, -} - -const JestedRouteRouteWithChildren = JestedRouteRoute._addFileChildren( - JestedRouteRouteChildren, -) - -interface LayoutA1RouteChildren { - LayoutA1FooRoute: typeof LayoutA1FooRoute -} - -const LayoutA1RouteChildren: LayoutA1RouteChildren = { - LayoutA1FooRoute: LayoutA1FooRoute, -} - -const LayoutA1RouteWithChildren = LayoutA1Route._addFileChildren( - LayoutA1RouteChildren, -) - -interface LayoutA2RouteChildren { - LayoutA2BarRoute: typeof LayoutA2BarRoute -} - -const LayoutA2RouteChildren: LayoutA2RouteChildren = { - LayoutA2BarRoute: LayoutA2BarRoute, -} - -const LayoutA2RouteWithChildren = LayoutA2Route._addFileChildren( - LayoutA2RouteChildren, -) - -interface FooLayoutB5RouteRouteChildren { - FooLayoutB5IdRoute: typeof FooLayoutB5IdRoute - FooLayoutB5IndexRoute: typeof FooLayoutB5IndexRoute -} - -const FooLayoutB5RouteRouteChildren: FooLayoutB5RouteRouteChildren = { - FooLayoutB5IdRoute: FooLayoutB5IdRoute, - FooLayoutB5IndexRoute: FooLayoutB5IndexRoute, -} - -const FooLayoutB5RouteRouteWithChildren = - FooLayoutB5RouteRoute._addFileChildren(FooLayoutB5RouteRouteChildren) - -interface NestedLayoutB1LayoutC1RouteChildren { - NestedLayoutB1LayoutC1BarRoute: typeof NestedLayoutB1LayoutC1BarRoute -} - -const NestedLayoutB1LayoutC1RouteChildren: NestedLayoutB1LayoutC1RouteChildren = - { - NestedLayoutB1LayoutC1BarRoute: NestedLayoutB1LayoutC1BarRoute, - } - -const NestedLayoutB1LayoutC1RouteWithChildren = - NestedLayoutB1LayoutC1Route._addFileChildren( - NestedLayoutB1LayoutC1RouteChildren, - ) - -interface NestedLayoutB1RouteChildren { - NestedLayoutB1LayoutC1Route: typeof NestedLayoutB1LayoutC1RouteWithChildren - NestedLayoutB1IndexRoute: typeof NestedLayoutB1IndexRoute -} - -const NestedLayoutB1RouteChildren: NestedLayoutB1RouteChildren = { - NestedLayoutB1LayoutC1Route: NestedLayoutB1LayoutC1RouteWithChildren, - NestedLayoutB1IndexRoute: NestedLayoutB1IndexRoute, -} - -const NestedLayoutB1RouteWithChildren = NestedLayoutB1Route._addFileChildren( - NestedLayoutB1RouteChildren, -) - -interface NestedLayoutB2RouteChildren { - NestedLayoutB2FooRoute: typeof NestedLayoutB2FooRoute -} - -const NestedLayoutB2RouteChildren: NestedLayoutB2RouteChildren = { - NestedLayoutB2FooRoute: NestedLayoutB2FooRoute, -} - -const NestedLayoutB2RouteWithChildren = NestedLayoutB2Route._addFileChildren( - NestedLayoutB2RouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - JestedRouteRoute: JestedRouteRouteWithChildren, - LayoutA1Route: LayoutA1RouteWithChildren, - LayoutA2Route: LayoutA2RouteWithChildren, - FooLayoutB5RouteRoute: FooLayoutB5RouteRouteWithChildren, - folderInFolderRoute: folderInFolderRoute, - FooBarRoute: FooBarRoute, - NestedLayoutB1Route: NestedLayoutB1RouteWithChildren, - NestedLayoutB2Route: NestedLayoutB2RouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx b/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx +++ b/packages/router-generator/tests/generator/nested-layouts/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts deleted file mode 100644 index bda946f97b..0000000000 --- a/packages/router-generator/tests/generator/nested-route-groups-with-layouts-before-physical/routeTree.snapshot.ts +++ /dev/null @@ -1,196 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as groupALayoutARouteImport } from './routes/(group-a)/_layout-a' -import { Route as groupBLayoutBRouteImport } from './routes/(group-b)/_layout-b' -import { Route as groupCLayoutCRouteImport } from './routes/(group-c)/_layout-c' -import { Route as groupALayoutALoginRouteImport } from './routes/(group-a)/_layout-a/login' -import { Route as groupALayoutASignupRouteImport } from './routes/(group-a)/_layout-a/signup' -import { Route as groupBLayoutBDashboardRouteImport } from './routes/(group-b)/_layout-b/dashboard' -import { Route as groupCLayoutCIndexRouteImport } from './routes/(group-c)/_layout-c/index' - -const groupALayoutARoute = groupALayoutARouteImport.update({ - id: '/(group-a)/_layout-a', - getParentRoute: () => rootRouteImport, -} as any) -const groupBLayoutBRoute = groupBLayoutBRouteImport.update({ - id: '/(group-b)/_layout-b', - getParentRoute: () => rootRouteImport, -} as any) -const groupCLayoutCRoute = groupCLayoutCRouteImport.update({ - id: '/(group-c)/_layout-c', - getParentRoute: () => rootRouteImport, -} as any) -const groupALayoutALoginRoute = groupALayoutALoginRouteImport.update({ - id: '/login', - path: '/login', - getParentRoute: () => groupALayoutARoute, -} as any) -const groupALayoutASignupRoute = groupALayoutASignupRouteImport.update({ - id: '/signup', - path: '/signup', - getParentRoute: () => groupALayoutARoute, -} as any) -const groupBLayoutBDashboardRoute = groupBLayoutBDashboardRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => groupBLayoutBRoute, -} as any) -const groupCLayoutCIndexRoute = groupCLayoutCIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => groupCLayoutCRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof groupCLayoutCIndexRoute - '/login': typeof groupALayoutALoginRoute - '/signup': typeof groupALayoutASignupRoute - '/dashboard': typeof groupBLayoutBDashboardRoute -} -export interface FileRoutesByTo { - '/': typeof groupCLayoutCIndexRoute - '/login': typeof groupALayoutALoginRoute - '/signup': typeof groupALayoutASignupRoute - '/dashboard': typeof groupBLayoutBDashboardRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/(group-a)/_layout-a': typeof groupALayoutARouteWithChildren - '/(group-b)/_layout-b': typeof groupBLayoutBRouteWithChildren - '/(group-c)/_layout-c': typeof groupCLayoutCRouteWithChildren - '/(group-a)/_layout-a/login': typeof groupALayoutALoginRoute - '/(group-a)/_layout-a/signup': typeof groupALayoutASignupRoute - '/(group-b)/_layout-b/dashboard': typeof groupBLayoutBDashboardRoute - '/(group-c)/_layout-c/': typeof groupCLayoutCIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/login' | '/signup' | '/dashboard' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/login' | '/signup' | '/dashboard' - id: - | '__root__' - | '/(group-a)/_layout-a' - | '/(group-b)/_layout-b' - | '/(group-c)/_layout-c' - | '/(group-a)/_layout-a/login' - | '/(group-a)/_layout-a/signup' - | '/(group-b)/_layout-b/dashboard' - | '/(group-c)/_layout-c/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - groupALayoutARoute: typeof groupALayoutARouteWithChildren - groupBLayoutBRoute: typeof groupBLayoutBRouteWithChildren - groupCLayoutCRoute: typeof groupCLayoutCRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/(group-a)/_layout-a': { - id: '/(group-a)/_layout-a' - path: '' - fullPath: '/' - preLoaderRoute: typeof groupALayoutARouteImport - parentRoute: typeof rootRouteImport - } - '/(group-b)/_layout-b': { - id: '/(group-b)/_layout-b' - path: '' - fullPath: '/' - preLoaderRoute: typeof groupBLayoutBRouteImport - parentRoute: typeof rootRouteImport - } - '/(group-c)/_layout-c': { - id: '/(group-c)/_layout-c' - path: '' - fullPath: '/' - preLoaderRoute: typeof groupCLayoutCRouteImport - parentRoute: typeof rootRouteImport - } - '/(group-a)/_layout-a/login': { - id: '/(group-a)/_layout-a/login' - path: '/login' - fullPath: '/login' - preLoaderRoute: typeof groupALayoutALoginRouteImport - parentRoute: typeof groupALayoutARoute - } - '/(group-a)/_layout-a/signup': { - id: '/(group-a)/_layout-a/signup' - path: '/signup' - fullPath: '/signup' - preLoaderRoute: typeof groupALayoutASignupRouteImport - parentRoute: typeof groupALayoutARoute - } - '/(group-b)/_layout-b/dashboard': { - id: '/(group-b)/_layout-b/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof groupBLayoutBDashboardRouteImport - parentRoute: typeof groupBLayoutBRoute - } - '/(group-c)/_layout-c/': { - id: '/(group-c)/_layout-c/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof groupCLayoutCIndexRouteImport - parentRoute: typeof groupCLayoutCRoute - } - } -} - -interface groupALayoutARouteChildren { - groupALayoutALoginRoute: typeof groupALayoutALoginRoute - groupALayoutASignupRoute: typeof groupALayoutASignupRoute -} - -const groupALayoutARouteChildren: groupALayoutARouteChildren = { - groupALayoutALoginRoute: groupALayoutALoginRoute, - groupALayoutASignupRoute: groupALayoutASignupRoute, -} - -const groupALayoutARouteWithChildren = groupALayoutARoute._addFileChildren( - groupALayoutARouteChildren, -) - -interface groupBLayoutBRouteChildren { - groupBLayoutBDashboardRoute: typeof groupBLayoutBDashboardRoute -} - -const groupBLayoutBRouteChildren: groupBLayoutBRouteChildren = { - groupBLayoutBDashboardRoute: groupBLayoutBDashboardRoute, -} - -const groupBLayoutBRouteWithChildren = groupBLayoutBRoute._addFileChildren( - groupBLayoutBRouteChildren, -) - -interface groupCLayoutCRouteChildren { - groupCLayoutCIndexRoute: typeof groupCLayoutCIndexRoute -} - -const groupCLayoutCRouteChildren: groupCLayoutCRouteChildren = { - groupCLayoutCIndexRoute: groupCLayoutCIndexRoute, -} - -const groupCLayoutCRouteWithChildren = groupCLayoutCRoute._addFileChildren( - groupCLayoutCRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - groupALayoutARoute: groupALayoutARouteWithChildren, - groupBLayoutBRoute: groupBLayoutBRouteWithChildren, - groupCLayoutCRoute: groupCLayoutCRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts deleted file mode 100644 index 685b1b29ca..0000000000 --- a/packages/router-generator/tests/generator/nested/routeTree.snapshot.ts +++ /dev/null @@ -1,388 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as PathlessLayoutRouteImport } from './routes/_pathlessLayout' -import { Route as BlogRouteRouteImport } from './routes/blog/route' -import { Route as PostsRouteRouteImport } from './routes/posts/route' -import { Route as PathlessLayoutSettingsRouteImport } from './routes/_pathlessLayout/settings' -import { Route as BlogIndexRouteImport } from './routes/blog/index' -import { Route as BlogSlugRouteImport } from './routes/blog/$slug' -import { Route as BlogBlogIdRouteRouteImport } from './routes/blog_/$blogId/route' -import { Route as BlogStatsRouteImport } from './routes/blog_/stats' -import { Route as PostsIndexRouteImport } from './routes/posts/index' -import { Route as BlogBlogIdSlugRouteRouteImport } from './routes/blog_/$blogId/$slug/route' -import { Route as BlogBlogIdEditRouteImport } from './routes/blog_/$blogId_/edit' -import { Route as PostsPostIdIndexRouteImport } from './routes/posts/$postId/index' -import { Route as PostsPostIdDeepRouteImport } from './routes/posts/$postId/deep' -import { Route as BlogBlogIdSlugBarRouteImport } from './routes/blog_/$blogId/$slug_/bar' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const PathlessLayoutRoute = PathlessLayoutRouteImport.update({ - id: '/_pathlessLayout', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRouteRoute = BlogRouteRouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) -const PostsRouteRoute = PostsRouteRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any) -const PathlessLayoutSettingsRoute = PathlessLayoutSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => PathlessLayoutRoute, -} as any) -const BlogIndexRoute = BlogIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => BlogRouteRoute, -} as any) -const BlogSlugRoute = BlogSlugRouteImport.update({ - id: '/$slug', - path: '/$slug', - getParentRoute: () => BlogRouteRoute, -} as any) -const BlogBlogIdRouteRoute = BlogBlogIdRouteRouteImport.update({ - id: '/blog_/$blogId', - path: '/blog/$blogId', - getParentRoute: () => rootRouteImport, -} as any) -const BlogStatsRoute = BlogStatsRouteImport.update({ - id: '/blog_/stats', - path: '/blog/stats', - getParentRoute: () => rootRouteImport, -} as any) -const PostsIndexRoute = PostsIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => PostsRouteRoute, -} as any) -const BlogBlogIdSlugRouteRoute = BlogBlogIdSlugRouteRouteImport.update({ - id: '/$slug', - path: '/$slug', - getParentRoute: () => BlogBlogIdRouteRoute, -} as any) -const BlogBlogIdEditRoute = BlogBlogIdEditRouteImport.update({ - id: '/blog_/$blogId_/edit', - path: '/blog/$blogId/edit', - getParentRoute: () => rootRouteImport, -} as any) -const PostsPostIdIndexRoute = PostsPostIdIndexRouteImport.update({ - id: '/$postId/', - path: '/$postId/', - getParentRoute: () => PostsRouteRoute, -} as any) -const PostsPostIdDeepRoute = PostsPostIdDeepRouteImport.update({ - id: '/$postId/deep', - path: '/$postId/deep', - getParentRoute: () => PostsRouteRoute, -} as any) -const BlogBlogIdSlugBarRoute = BlogBlogIdSlugBarRouteImport.update({ - id: '/$slug_/bar', - path: '/$slug/bar', - getParentRoute: () => BlogBlogIdRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRouteWithChildren - '/posts': typeof PostsRouteRouteWithChildren - '/blog/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/settings': typeof PathlessLayoutSettingsRoute - '/blog/$slug': typeof BlogSlugRoute - '/blog/stats': typeof BlogStatsRoute - '/blog/': typeof BlogIndexRoute - '/posts/': typeof PostsIndexRoute - '/blog/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog/$blogId/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId/': typeof PostsPostIdIndexRoute - '/blog/$blogId/$slug/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/blog/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/settings': typeof PathlessLayoutSettingsRoute - '/blog/$slug': typeof BlogSlugRoute - '/blog/stats': typeof BlogStatsRoute - '/blog': typeof BlogIndexRoute - '/posts': typeof PostsIndexRoute - '/blog/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog/$blogId/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId': typeof PostsPostIdIndexRoute - '/blog/$blogId/$slug/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/blog': typeof BlogRouteRouteWithChildren - '/posts': typeof PostsRouteRouteWithChildren - '/_pathlessLayout': typeof PathlessLayoutRouteWithChildren - '/blog_/$blogId': typeof BlogBlogIdRouteRouteWithChildren - '/_pathlessLayout/settings': typeof PathlessLayoutSettingsRoute - '/blog/$slug': typeof BlogSlugRoute - '/blog_/stats': typeof BlogStatsRoute - '/blog/': typeof BlogIndexRoute - '/posts/': typeof PostsIndexRoute - '/blog_/$blogId/$slug': typeof BlogBlogIdSlugRouteRoute - '/blog_/$blogId_/edit': typeof BlogBlogIdEditRoute - '/posts/$postId/deep': typeof PostsPostIdDeepRoute - '/posts/$postId/': typeof PostsPostIdIndexRoute - '/blog_/$blogId/$slug_/bar': typeof BlogBlogIdSlugBarRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/blog' - | '/posts' - | '/blog/$blogId' - | '/settings' - | '/blog/$slug' - | '/blog/stats' - | '/blog/' - | '/posts/' - | '/blog/$blogId/$slug' - | '/blog/$blogId/edit' - | '/posts/$postId/deep' - | '/posts/$postId/' - | '/blog/$blogId/$slug/bar' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/blog/$blogId' - | '/settings' - | '/blog/$slug' - | '/blog/stats' - | '/blog' - | '/posts' - | '/blog/$blogId/$slug' - | '/blog/$blogId/edit' - | '/posts/$postId/deep' - | '/posts/$postId' - | '/blog/$blogId/$slug/bar' - id: - | '__root__' - | '/' - | '/blog' - | '/posts' - | '/_pathlessLayout' - | '/blog_/$blogId' - | '/_pathlessLayout/settings' - | '/blog/$slug' - | '/blog_/stats' - | '/blog/' - | '/posts/' - | '/blog_/$blogId/$slug' - | '/blog_/$blogId_/edit' - | '/posts/$postId/deep' - | '/posts/$postId/' - | '/blog_/$blogId/$slug_/bar' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - BlogRouteRoute: typeof BlogRouteRouteWithChildren - PostsRouteRoute: typeof PostsRouteRouteWithChildren - PathlessLayoutRoute: typeof PathlessLayoutRouteWithChildren - BlogBlogIdRouteRoute: typeof BlogBlogIdRouteRouteWithChildren - BlogStatsRoute: typeof BlogStatsRoute - BlogBlogIdEditRoute: typeof BlogBlogIdEditRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_pathlessLayout': { - id: '/_pathlessLayout' - path: '' - fullPath: '/' - preLoaderRoute: typeof PathlessLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/_pathlessLayout/settings': { - id: '/_pathlessLayout/settings' - path: '/settings' - fullPath: '/settings' - preLoaderRoute: typeof PathlessLayoutSettingsRouteImport - parentRoute: typeof PathlessLayoutRoute - } - '/blog/': { - id: '/blog/' - path: '/' - fullPath: '/blog/' - preLoaderRoute: typeof BlogIndexRouteImport - parentRoute: typeof BlogRouteRoute - } - '/blog/$slug': { - id: '/blog/$slug' - path: '/$slug' - fullPath: '/blog/$slug' - preLoaderRoute: typeof BlogSlugRouteImport - parentRoute: typeof BlogRouteRoute - } - '/blog_/$blogId': { - id: '/blog_/$blogId' - path: '/blog/$blogId' - fullPath: '/blog/$blogId' - preLoaderRoute: typeof BlogBlogIdRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/blog_/stats': { - id: '/blog_/stats' - path: '/blog/stats' - fullPath: '/blog/stats' - preLoaderRoute: typeof BlogStatsRouteImport - parentRoute: typeof rootRouteImport - } - '/posts/': { - id: '/posts/' - path: '/' - fullPath: '/posts/' - preLoaderRoute: typeof PostsIndexRouteImport - parentRoute: typeof PostsRouteRoute - } - '/blog_/$blogId/$slug': { - id: '/blog_/$blogId/$slug' - path: '/$slug' - fullPath: '/blog/$blogId/$slug' - preLoaderRoute: typeof BlogBlogIdSlugRouteRouteImport - parentRoute: typeof BlogBlogIdRouteRoute - } - '/blog_/$blogId_/edit': { - id: '/blog_/$blogId_/edit' - path: '/blog/$blogId/edit' - fullPath: '/blog/$blogId/edit' - preLoaderRoute: typeof BlogBlogIdEditRouteImport - parentRoute: typeof rootRouteImport - } - '/posts/$postId/': { - id: '/posts/$postId/' - path: '/$postId' - fullPath: '/posts/$postId/' - preLoaderRoute: typeof PostsPostIdIndexRouteImport - parentRoute: typeof PostsRouteRoute - } - '/posts/$postId/deep': { - id: '/posts/$postId/deep' - path: '/$postId/deep' - fullPath: '/posts/$postId/deep' - preLoaderRoute: typeof PostsPostIdDeepRouteImport - parentRoute: typeof PostsRouteRoute - } - '/blog_/$blogId/$slug_/bar': { - id: '/blog_/$blogId/$slug_/bar' - path: '/$slug/bar' - fullPath: '/blog/$blogId/$slug/bar' - preLoaderRoute: typeof BlogBlogIdSlugBarRouteImport - parentRoute: typeof BlogBlogIdRouteRoute - } - } -} - -interface BlogRouteRouteChildren { - BlogSlugRoute: typeof BlogSlugRoute - BlogIndexRoute: typeof BlogIndexRoute -} - -const BlogRouteRouteChildren: BlogRouteRouteChildren = { - BlogSlugRoute: BlogSlugRoute, - BlogIndexRoute: BlogIndexRoute, -} - -const BlogRouteRouteWithChildren = BlogRouteRoute._addFileChildren( - BlogRouteRouteChildren, -) - -interface PostsRouteRouteChildren { - PostsIndexRoute: typeof PostsIndexRoute - PostsPostIdDeepRoute: typeof PostsPostIdDeepRoute - PostsPostIdIndexRoute: typeof PostsPostIdIndexRoute -} - -const PostsRouteRouteChildren: PostsRouteRouteChildren = { - PostsIndexRoute: PostsIndexRoute, - PostsPostIdDeepRoute: PostsPostIdDeepRoute, - PostsPostIdIndexRoute: PostsPostIdIndexRoute, -} - -const PostsRouteRouteWithChildren = PostsRouteRoute._addFileChildren( - PostsRouteRouteChildren, -) - -interface PathlessLayoutRouteChildren { - PathlessLayoutSettingsRoute: typeof PathlessLayoutSettingsRoute -} - -const PathlessLayoutRouteChildren: PathlessLayoutRouteChildren = { - PathlessLayoutSettingsRoute: PathlessLayoutSettingsRoute, -} - -const PathlessLayoutRouteWithChildren = PathlessLayoutRoute._addFileChildren( - PathlessLayoutRouteChildren, -) - -interface BlogBlogIdRouteRouteChildren { - BlogBlogIdSlugRouteRoute: typeof BlogBlogIdSlugRouteRoute - BlogBlogIdSlugBarRoute: typeof BlogBlogIdSlugBarRoute -} - -const BlogBlogIdRouteRouteChildren: BlogBlogIdRouteRouteChildren = { - BlogBlogIdSlugRouteRoute: BlogBlogIdSlugRouteRoute, - BlogBlogIdSlugBarRoute: BlogBlogIdSlugBarRoute, -} - -const BlogBlogIdRouteRouteWithChildren = BlogBlogIdRouteRoute._addFileChildren( - BlogBlogIdRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - BlogRouteRoute: BlogRouteRouteWithChildren, - PostsRouteRoute: PostsRouteRouteWithChildren, - PathlessLayoutRoute: PathlessLayoutRouteWithChildren, - BlogBlogIdRouteRoute: BlogBlogIdRouteRouteWithChildren, - BlogStatsRoute: BlogStatsRoute, - BlogBlogIdEditRoute: BlogBlogIdEditRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/nested/tests.test-d.ts b/packages/router-generator/tests/generator/nested/tests.test-d.ts index 47dcc0f5b1..f25097b005 100644 --- a/packages/router-generator/tests/generator/nested/tests.test-d.ts +++ b/packages/router-generator/tests/generator/nested/tests.test-d.ts @@ -10,32 +10,97 @@ import { useRouteContext, useSearch, } from '@tanstack/react-router' -import type { FileRoutesByPath, MakeRouteMatch } from '@tanstack/react-router' import { expectTypeOf, test } from 'vitest' import { routeTree } from './routeTree.gen' -import type { FileRouteTypes } from './routeTree.gen' +import type { FileRoutesByPath, MakeRouteMatch } from '@tanstack/react-router' +import type { InferFileRouteTypes } from '@tanstack/router-core' +// Read for its type only (`typeof`) +// eslint-disable-next-line unused-imports/no-unused-vars const defaultRouter = createRouter({ routeTree, }) type DefaultRouter = typeof defaultRouter +// Read for its type only (`typeof`) +// eslint-disable-next-line unused-imports/no-unused-vars const alwaysTrailingSlashRouter = createRouter({ routeTree, trailingSlash: 'always', }) +// Read for its type only (`typeof`) +// eslint-disable-next-line unused-imports/no-unused-vars const neverTrailingSlashRouter = createRouter({ routeTree, trailingSlash: 'never', }) +// Read for its type only (`typeof`) +// eslint-disable-next-line unused-imports/no-unused-vars const preserveTrailingSlashRouter = createRouter({ routeTree, trailingSlash: 'preserve', }) +// The file route types router-core reads from the route tree (the types of +// `fullPath`, `to` and `id` it derives when they are not `never`). The full +// paths have no empty string (issue #4892). +type NestedFileRouteTypes = InferFileRouteTypes + +test('router-core infers the file route types of the route tree', () => { + expectTypeOf().not.toBeNever() + expectTypeOf().toEqualTypeOf< + | '/' + | '/blog' + | '/posts' + | '/blog/$blogId' + | '/settings' + | '/blog/$slug' + | '/blog/stats' + | '/blog/' + | '/posts/' + | '/blog/$blogId/$slug' + | '/blog/$blogId/edit' + | '/posts/$postId/deep' + | '/posts/$postId/' + | '/blog/$blogId/$slug/bar' + >() + expectTypeOf().toEqualTypeOf< + | '/' + | '/blog/$blogId' + | '/settings' + | '/blog/$slug' + | '/blog/stats' + | '/blog' + | '/posts' + | '/blog/$blogId/$slug' + | '/blog/$blogId/edit' + | '/posts/$postId/deep' + | '/posts/$postId' + | '/blog/$blogId/$slug/bar' + >() + expectTypeOf().toEqualTypeOf< + | '__root__' + | '/' + | '/blog' + | '/posts' + | '/_pathlessLayout' + | '/blog_/$blogId' + | '/_pathlessLayout/settings' + | '/blog/$slug' + | '/blog_/stats' + | '/blog/' + | '/posts/' + | '/blog_/$blogId/$slug' + | '/blog_/$blogId_/edit' + | '/posts/$postId/deep' + | '/posts/$postId/' + | '/blog_/$blogId/$slug_/bar' + >() +}) + test('when navigating to the root', () => { // Issue #4892: Pathless layout routes should have fullPath: '/' not '' expectTypeOf().toEqualTypeOf<'/'>() @@ -49,8 +114,6 @@ test('when navigating to the root', () => { expectTypeOf< FileRoutesByPath['/blog/']['fullPath'] >().toEqualTypeOf<'/blog/'>() - // Verify empty string is not in fullPaths union - expectTypeOf<''>().not.toMatchTypeOf() // Verify pathless layout's fullPath is '/' (not '') expectTypeOf< FileRoutesByPath['/_pathlessLayout']['fullPath'] diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts deleted file mode 100644 index 9eea11a3f0..0000000000 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routeTree.snapshot.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as FooLayoutRouteRouteImport } from './routes/foo/_layout/route' -import { Route as FooLayoutIndexRouteImport } from './routes/foo/_layout/index' - -const FooLayoutRouteRoute = FooLayoutRouteRouteImport.update({ - id: '/foo/_layout', - path: '/foo', - getParentRoute: () => rootRouteImport, -} as any) -const FooLayoutIndexRoute = FooLayoutIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => FooLayoutRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/foo': typeof FooLayoutRouteRouteWithChildren - '/foo/': typeof FooLayoutIndexRoute -} -export interface FileRoutesByTo { - '/foo': typeof FooLayoutIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/foo/_layout': typeof FooLayoutRouteRouteWithChildren - '/foo/_layout/': typeof FooLayoutIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/foo' | '/foo/' - fileRoutesByTo: FileRoutesByTo - to: '/foo' - id: '__root__' | '/foo/_layout' | '/foo/_layout/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - FooLayoutRouteRoute: typeof FooLayoutRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/foo/_layout': { - id: '/foo/_layout' - path: '/foo' - fullPath: '/foo' - preLoaderRoute: typeof FooLayoutRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/foo/_layout/': { - id: '/foo/_layout/' - path: '/' - fullPath: '/foo/' - preLoaderRoute: typeof FooLayoutIndexRouteImport - parentRoute: typeof FooLayoutRouteRoute - } - } -} - -interface FooLayoutRouteRouteChildren { - FooLayoutIndexRoute: typeof FooLayoutIndexRoute -} - -const FooLayoutRouteRouteChildren: FooLayoutRouteRouteChildren = { - FooLayoutIndexRoute: FooLayoutIndexRoute, -} - -const FooLayoutRouteRouteWithChildren = FooLayoutRouteRoute._addFileChildren( - FooLayoutRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - FooLayoutRouteRoute: FooLayoutRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx +++ b/packages/router-generator/tests/generator/no-duplicate-route-segment/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts b/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts deleted file mode 100644 index b2ff973765..0000000000 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as NestedIndexRouteImport } from './routes/nested/index' -import { Route as NestedChildRouteImport } from './routes/nested/child' - -const IndexRoute = IndexRouteImport.update({ - id: '/',path: '/',getParentRoute: () => rootRouteImport - }as any) -const NestedIndexRoute = NestedIndexRouteImport.update({ - id: '/nested/',path: '/nested/',getParentRoute: () => rootRouteImport - }as any) -const NestedChildRoute = NestedChildRouteImport.update({ - id: '/nested/child',path: '/nested/child',getParentRoute: () => rootRouteImport - }as any) - -export interface FileRoutesByFullPath { -'/': typeof IndexRoute,'/nested/child': typeof NestedChildRoute,'/nested/': typeof NestedIndexRoute -} -export interface FileRoutesByTo { -'/': typeof IndexRoute,'/nested/child': typeof NestedChildRoute,'/nested': typeof NestedIndexRoute -} -export interface FileRoutesById { -'__root__': typeof rootRouteImport, -'/': typeof IndexRoute,'/nested/child': typeof NestedChildRoute,'/nested/': typeof NestedIndexRoute -} -export interface FileRouteTypes { -fileRoutesByFullPath: FileRoutesByFullPath -fullPaths: '/'|'/nested/child'|'/nested/' -fileRoutesByTo: FileRoutesByTo -to: '/'|'/nested/child'|'/nested' -id: '__root__'|'/'|'/nested/child'|'/nested/' -fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { -IndexRoute: typeof IndexRoute,NestedChildRoute: typeof NestedChildRoute,NestedIndexRoute: typeof NestedIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } -'/nested/': { - id: '/nested/' - path: '/nested' - fullPath: '/nested/' - preLoaderRoute: typeof NestedIndexRouteImport - parentRoute: typeof rootRouteImport - } -'/nested/child': { - id: '/nested/child' - path: '/nested/child' - fullPath: '/nested/child' - preLoaderRoute: typeof NestedChildRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute,NestedChildRoute: NestedChildRoute,NestedIndexRoute: NestedIndexRoute -} -export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren)._addFileTypes() \ No newline at end of file diff --git a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx +++ b/packages/router-generator/tests/generator/no-formatted-route-tree/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts b/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts deleted file mode 100644 index 826e1b8b4f..0000000000 --- a/packages/router-generator/tests/generator/numbers-in-path/routeTree.snapshot.ts +++ /dev/null @@ -1,131 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as R03RouteImport } from './routes/03' -import { Route as AboutRouteImport } from './routes/about' -import { Route as R01ExampleIndexRouteImport } from './routes/01-example/index' -import { Route as R02IndexRouteImport } from './routes/02.index' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const R03Route = R03RouteImport.update({ - id: '/03', - path: '/03', - getParentRoute: () => rootRouteImport, -} as any) -const AboutRoute = AboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => rootRouteImport, -} as any) -const R01ExampleIndexRoute = R01ExampleIndexRouteImport.update({ - id: '/01-example/', - path: '/01-example/', - getParentRoute: () => rootRouteImport, -} as any) -const R02IndexRoute = R02IndexRouteImport.update({ - id: '/02/', - path: '/02/', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/03': typeof R03Route - '/about': typeof AboutRoute - '/01-example/': typeof R01ExampleIndexRoute - '/02/': typeof R02IndexRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/03': typeof R03Route - '/about': typeof AboutRoute - '/01-example': typeof R01ExampleIndexRoute - '/02': typeof R02IndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/03': typeof R03Route - '/about': typeof AboutRoute - '/01-example/': typeof R01ExampleIndexRoute - '/02/': typeof R02IndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/03' | '/about' | '/01-example/' | '/02/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/03' | '/about' | '/01-example' | '/02' - id: '__root__' | '/' | '/03' | '/about' | '/01-example/' | '/02/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - R03Route: typeof R03Route - AboutRoute: typeof AboutRoute - R01ExampleIndexRoute: typeof R01ExampleIndexRoute - R02IndexRoute: typeof R02IndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/03': { - id: '/03' - path: '/03' - fullPath: '/03' - preLoaderRoute: typeof R03RouteImport - parentRoute: typeof rootRouteImport - } - '/about': { - id: '/about' - path: '/about' - fullPath: '/about' - preLoaderRoute: typeof AboutRouteImport - parentRoute: typeof rootRouteImport - } - '/01-example/': { - id: '/01-example/' - path: '/01-example' - fullPath: '/01-example/' - preLoaderRoute: typeof R01ExampleIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/02/': { - id: '/02/' - path: '/02' - fullPath: '/02/' - preLoaderRoute: typeof R02IndexRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - R03Route: R03Route, - AboutRoute: AboutRoute, - R01ExampleIndexRoute: R01ExampleIndexRoute, - R02IndexRoute: R02IndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts deleted file mode 100644 index 7766df9832..0000000000 --- a/packages/router-generator/tests/generator/only-root/routeTree.generated.snapshot.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './../routes/__root' - -export interface FileRoutesByFullPath {} -export interface FileRoutesByTo {} -export interface FileRoutesById { - __root__: typeof rootRouteImport -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: never - fileRoutesByTo: FileRoutesByTo - to: never - id: '__root__' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren {} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath {} -} - -const rootRouteChildren: RootRouteChildren = {} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts b/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts deleted file mode 100644 index d9b0e2be23..0000000000 --- a/packages/router-generator/tests/generator/only-root/routeTree.snapshot.ts +++ /dev/null @@ -1,35 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' - -export interface FileRoutesByFullPath {} -export interface FileRoutesByTo {} -export interface FileRoutesById { - __root__: typeof rootRouteImport -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: never - fileRoutesByTo: FileRoutesByTo - to: never - id: '__root__' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren {} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath {} -} - -const rootRouteChildren: RootRouteChildren = {} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/path-above-route-in-group/routeTree.snapshot.ts b/packages/router-generator/tests/generator/path-above-route-in-group/routeTree.snapshot.ts deleted file mode 100644 index 1a8ad18a10..0000000000 --- a/packages/router-generator/tests/generator/path-above-route-in-group/routeTree.snapshot.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as ABcRouteRouteImport } from './routes/a/$b/(c)/route' -import { Route as ABcIndexRouteImport } from './routes/a/$b/(c)/index' -import { Route as ABcDEIndexRouteImport } from './routes/a/$b/(c)/d/e/index' - -const ABcRouteRoute = ABcRouteRouteImport.update({ - id: '/a/$b/(c)', - path: '/a/$b', - getParentRoute: () => rootRouteImport, -} as any) -const ABcIndexRoute = ABcIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => ABcRouteRoute, -} as any) -const ABcDEIndexRoute = ABcDEIndexRouteImport.update({ - id: '/d/e/', - path: '/d/e/', - getParentRoute: () => ABcRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/a/$b': typeof ABcRouteRouteWithChildren - '/a/$b/': typeof ABcIndexRoute - '/a/$b/d/e/': typeof ABcDEIndexRoute -} -export interface FileRoutesByTo { - '/a/$b': typeof ABcIndexRoute - '/a/$b/d/e': typeof ABcDEIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/a/$b/(c)': typeof ABcRouteRouteWithChildren - '/a/$b/(c)/': typeof ABcIndexRoute - '/a/$b/(c)/d/e/': typeof ABcDEIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/a/$b' | '/a/$b/' | '/a/$b/d/e/' - fileRoutesByTo: FileRoutesByTo - to: '/a/$b' | '/a/$b/d/e' - id: '__root__' | '/a/$b/(c)' | '/a/$b/(c)/' | '/a/$b/(c)/d/e/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - ABcRouteRoute: typeof ABcRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/a/$b/(c)': { - id: '/a/$b/(c)' - path: '/a/$b' - fullPath: '/a/$b' - preLoaderRoute: typeof ABcRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/a/$b/(c)/': { - id: '/a/$b/(c)/' - path: '/' - fullPath: '/a/$b/' - preLoaderRoute: typeof ABcIndexRouteImport - parentRoute: typeof ABcRouteRoute - } - '/a/$b/(c)/d/e/': { - id: '/a/$b/(c)/d/e/' - path: '/d/e' - fullPath: '/a/$b/d/e/' - preLoaderRoute: typeof ABcDEIndexRouteImport - parentRoute: typeof ABcRouteRoute - } - } -} - -interface ABcRouteRouteChildren { - ABcIndexRoute: typeof ABcIndexRoute - ABcDEIndexRoute: typeof ABcDEIndexRoute -} - -const ABcRouteRouteChildren: ABcRouteRouteChildren = { - ABcIndexRoute: ABcIndexRoute, - ABcDEIndexRoute: ABcDEIndexRoute, -} - -const ABcRouteRouteWithChildren = ABcRouteRoute._addFileChildren( - ABcRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - ABcRouteRoute: ABcRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/pathless-to-index-preference/routeTree.snapshot.ts b/packages/router-generator/tests/generator/pathless-to-index-preference/routeTree.snapshot.ts deleted file mode 100644 index e9c9d6fac6..0000000000 --- a/packages/router-generator/tests/generator/pathless-to-index-preference/routeTree.snapshot.ts +++ /dev/null @@ -1,147 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as LivestockFarmIdMedicineRouteRouteImport } from './routes/livestock/$farmId/medicine/route' -import { Route as LivestockFarmIdMedicineIndexRouteImport } from './routes/livestock/$farmId/medicine/index' -import { Route as LivestockFarmIdMedicineFormRouteImport } from './routes/livestock/$farmId/medicine/_form' -import { Route as LivestockFarmIdMedicineFormNewRouteImport } from './routes/livestock/$farmId/medicine/_form.new' - -const LivestockFarmIdMedicineRouteRoute = - LivestockFarmIdMedicineRouteRouteImport.update({ - id: '/livestock/$farmId/medicine', - path: '/livestock/$farmId/medicine', - getParentRoute: () => rootRouteImport, - } as any) -const LivestockFarmIdMedicineIndexRoute = - LivestockFarmIdMedicineIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => LivestockFarmIdMedicineRouteRoute, - } as any) -const LivestockFarmIdMedicineFormRoute = - LivestockFarmIdMedicineFormRouteImport.update({ - id: '/_form', - getParentRoute: () => LivestockFarmIdMedicineRouteRoute, - } as any) -const LivestockFarmIdMedicineFormNewRoute = - LivestockFarmIdMedicineFormNewRouteImport.update({ - id: '/new', - path: '/new', - getParentRoute: () => LivestockFarmIdMedicineFormRoute, - } as any) - -export interface FileRoutesByFullPath { - '/livestock/$farmId/medicine': typeof LivestockFarmIdMedicineRouteRouteWithChildren - '/livestock/$farmId/medicine/': typeof LivestockFarmIdMedicineIndexRoute - '/livestock/$farmId/medicine/new': typeof LivestockFarmIdMedicineFormNewRoute -} -export interface FileRoutesByTo { - '/livestock/$farmId/medicine': typeof LivestockFarmIdMedicineIndexRoute - '/livestock/$farmId/medicine/new': typeof LivestockFarmIdMedicineFormNewRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/livestock/$farmId/medicine': typeof LivestockFarmIdMedicineRouteRouteWithChildren - '/livestock/$farmId/medicine/_form': typeof LivestockFarmIdMedicineFormRouteWithChildren - '/livestock/$farmId/medicine/': typeof LivestockFarmIdMedicineIndexRoute - '/livestock/$farmId/medicine/_form/new': typeof LivestockFarmIdMedicineFormNewRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/livestock/$farmId/medicine' - | '/livestock/$farmId/medicine/' - | '/livestock/$farmId/medicine/new' - fileRoutesByTo: FileRoutesByTo - to: '/livestock/$farmId/medicine' | '/livestock/$farmId/medicine/new' - id: - | '__root__' - | '/livestock/$farmId/medicine' - | '/livestock/$farmId/medicine/_form' - | '/livestock/$farmId/medicine/' - | '/livestock/$farmId/medicine/_form/new' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - LivestockFarmIdMedicineRouteRoute: typeof LivestockFarmIdMedicineRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/livestock/$farmId/medicine': { - id: '/livestock/$farmId/medicine' - path: '/livestock/$farmId/medicine' - fullPath: '/livestock/$farmId/medicine' - preLoaderRoute: typeof LivestockFarmIdMedicineRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/livestock/$farmId/medicine/': { - id: '/livestock/$farmId/medicine/' - path: '/' - fullPath: '/livestock/$farmId/medicine/' - preLoaderRoute: typeof LivestockFarmIdMedicineIndexRouteImport - parentRoute: typeof LivestockFarmIdMedicineRouteRoute - } - '/livestock/$farmId/medicine/_form': { - id: '/livestock/$farmId/medicine/_form' - path: '' - fullPath: '/livestock/$farmId/medicine' - preLoaderRoute: typeof LivestockFarmIdMedicineFormRouteImport - parentRoute: typeof LivestockFarmIdMedicineRouteRoute - } - '/livestock/$farmId/medicine/_form/new': { - id: '/livestock/$farmId/medicine/_form/new' - path: '/new' - fullPath: '/livestock/$farmId/medicine/new' - preLoaderRoute: typeof LivestockFarmIdMedicineFormNewRouteImport - parentRoute: typeof LivestockFarmIdMedicineFormRoute - } - } -} - -interface LivestockFarmIdMedicineFormRouteChildren { - LivestockFarmIdMedicineFormNewRoute: typeof LivestockFarmIdMedicineFormNewRoute -} - -const LivestockFarmIdMedicineFormRouteChildren: LivestockFarmIdMedicineFormRouteChildren = - { - LivestockFarmIdMedicineFormNewRoute: LivestockFarmIdMedicineFormNewRoute, - } - -const LivestockFarmIdMedicineFormRouteWithChildren = - LivestockFarmIdMedicineFormRoute._addFileChildren( - LivestockFarmIdMedicineFormRouteChildren, - ) - -interface LivestockFarmIdMedicineRouteRouteChildren { - LivestockFarmIdMedicineFormRoute: typeof LivestockFarmIdMedicineFormRouteWithChildren - LivestockFarmIdMedicineIndexRoute: typeof LivestockFarmIdMedicineIndexRoute -} - -const LivestockFarmIdMedicineRouteRouteChildren: LivestockFarmIdMedicineRouteRouteChildren = - { - LivestockFarmIdMedicineFormRoute: - LivestockFarmIdMedicineFormRouteWithChildren, - LivestockFarmIdMedicineIndexRoute: LivestockFarmIdMedicineIndexRoute, - } - -const LivestockFarmIdMedicineRouteRouteWithChildren = - LivestockFarmIdMedicineRouteRoute._addFileChildren( - LivestockFarmIdMedicineRouteRouteChildren, - ) - -const rootRouteChildren: RootRouteChildren = { - LivestockFarmIdMedicineRouteRoute: - LivestockFarmIdMedicineRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/physical-pathless-layout-escaped-underscore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/physical-pathless-layout-escaped-underscore/routeTree.snapshot.ts deleted file mode 100644 index 7c7789143a..0000000000 --- a/packages/router-generator/tests/generator/physical-pathless-layout-escaped-underscore/routeTree.snapshot.ts +++ /dev/null @@ -1,471 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as Char91__rootIndexChar93IndexRouteImport } from './routes/[__root-index]/index' -import { Route as _layoutRouteImport } from './routes/__layout' -import { Route as Char91__literalChar93RouteImport } from './routes/[__literal]' -import { Route as FooRouteImport } from './routes/[_]foo' -import { Route as LayoutRouteImport } from './routes/_layout' -import { Route as _layoutQuxRouteImport } from './routes/__layout/[_]qux' -import { Route as LayoutChar91__doubleChar93RouteImport } from './routes/_layout/[__double]' -import { Route as Layout_nested2RouteImport } from './routes/_layout/__nested2' -import { Route as LayoutBarRouteImport } from './routes/_layout/[_]bar' -import { Route as LayoutNestedRouteImport } from './routes/_layout/_nested' -import { Route as RootIndexIndexRouteImport } from './routes/[_]root-index/index' -import { Route as LayoutChar91__doubleIndexChar93IndexRouteImport } from './routes/_layout/[__double-index]/index' -import { Route as LayoutChar91__doubleIndexChar93IdRouteImport } from './routes/_layout/[__double-index]/$id' -import { Route as Layout_nested2DeepRouteImport } from './routes/_layout/__nested2/[_]deep' -import { Route as LayoutNestedIndexIndexRouteImport } from './routes/_layout/[_]nested-index/index' -import { Route as LayoutNestedIndexIdRouteImport } from './routes/_layout/[_]nested-index/$id' -import { Route as LayoutNestedBazRouteImport } from './routes/_layout/_nested/[_]baz' -import { Route as LayoutNestedTrailingIndexRouteImport } from './routes/_layout/nested-trailing[_]/index' -import { Route as LayoutNestedDeepIndexIndexRouteImport } from './routes/_layout/_nested/[_]deep-index/index' - -const Char91__rootIndexChar93IndexRoute = - Char91__rootIndexChar93IndexRouteImport.update({ - id: '/__root-index/', - path: '/__root-index/', - getParentRoute: () => rootRouteImport, - } as any) -const _layoutRoute = _layoutRouteImport.update({ - id: '/__layout', - getParentRoute: () => rootRouteImport, -} as any) -const Char91__literalChar93Route = Char91__literalChar93RouteImport.update({ - id: '/__literal', - path: '/__literal', - getParentRoute: () => rootRouteImport, -} as any) -const FooRoute = FooRouteImport.update({ - id: '/_foo', - path: '/_foo', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutRoute = LayoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const _layoutQuxRoute = _layoutQuxRouteImport.update({ - id: '/_qux', - path: '/_qux', - getParentRoute: () => _layoutRoute, -} as any) -const LayoutChar91__doubleChar93Route = - LayoutChar91__doubleChar93RouteImport.update({ - id: '/__double', - path: '/__double', - getParentRoute: () => LayoutRoute, - } as any) -const Layout_nested2Route = Layout_nested2RouteImport.update({ - id: '/__nested2', - getParentRoute: () => LayoutRoute, -} as any) -const LayoutBarRoute = LayoutBarRouteImport.update({ - id: '/_bar', - path: '/_bar', - getParentRoute: () => LayoutRoute, -} as any) -const LayoutNestedRoute = LayoutNestedRouteImport.update({ - id: '/_nested', - getParentRoute: () => LayoutRoute, -} as any) -const RootIndexIndexRoute = RootIndexIndexRouteImport.update({ - id: '/_root-index/', - path: '/_root-index/', - getParentRoute: () => rootRouteImport, -} as any) -const LayoutChar91__doubleIndexChar93IndexRoute = - LayoutChar91__doubleIndexChar93IndexRouteImport.update({ - id: '/__double-index/', - path: '/__double-index/', - getParentRoute: () => LayoutRoute, - } as any) -const LayoutChar91__doubleIndexChar93IdRoute = - LayoutChar91__doubleIndexChar93IdRouteImport.update({ - id: '/__double-index/$id', - path: '/__double-index/$id', - getParentRoute: () => LayoutRoute, - } as any) -const Layout_nested2DeepRoute = Layout_nested2DeepRouteImport.update({ - id: '/_deep', - path: '/_deep', - getParentRoute: () => Layout_nested2Route, -} as any) -const LayoutNestedIndexIndexRoute = LayoutNestedIndexIndexRouteImport.update({ - id: '/_nested-index/', - path: '/_nested-index/', - getParentRoute: () => LayoutRoute, -} as any) -const LayoutNestedIndexIdRoute = LayoutNestedIndexIdRouteImport.update({ - id: '/_nested-index/$id', - path: '/_nested-index/$id', - getParentRoute: () => LayoutRoute, -} as any) -const LayoutNestedBazRoute = LayoutNestedBazRouteImport.update({ - id: '/_baz', - path: '/_baz', - getParentRoute: () => LayoutNestedRoute, -} as any) -const LayoutNestedTrailingIndexRoute = - LayoutNestedTrailingIndexRouteImport.update({ - id: '/nested-trailing_/', - path: '/nested-trailing_/', - getParentRoute: () => LayoutRoute, - } as any) -const LayoutNestedDeepIndexIndexRoute = - LayoutNestedDeepIndexIndexRouteImport.update({ - id: '/_deep-index/', - path: '/_deep-index/', - getParentRoute: () => LayoutNestedRoute, - } as any) - -export interface FileRoutesByFullPath { - '/': typeof LayoutNestedRouteWithChildren - '/__literal': typeof Char91__literalChar93Route - '/_foo': typeof FooRoute - '/_qux': typeof _layoutQuxRoute - '/__double': typeof LayoutChar91__doubleChar93Route - '/_bar': typeof LayoutBarRoute - '/__root-index/': typeof Char91__rootIndexChar93IndexRoute - '/_root-index/': typeof RootIndexIndexRoute - '/__double-index/$id': typeof LayoutChar91__doubleIndexChar93IdRoute - '/_deep': typeof Layout_nested2DeepRoute - '/_nested-index/$id': typeof LayoutNestedIndexIdRoute - '/_baz': typeof LayoutNestedBazRoute - '/__double-index/': typeof LayoutChar91__doubleIndexChar93IndexRoute - '/_nested-index/': typeof LayoutNestedIndexIndexRoute - '/nested-trailing_/': typeof LayoutNestedTrailingIndexRoute - '/_deep-index/': typeof LayoutNestedDeepIndexIndexRoute -} -export interface FileRoutesByTo { - '/': typeof LayoutNestedRouteWithChildren - '/__literal': typeof Char91__literalChar93Route - '/_foo': typeof FooRoute - '/_qux': typeof _layoutQuxRoute - '/__double': typeof LayoutChar91__doubleChar93Route - '/_bar': typeof LayoutBarRoute - '/__root-index': typeof Char91__rootIndexChar93IndexRoute - '/_root-index': typeof RootIndexIndexRoute - '/__double-index/$id': typeof LayoutChar91__doubleIndexChar93IdRoute - '/_deep': typeof Layout_nested2DeepRoute - '/_nested-index/$id': typeof LayoutNestedIndexIdRoute - '/_baz': typeof LayoutNestedBazRoute - '/__double-index': typeof LayoutChar91__doubleIndexChar93IndexRoute - '/_nested-index': typeof LayoutNestedIndexIndexRoute - '/nested-trailing_': typeof LayoutNestedTrailingIndexRoute - '/_deep-index': typeof LayoutNestedDeepIndexIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/__layout': typeof _layoutRouteWithChildren - '/__literal': typeof Char91__literalChar93Route - '/_foo': typeof FooRoute - '/_layout': typeof LayoutRouteWithChildren - '/__layout/_qux': typeof _layoutQuxRoute - '/_layout/__double': typeof LayoutChar91__doubleChar93Route - '/_layout/__nested2': typeof Layout_nested2RouteWithChildren - '/_layout/_bar': typeof LayoutBarRoute - '/_layout/_nested': typeof LayoutNestedRouteWithChildren - '/__root-index/': typeof Char91__rootIndexChar93IndexRoute - '/_root-index/': typeof RootIndexIndexRoute - '/_layout/__double-index/$id': typeof LayoutChar91__doubleIndexChar93IdRoute - '/_layout/__nested2/_deep': typeof Layout_nested2DeepRoute - '/_layout/_nested-index/$id': typeof LayoutNestedIndexIdRoute - '/_layout/_nested/_baz': typeof LayoutNestedBazRoute - '/_layout/__double-index/': typeof LayoutChar91__doubleIndexChar93IndexRoute - '/_layout/_nested-index/': typeof LayoutNestedIndexIndexRoute - '/_layout/nested-trailing_/': typeof LayoutNestedTrailingIndexRoute - '/_layout/_nested/_deep-index/': typeof LayoutNestedDeepIndexIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/__literal' - | '/_foo' - | '/_qux' - | '/__double' - | '/_bar' - | '/__root-index/' - | '/_root-index/' - | '/__double-index/$id' - | '/_deep' - | '/_nested-index/$id' - | '/_baz' - | '/__double-index/' - | '/_nested-index/' - | '/nested-trailing_/' - | '/_deep-index/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/__literal' - | '/_foo' - | '/_qux' - | '/__double' - | '/_bar' - | '/__root-index' - | '/_root-index' - | '/__double-index/$id' - | '/_deep' - | '/_nested-index/$id' - | '/_baz' - | '/__double-index' - | '/_nested-index' - | '/nested-trailing_' - | '/_deep-index' - id: - | '__root__' - | '/__layout' - | '/__literal' - | '/_foo' - | '/_layout' - | '/__layout/_qux' - | '/_layout/__double' - | '/_layout/__nested2' - | '/_layout/_bar' - | '/_layout/_nested' - | '/__root-index/' - | '/_root-index/' - | '/_layout/__double-index/$id' - | '/_layout/__nested2/_deep' - | '/_layout/_nested-index/$id' - | '/_layout/_nested/_baz' - | '/_layout/__double-index/' - | '/_layout/_nested-index/' - | '/_layout/nested-trailing_/' - | '/_layout/_nested/_deep-index/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - _layoutRoute: typeof _layoutRouteWithChildren - Char91__literalChar93Route: typeof Char91__literalChar93Route - FooRoute: typeof FooRoute - LayoutRoute: typeof LayoutRouteWithChildren - Char91__rootIndexChar93IndexRoute: typeof Char91__rootIndexChar93IndexRoute - RootIndexIndexRoute: typeof RootIndexIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/__root-index/': { - id: '/__root-index/' - path: '/__root-index' - fullPath: '/__root-index/' - preLoaderRoute: typeof Char91__rootIndexChar93IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/__layout': { - id: '/__layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof _layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/__literal': { - id: '/__literal' - path: '/__literal' - fullPath: '/__literal' - preLoaderRoute: typeof Char91__literalChar93RouteImport - parentRoute: typeof rootRouteImport - } - '/_foo': { - id: '/_foo' - path: '/_foo' - fullPath: '/_foo' - preLoaderRoute: typeof FooRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/__layout/_qux': { - id: '/__layout/_qux' - path: '/_qux' - fullPath: '/_qux' - preLoaderRoute: typeof _layoutQuxRouteImport - parentRoute: typeof _layoutRoute - } - '/_layout/__double': { - id: '/_layout/__double' - path: '/__double' - fullPath: '/__double' - preLoaderRoute: typeof LayoutChar91__doubleChar93RouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/__nested2': { - id: '/_layout/__nested2' - path: '' - fullPath: '/' - preLoaderRoute: typeof Layout_nested2RouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/_bar': { - id: '/_layout/_bar' - path: '/_bar' - fullPath: '/_bar' - preLoaderRoute: typeof LayoutBarRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/_nested': { - id: '/_layout/_nested' - path: '' - fullPath: '/' - preLoaderRoute: typeof LayoutNestedRouteImport - parentRoute: typeof LayoutRoute - } - '/_root-index/': { - id: '/_root-index/' - path: '/_root-index' - fullPath: '/_root-index/' - preLoaderRoute: typeof RootIndexIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/__double-index/': { - id: '/_layout/__double-index/' - path: '/__double-index' - fullPath: '/__double-index/' - preLoaderRoute: typeof LayoutChar91__doubleIndexChar93IndexRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/__double-index/$id': { - id: '/_layout/__double-index/$id' - path: '/__double-index/$id' - fullPath: '/__double-index/$id' - preLoaderRoute: typeof LayoutChar91__doubleIndexChar93IdRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/__nested2/_deep': { - id: '/_layout/__nested2/_deep' - path: '/_deep' - fullPath: '/_deep' - preLoaderRoute: typeof Layout_nested2DeepRouteImport - parentRoute: typeof Layout_nested2Route - } - '/_layout/_nested-index/': { - id: '/_layout/_nested-index/' - path: '/_nested-index' - fullPath: '/_nested-index/' - preLoaderRoute: typeof LayoutNestedIndexIndexRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/_nested-index/$id': { - id: '/_layout/_nested-index/$id' - path: '/_nested-index/$id' - fullPath: '/_nested-index/$id' - preLoaderRoute: typeof LayoutNestedIndexIdRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/_nested/_baz': { - id: '/_layout/_nested/_baz' - path: '/_baz' - fullPath: '/_baz' - preLoaderRoute: typeof LayoutNestedBazRouteImport - parentRoute: typeof LayoutNestedRoute - } - '/_layout/nested-trailing_/': { - id: '/_layout/nested-trailing_/' - path: '/nested-trailing_' - fullPath: '/nested-trailing_/' - preLoaderRoute: typeof LayoutNestedTrailingIndexRouteImport - parentRoute: typeof LayoutRoute - } - '/_layout/_nested/_deep-index/': { - id: '/_layout/_nested/_deep-index/' - path: '/_deep-index' - fullPath: '/_deep-index/' - preLoaderRoute: typeof LayoutNestedDeepIndexIndexRouteImport - parentRoute: typeof LayoutNestedRoute - } - } -} - -interface _layoutRouteChildren { - _layoutQuxRoute: typeof _layoutQuxRoute -} - -const _layoutRouteChildren: _layoutRouteChildren = { - _layoutQuxRoute: _layoutQuxRoute, -} - -const _layoutRouteWithChildren = - _layoutRoute._addFileChildren(_layoutRouteChildren) - -interface Layout_nested2RouteChildren { - Layout_nested2DeepRoute: typeof Layout_nested2DeepRoute -} - -const Layout_nested2RouteChildren: Layout_nested2RouteChildren = { - Layout_nested2DeepRoute: Layout_nested2DeepRoute, -} - -const Layout_nested2RouteWithChildren = Layout_nested2Route._addFileChildren( - Layout_nested2RouteChildren, -) - -interface LayoutNestedRouteChildren { - LayoutNestedBazRoute: typeof LayoutNestedBazRoute - LayoutNestedDeepIndexIndexRoute: typeof LayoutNestedDeepIndexIndexRoute -} - -const LayoutNestedRouteChildren: LayoutNestedRouteChildren = { - LayoutNestedBazRoute: LayoutNestedBazRoute, - LayoutNestedDeepIndexIndexRoute: LayoutNestedDeepIndexIndexRoute, -} - -const LayoutNestedRouteWithChildren = LayoutNestedRoute._addFileChildren( - LayoutNestedRouteChildren, -) - -interface LayoutRouteChildren { - LayoutChar91__doubleChar93Route: typeof LayoutChar91__doubleChar93Route - Layout_nested2Route: typeof Layout_nested2RouteWithChildren - LayoutBarRoute: typeof LayoutBarRoute - LayoutNestedRoute: typeof LayoutNestedRouteWithChildren - LayoutChar91__doubleIndexChar93IdRoute: typeof LayoutChar91__doubleIndexChar93IdRoute - LayoutNestedIndexIdRoute: typeof LayoutNestedIndexIdRoute - LayoutChar91__doubleIndexChar93IndexRoute: typeof LayoutChar91__doubleIndexChar93IndexRoute - LayoutNestedIndexIndexRoute: typeof LayoutNestedIndexIndexRoute - LayoutNestedTrailingIndexRoute: typeof LayoutNestedTrailingIndexRoute -} - -const LayoutRouteChildren: LayoutRouteChildren = { - LayoutChar91__doubleChar93Route: LayoutChar91__doubleChar93Route, - Layout_nested2Route: Layout_nested2RouteWithChildren, - LayoutBarRoute: LayoutBarRoute, - LayoutNestedRoute: LayoutNestedRouteWithChildren, - LayoutChar91__doubleIndexChar93IdRoute: - LayoutChar91__doubleIndexChar93IdRoute, - LayoutNestedIndexIdRoute: LayoutNestedIndexIdRoute, - LayoutChar91__doubleIndexChar93IndexRoute: - LayoutChar91__doubleIndexChar93IndexRoute, - LayoutNestedIndexIndexRoute: LayoutNestedIndexIndexRoute, - LayoutNestedTrailingIndexRoute: LayoutNestedTrailingIndexRoute, -} - -const LayoutRouteWithChildren = - LayoutRoute._addFileChildren(LayoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - _layoutRoute: _layoutRouteWithChildren, - Char91__literalChar93Route: Char91__literalChar93Route, - FooRoute: FooRoute, - LayoutRoute: LayoutRouteWithChildren, - Char91__rootIndexChar93IndexRoute: Char91__rootIndexChar93IndexRoute, - RootIndexIndexRoute: RootIndexIndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts b/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts deleted file mode 100644 index 2ef38f491d..0000000000 --- a/packages/router-generator/tests/generator/prefix-suffix/routeTree.snapshot.ts +++ /dev/null @@ -1,129 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as WildcardSplatRouteImport } from './routes/wildcard/$' -import { Route as WildcardPrefixChar123Char125RouteImport } from './routes/wildcard/prefix{$}' -import { Route as WildcardChar123Char125DotsuffixRouteImport } from './routes/wildcard/{$}[.]suffix' -import { Route as WildcardChar123Char125suffixRouteImport } from './routes/wildcard/{$}suffix' - -const WildcardSplatRoute = WildcardSplatRouteImport.update({ - id: '/wildcard/$', - path: '/wildcard/$', - getParentRoute: () => rootRouteImport, -} as any) -const WildcardPrefixChar123Char125Route = - WildcardPrefixChar123Char125RouteImport.update({ - id: '/wildcard/prefix{$}', - path: '/wildcard/prefix{$}', - getParentRoute: () => rootRouteImport, - } as any) -const WildcardChar123Char125DotsuffixRoute = - WildcardChar123Char125DotsuffixRouteImport.update({ - id: '/wildcard/{$}.suffix', - path: '/wildcard/{$}.suffix', - getParentRoute: () => rootRouteImport, - } as any) -const WildcardChar123Char125suffixRoute = - WildcardChar123Char125suffixRouteImport.update({ - id: '/wildcard/{$}suffix', - path: '/wildcard/{$}suffix', - getParentRoute: () => rootRouteImport, - } as any) - -export interface FileRoutesByFullPath { - '/wildcard/$': typeof WildcardSplatRoute - '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route - '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute - '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute -} -export interface FileRoutesByTo { - '/wildcard/$': typeof WildcardSplatRoute - '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route - '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute - '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/wildcard/$': typeof WildcardSplatRoute - '/wildcard/prefix{$}': typeof WildcardPrefixChar123Char125Route - '/wildcard/{$}.suffix': typeof WildcardChar123Char125DotsuffixRoute - '/wildcard/{$}suffix': typeof WildcardChar123Char125suffixRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/wildcard/$' - | '/wildcard/prefix{$}' - | '/wildcard/{$}.suffix' - | '/wildcard/{$}suffix' - fileRoutesByTo: FileRoutesByTo - to: - | '/wildcard/$' - | '/wildcard/prefix{$}' - | '/wildcard/{$}.suffix' - | '/wildcard/{$}suffix' - id: - | '__root__' - | '/wildcard/$' - | '/wildcard/prefix{$}' - | '/wildcard/{$}.suffix' - | '/wildcard/{$}suffix' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - WildcardSplatRoute: typeof WildcardSplatRoute - WildcardPrefixChar123Char125Route: typeof WildcardPrefixChar123Char125Route - WildcardChar123Char125DotsuffixRoute: typeof WildcardChar123Char125DotsuffixRoute - WildcardChar123Char125suffixRoute: typeof WildcardChar123Char125suffixRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/wildcard/$': { - id: '/wildcard/$' - path: '/wildcard/$' - fullPath: '/wildcard/$' - preLoaderRoute: typeof WildcardSplatRouteImport - parentRoute: typeof rootRouteImport - } - '/wildcard/prefix{$}': { - id: '/wildcard/prefix{$}' - path: '/wildcard/prefix{$}' - fullPath: '/wildcard/prefix{$}' - preLoaderRoute: typeof WildcardPrefixChar123Char125RouteImport - parentRoute: typeof rootRouteImport - } - '/wildcard/{$}.suffix': { - id: '/wildcard/{$}.suffix' - path: '/wildcard/{$}.suffix' - fullPath: '/wildcard/{$}.suffix' - preLoaderRoute: typeof WildcardChar123Char125DotsuffixRouteImport - parentRoute: typeof rootRouteImport - } - '/wildcard/{$}suffix': { - id: '/wildcard/{$}suffix' - path: '/wildcard/{$}suffix' - fullPath: '/wildcard/{$}suffix' - preLoaderRoute: typeof WildcardChar123Char125suffixRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - WildcardSplatRoute: WildcardSplatRoute, - WildcardPrefixChar123Char125Route: WildcardPrefixChar123Char125Route, - WildcardChar123Char125DotsuffixRoute: WildcardChar123Char125DotsuffixRoute, - WildcardChar123Char125suffixRoute: WildcardChar123Char125suffixRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/regex-tokens-inline/routeTree.snapshot.ts b/packages/router-generator/tests/generator/regex-tokens-inline/routeTree.snapshot.ts deleted file mode 100644 index 669cebaf59..0000000000 --- a/packages/router-generator/tests/generator/regex-tokens-inline/routeTree.snapshot.ts +++ /dev/null @@ -1,121 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexPageRouteImport } from './routes/index-page' -import { Route as DashboardMainLayoutRouteImport } from './routes/dashboard.main-layout' -import { Route as DashboardHomePageRouteImport } from './routes/dashboard.home-page' -import { Route as DashboardSettingsRouteImport } from './routes/dashboard.settings' - -const IndexPageRoute = IndexPageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardMainLayoutRoute = DashboardMainLayoutRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardHomePageRoute = DashboardHomePageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => DashboardMainLayoutRoute, -} as any) -const DashboardSettingsRoute = DashboardSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => DashboardMainLayoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexPageRoute - '/dashboard': typeof DashboardMainLayoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardHomePageRoute -} -export interface FileRoutesByTo { - '/': typeof IndexPageRoute - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard': typeof DashboardHomePageRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexPageRoute - '/dashboard': typeof DashboardMainLayoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardHomePageRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/dashboard/settings' | '/dashboard' - id: '__root__' | '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexPageRoute: typeof IndexPageRoute - DashboardMainLayoutRoute: typeof DashboardMainLayoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexPageRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard': { - id: '/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof DashboardMainLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard/': { - id: '/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardHomePageRouteImport - parentRoute: typeof DashboardMainLayoutRoute - } - '/dashboard/settings': { - id: '/dashboard/settings' - path: '/settings' - fullPath: '/dashboard/settings' - preLoaderRoute: typeof DashboardSettingsRouteImport - parentRoute: typeof DashboardMainLayoutRoute - } - } -} - -interface DashboardMainLayoutRouteChildren { - DashboardSettingsRoute: typeof DashboardSettingsRoute - DashboardHomePageRoute: typeof DashboardHomePageRoute -} - -const DashboardMainLayoutRouteChildren: DashboardMainLayoutRouteChildren = { - DashboardSettingsRoute: DashboardSettingsRoute, - DashboardHomePageRoute: DashboardHomePageRoute, -} - -const DashboardMainLayoutRouteWithChildren = - DashboardMainLayoutRoute._addFileChildren(DashboardMainLayoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - IndexPageRoute: IndexPageRoute, - DashboardMainLayoutRoute: DashboardMainLayoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/regex-tokens-json/routeTree.snapshot.ts b/packages/router-generator/tests/generator/regex-tokens-json/routeTree.snapshot.ts deleted file mode 100644 index 669cebaf59..0000000000 --- a/packages/router-generator/tests/generator/regex-tokens-json/routeTree.snapshot.ts +++ /dev/null @@ -1,121 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexPageRouteImport } from './routes/index-page' -import { Route as DashboardMainLayoutRouteImport } from './routes/dashboard.main-layout' -import { Route as DashboardHomePageRouteImport } from './routes/dashboard.home-page' -import { Route as DashboardSettingsRouteImport } from './routes/dashboard.settings' - -const IndexPageRoute = IndexPageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardMainLayoutRoute = DashboardMainLayoutRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardHomePageRoute = DashboardHomePageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => DashboardMainLayoutRoute, -} as any) -const DashboardSettingsRoute = DashboardSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => DashboardMainLayoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexPageRoute - '/dashboard': typeof DashboardMainLayoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardHomePageRoute -} -export interface FileRoutesByTo { - '/': typeof IndexPageRoute - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard': typeof DashboardHomePageRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexPageRoute - '/dashboard': typeof DashboardMainLayoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardHomePageRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/dashboard/settings' | '/dashboard' - id: '__root__' | '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexPageRoute: typeof IndexPageRoute - DashboardMainLayoutRoute: typeof DashboardMainLayoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexPageRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard': { - id: '/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof DashboardMainLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard/': { - id: '/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardHomePageRouteImport - parentRoute: typeof DashboardMainLayoutRoute - } - '/dashboard/settings': { - id: '/dashboard/settings' - path: '/settings' - fullPath: '/dashboard/settings' - preLoaderRoute: typeof DashboardSettingsRouteImport - parentRoute: typeof DashboardMainLayoutRoute - } - } -} - -interface DashboardMainLayoutRouteChildren { - DashboardSettingsRoute: typeof DashboardSettingsRoute - DashboardHomePageRoute: typeof DashboardHomePageRoute -} - -const DashboardMainLayoutRouteChildren: DashboardMainLayoutRouteChildren = { - DashboardSettingsRoute: DashboardSettingsRoute, - DashboardHomePageRoute: DashboardHomePageRoute, -} - -const DashboardMainLayoutRouteWithChildren = - DashboardMainLayoutRoute._addFileChildren(DashboardMainLayoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - IndexPageRoute: IndexPageRoute, - DashboardMainLayoutRoute: DashboardMainLayoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/regex-tokens-plus-json/routeTree.snapshot.ts b/packages/router-generator/tests/generator/regex-tokens-plus-json/routeTree.snapshot.ts deleted file mode 100644 index 74c38f90ad..0000000000 --- a/packages/router-generator/tests/generator/regex-tokens-plus-json/routeTree.snapshot.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as Char43pageRouteImport } from './routes/+page' -import { Route as DashboardChar43layoutRouteImport } from './routes/dashboard/+layout' -import { Route as DashboardChar43pageRouteImport } from './routes/dashboard/+page' -import { Route as DashboardSettingsRouteImport } from './routes/dashboard/settings' - -const Char43pageRoute = Char43pageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardChar43layoutRoute = DashboardChar43layoutRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => rootRouteImport, -} as any) -const DashboardChar43pageRoute = DashboardChar43pageRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => DashboardChar43layoutRoute, -} as any) -const DashboardSettingsRoute = DashboardSettingsRouteImport.update({ - id: '/settings', - path: '/settings', - getParentRoute: () => DashboardChar43layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof Char43pageRoute - '/dashboard': typeof DashboardChar43layoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardChar43pageRoute -} -export interface FileRoutesByTo { - '/': typeof Char43pageRoute - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard': typeof DashboardChar43pageRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof Char43pageRoute - '/dashboard': typeof DashboardChar43layoutRouteWithChildren - '/dashboard/settings': typeof DashboardSettingsRoute - '/dashboard/': typeof DashboardChar43pageRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/dashboard/settings' | '/dashboard' - id: '__root__' | '/' | '/dashboard' | '/dashboard/settings' | '/dashboard/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - Char43pageRoute: typeof Char43pageRoute - DashboardChar43layoutRoute: typeof DashboardChar43layoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof Char43pageRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard': { - id: '/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof DashboardChar43layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/dashboard/': { - id: '/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof DashboardChar43pageRouteImport - parentRoute: typeof DashboardChar43layoutRoute - } - '/dashboard/settings': { - id: '/dashboard/settings' - path: '/settings' - fullPath: '/dashboard/settings' - preLoaderRoute: typeof DashboardSettingsRouteImport - parentRoute: typeof DashboardChar43layoutRoute - } - } -} - -interface DashboardChar43layoutRouteChildren { - DashboardSettingsRoute: typeof DashboardSettingsRoute - DashboardChar43pageRoute: typeof DashboardChar43pageRoute -} - -const DashboardChar43layoutRouteChildren: DashboardChar43layoutRouteChildren = { - DashboardSettingsRoute: DashboardSettingsRoute, - DashboardChar43pageRoute: DashboardChar43pageRoute, -} - -const DashboardChar43layoutRouteWithChildren = - DashboardChar43layoutRoute._addFileChildren( - DashboardChar43layoutRouteChildren, - ) - -const rootRouteChildren: RootRouteChildren = { - Char43pageRoute: Char43pageRoute, - DashboardChar43layoutRoute: DashboardChar43layoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/root-export-specifier/routeTree.snapshot.ts b/packages/router-generator/tests/generator/root-export-specifier/routeTree.snapshot.ts deleted file mode 100644 index 12bc916ae4..0000000000 --- a/packages/router-generator/tests/generator/root-export-specifier/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as AboutRouteImport } from './routes/about' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const AboutRoute = AboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/about': typeof AboutRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/about': typeof AboutRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/about': typeof AboutRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/about' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/about' - id: '__root__' | '/' | '/about' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - AboutRoute: typeof AboutRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/about': { - id: '/about' - path: '/about' - fullPath: '/about' - preLoaderRoute: typeof AboutRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - AboutRoute: AboutRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts b/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts deleted file mode 100644 index d3ffbba9e2..0000000000 --- a/packages/router-generator/tests/generator/route-groups/routeTree.snapshot.ts +++ /dev/null @@ -1,268 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { createFileRoute } from '@tanstack/react-router' - -import { Route as rootRouteImport } from './routes/__root' -import { Route as barBarRouteImport } from './routes/(bar)/_bar' -import { Route as barBarHelloRouteImport } from './routes/(bar)/_bar.hello' -import { Route as fooAsdfLayoutRouteImport } from './routes/(foo)/asdf/_layout' -import { Route as fooAsdfanotherGroupLayoutRouteImport } from './routes/(foo)/asdf/(another-group)/_layout' -import { Route as fooAsdfbarIdRouteImport } from './routes/(foo)/asdf/(bar)/$id' -import { Route as fooAsdfLayoutFooRouteImport } from './routes/(foo)/asdf/_layout.foo' -import { Route as fooAsdfanotherGroupLayoutBazRouteImport } from './routes/(foo)/asdf/(another-group)/_layout.baz' -import { Route as fooAsdfbarLayoutAboutRouteImport } from './routes/(foo)/asdf/(bar)/_layout.about' - -const fooAsdfbarLayoutXyzLazyRouteImport = createFileRoute( - '/(foo)/asdf/(bar)/_layout/xyz', -)() - -const barBarRoute = barBarRouteImport.update({ - id: '/(bar)/_bar', - getParentRoute: () => rootRouteImport, -} as any) -const barBarHelloRoute = barBarHelloRouteImport.update({ - id: '/hello', - path: '/hello', - getParentRoute: () => barBarRoute, -} as any) -const fooAsdfLayoutRoute = fooAsdfLayoutRouteImport.update({ - id: '/(foo)/asdf/_layout', - path: '/asdf', - getParentRoute: () => rootRouteImport, -} as any) -const fooAsdfanotherGroupLayoutRoute = - fooAsdfanotherGroupLayoutRouteImport.update({ - id: '/(foo)/asdf/(another-group)/_layout', - path: '/asdf', - getParentRoute: () => rootRouteImport, - } as any) -const fooAsdfbarIdRoute = fooAsdfbarIdRouteImport.update({ - id: '/(foo)/asdf/(bar)/$id', - path: '/asdf/$id', - getParentRoute: () => rootRouteImport, -} as any) -const fooAsdfLayoutFooRoute = fooAsdfLayoutFooRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => fooAsdfLayoutRoute, -} as any) -const fooAsdfanotherGroupLayoutBazRoute = - fooAsdfanotherGroupLayoutBazRouteImport.update({ - id: '/baz', - path: '/baz', - getParentRoute: () => fooAsdfanotherGroupLayoutRoute, - } as any) -const fooAsdfbarLayoutAboutRoute = fooAsdfbarLayoutAboutRouteImport.update({ - id: '/(foo)/asdf/(bar)/_layout/about', - path: '/asdf/about', - getParentRoute: () => rootRouteImport, -} as any) -const fooAsdfbarLayoutXyzLazyRoute = fooAsdfbarLayoutXyzLazyRouteImport - .update({ - id: '/(foo)/asdf/(bar)/_layout/xyz', - path: '/asdf/xyz', - getParentRoute: () => rootRouteImport, - } as any) - .lazy(() => - import('./routes/(foo)/asdf/(bar)/_layout.xyz.lazy').then((d) => d.Route), - ) - -export interface FileRoutesByFullPath { - '/': typeof barBarRouteWithChildren - '/hello': typeof barBarHelloRoute - '/asdf': typeof fooAsdfanotherGroupLayoutRouteWithChildren - '/asdf/$id': typeof fooAsdfbarIdRoute - '/asdf/foo': typeof fooAsdfLayoutFooRoute - '/asdf/baz': typeof fooAsdfanotherGroupLayoutBazRoute - '/asdf/about': typeof fooAsdfbarLayoutAboutRoute - '/asdf/xyz': typeof fooAsdfbarLayoutXyzLazyRoute -} -export interface FileRoutesByTo { - '/': typeof barBarRouteWithChildren - '/hello': typeof barBarHelloRoute - '/asdf': typeof fooAsdfanotherGroupLayoutRouteWithChildren - '/asdf/$id': typeof fooAsdfbarIdRoute - '/asdf/foo': typeof fooAsdfLayoutFooRoute - '/asdf/baz': typeof fooAsdfanotherGroupLayoutBazRoute - '/asdf/about': typeof fooAsdfbarLayoutAboutRoute - '/asdf/xyz': typeof fooAsdfbarLayoutXyzLazyRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/(bar)/_bar': typeof barBarRouteWithChildren - '/(bar)/_bar/hello': typeof barBarHelloRoute - '/(foo)/asdf/_layout': typeof fooAsdfLayoutRouteWithChildren - '/(foo)/asdf/(another-group)/_layout': typeof fooAsdfanotherGroupLayoutRouteWithChildren - '/(foo)/asdf/(bar)/$id': typeof fooAsdfbarIdRoute - '/(foo)/asdf/_layout/foo': typeof fooAsdfLayoutFooRoute - '/(foo)/asdf/(another-group)/_layout/baz': typeof fooAsdfanotherGroupLayoutBazRoute - '/(foo)/asdf/(bar)/_layout/about': typeof fooAsdfbarLayoutAboutRoute - '/(foo)/asdf/(bar)/_layout/xyz': typeof fooAsdfbarLayoutXyzLazyRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/hello' - | '/asdf' - | '/asdf/$id' - | '/asdf/foo' - | '/asdf/baz' - | '/asdf/about' - | '/asdf/xyz' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/hello' - | '/asdf' - | '/asdf/$id' - | '/asdf/foo' - | '/asdf/baz' - | '/asdf/about' - | '/asdf/xyz' - id: - | '__root__' - | '/(bar)/_bar' - | '/(bar)/_bar/hello' - | '/(foo)/asdf/_layout' - | '/(foo)/asdf/(another-group)/_layout' - | '/(foo)/asdf/(bar)/$id' - | '/(foo)/asdf/_layout/foo' - | '/(foo)/asdf/(another-group)/_layout/baz' - | '/(foo)/asdf/(bar)/_layout/about' - | '/(foo)/asdf/(bar)/_layout/xyz' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - barBarRoute: typeof barBarRouteWithChildren - fooAsdfLayoutRoute: typeof fooAsdfLayoutRouteWithChildren - fooAsdfanotherGroupLayoutRoute: typeof fooAsdfanotherGroupLayoutRouteWithChildren - fooAsdfbarIdRoute: typeof fooAsdfbarIdRoute - fooAsdfbarLayoutAboutRoute: typeof fooAsdfbarLayoutAboutRoute - fooAsdfbarLayoutXyzLazyRoute: typeof fooAsdfbarLayoutXyzLazyRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/(bar)/_bar': { - id: '/(bar)/_bar' - path: '' - fullPath: '/' - preLoaderRoute: typeof barBarRouteImport - parentRoute: typeof rootRouteImport - } - '/(bar)/_bar/hello': { - id: '/(bar)/_bar/hello' - path: '/hello' - fullPath: '/hello' - preLoaderRoute: typeof barBarHelloRouteImport - parentRoute: typeof barBarRoute - } - '/(foo)/asdf/_layout': { - id: '/(foo)/asdf/_layout' - path: '/asdf' - fullPath: '/asdf' - preLoaderRoute: typeof fooAsdfLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/(foo)/asdf/(another-group)/_layout': { - id: '/(foo)/asdf/(another-group)/_layout' - path: '/asdf' - fullPath: '/asdf' - preLoaderRoute: typeof fooAsdfanotherGroupLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/(foo)/asdf/(bar)/$id': { - id: '/(foo)/asdf/(bar)/$id' - path: '/asdf/$id' - fullPath: '/asdf/$id' - preLoaderRoute: typeof fooAsdfbarIdRouteImport - parentRoute: typeof rootRouteImport - } - '/(foo)/asdf/_layout/foo': { - id: '/(foo)/asdf/_layout/foo' - path: '/foo' - fullPath: '/asdf/foo' - preLoaderRoute: typeof fooAsdfLayoutFooRouteImport - parentRoute: typeof fooAsdfLayoutRoute - } - '/(foo)/asdf/(another-group)/_layout/baz': { - id: '/(foo)/asdf/(another-group)/_layout/baz' - path: '/baz' - fullPath: '/asdf/baz' - preLoaderRoute: typeof fooAsdfanotherGroupLayoutBazRouteImport - parentRoute: typeof fooAsdfanotherGroupLayoutRoute - } - '/(foo)/asdf/(bar)/_layout/about': { - id: '/(foo)/asdf/(bar)/_layout/about' - path: '/asdf/about' - fullPath: '/asdf/about' - preLoaderRoute: typeof fooAsdfbarLayoutAboutRouteImport - parentRoute: typeof rootRouteImport - } - '/(foo)/asdf/(bar)/_layout/xyz': { - id: '/(foo)/asdf/(bar)/_layout/xyz' - path: '/asdf/xyz' - fullPath: '/asdf/xyz' - preLoaderRoute: typeof fooAsdfbarLayoutXyzLazyRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -interface barBarRouteChildren { - barBarHelloRoute: typeof barBarHelloRoute -} - -const barBarRouteChildren: barBarRouteChildren = { - barBarHelloRoute: barBarHelloRoute, -} - -const barBarRouteWithChildren = - barBarRoute._addFileChildren(barBarRouteChildren) - -interface fooAsdfLayoutRouteChildren { - fooAsdfLayoutFooRoute: typeof fooAsdfLayoutFooRoute -} - -const fooAsdfLayoutRouteChildren: fooAsdfLayoutRouteChildren = { - fooAsdfLayoutFooRoute: fooAsdfLayoutFooRoute, -} - -const fooAsdfLayoutRouteWithChildren = fooAsdfLayoutRoute._addFileChildren( - fooAsdfLayoutRouteChildren, -) - -interface fooAsdfanotherGroupLayoutRouteChildren { - fooAsdfanotherGroupLayoutBazRoute: typeof fooAsdfanotherGroupLayoutBazRoute -} - -const fooAsdfanotherGroupLayoutRouteChildren: fooAsdfanotherGroupLayoutRouteChildren = - { - fooAsdfanotherGroupLayoutBazRoute: fooAsdfanotherGroupLayoutBazRoute, - } - -const fooAsdfanotherGroupLayoutRouteWithChildren = - fooAsdfanotherGroupLayoutRoute._addFileChildren( - fooAsdfanotherGroupLayoutRouteChildren, - ) - -const rootRouteChildren: RootRouteChildren = { - barBarRoute: barBarRouteWithChildren, - fooAsdfLayoutRoute: fooAsdfLayoutRouteWithChildren, - fooAsdfanotherGroupLayoutRoute: fooAsdfanotherGroupLayoutRouteWithChildren, - fooAsdfbarIdRoute: fooAsdfbarIdRoute, - fooAsdfbarLayoutAboutRoute: fooAsdfbarLayoutAboutRoute, - fooAsdfbarLayoutXyzLazyRoute: fooAsdfbarLayoutXyzLazyRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.tsx b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.tsx new file mode 100644 index 0000000000..6062e5b242 --- /dev/null +++ b/packages/router-generator/tests/generator/route-groups/routes/(foo)/asdf/(bar)/_layout.tsx @@ -0,0 +1,9 @@ +import { Outlet, createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/(foo)/asdf/(bar)/_layout')({ + component: () => ( +
+ Hello /(foo)/asdf/(bar)/_layout! + +
+ ), +}) diff --git a/packages/router-generator/tests/generator/route-groups/routes/__root.tsx b/packages/router-generator/tests/generator/route-groups/routes/__root.tsx index ab504e42e9..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/route-groups/routes/__root.tsx +++ b/packages/router-generator/tests/generator/route-groups/routes/__root.tsx @@ -1 +1,3 @@ -/** */ +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/routeFileIgnore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/routeFileIgnore/routeTree.snapshot.ts deleted file mode 100644 index ceb6811cf7..0000000000 --- a/packages/router-generator/tests/generator/routeFileIgnore/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as BlogRouteRouteImport } from './routes/blog.route' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRouteRoute = BlogRouteRouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/blog' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/blog' - id: '__root__' | '/' | '/blog' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - BlogRouteRoute: typeof BlogRouteRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogRouteRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - BlogRouteRoute: BlogRouteRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/routeFileIgnore/routes/__root.tsx b/packages/router-generator/tests/generator/routeFileIgnore/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/routeFileIgnore/routes/__root.tsx +++ b/packages/router-generator/tests/generator/routeFileIgnore/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/routeFilePrefix/routeTree.snapshot.ts b/packages/router-generator/tests/generator/routeFilePrefix/routeTree.snapshot.ts deleted file mode 100644 index 9805633c47..0000000000 --- a/packages/router-generator/tests/generator/routeFilePrefix/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/r&__root' -import { Route as IndexRouteImport } from './routes/r&index' -import { Route as BlogRouteRouteImport } from './routes/r&blog.route' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const BlogRouteRoute = BlogRouteRouteImport.update({ - id: '/blog', - path: '/blog', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/blog': typeof BlogRouteRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/blog' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/blog' - id: '__root__' | '/' | '/blog' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - BlogRouteRoute: typeof BlogRouteRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/blog': { - id: '/blog' - path: '/blog' - fullPath: '/blog' - preLoaderRoute: typeof BlogRouteRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - BlogRouteRoute: BlogRouteRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/routeFilePrefix/routes/r&__root.tsx b/packages/router-generator/tests/generator/routeFilePrefix/routes/r&__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/routeFilePrefix/routes/r&__root.tsx +++ b/packages/router-generator/tests/generator/routeFilePrefix/routes/r&__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts b/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts deleted file mode 100644 index 12b48f052a..0000000000 --- a/packages/router-generator/tests/generator/single-level/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as PostsRouteImport } from './routes/posts' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const PostsRoute = PostsRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/posts': typeof PostsRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/posts' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/posts' - id: '__root__' | '/' | '/posts' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - PostsRoute: typeof PostsRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/posts': { - id: '/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof PostsRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - PostsRoute: PostsRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/single-level/routes/__root.tsx b/packages/router-generator/tests/generator/single-level/routes/__root.tsx index a8c4d4c893..9c657c7d5b 100644 --- a/packages/router-generator/tests/generator/single-level/routes/__root.tsx +++ b/packages/router-generator/tests/generator/single-level/routes/__root.tsx @@ -1,2 +1,3 @@ -// @ts-nocheck -export const Route = createFileRoute() +import { createRootRoute } from '@tanstack/react-router' + +export const Route = createRootRoute() diff --git a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js b/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js deleted file mode 100644 index 4dc8f12ad7..0000000000 --- a/packages/router-generator/tests/generator/types-disabled/routeTree.snapshot.js +++ /dev/null @@ -1,49 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as PostsRouteImport } from './routes/posts' -import { Route as PostsPostIdRouteImport } from './routes/posts/$postId' -import { Route as UsersUserIdRouteImport } from './routes/users.$userId' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -}) -const PostsRoute = PostsRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => rootRouteImport, -}) -const PostsPostIdRoute = PostsPostIdRouteImport.update({ - id: '/$postId', - path: '/$postId', - getParentRoute: () => PostsRoute, -}) -const UsersUserIdRoute = UsersUserIdRouteImport.update({ - id: '/users/$userId', - path: '/users/$userId', - getParentRoute: () => rootRouteImport, -}) - -const PostsRouteChildren = { - PostsPostIdRoute: PostsPostIdRoute, -} - -const PostsRouteWithChildren = PostsRoute._addFileChildren(PostsRouteChildren) - -const rootRouteChildren = { - IndexRoute: IndexRoute, - PostsRoute: PostsRouteWithChildren, - UsersUserIdRoute: UsersUserIdRoute, -} -export const routeTree = rootRouteImport._addFileChildren(rootRouteChildren) diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts deleted file mode 100644 index 6b16924d5b..0000000000 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routeTree.snapshot.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root' -import { Route as indexRouteImport } from './routes/index' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as pagesRouteImport } from './routes/pages' -import { Route as dbDashboardRouteImport } from './routes/db/dashboard' -import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' -import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' -import { Route as HelloIndexRouteImport } from './routes/subtree/index' -import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' -import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' -import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const pagesRoute = pagesRouteImport.update({ - id: '/$lang/', - path: '/$lang/', - getParentRoute: () => rootRouteImport, -} as any) -const dbDashboardRoute = dbDashboardRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => layoutRoute, -} as any) -const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardRoute, -} as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ - id: '/invoices', - path: '/invoices', - getParentRoute: () => dbDashboardRoute, -} as any) -const HelloIndexRoute = HelloIndexRouteImport.update({ - id: '/hello/', - path: '/hello/', - getParentRoute: () => layoutRoute, -} as any) -const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ - id: '/hello/foo/', - path: '/hello/foo/', - getParentRoute: () => layoutRoute, -} as any) -const HelloFooIdRoute = HelloFooIdRouteImport.update({ - id: '/hello/foo/$id', - path: '/hello/foo/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/$lang/': typeof pagesRoute - '/dashboard': typeof dbDashboardRouteWithChildren - '/dashboard/': typeof dbDashboardIndexRoute - '/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/hello/': typeof HelloIndexRoute - '/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/$lang': typeof pagesRoute - '/dashboard': typeof dbDashboardIndexRoute - '/hello': typeof HelloIndexRoute - '/dashboard/invoices': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo': typeof HelloFooIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/_layout': typeof layoutRouteWithChildren - '/$lang/': typeof pagesRoute - '/_layout/dashboard': typeof dbDashboardRouteWithChildren - '/_layout/dashboard/': typeof dbDashboardIndexRoute - '/_layout/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/_layout/hello/': typeof HelloIndexRoute - '/_layout/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/_layout/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/_layout/hello/foo/$id': typeof HelloFooIdRoute - '/_layout/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/$lang/' - | '/dashboard' - | '/dashboard/' - | '/dashboard/invoices' - | '/hello/' - | '/dashboard/invoices/' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/$lang' - | '/dashboard' - | '/hello' - | '/dashboard/invoices' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo' - id: - | '__root__' - | '/' - | '/_layout' - | '/$lang/' - | '/_layout/dashboard' - | '/_layout/dashboard/' - | '/_layout/dashboard/invoices' - | '/_layout/hello/' - | '/_layout/dashboard/invoices/' - | '/_layout/dashboard/invoices/$id' - | '/_layout/hello/foo/$id' - | '/_layout/hello/foo/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - layoutRoute: typeof layoutRouteWithChildren - pagesRoute: typeof pagesRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/$lang/': { - id: '/$lang/' - path: '/$lang' - fullPath: '/$lang/' - preLoaderRoute: typeof pagesRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/dashboard': { - id: '/_layout/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/': { - id: '/_layout/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/dashboard/invoices': { - id: '/_layout/dashboard/invoices' - path: '/invoices' - fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/hello/': { - id: '/_layout/hello/' - path: '/hello' - fullPath: '/hello/' - preLoaderRoute: typeof HelloIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/invoices/': { - id: '/_layout/dashboard/invoices/' - path: '/' - fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/dashboard/invoices/$id': { - id: '/_layout/dashboard/invoices/$id' - path: '/$id' - fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/hello/foo/': { - id: '/_layout/hello/foo/' - path: '/hello/foo' - fullPath: '/hello/foo/' - preLoaderRoute: typeof HelloFooIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/hello/foo/$id': { - id: '/_layout/hello/foo/$id' - path: '/hello/foo/$id' - fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface dbDashboardInvoicesRouteChildren { - dbInvoicesIndexRoute: typeof dbInvoicesIndexRoute - dbInvoiceDetailRoute: typeof dbInvoiceDetailRoute -} - -const dbDashboardInvoicesRouteChildren: dbDashboardInvoicesRouteChildren = { - dbInvoicesIndexRoute: dbInvoicesIndexRoute, - dbInvoiceDetailRoute: dbInvoiceDetailRoute, -} - -const dbDashboardInvoicesRouteWithChildren = - dbDashboardInvoicesRoute._addFileChildren(dbDashboardInvoicesRouteChildren) - -interface dbDashboardRouteChildren { - dbDashboardIndexRoute: typeof dbDashboardIndexRoute - dbDashboardInvoicesRoute: typeof dbDashboardInvoicesRouteWithChildren -} - -const dbDashboardRouteChildren: dbDashboardRouteChildren = { - dbDashboardIndexRoute: dbDashboardIndexRoute, - dbDashboardInvoicesRoute: dbDashboardInvoicesRouteWithChildren, -} - -const dbDashboardRouteWithChildren = dbDashboardRoute._addFileChildren( - dbDashboardRouteChildren, -) - -interface layoutRouteChildren { - dbDashboardRoute: typeof dbDashboardRouteWithChildren - HelloIndexRoute: typeof HelloIndexRoute - HelloFooIdRoute: typeof HelloFooIdRoute - HelloFooIndexRoute: typeof HelloFooIndexRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - dbDashboardRoute: dbDashboardRouteWithChildren, - HelloIndexRoute: HelloIndexRoute, - HelloFooIdRoute: HelloFooIdRoute, - HelloFooIndexRoute: HelloFooIndexRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - layoutRoute: layoutRouteWithChildren, - pagesRoute: pagesRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/root.tsx b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/root.tsx index a294139860..a6e78e4ce6 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/root.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-default-export/routes/root.tsx @@ -1,5 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' +import { createRootRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createRootRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts deleted file mode 100644 index 6b16924d5b..0000000000 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routeTree.snapshot.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root' -import { Route as indexRouteImport } from './routes/index' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as pagesRouteImport } from './routes/pages' -import { Route as dbDashboardRouteImport } from './routes/db/dashboard' -import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' -import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' -import { Route as HelloIndexRouteImport } from './routes/subtree/index' -import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' -import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' -import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const pagesRoute = pagesRouteImport.update({ - id: '/$lang/', - path: '/$lang/', - getParentRoute: () => rootRouteImport, -} as any) -const dbDashboardRoute = dbDashboardRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => layoutRoute, -} as any) -const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardRoute, -} as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ - id: '/invoices', - path: '/invoices', - getParentRoute: () => dbDashboardRoute, -} as any) -const HelloIndexRoute = HelloIndexRouteImport.update({ - id: '/hello/', - path: '/hello/', - getParentRoute: () => layoutRoute, -} as any) -const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ - id: '/hello/foo/', - path: '/hello/foo/', - getParentRoute: () => layoutRoute, -} as any) -const HelloFooIdRoute = HelloFooIdRouteImport.update({ - id: '/hello/foo/$id', - path: '/hello/foo/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/$lang/': typeof pagesRoute - '/dashboard': typeof dbDashboardRouteWithChildren - '/dashboard/': typeof dbDashboardIndexRoute - '/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/hello/': typeof HelloIndexRoute - '/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/$lang': typeof pagesRoute - '/dashboard': typeof dbDashboardIndexRoute - '/hello': typeof HelloIndexRoute - '/dashboard/invoices': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo': typeof HelloFooIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/_layout': typeof layoutRouteWithChildren - '/$lang/': typeof pagesRoute - '/_layout/dashboard': typeof dbDashboardRouteWithChildren - '/_layout/dashboard/': typeof dbDashboardIndexRoute - '/_layout/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/_layout/hello/': typeof HelloIndexRoute - '/_layout/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/_layout/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/_layout/hello/foo/$id': typeof HelloFooIdRoute - '/_layout/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/$lang/' - | '/dashboard' - | '/dashboard/' - | '/dashboard/invoices' - | '/hello/' - | '/dashboard/invoices/' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/$lang' - | '/dashboard' - | '/hello' - | '/dashboard/invoices' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo' - id: - | '__root__' - | '/' - | '/_layout' - | '/$lang/' - | '/_layout/dashboard' - | '/_layout/dashboard/' - | '/_layout/dashboard/invoices' - | '/_layout/hello/' - | '/_layout/dashboard/invoices/' - | '/_layout/dashboard/invoices/$id' - | '/_layout/hello/foo/$id' - | '/_layout/hello/foo/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - layoutRoute: typeof layoutRouteWithChildren - pagesRoute: typeof pagesRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/$lang/': { - id: '/$lang/' - path: '/$lang' - fullPath: '/$lang/' - preLoaderRoute: typeof pagesRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/dashboard': { - id: '/_layout/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/': { - id: '/_layout/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/dashboard/invoices': { - id: '/_layout/dashboard/invoices' - path: '/invoices' - fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/hello/': { - id: '/_layout/hello/' - path: '/hello' - fullPath: '/hello/' - preLoaderRoute: typeof HelloIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/invoices/': { - id: '/_layout/dashboard/invoices/' - path: '/' - fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/dashboard/invoices/$id': { - id: '/_layout/dashboard/invoices/$id' - path: '/$id' - fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/hello/foo/': { - id: '/_layout/hello/foo/' - path: '/hello/foo' - fullPath: '/hello/foo/' - preLoaderRoute: typeof HelloFooIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/hello/foo/$id': { - id: '/_layout/hello/foo/$id' - path: '/hello/foo/$id' - fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface dbDashboardInvoicesRouteChildren { - dbInvoicesIndexRoute: typeof dbInvoicesIndexRoute - dbInvoiceDetailRoute: typeof dbInvoiceDetailRoute -} - -const dbDashboardInvoicesRouteChildren: dbDashboardInvoicesRouteChildren = { - dbInvoicesIndexRoute: dbInvoicesIndexRoute, - dbInvoiceDetailRoute: dbInvoiceDetailRoute, -} - -const dbDashboardInvoicesRouteWithChildren = - dbDashboardInvoicesRoute._addFileChildren(dbDashboardInvoicesRouteChildren) - -interface dbDashboardRouteChildren { - dbDashboardIndexRoute: typeof dbDashboardIndexRoute - dbDashboardInvoicesRoute: typeof dbDashboardInvoicesRouteWithChildren -} - -const dbDashboardRouteChildren: dbDashboardRouteChildren = { - dbDashboardIndexRoute: dbDashboardIndexRoute, - dbDashboardInvoicesRoute: dbDashboardInvoicesRouteWithChildren, -} - -const dbDashboardRouteWithChildren = dbDashboardRoute._addFileChildren( - dbDashboardRouteChildren, -) - -interface layoutRouteChildren { - dbDashboardRoute: typeof dbDashboardRouteWithChildren - HelloIndexRoute: typeof HelloIndexRoute - HelloFooIdRoute: typeof HelloFooIdRoute - HelloFooIndexRoute: typeof HelloFooIndexRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - dbDashboardRoute: dbDashboardRouteWithChildren, - HelloIndexRoute: HelloIndexRoute, - HelloFooIdRoute: HelloFooIdRoute, - HelloFooIndexRoute: HelloFooIndexRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - layoutRoute: layoutRouteWithChildren, - pagesRoute: pagesRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/root.tsx b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/root.tsx index a294139860..a6e78e4ce6 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/root.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-named-export/routes/root.tsx @@ -1,5 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' +import { createRootRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createRootRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routeTree.snapshot.ts deleted file mode 100644 index 6b16924d5b..0000000000 --- a/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routeTree.snapshot.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root' -import { Route as indexRouteImport } from './routes/index' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as pagesRouteImport } from './routes/pages' -import { Route as dbDashboardRouteImport } from './routes/db/dashboard' -import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' -import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' -import { Route as HelloIndexRouteImport } from './routes/subtree/index' -import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' -import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' -import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const pagesRoute = pagesRouteImport.update({ - id: '/$lang/', - path: '/$lang/', - getParentRoute: () => rootRouteImport, -} as any) -const dbDashboardRoute = dbDashboardRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => layoutRoute, -} as any) -const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardRoute, -} as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ - id: '/invoices', - path: '/invoices', - getParentRoute: () => dbDashboardRoute, -} as any) -const HelloIndexRoute = HelloIndexRouteImport.update({ - id: '/hello/', - path: '/hello/', - getParentRoute: () => layoutRoute, -} as any) -const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ - id: '/hello/foo/', - path: '/hello/foo/', - getParentRoute: () => layoutRoute, -} as any) -const HelloFooIdRoute = HelloFooIdRouteImport.update({ - id: '/hello/foo/$id', - path: '/hello/foo/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/$lang/': typeof pagesRoute - '/dashboard': typeof dbDashboardRouteWithChildren - '/dashboard/': typeof dbDashboardIndexRoute - '/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/hello/': typeof HelloIndexRoute - '/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/$lang': typeof pagesRoute - '/dashboard': typeof dbDashboardIndexRoute - '/hello': typeof HelloIndexRoute - '/dashboard/invoices': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo': typeof HelloFooIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/_layout': typeof layoutRouteWithChildren - '/$lang/': typeof pagesRoute - '/_layout/dashboard': typeof dbDashboardRouteWithChildren - '/_layout/dashboard/': typeof dbDashboardIndexRoute - '/_layout/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/_layout/hello/': typeof HelloIndexRoute - '/_layout/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/_layout/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/_layout/hello/foo/$id': typeof HelloFooIdRoute - '/_layout/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/$lang/' - | '/dashboard' - | '/dashboard/' - | '/dashboard/invoices' - | '/hello/' - | '/dashboard/invoices/' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/$lang' - | '/dashboard' - | '/hello' - | '/dashboard/invoices' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo' - id: - | '__root__' - | '/' - | '/_layout' - | '/$lang/' - | '/_layout/dashboard' - | '/_layout/dashboard/' - | '/_layout/dashboard/invoices' - | '/_layout/hello/' - | '/_layout/dashboard/invoices/' - | '/_layout/dashboard/invoices/$id' - | '/_layout/hello/foo/$id' - | '/_layout/hello/foo/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - layoutRoute: typeof layoutRouteWithChildren - pagesRoute: typeof pagesRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/$lang/': { - id: '/$lang/' - path: '/$lang' - fullPath: '/$lang/' - preLoaderRoute: typeof pagesRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/dashboard': { - id: '/_layout/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/': { - id: '/_layout/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/dashboard/invoices': { - id: '/_layout/dashboard/invoices' - path: '/invoices' - fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/hello/': { - id: '/_layout/hello/' - path: '/hello' - fullPath: '/hello/' - preLoaderRoute: typeof HelloIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/invoices/': { - id: '/_layout/dashboard/invoices/' - path: '/' - fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/dashboard/invoices/$id': { - id: '/_layout/dashboard/invoices/$id' - path: '/$id' - fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/hello/foo/': { - id: '/_layout/hello/foo/' - path: '/hello/foo' - fullPath: '/hello/foo/' - preLoaderRoute: typeof HelloFooIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/hello/foo/$id': { - id: '/_layout/hello/foo/$id' - path: '/hello/foo/$id' - fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface dbDashboardInvoicesRouteChildren { - dbInvoicesIndexRoute: typeof dbInvoicesIndexRoute - dbInvoiceDetailRoute: typeof dbInvoiceDetailRoute -} - -const dbDashboardInvoicesRouteChildren: dbDashboardInvoicesRouteChildren = { - dbInvoicesIndexRoute: dbInvoicesIndexRoute, - dbInvoiceDetailRoute: dbInvoiceDetailRoute, -} - -const dbDashboardInvoicesRouteWithChildren = - dbDashboardInvoicesRoute._addFileChildren(dbDashboardInvoicesRouteChildren) - -interface dbDashboardRouteChildren { - dbDashboardIndexRoute: typeof dbDashboardIndexRoute - dbDashboardInvoicesRoute: typeof dbDashboardInvoicesRouteWithChildren -} - -const dbDashboardRouteChildren: dbDashboardRouteChildren = { - dbDashboardIndexRoute: dbDashboardIndexRoute, - dbDashboardInvoicesRoute: dbDashboardInvoicesRouteWithChildren, -} - -const dbDashboardRouteWithChildren = dbDashboardRoute._addFileChildren( - dbDashboardRouteChildren, -) - -interface layoutRouteChildren { - dbDashboardRoute: typeof dbDashboardRouteWithChildren - HelloIndexRoute: typeof HelloIndexRoute - HelloFooIdRoute: typeof HelloFooIdRoute - HelloFooIndexRoute: typeof HelloFooIndexRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - dbDashboardRoute: dbDashboardRouteWithChildren, - HelloIndexRoute: HelloIndexRoute, - HelloFooIdRoute: HelloFooIdRoute, - HelloFooIndexRoute: HelloFooIndexRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - layoutRoute: layoutRouteWithChildren, - pagesRoute: pagesRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routes/root.tsx b/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routes/root.tsx index a294139860..a6e78e4ce6 100644 --- a/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routes/root.tsx +++ b/packages/router-generator/tests/generator/virtual-config-file-tsconfig-paths/routes/root.tsx @@ -1,5 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' +import { createRootRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createRootRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/generator/virtual-explicit-dotted-paths/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-explicit-dotted-paths/routeTree.snapshot.ts deleted file mode 100644 index 6a5263d55b..0000000000 --- a/packages/router-generator/tests/generator/virtual-explicit-dotted-paths/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root' -import { Route as directRouteImport } from './routes/direct' -import { Route as MountedDotpathIndexRouteImport } from './routes/physical-routes/index' - -const directRoute = directRouteImport.update({ - id: '/direct.path', - path: '/direct.path', - getParentRoute: () => rootRouteImport, -} as any) -const MountedDotpathIndexRoute = MountedDotpathIndexRouteImport.update({ - id: '/mounted.path/', - path: '/mounted.path/', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/direct.path': typeof directRoute - '/mounted.path/': typeof MountedDotpathIndexRoute -} -export interface FileRoutesByTo { - '/direct.path': typeof directRoute - '/mounted.path': typeof MountedDotpathIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/direct.path': typeof directRoute - '/mounted.path/': typeof MountedDotpathIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/direct.path' | '/mounted.path/' - fileRoutesByTo: FileRoutesByTo - to: '/direct.path' | '/mounted.path' - id: '__root__' | '/direct.path' | '/mounted.path/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - directRoute: typeof directRoute - MountedDotpathIndexRoute: typeof MountedDotpathIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/direct.path': { - id: '/direct.path' - path: '/direct.path' - fullPath: '/direct.path' - preLoaderRoute: typeof directRouteImport - parentRoute: typeof rootRouteImport - } - '/mounted.path/': { - id: '/mounted.path/' - path: '/mounted.path' - fullPath: '/mounted.path/' - preLoaderRoute: typeof MountedDotpathIndexRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - directRoute: directRoute, - MountedDotpathIndexRoute: MountedDotpathIndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts deleted file mode 100644 index 37de7dc290..0000000000 --- a/packages/router-generator/tests/generator/virtual-inside-nested/routeTree.snapshot.ts +++ /dev/null @@ -1,121 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as FooBarRouteImport } from './routes/foo/bar' -import { Route as FooBarHomeRouteImport } from './routes/foo/bar/home' -import { Route as FooBarDetailsRouteImport } from './routes/foo/bar/details' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const FooBarRoute = FooBarRouteImport.update({ - id: '/foo/bar', - path: '/foo/bar', - getParentRoute: () => rootRouteImport, -} as any) -const FooBarHomeRoute = FooBarHomeRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => FooBarRoute, -} as any) -const FooBarDetailsRoute = FooBarDetailsRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => FooBarRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/foo/bar': typeof FooBarRouteWithChildren - '/foo/bar/': typeof FooBarHomeRoute - '/foo/bar/$id': typeof FooBarDetailsRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/foo/bar': typeof FooBarHomeRoute - '/foo/bar/$id': typeof FooBarDetailsRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/foo/bar': typeof FooBarRouteWithChildren - '/foo/bar/': typeof FooBarHomeRoute - '/foo/bar/$id': typeof FooBarDetailsRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/foo/bar' | '/foo/bar/' | '/foo/bar/$id' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/foo/bar' | '/foo/bar/$id' - id: '__root__' | '/' | '/foo/bar' | '/foo/bar/' | '/foo/bar/$id' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - FooBarRoute: typeof FooBarRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/foo/bar': { - id: '/foo/bar' - path: '/foo/bar' - fullPath: '/foo/bar' - preLoaderRoute: typeof FooBarRouteImport - parentRoute: typeof rootRouteImport - } - '/foo/bar/': { - id: '/foo/bar/' - path: '/' - fullPath: '/foo/bar/' - preLoaderRoute: typeof FooBarHomeRouteImport - parentRoute: typeof FooBarRoute - } - '/foo/bar/$id': { - id: '/foo/bar/$id' - path: '/$id' - fullPath: '/foo/bar/$id' - preLoaderRoute: typeof FooBarDetailsRouteImport - parentRoute: typeof FooBarRoute - } - } -} - -interface FooBarRouteChildren { - FooBarHomeRoute: typeof FooBarHomeRoute - FooBarDetailsRoute: typeof FooBarDetailsRoute -} - -const FooBarRouteChildren: FooBarRouteChildren = { - FooBarHomeRoute: FooBarHomeRoute, - FooBarDetailsRoute: FooBarDetailsRoute, -} - -const FooBarRouteWithChildren = - FooBarRoute._addFileChildren(FooBarRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - FooBarRoute: FooBarRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts deleted file mode 100644 index 340a1f0f5e..0000000000 --- a/packages/router-generator/tests/generator/virtual-inside-with-escaped-underscore/routeTree.snapshot.ts +++ /dev/null @@ -1,113 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/index' -import { Route as NestedHomeRouteImport } from './routes/nested/home' -import { Route as NestedAuthRouteImport } from './routes/nested/auth' -import { Route as NestedCallbackRouteImport } from './routes/nested/callback' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const NestedHomeRoute = NestedHomeRouteImport.update({ - id: '/nested/', - path: '/nested/', - getParentRoute: () => rootRouteImport, -} as any) -const NestedAuthRoute = NestedAuthRouteImport.update({ - id: '/nested/_auth', - path: '/nested/_auth', - getParentRoute: () => rootRouteImport, -} as any) -const NestedCallbackRoute = NestedCallbackRouteImport.update({ - id: '/nested/_callback', - path: '/nested/_callback', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/nested/': typeof NestedHomeRoute - '/nested/_auth': typeof NestedAuthRoute - '/nested/_callback': typeof NestedCallbackRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/nested': typeof NestedHomeRoute - '/nested/_auth': typeof NestedAuthRoute - '/nested/_callback': typeof NestedCallbackRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/nested/': typeof NestedHomeRoute - '/nested/_auth': typeof NestedAuthRoute - '/nested/_callback': typeof NestedCallbackRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/nested/' | '/nested/_auth' | '/nested/_callback' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/nested' | '/nested/_auth' | '/nested/_callback' - id: '__root__' | '/' | '/nested/' | '/nested/_auth' | '/nested/_callback' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - NestedHomeRoute: typeof NestedHomeRoute - NestedAuthRoute: typeof NestedAuthRoute - NestedCallbackRoute: typeof NestedCallbackRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/nested/': { - id: '/nested/' - path: '/nested' - fullPath: '/nested/' - preLoaderRoute: typeof NestedHomeRouteImport - parentRoute: typeof rootRouteImport - } - '/nested/_auth': { - id: '/nested/_auth' - path: '/nested/_auth' - fullPath: '/nested/_auth' - preLoaderRoute: typeof NestedAuthRouteImport - parentRoute: typeof rootRouteImport - } - '/nested/_callback': { - id: '/nested/_callback' - path: '/nested/_callback' - fullPath: '/nested/_callback' - preLoaderRoute: typeof NestedCallbackRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - NestedHomeRoute: NestedHomeRoute, - NestedAuthRoute: NestedAuthRoute, - NestedCallbackRoute: NestedCallbackRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-nested-layouts-with-virtual-route/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-nested-layouts-with-virtual-route/routeTree.snapshot.ts deleted file mode 100644 index f4970bd003..0000000000 --- a/packages/router-generator/tests/generator/virtual-nested-layouts-with-virtual-route/routeTree.snapshot.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as homeRouteImport } from './routes/home' -import { Route as layoutFirstLayoutRouteImport } from './routes/layout/first-layout' -import { Route as layoutSecondLayoutRouteImport } from './routes/layout/second-layout' -import { Route as aRouteImport } from './routes/a' -import { Route as bRouteImport } from './routes/b' - -const homeRoute = homeRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const layoutFirstLayoutRoute = layoutFirstLayoutRouteImport.update({ - id: '/_first', - getParentRoute: () => rootRouteImport, -} as any) -const layoutSecondLayoutRoute = layoutSecondLayoutRouteImport.update({ - id: '/_second-layout', - getParentRoute: () => layoutFirstLayoutRoute, -} as any) -const aRoute = aRouteImport.update({ - id: '/route-without-file/layout-a', - path: '/route-without-file/layout-a', - getParentRoute: () => layoutSecondLayoutRoute, -} as any) -const bRoute = bRouteImport.update({ - id: '/route-without-file/layout-b', - path: '/route-without-file/layout-b', - getParentRoute: () => layoutSecondLayoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof homeRoute - '/route-without-file/layout-a': typeof aRoute - '/route-without-file/layout-b': typeof bRoute -} -export interface FileRoutesByTo { - '/': typeof homeRoute - '/route-without-file/layout-a': typeof aRoute - '/route-without-file/layout-b': typeof bRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof homeRoute - '/_first': typeof layoutFirstLayoutRouteWithChildren - '/_first/_second-layout': typeof layoutSecondLayoutRouteWithChildren - '/_first/_second-layout/route-without-file/layout-a': typeof aRoute - '/_first/_second-layout/route-without-file/layout-b': typeof bRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - '/' | '/route-without-file/layout-a' | '/route-without-file/layout-b' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/route-without-file/layout-a' | '/route-without-file/layout-b' - id: - | '__root__' - | '/' - | '/_first' - | '/_first/_second-layout' - | '/_first/_second-layout/route-without-file/layout-a' - | '/_first/_second-layout/route-without-file/layout-b' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - homeRoute: typeof homeRoute - layoutFirstLayoutRoute: typeof layoutFirstLayoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof homeRouteImport - parentRoute: typeof rootRouteImport - } - '/_first': { - id: '/_first' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutFirstLayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_first/_second-layout': { - id: '/_first/_second-layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutSecondLayoutRouteImport - parentRoute: typeof layoutFirstLayoutRoute - } - '/_first/_second-layout/route-without-file/layout-a': { - id: '/_first/_second-layout/route-without-file/layout-a' - path: '/route-without-file/layout-a' - fullPath: '/route-without-file/layout-a' - preLoaderRoute: typeof aRouteImport - parentRoute: typeof layoutSecondLayoutRoute - } - '/_first/_second-layout/route-without-file/layout-b': { - id: '/_first/_second-layout/route-without-file/layout-b' - path: '/route-without-file/layout-b' - fullPath: '/route-without-file/layout-b' - preLoaderRoute: typeof bRouteImport - parentRoute: typeof layoutSecondLayoutRoute - } - } -} - -interface layoutSecondLayoutRouteChildren { - aRoute: typeof aRoute - bRoute: typeof bRoute -} - -const layoutSecondLayoutRouteChildren: layoutSecondLayoutRouteChildren = { - aRoute: aRoute, - bRoute: bRoute, -} - -const layoutSecondLayoutRouteWithChildren = - layoutSecondLayoutRoute._addFileChildren(layoutSecondLayoutRouteChildren) - -interface layoutFirstLayoutRouteChildren { - layoutSecondLayoutRoute: typeof layoutSecondLayoutRouteWithChildren -} - -const layoutFirstLayoutRouteChildren: layoutFirstLayoutRouteChildren = { - layoutSecondLayoutRoute: layoutSecondLayoutRouteWithChildren, -} - -const layoutFirstLayoutRouteWithChildren = - layoutFirstLayoutRoute._addFileChildren(layoutFirstLayoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - homeRoute: homeRoute, - layoutFirstLayoutRoute: layoutFirstLayoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routeTree.snapshot.ts deleted file mode 100644 index e9d9980378..0000000000 --- a/packages/router-generator/tests/generator/virtual-pathless-layout-dotted-filename/routeTree.snapshot.ts +++ /dev/null @@ -1,101 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root.route' -import { Route as indexDotrouteRouteImport } from './routes/index.route' -import { Route as pathlessDotlayoutRouteImport } from './routes/pathless.layout' -import { Route as subpathDotrouteRouteImport } from './routes/subpath.route' - -const indexDotrouteRoute = indexDotrouteRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const pathlessDotlayoutRoute = pathlessDotlayoutRouteImport.update({ - id: '/_pathless.layout', - getParentRoute: () => rootRouteImport, -} as any) -const subpathDotrouteRoute = subpathDotrouteRouteImport.update({ - id: '/subpath', - path: '/subpath', - getParentRoute: () => pathlessDotlayoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexDotrouteRoute - '/subpath': typeof subpathDotrouteRoute -} -export interface FileRoutesByTo { - '/': typeof indexDotrouteRoute - '/subpath': typeof subpathDotrouteRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexDotrouteRoute - '/_pathless.layout': typeof pathlessDotlayoutRouteWithChildren - '/_pathless.layout/subpath': typeof subpathDotrouteRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/subpath' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/subpath' - id: '__root__' | '/' | '/_pathless.layout' | '/_pathless.layout/subpath' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexDotrouteRoute: typeof indexDotrouteRoute - pathlessDotlayoutRoute: typeof pathlessDotlayoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexDotrouteRouteImport - parentRoute: typeof rootRouteImport - } - '/_pathless.layout': { - id: '/_pathless.layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof pathlessDotlayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_pathless.layout/subpath': { - id: '/_pathless.layout/subpath' - path: '/subpath' - fullPath: '/subpath' - preLoaderRoute: typeof subpathDotrouteRouteImport - parentRoute: typeof pathlessDotlayoutRoute - } - } -} - -interface pathlessDotlayoutRouteChildren { - subpathDotrouteRoute: typeof subpathDotrouteRoute -} - -const pathlessDotlayoutRouteChildren: pathlessDotlayoutRouteChildren = { - subpathDotrouteRoute: subpathDotrouteRoute, -} - -const pathlessDotlayoutRouteWithChildren = - pathlessDotlayoutRoute._addFileChildren(pathlessDotlayoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - indexDotrouteRoute: indexDotrouteRoute, - pathlessDotlayoutRoute: pathlessDotlayoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-pathless-layout-escaped-underscore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-pathless-layout-escaped-underscore/routeTree.snapshot.ts deleted file mode 100644 index ec20742d1e..0000000000 --- a/packages/router-generator/tests/generator/virtual-pathless-layout-escaped-underscore/routeTree.snapshot.ts +++ /dev/null @@ -1,480 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as doubleRouteImport } from './routes/double' -import { Route as escapedRouteImport } from './routes/escaped' -import { Route as fooRouteImport } from './routes/foo' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as doubleBarRouteImport } from './routes/double-bar' -import { Route as barRouteImport } from './routes/bar' -import { Route as escapedBarRouteImport } from './routes/escaped-bar' -import { Route as innerLayoutRouteImport } from './routes/inner-layout' -import { Route as nestedLayoutRouteImport } from './routes/nested-layout' -import { Route as rootIndexRouteImport } from './routes/root-index' -import { Route as rootIdRouteImport } from './routes/root-id' -import { Route as doubleIndexRouteImport } from './routes/double-index' -import { Route as doubleIdRouteImport } from './routes/double-id' -import { Route as escapedIndexRouteImport } from './routes/escaped-index' -import { Route as escapedIdRouteImport } from './routes/escaped-id' -import { Route as nestedIndexRouteImport } from './routes/nested-index' -import { Route as nestedIdRouteImport } from './routes/nested-id' -import { Route as bazRouteImport } from './routes/baz' -import { Route as trailIndexRouteImport } from './routes/trail-index' -import { Route as deepIndexRouteImport } from './routes/deep-index' - -const doubleRoute = doubleRouteImport.update({ - id: '/__double', - path: '/__double', - getParentRoute: () => rootRouteImport, -} as any) -const escapedRoute = escapedRouteImport.update({ - id: '/_escaped', - path: '/_escaped', - getParentRoute: () => rootRouteImport, -} as any) -const fooRoute = fooRouteImport.update({ - id: '/_foo', - path: '/_foo', - getParentRoute: () => rootRouteImport, -} as any) -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const doubleBarRoute = doubleBarRouteImport.update({ - id: '/__double-bar', - path: '/__double-bar', - getParentRoute: () => layoutRoute, -} as any) -const barRoute = barRouteImport.update({ - id: '/_bar', - path: '/_bar', - getParentRoute: () => layoutRoute, -} as any) -const escapedBarRoute = escapedBarRouteImport.update({ - id: '/_escaped-bar', - path: '/_escaped-bar', - getParentRoute: () => layoutRoute, -} as any) -const innerLayoutRoute = innerLayoutRouteImport.update({ - id: '/_inner', - getParentRoute: () => layoutRoute, -} as any) -const nestedLayoutRoute = nestedLayoutRouteImport.update({ - id: '/_nested', - getParentRoute: () => layoutRoute, -} as any) -const rootIndexRoute = rootIndexRouteImport.update({ - id: '/_root-index/', - path: '/_root-index/', - getParentRoute: () => rootRouteImport, -} as any) -const rootIdRoute = rootIdRouteImport.update({ - id: '/_root-index/$id', - path: '/_root-index/$id', - getParentRoute: () => rootRouteImport, -} as any) -const doubleIndexRoute = doubleIndexRouteImport.update({ - id: '/__double-index/', - path: '/__double-index/', - getParentRoute: () => layoutRoute, -} as any) -const doubleIdRoute = doubleIdRouteImport.update({ - id: '/__double-index/$id', - path: '/__double-index/$id', - getParentRoute: () => layoutRoute, -} as any) -const escapedIndexRoute = escapedIndexRouteImport.update({ - id: '/_escaped-index/', - path: '/_escaped-index/', - getParentRoute: () => layoutRoute, -} as any) -const escapedIdRoute = escapedIdRouteImport.update({ - id: '/_escaped-index/$id', - path: '/_escaped-index/$id', - getParentRoute: () => layoutRoute, -} as any) -const nestedIndexRoute = nestedIndexRouteImport.update({ - id: '/_nested-index/', - path: '/_nested-index/', - getParentRoute: () => layoutRoute, -} as any) -const nestedIdRoute = nestedIdRouteImport.update({ - id: '/_nested-index/$id', - path: '/_nested-index/$id', - getParentRoute: () => layoutRoute, -} as any) -const bazRoute = bazRouteImport.update({ - id: '/_baz', - path: '/_baz', - getParentRoute: () => nestedLayoutRoute, -} as any) -const trailIndexRoute = trailIndexRouteImport.update({ - id: '/trail_/', - path: '/trail_/', - getParentRoute: () => layoutRoute, -} as any) -const deepIndexRoute = deepIndexRouteImport.update({ - id: '/_deep-index/', - path: '/_deep-index/', - getParentRoute: () => innerLayoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/__double': typeof doubleRoute - '/_escaped': typeof escapedRoute - '/_foo': typeof fooRoute - '/': typeof nestedLayoutRouteWithChildren - '/_root-index/': typeof rootIndexRoute - '/__double-bar': typeof doubleBarRoute - '/_bar': typeof barRoute - '/_escaped-bar': typeof escapedBarRoute - '/_root-index/$id': typeof rootIdRoute - '/__double-index/': typeof doubleIndexRoute - '/_escaped-index/': typeof escapedIndexRoute - '/_nested-index/': typeof nestedIndexRoute - '/trail_/': typeof trailIndexRoute - '/__double-index/$id': typeof doubleIdRoute - '/_escaped-index/$id': typeof escapedIdRoute - '/_nested-index/$id': typeof nestedIdRoute - '/_baz': typeof bazRoute - '/_deep-index/': typeof deepIndexRoute -} -export interface FileRoutesByTo { - '/__double': typeof doubleRoute - '/_escaped': typeof escapedRoute - '/_foo': typeof fooRoute - '/': typeof nestedLayoutRouteWithChildren - '/_root-index': typeof rootIndexRoute - '/__double-bar': typeof doubleBarRoute - '/_bar': typeof barRoute - '/_escaped-bar': typeof escapedBarRoute - '/_root-index/$id': typeof rootIdRoute - '/__double-index': typeof doubleIndexRoute - '/_escaped-index': typeof escapedIndexRoute - '/_nested-index': typeof nestedIndexRoute - '/trail_': typeof trailIndexRoute - '/__double-index/$id': typeof doubleIdRoute - '/_escaped-index/$id': typeof escapedIdRoute - '/_nested-index/$id': typeof nestedIdRoute - '/_baz': typeof bazRoute - '/_deep-index': typeof deepIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/__double': typeof doubleRoute - '/_escaped': typeof escapedRoute - '/_foo': typeof fooRoute - '/_layout': typeof layoutRouteWithChildren - '/_root-index/': typeof rootIndexRoute - '/_layout/__double-bar': typeof doubleBarRoute - '/_layout/_bar': typeof barRoute - '/_layout/_escaped-bar': typeof escapedBarRoute - '/_layout/_inner': typeof innerLayoutRouteWithChildren - '/_layout/_nested': typeof nestedLayoutRouteWithChildren - '/_root-index/$id': typeof rootIdRoute - '/_layout/__double-index/': typeof doubleIndexRoute - '/_layout/_escaped-index/': typeof escapedIndexRoute - '/_layout/_nested-index/': typeof nestedIndexRoute - '/_layout/trail_/': typeof trailIndexRoute - '/_layout/__double-index/$id': typeof doubleIdRoute - '/_layout/_escaped-index/$id': typeof escapedIdRoute - '/_layout/_nested-index/$id': typeof nestedIdRoute - '/_layout/_nested/_baz': typeof bazRoute - '/_layout/_inner/_deep-index/': typeof deepIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/__double' - | '/_escaped' - | '/_foo' - | '/' - | '/_root-index/' - | '/__double-bar' - | '/_bar' - | '/_escaped-bar' - | '/_root-index/$id' - | '/__double-index/' - | '/_escaped-index/' - | '/_nested-index/' - | '/trail_/' - | '/__double-index/$id' - | '/_escaped-index/$id' - | '/_nested-index/$id' - | '/_baz' - | '/_deep-index/' - fileRoutesByTo: FileRoutesByTo - to: - | '/__double' - | '/_escaped' - | '/_foo' - | '/' - | '/_root-index' - | '/__double-bar' - | '/_bar' - | '/_escaped-bar' - | '/_root-index/$id' - | '/__double-index' - | '/_escaped-index' - | '/_nested-index' - | '/trail_' - | '/__double-index/$id' - | '/_escaped-index/$id' - | '/_nested-index/$id' - | '/_baz' - | '/_deep-index' - id: - | '__root__' - | '/__double' - | '/_escaped' - | '/_foo' - | '/_layout' - | '/_root-index/' - | '/_layout/__double-bar' - | '/_layout/_bar' - | '/_layout/_escaped-bar' - | '/_layout/_inner' - | '/_layout/_nested' - | '/_root-index/$id' - | '/_layout/__double-index/' - | '/_layout/_escaped-index/' - | '/_layout/_nested-index/' - | '/_layout/trail_/' - | '/_layout/__double-index/$id' - | '/_layout/_escaped-index/$id' - | '/_layout/_nested-index/$id' - | '/_layout/_nested/_baz' - | '/_layout/_inner/_deep-index/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - doubleRoute: typeof doubleRoute - escapedRoute: typeof escapedRoute - fooRoute: typeof fooRoute - layoutRoute: typeof layoutRouteWithChildren - rootIndexRoute: typeof rootIndexRoute - rootIdRoute: typeof rootIdRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/__double': { - id: '/__double' - path: '/__double' - fullPath: '/__double' - preLoaderRoute: typeof doubleRouteImport - parentRoute: typeof rootRouteImport - } - '/_escaped': { - id: '/_escaped' - path: '/_escaped' - fullPath: '/_escaped' - preLoaderRoute: typeof escapedRouteImport - parentRoute: typeof rootRouteImport - } - '/_foo': { - id: '/_foo' - path: '/_foo' - fullPath: '/_foo' - preLoaderRoute: typeof fooRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/__double-bar': { - id: '/_layout/__double-bar' - path: '/__double-bar' - fullPath: '/__double-bar' - preLoaderRoute: typeof doubleBarRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_bar': { - id: '/_layout/_bar' - path: '/_bar' - fullPath: '/_bar' - preLoaderRoute: typeof barRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_escaped-bar': { - id: '/_layout/_escaped-bar' - path: '/_escaped-bar' - fullPath: '/_escaped-bar' - preLoaderRoute: typeof escapedBarRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_inner': { - id: '/_layout/_inner' - path: '' - fullPath: '/' - preLoaderRoute: typeof innerLayoutRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_nested': { - id: '/_layout/_nested' - path: '' - fullPath: '/' - preLoaderRoute: typeof nestedLayoutRouteImport - parentRoute: typeof layoutRoute - } - '/_root-index/': { - id: '/_root-index/' - path: '/_root-index' - fullPath: '/_root-index/' - preLoaderRoute: typeof rootIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_root-index/$id': { - id: '/_root-index/$id' - path: '/_root-index/$id' - fullPath: '/_root-index/$id' - preLoaderRoute: typeof rootIdRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/__double-index/': { - id: '/_layout/__double-index/' - path: '/__double-index' - fullPath: '/__double-index/' - preLoaderRoute: typeof doubleIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/__double-index/$id': { - id: '/_layout/__double-index/$id' - path: '/__double-index/$id' - fullPath: '/__double-index/$id' - preLoaderRoute: typeof doubleIdRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_escaped-index/': { - id: '/_layout/_escaped-index/' - path: '/_escaped-index' - fullPath: '/_escaped-index/' - preLoaderRoute: typeof escapedIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_escaped-index/$id': { - id: '/_layout/_escaped-index/$id' - path: '/_escaped-index/$id' - fullPath: '/_escaped-index/$id' - preLoaderRoute: typeof escapedIdRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_nested-index/': { - id: '/_layout/_nested-index/' - path: '/_nested-index' - fullPath: '/_nested-index/' - preLoaderRoute: typeof nestedIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_nested-index/$id': { - id: '/_layout/_nested-index/$id' - path: '/_nested-index/$id' - fullPath: '/_nested-index/$id' - preLoaderRoute: typeof nestedIdRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_nested/_baz': { - id: '/_layout/_nested/_baz' - path: '/_baz' - fullPath: '/_baz' - preLoaderRoute: typeof bazRouteImport - parentRoute: typeof nestedLayoutRoute - } - '/_layout/trail_/': { - id: '/_layout/trail_/' - path: '/trail_' - fullPath: '/trail_/' - preLoaderRoute: typeof trailIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_inner/_deep-index/': { - id: '/_layout/_inner/_deep-index/' - path: '/_deep-index' - fullPath: '/_deep-index/' - preLoaderRoute: typeof deepIndexRouteImport - parentRoute: typeof innerLayoutRoute - } - } -} - -interface innerLayoutRouteChildren { - deepIndexRoute: typeof deepIndexRoute -} - -const innerLayoutRouteChildren: innerLayoutRouteChildren = { - deepIndexRoute: deepIndexRoute, -} - -const innerLayoutRouteWithChildren = innerLayoutRoute._addFileChildren( - innerLayoutRouteChildren, -) - -interface nestedLayoutRouteChildren { - bazRoute: typeof bazRoute -} - -const nestedLayoutRouteChildren: nestedLayoutRouteChildren = { - bazRoute: bazRoute, -} - -const nestedLayoutRouteWithChildren = nestedLayoutRoute._addFileChildren( - nestedLayoutRouteChildren, -) - -interface layoutRouteChildren { - doubleBarRoute: typeof doubleBarRoute - barRoute: typeof barRoute - escapedBarRoute: typeof escapedBarRoute - innerLayoutRoute: typeof innerLayoutRouteWithChildren - nestedLayoutRoute: typeof nestedLayoutRouteWithChildren - doubleIndexRoute: typeof doubleIndexRoute - escapedIndexRoute: typeof escapedIndexRoute - nestedIndexRoute: typeof nestedIndexRoute - trailIndexRoute: typeof trailIndexRoute - doubleIdRoute: typeof doubleIdRoute - escapedIdRoute: typeof escapedIdRoute - nestedIdRoute: typeof nestedIdRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - doubleBarRoute: doubleBarRoute, - barRoute: barRoute, - escapedBarRoute: escapedBarRoute, - innerLayoutRoute: innerLayoutRouteWithChildren, - nestedLayoutRoute: nestedLayoutRouteWithChildren, - doubleIndexRoute: doubleIndexRoute, - escapedIndexRoute: escapedIndexRoute, - nestedIndexRoute: nestedIndexRoute, - trailIndexRoute: trailIndexRoute, - doubleIdRoute: doubleIdRoute, - escapedIdRoute: escapedIdRoute, - nestedIdRoute: nestedIdRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - doubleRoute: doubleRoute, - escapedRoute: escapedRoute, - fooRoute: fooRoute, - layoutRoute: layoutRouteWithChildren, - rootIndexRoute: rootIndexRoute, - rootIdRoute: rootIdRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes.ts b/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes.ts deleted file mode 100644 index c2b6660fc3..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { physical, rootRoute } from '@tanstack/virtual-file-routes' - -// This test verifies that a __root.tsx in a physical directory mounted at root -// produces a proper conflict error with the virtual root -export const routes = rootRoute('__root.tsx', [physical('', 'merged')]) diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/__root.tsx b/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/__root.tsx deleted file mode 100644 index f463b796b4..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/__root.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createRootRoute, Outlet } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: () => , -}) diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/index.tsx b/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/index.tsx deleted file mode 100644 index bad00da72c..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/index.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: () =>
Index
, -}) diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/route.tsx b/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/route.tsx deleted file mode 100644 index a164afcb81..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/routes/merged/route.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' - -// This route.tsx in a physical directory mounted at root level -// conflicts with the virtual root __root.tsx - can't have two root routes -export const Route = createFileRoute('')({}) diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/tsr.config.json b/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/tsr.config.json deleted file mode 100644 index 4d587108e3..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-conflict-root/tsr.config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "routesDirectory": "./routes", - "generatedRouteTree": "./routeTree.gen.ts", - "virtualRouteConfig": "./routes.ts" -} diff --git a/packages/router-generator/tests/generator/virtual-physical-empty-path-merge/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-empty-path-merge/routeTree.snapshot.ts deleted file mode 100644 index eeb3c71359..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-empty-path-merge/routeTree.snapshot.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/merged/index' -import { Route as aboutRouteImport } from './routes/about' -import { Route as ContactRouteImport } from './routes/merged/contact' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const aboutRoute = aboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => rootRouteImport, -} as any) -const ContactRoute = ContactRouteImport.update({ - id: '/contact', - path: '/contact', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/about' | '/contact' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/about' | '/contact' - id: '__root__' | '/' | '/about' | '/contact' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - aboutRoute: typeof aboutRoute - ContactRoute: typeof ContactRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/about': { - id: '/about' - path: '/about' - fullPath: '/about' - preLoaderRoute: typeof aboutRouteImport - parentRoute: typeof rootRouteImport - } - '/contact': { - id: '/contact' - path: '/contact' - fullPath: '/contact' - preLoaderRoute: typeof ContactRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - aboutRoute: aboutRoute, - ContactRoute: ContactRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-inside-nested/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-inside-nested/routeTree.snapshot.ts deleted file mode 100644 index 94d84fb790..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-inside-nested/routeTree.snapshot.ts +++ /dev/null @@ -1,134 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as indexRouteImport } from './routes/index' -import { Route as S1LayoutRouteImport } from './subtree/routes/_layout' -import { Route as S1DotDotFooRoutesRouteRouteImport } from './subtree/foo/routes/route' -import { Route as S1DotDotFooRoutesIndexRouteImport } from './subtree/foo/routes/index' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const S1LayoutRoute = S1LayoutRouteImport.update({ - id: '/s1/_layout', - path: '/s1', - getParentRoute: () => rootRouteImport, -} as any) -const S1DotDotFooRoutesRouteRoute = S1DotDotFooRoutesRouteRouteImport.update({ - id: '/foo', - path: '/foo', - getParentRoute: () => S1LayoutRoute, -} as any) -const S1DotDotFooRoutesIndexRoute = S1DotDotFooRoutesIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => S1DotDotFooRoutesRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/s1': typeof S1LayoutRouteWithChildren - '/s1/foo': typeof S1DotDotFooRoutesRouteRouteWithChildren - '/s1/foo/': typeof S1DotDotFooRoutesIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/s1': typeof S1LayoutRouteWithChildren - '/s1/foo': typeof S1DotDotFooRoutesIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/s1/_layout': typeof S1LayoutRouteWithChildren - '/s1/_layout/foo': typeof S1DotDotFooRoutesRouteRouteWithChildren - '/s1/_layout/foo/': typeof S1DotDotFooRoutesIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/s1' | '/s1/foo' | '/s1/foo/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/s1' | '/s1/foo' - id: '__root__' | '/' | '/s1/_layout' | '/s1/_layout/foo' | '/s1/_layout/foo/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - S1LayoutRoute: typeof S1LayoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/s1/_layout': { - id: '/s1/_layout' - path: '/s1' - fullPath: '/s1' - preLoaderRoute: typeof S1LayoutRouteImport - parentRoute: typeof rootRouteImport - } - '/s1/_layout/foo': { - id: '/s1/_layout/foo' - path: '/foo' - fullPath: '/s1/foo' - preLoaderRoute: typeof S1DotDotFooRoutesRouteRouteImport - parentRoute: typeof S1LayoutRoute - } - '/s1/_layout/foo/': { - id: '/s1/_layout/foo/' - path: '/' - fullPath: '/s1/foo/' - preLoaderRoute: typeof S1DotDotFooRoutesIndexRouteImport - parentRoute: typeof S1DotDotFooRoutesRouteRoute - } - } -} - -interface S1DotDotFooRoutesRouteRouteChildren { - S1DotDotFooRoutesIndexRoute: typeof S1DotDotFooRoutesIndexRoute -} - -const S1DotDotFooRoutesRouteRouteChildren: S1DotDotFooRoutesRouteRouteChildren = - { - S1DotDotFooRoutesIndexRoute: S1DotDotFooRoutesIndexRoute, - } - -const S1DotDotFooRoutesRouteRouteWithChildren = - S1DotDotFooRoutesRouteRoute._addFileChildren( - S1DotDotFooRoutesRouteRouteChildren, - ) - -interface S1LayoutRouteChildren { - S1DotDotFooRoutesRouteRoute: typeof S1DotDotFooRoutesRouteRouteWithChildren -} - -const S1LayoutRouteChildren: S1LayoutRouteChildren = { - S1DotDotFooRoutesRouteRoute: S1DotDotFooRoutesRouteRouteWithChildren, -} - -const S1LayoutRouteWithChildren = S1LayoutRoute._addFileChildren( - S1LayoutRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - S1LayoutRoute: S1LayoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.ts deleted file mode 100644 index e8cddcbc9c..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-layout-and-index/routeTree.snapshot.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as indexRouteImport } from './routes/index' -import { Route as FeatureRouteRouteImport } from './routes/feature/route' -import { Route as FeatureIndexRouteImport } from './routes/feature/index' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const FeatureRouteRoute = FeatureRouteRouteImport.update({ - id: '/feature', - path: '/feature', - getParentRoute: () => rootRouteImport, -} as any) -const FeatureIndexRoute = FeatureIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => FeatureRouteRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/feature': typeof FeatureRouteRouteWithChildren - '/feature/': typeof FeatureIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/feature': typeof FeatureIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/feature': typeof FeatureRouteRouteWithChildren - '/feature/': typeof FeatureIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/feature' | '/feature/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/feature' - id: '__root__' | '/' | '/feature' | '/feature/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - FeatureRouteRoute: typeof FeatureRouteRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/feature': { - id: '/feature' - path: '/feature' - fullPath: '/feature' - preLoaderRoute: typeof FeatureRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/feature/': { - id: '/feature/' - path: '/' - fullPath: '/feature/' - preLoaderRoute: typeof FeatureIndexRouteImport - parentRoute: typeof FeatureRouteRoute - } - } -} - -interface FeatureRouteRouteChildren { - FeatureIndexRoute: typeof FeatureIndexRoute -} - -const FeatureRouteRouteChildren: FeatureRouteRouteChildren = { - FeatureIndexRoute: FeatureIndexRoute, -} - -const FeatureRouteRouteWithChildren = FeatureRouteRoute._addFileChildren( - FeatureRouteRouteChildren, -) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - FeatureRouteRoute: FeatureRouteRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-no-prefix/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-no-prefix/routeTree.snapshot.ts deleted file mode 100644 index eeb3c71359..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-no-prefix/routeTree.snapshot.ts +++ /dev/null @@ -1,95 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as IndexRouteImport } from './routes/merged/index' -import { Route as aboutRouteImport } from './routes/about' -import { Route as ContactRouteImport } from './routes/merged/contact' - -const IndexRoute = IndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const aboutRoute = aboutRouteImport.update({ - id: '/about', - path: '/about', - getParentRoute: () => rootRouteImport, -} as any) -const ContactRoute = ContactRouteImport.update({ - id: '/contact', - path: '/contact', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRoutesByTo { - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof IndexRoute - '/about': typeof aboutRoute - '/contact': typeof ContactRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/about' | '/contact' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/about' | '/contact' - id: '__root__' | '/' | '/about' | '/contact' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - IndexRoute: typeof IndexRoute - aboutRoute: typeof aboutRoute - ContactRoute: typeof ContactRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof IndexRouteImport - parentRoute: typeof rootRouteImport - } - '/about': { - id: '/about' - path: '/about' - fullPath: '/about' - preLoaderRoute: typeof aboutRouteImport - parentRoute: typeof rootRouteImport - } - '/contact': { - id: '/contact' - path: '/contact' - fullPath: '/contact' - preLoaderRoute: typeof ContactRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - IndexRoute: IndexRoute, - aboutRoute: aboutRoute, - ContactRoute: ContactRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-pathless-layout-literal-index/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-pathless-layout-literal-index/routeTree.snapshot.ts deleted file mode 100644 index b0fd76d1ef..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-pathless-layout-literal-index/routeTree.snapshot.ts +++ /dev/null @@ -1,104 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as Char91_Char93nestedIndexRouteImport } from './routes/physical-routes/[_]nested/index' -import { Route as Char91_Char93nestedIdRouteImport } from './routes/physical-routes/[_]nested/$id' - -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const Char91_Char93nestedIndexRoute = - Char91_Char93nestedIndexRouteImport.update({ - id: '/_nested/', - path: '/_nested/', - getParentRoute: () => layoutRoute, - } as any) -const Char91_Char93nestedIdRoute = Char91_Char93nestedIdRouteImport.update({ - id: '/_nested/$id', - path: '/_nested/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof layoutRouteWithChildren - '/_nested/$id': typeof Char91_Char93nestedIdRoute - '/_nested/': typeof Char91_Char93nestedIndexRoute -} -export interface FileRoutesByTo { - '/': typeof layoutRouteWithChildren - '/_nested/$id': typeof Char91_Char93nestedIdRoute - '/_nested': typeof Char91_Char93nestedIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/_layout': typeof layoutRouteWithChildren - '/_layout/_nested/$id': typeof Char91_Char93nestedIdRoute - '/_layout/_nested/': typeof Char91_Char93nestedIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/_nested/$id' | '/_nested/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/_nested/$id' | '/_nested' - id: '__root__' | '/_layout' | '/_layout/_nested/$id' | '/_layout/_nested/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - layoutRoute: typeof layoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/_nested/': { - id: '/_layout/_nested/' - path: '/_nested' - fullPath: '/_nested/' - preLoaderRoute: typeof Char91_Char93nestedIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/_nested/$id': { - id: '/_layout/_nested/$id' - path: '/_nested/$id' - fullPath: '/_nested/$id' - preLoaderRoute: typeof Char91_Char93nestedIdRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface layoutRouteChildren { - Char91_Char93nestedIdRoute: typeof Char91_Char93nestedIdRoute - Char91_Char93nestedIndexRoute: typeof Char91_Char93nestedIndexRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - Char91_Char93nestedIdRoute: Char91_Char93nestedIdRoute, - Char91_Char93nestedIndexRoute: Char91_Char93nestedIndexRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - layoutRoute: layoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-physical-prefix-escaped-underscore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-physical-prefix-escaped-underscore/routeTree.snapshot.ts deleted file mode 100644 index 63b1df0f40..0000000000 --- a/packages/router-generator/tests/generator/virtual-physical-prefix-escaped-underscore/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as ApiIndexRouteImport } from './routes/physical-routes/index' -import { Route as ApiIdRouteImport } from './routes/physical-routes/$id' - -const ApiIndexRoute = ApiIndexRouteImport.update({ - id: '/_api/', - path: '/_api/', - getParentRoute: () => rootRouteImport, -} as any) -const ApiIdRoute = ApiIdRouteImport.update({ - id: '/_api/$id', - path: '/_api/$id', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/_api/$id': typeof ApiIdRoute - '/_api/': typeof ApiIndexRoute -} -export interface FileRoutesByTo { - '/_api/$id': typeof ApiIdRoute - '/_api': typeof ApiIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/_api/$id': typeof ApiIdRoute - '/_api/': typeof ApiIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/_api/$id' | '/_api/' - fileRoutesByTo: FileRoutesByTo - to: '/_api/$id' | '/_api' - id: '__root__' | '/_api/$id' | '/_api/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - ApiIdRoute: typeof ApiIdRoute - ApiIndexRoute: typeof ApiIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_api/': { - id: '/_api/' - path: '/_api' - fullPath: '/_api/' - preLoaderRoute: typeof ApiIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_api/$id': { - id: '/_api/$id' - path: '/_api/$id' - fullPath: '/_api/$id' - preLoaderRoute: typeof ApiIdRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - ApiIdRoute: ApiIdRoute, - ApiIndexRoute: ApiIndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-root-sibling-routes/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-root-sibling-routes/routeTree.snapshot.ts deleted file mode 100644 index f1022cabc7..0000000000 --- a/packages/router-generator/tests/generator/virtual-root-sibling-routes/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as deviceRouteRouteImport } from './routes/device/route' -import { Route as historyRouteRouteImport } from './routes/history/route' - -const deviceRouteRoute = deviceRouteRouteImport.update({ - id: '/device/$id', - path: '/device/$id', - getParentRoute: () => rootRouteImport, -} as any) -const historyRouteRoute = historyRouteRouteImport.update({ - id: '/device/$id/history/$filename', - path: '/device/$id/history/$filename', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/device/$id': typeof deviceRouteRoute - '/device/$id/history/$filename': typeof historyRouteRoute -} -export interface FileRoutesByTo { - '/device/$id': typeof deviceRouteRoute - '/device/$id/history/$filename': typeof historyRouteRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/device/$id': typeof deviceRouteRoute - '/device/$id/history/$filename': typeof historyRouteRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/device/$id' | '/device/$id/history/$filename' - fileRoutesByTo: FileRoutesByTo - to: '/device/$id' | '/device/$id/history/$filename' - id: '__root__' | '/device/$id' | '/device/$id/history/$filename' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - deviceRouteRoute: typeof deviceRouteRoute - historyRouteRoute: typeof historyRouteRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/device/$id': { - id: '/device/$id' - path: '/device/$id' - fullPath: '/device/$id' - preLoaderRoute: typeof deviceRouteRouteImport - parentRoute: typeof rootRouteImport - } - '/device/$id/history/$filename': { - id: '/device/$id/history/$filename' - path: '/device/$id/history/$filename' - fullPath: '/device/$id/history/$filename' - preLoaderRoute: typeof historyRouteRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - deviceRouteRoute: deviceRouteRoute, - historyRouteRoute: historyRouteRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-sibling-routes/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-sibling-routes/routeTree.snapshot.ts deleted file mode 100644 index 8bd4dede1e..0000000000 --- a/packages/router-generator/tests/generator/virtual-sibling-routes/routeTree.snapshot.ts +++ /dev/null @@ -1,103 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as postsRouteImport } from './routes/posts' -import { Route as postDetailRouteImport } from './routes/post-detail' - -const layoutRoute = layoutRouteImport.update({ - id: '/_main', - getParentRoute: () => rootRouteImport, -} as any) -const postsRoute = postsRouteImport.update({ - id: '/posts', - path: '/posts', - getParentRoute: () => layoutRoute, -} as any) -const postDetailRoute = postDetailRouteImport.update({ - id: '/posts/$id', - path: '/posts/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof layoutRouteWithChildren - '/posts': typeof postsRoute - '/posts/$id': typeof postDetailRoute -} -export interface FileRoutesByTo { - '/': typeof layoutRouteWithChildren - '/posts': typeof postsRoute - '/posts/$id': typeof postDetailRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/_main': typeof layoutRouteWithChildren - '/_main/posts': typeof postsRoute - '/_main/posts/$id': typeof postDetailRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/posts' | '/posts/$id' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/posts' | '/posts/$id' - id: '__root__' | '/_main' | '/_main/posts' | '/_main/posts/$id' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - layoutRoute: typeof layoutRouteWithChildren -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_main': { - id: '/_main' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/_main/posts': { - id: '/_main/posts' - path: '/posts' - fullPath: '/posts' - preLoaderRoute: typeof postsRouteImport - parentRoute: typeof layoutRoute - } - '/_main/posts/$id': { - id: '/_main/posts/$id' - path: '/posts/$id' - fullPath: '/posts/$id' - preLoaderRoute: typeof postDetailRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface layoutRouteChildren { - postsRoute: typeof postsRoute - postDetailRoute: typeof postDetailRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - postsRoute: postsRoute, - postDetailRoute: postDetailRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - layoutRoute: layoutRouteWithChildren, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-subtree-in-escaped-physical-directory/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-subtree-in-escaped-physical-directory/routeTree.snapshot.ts deleted file mode 100644 index bb8b39ad4a..0000000000 --- a/packages/router-generator/tests/generator/virtual-subtree-in-escaped-physical-directory/routeTree.snapshot.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as AreaIndexRouteImport } from './routes/[_]area/index' -import { Route as AreaChildRouteImport } from './routes/[_]area/child' - -const AreaIndexRoute = AreaIndexRouteImport.update({ - id: '/_area/', - path: '/_area/', - getParentRoute: () => rootRouteImport, -} as any) -const AreaChildRoute = AreaChildRouteImport.update({ - id: '/_area/child', - path: '/_area/child', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/_area/child': typeof AreaChildRoute - '/_area/': typeof AreaIndexRoute -} -export interface FileRoutesByTo { - '/_area/child': typeof AreaChildRoute - '/_area': typeof AreaIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/_area/child': typeof AreaChildRoute - '/_area/': typeof AreaIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/_area/child' | '/_area/' - fileRoutesByTo: FileRoutesByTo - to: '/_area/child' | '/_area' - id: '__root__' | '/_area/child' | '/_area/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - AreaChildRoute: typeof AreaChildRoute - AreaIndexRoute: typeof AreaIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/_area/': { - id: '/_area/' - path: '/_area' - fullPath: '/_area/' - preLoaderRoute: typeof AreaIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/_area/child': { - id: '/_area/child' - path: '/_area/child' - fullPath: '/_area/child' - preLoaderRoute: typeof AreaChildRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - AreaChildRoute: AreaChildRoute, - AreaIndexRoute: AreaIndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts deleted file mode 100644 index 18d7439610..0000000000 --- a/packages/router-generator/tests/generator/virtual-with-escaped-underscore/routeTree.snapshot.ts +++ /dev/null @@ -1,114 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/__root' -import { Route as indexRouteImport } from './routes/index' -import { Route as ApiIndexRouteImport } from './routes/physical-routes/index' -import { Route as ApiChar91_Char93authDotrouteRouteImport } from './routes/physical-routes/[_]auth.route' -import { Route as ApiChar91_Char93helloRouteImport } from './routes/physical-routes/[_]hello' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const ApiIndexRoute = ApiIndexRouteImport.update({ - id: '/api/', - path: '/api/', - getParentRoute: () => rootRouteImport, -} as any) -const ApiChar91_Char93authDotrouteRoute = - ApiChar91_Char93authDotrouteRouteImport.update({ - id: '/api/_auth', - path: '/api/_auth', - getParentRoute: () => rootRouteImport, - } as any) -const ApiChar91_Char93helloRoute = ApiChar91_Char93helloRouteImport.update({ - id: '/api/_hello', - path: '/api/_hello', - getParentRoute: () => rootRouteImport, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/api/_auth': typeof ApiChar91_Char93authDotrouteRoute - '/api/_hello': typeof ApiChar91_Char93helloRoute - '/api/': typeof ApiIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/api/_auth': typeof ApiChar91_Char93authDotrouteRoute - '/api/_hello': typeof ApiChar91_Char93helloRoute - '/api': typeof ApiIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/api/_auth': typeof ApiChar91_Char93authDotrouteRoute - '/api/_hello': typeof ApiChar91_Char93helloRoute - '/api/': typeof ApiIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: '/' | '/api/_auth' | '/api/_hello' | '/api/' - fileRoutesByTo: FileRoutesByTo - to: '/' | '/api/_auth' | '/api/_hello' | '/api' - id: '__root__' | '/' | '/api/_auth' | '/api/_hello' | '/api/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - ApiChar91_Char93authDotrouteRoute: typeof ApiChar91_Char93authDotrouteRoute - ApiChar91_Char93helloRoute: typeof ApiChar91_Char93helloRoute - ApiIndexRoute: typeof ApiIndexRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/api/': { - id: '/api/' - path: '/api' - fullPath: '/api/' - preLoaderRoute: typeof ApiIndexRouteImport - parentRoute: typeof rootRouteImport - } - '/api/_auth': { - id: '/api/_auth' - path: '/api/_auth' - fullPath: '/api/_auth' - preLoaderRoute: typeof ApiChar91_Char93authDotrouteRouteImport - parentRoute: typeof rootRouteImport - } - '/api/_hello': { - id: '/api/_hello' - path: '/api/_hello' - fullPath: '/api/_hello' - preLoaderRoute: typeof ApiChar91_Char93helloRouteImport - parentRoute: typeof rootRouteImport - } - } -} - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - ApiChar91_Char93authDotrouteRoute: ApiChar91_Char93authDotrouteRoute, - ApiChar91_Char93helloRoute: ApiChar91_Char93helloRoute, - ApiIndexRoute: ApiIndexRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts b/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts deleted file mode 100644 index 6b16924d5b..0000000000 --- a/packages/router-generator/tests/generator/virtual/routeTree.snapshot.ts +++ /dev/null @@ -1,292 +0,0 @@ -/* eslint-disable */ - -// @ts-nocheck - -// noinspection JSUnusedGlobalSymbols - -// This file was automatically generated by TanStack Router. -// You should NOT make any changes in this file as it will be overwritten. -// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified. - -import { Route as rootRouteImport } from './routes/root' -import { Route as indexRouteImport } from './routes/index' -import { Route as layoutRouteImport } from './routes/layout' -import { Route as pagesRouteImport } from './routes/pages' -import { Route as dbDashboardRouteImport } from './routes/db/dashboard' -import { Route as dbDashboardIndexRouteImport } from './routes/db/dashboard-index' -import { Route as dbDashboardInvoicesRouteImport } from './routes/db/dashboard-invoices' -import { Route as HelloIndexRouteImport } from './routes/subtree/index' -import { Route as dbInvoicesIndexRouteImport } from './routes/db/invoices-index' -import { Route as dbInvoiceDetailRouteImport } from './routes/db/invoice-detail' -import { Route as HelloFooIndexRouteImport } from './routes/subtree/foo/index' -import { Route as HelloFooIdRouteImport } from './routes/subtree/foo/$id' - -const indexRoute = indexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => rootRouteImport, -} as any) -const layoutRoute = layoutRouteImport.update({ - id: '/_layout', - getParentRoute: () => rootRouteImport, -} as any) -const pagesRoute = pagesRouteImport.update({ - id: '/$lang/', - path: '/$lang/', - getParentRoute: () => rootRouteImport, -} as any) -const dbDashboardRoute = dbDashboardRouteImport.update({ - id: '/dashboard', - path: '/dashboard', - getParentRoute: () => layoutRoute, -} as any) -const dbDashboardIndexRoute = dbDashboardIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardRoute, -} as any) -const dbDashboardInvoicesRoute = dbDashboardInvoicesRouteImport.update({ - id: '/invoices', - path: '/invoices', - getParentRoute: () => dbDashboardRoute, -} as any) -const HelloIndexRoute = HelloIndexRouteImport.update({ - id: '/hello/', - path: '/hello/', - getParentRoute: () => layoutRoute, -} as any) -const dbInvoicesIndexRoute = dbInvoicesIndexRouteImport.update({ - id: '/', - path: '/', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const dbInvoiceDetailRoute = dbInvoiceDetailRouteImport.update({ - id: '/$id', - path: '/$id', - getParentRoute: () => dbDashboardInvoicesRoute, -} as any) -const HelloFooIndexRoute = HelloFooIndexRouteImport.update({ - id: '/hello/foo/', - path: '/hello/foo/', - getParentRoute: () => layoutRoute, -} as any) -const HelloFooIdRoute = HelloFooIdRouteImport.update({ - id: '/hello/foo/$id', - path: '/hello/foo/$id', - getParentRoute: () => layoutRoute, -} as any) - -export interface FileRoutesByFullPath { - '/': typeof indexRoute - '/$lang/': typeof pagesRoute - '/dashboard': typeof dbDashboardRouteWithChildren - '/dashboard/': typeof dbDashboardIndexRoute - '/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/hello/': typeof HelloIndexRoute - '/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRoutesByTo { - '/': typeof indexRoute - '/$lang': typeof pagesRoute - '/dashboard': typeof dbDashboardIndexRoute - '/hello': typeof HelloIndexRoute - '/dashboard/invoices': typeof dbInvoicesIndexRoute - '/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/hello/foo/$id': typeof HelloFooIdRoute - '/hello/foo': typeof HelloFooIndexRoute -} -export interface FileRoutesById { - __root__: typeof rootRouteImport - '/': typeof indexRoute - '/_layout': typeof layoutRouteWithChildren - '/$lang/': typeof pagesRoute - '/_layout/dashboard': typeof dbDashboardRouteWithChildren - '/_layout/dashboard/': typeof dbDashboardIndexRoute - '/_layout/dashboard/invoices': typeof dbDashboardInvoicesRouteWithChildren - '/_layout/hello/': typeof HelloIndexRoute - '/_layout/dashboard/invoices/': typeof dbInvoicesIndexRoute - '/_layout/dashboard/invoices/$id': typeof dbInvoiceDetailRoute - '/_layout/hello/foo/$id': typeof HelloFooIdRoute - '/_layout/hello/foo/': typeof HelloFooIndexRoute -} -export interface FileRouteTypes { - fileRoutesByFullPath: FileRoutesByFullPath - fullPaths: - | '/' - | '/$lang/' - | '/dashboard' - | '/dashboard/' - | '/dashboard/invoices' - | '/hello/' - | '/dashboard/invoices/' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo/' - fileRoutesByTo: FileRoutesByTo - to: - | '/' - | '/$lang' - | '/dashboard' - | '/hello' - | '/dashboard/invoices' - | '/dashboard/invoices/$id' - | '/hello/foo/$id' - | '/hello/foo' - id: - | '__root__' - | '/' - | '/_layout' - | '/$lang/' - | '/_layout/dashboard' - | '/_layout/dashboard/' - | '/_layout/dashboard/invoices' - | '/_layout/hello/' - | '/_layout/dashboard/invoices/' - | '/_layout/dashboard/invoices/$id' - | '/_layout/hello/foo/$id' - | '/_layout/hello/foo/' - fileRoutesById: FileRoutesById -} -export interface RootRouteChildren { - indexRoute: typeof indexRoute - layoutRoute: typeof layoutRouteWithChildren - pagesRoute: typeof pagesRoute -} - -declare module '@tanstack/react-router' { - interface FileRoutesByPath { - '/': { - id: '/' - path: '/' - fullPath: '/' - preLoaderRoute: typeof indexRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout': { - id: '/_layout' - path: '' - fullPath: '/' - preLoaderRoute: typeof layoutRouteImport - parentRoute: typeof rootRouteImport - } - '/$lang/': { - id: '/$lang/' - path: '/$lang' - fullPath: '/$lang/' - preLoaderRoute: typeof pagesRouteImport - parentRoute: typeof rootRouteImport - } - '/_layout/dashboard': { - id: '/_layout/dashboard' - path: '/dashboard' - fullPath: '/dashboard' - preLoaderRoute: typeof dbDashboardRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/': { - id: '/_layout/dashboard/' - path: '/' - fullPath: '/dashboard/' - preLoaderRoute: typeof dbDashboardIndexRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/dashboard/invoices': { - id: '/_layout/dashboard/invoices' - path: '/invoices' - fullPath: '/dashboard/invoices' - preLoaderRoute: typeof dbDashboardInvoicesRouteImport - parentRoute: typeof dbDashboardRoute - } - '/_layout/hello/': { - id: '/_layout/hello/' - path: '/hello' - fullPath: '/hello/' - preLoaderRoute: typeof HelloIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/dashboard/invoices/': { - id: '/_layout/dashboard/invoices/' - path: '/' - fullPath: '/dashboard/invoices/' - preLoaderRoute: typeof dbInvoicesIndexRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/dashboard/invoices/$id': { - id: '/_layout/dashboard/invoices/$id' - path: '/$id' - fullPath: '/dashboard/invoices/$id' - preLoaderRoute: typeof dbInvoiceDetailRouteImport - parentRoute: typeof dbDashboardInvoicesRoute - } - '/_layout/hello/foo/': { - id: '/_layout/hello/foo/' - path: '/hello/foo' - fullPath: '/hello/foo/' - preLoaderRoute: typeof HelloFooIndexRouteImport - parentRoute: typeof layoutRoute - } - '/_layout/hello/foo/$id': { - id: '/_layout/hello/foo/$id' - path: '/hello/foo/$id' - fullPath: '/hello/foo/$id' - preLoaderRoute: typeof HelloFooIdRouteImport - parentRoute: typeof layoutRoute - } - } -} - -interface dbDashboardInvoicesRouteChildren { - dbInvoicesIndexRoute: typeof dbInvoicesIndexRoute - dbInvoiceDetailRoute: typeof dbInvoiceDetailRoute -} - -const dbDashboardInvoicesRouteChildren: dbDashboardInvoicesRouteChildren = { - dbInvoicesIndexRoute: dbInvoicesIndexRoute, - dbInvoiceDetailRoute: dbInvoiceDetailRoute, -} - -const dbDashboardInvoicesRouteWithChildren = - dbDashboardInvoicesRoute._addFileChildren(dbDashboardInvoicesRouteChildren) - -interface dbDashboardRouteChildren { - dbDashboardIndexRoute: typeof dbDashboardIndexRoute - dbDashboardInvoicesRoute: typeof dbDashboardInvoicesRouteWithChildren -} - -const dbDashboardRouteChildren: dbDashboardRouteChildren = { - dbDashboardIndexRoute: dbDashboardIndexRoute, - dbDashboardInvoicesRoute: dbDashboardInvoicesRouteWithChildren, -} - -const dbDashboardRouteWithChildren = dbDashboardRoute._addFileChildren( - dbDashboardRouteChildren, -) - -interface layoutRouteChildren { - dbDashboardRoute: typeof dbDashboardRouteWithChildren - HelloIndexRoute: typeof HelloIndexRoute - HelloFooIdRoute: typeof HelloFooIdRoute - HelloFooIndexRoute: typeof HelloFooIndexRoute -} - -const layoutRouteChildren: layoutRouteChildren = { - dbDashboardRoute: dbDashboardRouteWithChildren, - HelloIndexRoute: HelloIndexRoute, - HelloFooIdRoute: HelloFooIdRoute, - HelloFooIndexRoute: HelloFooIndexRoute, -} - -const layoutRouteWithChildren = - layoutRoute._addFileChildren(layoutRouteChildren) - -const rootRouteChildren: RootRouteChildren = { - indexRoute: indexRoute, - layoutRoute: layoutRouteWithChildren, - pagesRoute: pagesRoute, -} -export const routeTree = rootRouteImport - ._addFileChildren(rootRouteChildren) - ._addFileTypes() diff --git a/packages/router-generator/tests/generator/virtual/routes/root.tsx b/packages/router-generator/tests/generator/virtual/routes/root.tsx index a294139860..a6e78e4ce6 100644 --- a/packages/router-generator/tests/generator/virtual/routes/root.tsx +++ b/packages/router-generator/tests/generator/virtual/routes/root.tsx @@ -1,5 +1,5 @@ -import { createFileRoute } from '@tanstack/react-router' +import { createRootRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ +export const Route = createRootRoute({ component: () =>
Hello !
, }) diff --git a/packages/router-generator/tests/integration/fixture-types-nested.test.ts b/packages/router-generator/tests/integration/fixture-types-nested.test.ts new file mode 100644 index 0000000000..82d8bec9c1 --- /dev/null +++ b/packages/router-generator/tests/integration/fixture-types-nested.test.ts @@ -0,0 +1,24 @@ +/** + * The type tests of the `nested` fixture (`generator/nested/tests.test-d.ts`, + * SPEC J1.13): what its route tree types for links, navigation, redirects + * and hooks of the real router, and the file route types router-core infers + * from the tree. Checked by the real TypeScript compiler on a copy of the + * fixture, where the tree is generated. + */ +import path from 'node:path' +import { expect, test } from 'vitest' +import { Generator } from '../../src' +import { copyFixture, fixtureConfig } from '../generator-fixture' +import { typeErrorsOfModules } from '../type-check' + +test('the "nested" route tree types the router APIs of its type tests', async () => { + const dir = await copyFixture('nested') + // (temporary files on the copy's filesystem) + const config = { + ...fixtureConfig('nested', dir), + tmpDir: path.join(dir, 'tmp'), + } + await new Generator({ config, root: dir }).run() + const typeTests = path.join(dir, 'tests.test-d.ts') + expect(typeErrorsOfModules([typeTests]).get(typeTests)).toEqual([]) +}) diff --git a/packages/router-generator/tests/integration/fixture-types-physical.test.ts b/packages/router-generator/tests/integration/fixture-types-physical.test.ts new file mode 100644 index 0000000000..c97ca8ff33 --- /dev/null +++ b/packages/router-generator/tests/integration/fixture-types-physical.test.ts @@ -0,0 +1,40 @@ +/** + * The types of the route trees of the generator fixtures without a virtual + * route config agree with the router (SPEC J1.13; helper and method: + * fixture-types.ts). + */ +import { describe, expect, test } from 'vitest' +import { + knownTypeBugs, + typeErrorsOfFixture, + typedFixtureNames, +} from './fixture-types' + +const names = (await typedFixtureNames()).filter( + (name) => !name.startsWith('virtual'), +) + +describe('the types of the generator fixtures without a virtual route config', () => { + test.each(names)( + 'the "%s" route tree types its routes like the router', + async (name) => { + expect(await typeErrorsOfFixture(name)).toEqual([]) + }, + ) + + // Bug: a pathless layout in a route group directory + // (`(group-a)/_layout-a.tsx`, `(bar)/_bar.tsx`) is typed with + // `fullPath: ''` while the router gives it `/` (the same bug as the + // group layout pin of route-types.test.ts, `(marketing)/route.tsx`). + // Source: src/utils.ts:929-950 (`inferFullPath`: `/(group-a)/_layout-a` + // without its layout segment and group is `/`, which is no index path, so + // its trailing slash is dropped). + // Impact: `Route.fullPath` and the types derived from it (`from` of links + // and hooks) say `''` in such a layout while the app sees `/`. + test.fails.each([...knownTypeBugs])( + 'the "%s" route tree types its routes like the router', + async (name) => { + expect(await typeErrorsOfFixture(name)).toEqual([]) + }, + ) +}) diff --git a/packages/router-generator/tests/integration/fixture-types-virtual.test.ts b/packages/router-generator/tests/integration/fixture-types-virtual.test.ts new file mode 100644 index 0000000000..d7a6bf4cd3 --- /dev/null +++ b/packages/router-generator/tests/integration/fixture-types-virtual.test.ts @@ -0,0 +1,20 @@ +/** + * The types of the route trees of the generator fixtures with a virtual + * route config (`virtual*`) agree with the router (SPEC J1.13; helper and + * method: fixture-types.ts). + */ +import { describe, expect, test } from 'vitest' +import { typeErrorsOfFixture, typedFixtureNames } from './fixture-types' + +const names = (await typedFixtureNames()).filter((name) => + name.startsWith('virtual'), +) + +describe('the types of the generator fixtures with a virtual route config', () => { + test.each(names)( + 'the "%s" route tree types its routes like the router', + async (name) => { + expect(await typeErrorsOfFixture(name)).toEqual([]) + }, + ) +}) diff --git a/packages/router-generator/tests/integration/fixture-types.ts b/packages/router-generator/tests/integration/fixture-types.ts new file mode 100644 index 0000000000..c837365599 --- /dev/null +++ b/packages/router-generator/tests/integration/fixture-types.ts @@ -0,0 +1,70 @@ +/** + * Shared test helper of fixture-types-*.test.ts: the types of the generator + * fixtures' route trees (SPEC J1.13). With types enabled, each tree types + * the routes of generator-fixtures.ts (the routes the real router builds + * from it, generator.test.ts) alike: the same route ids, and for each route + * the same full path and parent. Checked by the real TypeScript compiler + * with the real router types, on a copy of the fixture. + * + * Slow tier: each tree augments the router's types globally + * (`declare module '@tanstack/react-router'`), so each needs a program of + * its own (about 0.2 s each); the fixtures are split over two files. + */ +import fs from 'node:fs/promises' +import path from 'node:path' +import { Generator } from '../../src' +import { + conflictingFiles, + copyFixture, + fixtureConfig, + fixtureNames, + prepareFixture, +} from '../generator-fixture' +import { fixtureRoutes } from '../generator-fixtures' +import { routeTypeChecks } from '../real-router' +import { typeErrorsOfModules } from '../type-check' + +/** + * Generates the fixture `name` in a copy and returns the type errors of a + * module asserting that its tree types the fixture's routes. + */ +export async function typeErrorsOfFixture(name: string) { + const dir = await copyFixture(name) + // (temporary files on the copy's filesystem) + const config = { ...fixtureConfig(name, dir), tmpDir: path.join(dir, 'tmp') } + await prepareFixture(name, dir) + await new Generator({ config, root: dir }).run() + const checks = path.join(dir, 'route-checks.ts') + await fs.writeFile( + checks, + routeTypeChecks( + `./${path.relative(dir, config.generatedRouteTree).replace(/\.ts$/, '')}`, + fixtureRoutes[name]!, + ), + ) + // (the checks compare string literal types only: no DOM types needed, + // which halves the time of a program) + return typeErrorsOfModules([checks], ['lib.es2022.d.ts']).get(checks) +} + +/** + * Fixtures whose tree types a route otherwise than the router: the bug, + * pinned in fixture-types-physical.test.ts. + */ +export const knownTypeBugs = new Set([ + 'nested-route-groups-with-layouts-before-physical', + 'route-groups', +]) + +/** + * The fixtures with types to check (no conflicting routes, types enabled) + * and without a known types bug. + */ +export async function typedFixtureNames() { + return (await fixtureNames()).filter( + (name) => + !conflictingFiles(name) && + !fixtureConfig(name).disableTypes && + !knownTypeBugs.has(name), + ) +} diff --git a/packages/router-generator/tests/integration/real-router-browser.test.ts b/packages/router-generator/tests/integration/real-router-browser.test.ts new file mode 100644 index 0000000000..126cbfda54 --- /dev/null +++ b/packages/router-generator/tests/integration/real-router-browser.test.ts @@ -0,0 +1,30 @@ +/** Generated trees consumed by the real routers and renderers in Chromium. */ +import { test } from 'vitest' +import { checkApp } from '../real-router' +import { frameworkCases, groupLayout, shapeCases } from '../real-router-cases' +import type { Case } from '../real-router' + +const nativeAsyncVue: Case = { + name: 'a Vue route using the framework async-component API', + config: { target: 'vue' }, + files: { + 'src/routes/__root.ts': `import { h } from 'vue' +import { createRootRoute, Outlet } from '@tanstack/vue-router' +export const Route = createRootRoute({ component: () => h(Outlet) })`, + 'src/routes/index.ts': `import { defineAsyncComponent } from 'vue' +import { createFileRoute } from '@tanstack/vue-router' +export const Route = createFileRoute('/')({ + component: defineAsyncComponent(() => import('./-native-page.vue')), +})`, + 'src/routes/-native-page.vue': + '', + }, + expected: { __root__: ['/', null], '/': ['/', '__root__'] }, + visits: { '/': '/' }, + pages: { '/': ['native async page'] }, +} + +test.each([...frameworkCases, ...shapeCases, groupLayout, nativeAsyncVue])( + 'the browser renders $name', + (testCase) => checkApp(testCase, { types: false, client: true }), +) diff --git a/packages/router-generator/tests/integration/route-types.test.ts b/packages/router-generator/tests/integration/route-types.test.ts new file mode 100644 index 0000000000..87ab762aa0 --- /dev/null +++ b/packages/router-generator/tests/integration/route-types.test.ts @@ -0,0 +1,126 @@ +/** + * The types of generated route trees (SPEC J1.13), checked by the real + * TypeScript compiler with the real router types: the trees of the apps of + * real-router-cases.ts type the routes the real router builds from them + * (real-router.test.ts, real-router-frameworks.test.ts) alike, and `to` and + * full paths stand for the right routes. Slow tier: one TypeScript program + * per app (each tree augments the router's types globally). + */ +import { describe, expect, test } from 'vitest' +import { + createApp, + fileRoute, + generate, + lazyFileRoute, + rootRoute, +} from '../app' +import { checkApp } from '../real-router' +import { frameworkCases, groupLayout, shapeCases } from '../real-router-cases' +import { typeAssertions, typeErrorsOf } from '../type-check' + +/** An app with a root route and a route file for each of `files`. */ +async function appWithRoutes(files: Array) { + const routeFiles: Record = { + 'src/routes/__root.tsx': rootRoute(), + } + for (const file of files) { + routeFiles[`src/routes/${file}`] = fileRoute('/wrong') + } + return createApp(routeFiles) +} + +describe('route tree types agree with the router', () => { + test.each( + [...shapeCases, ...frameworkCases].filter( + (testCase) => testCase.types !== false, + ), + )('$name', (testCase) => checkApp(testCase, { runtime: false }), 60_000) + + // Bug: the route tree types the layout route of a route group directory + // (`(marketing)/route.tsx`) with `fullPath: ''` in `FileRoutesByPath`, + // while the router gives it the full path `/` (real-router.test.ts, "the + // layout route of a route group directory adds no path segment"; a + // pathless layout, `_auth.tsx`, is typed `/`, and agrees). + // Source: src/utils.ts:929-950 (`inferFullPath`: `/(marketing)` without + // its group is `/`, which is not an index path, so its trailing slash is + // dropped), printed at src/utils.ts:1260. + // Impact: `Route.fullPath` and the types derived from it (`from` of + // links and hooks) say `''` in such a layout while the app sees `/`. + test.fails( + 'the layout route of a route group directory has the full path of the router in the types', + () => checkApp(groupLayout, { runtime: false }), + 60_000, + ) +}) + +// The route tree's types, checked by the real TypeScript compiler with the +// real router types: the whole app type-checks, and a `to` or full path +// stands for the right route (its `id`). +describe('FileRoutesByTo', () => { + test('`to` of an index route is the index route, not a route under pathless layouts with the same path', async () => { + const root = await appWithRoutes([ + 'posts/index.tsx', + '_a.tsx', + '_a/_b.tsx', + '_a/_b/posts.tsx', + ]) + await generate(root) + + expect( + await typeErrorsOf( + root, + 'src/checks.ts', + `import type { FileRoutesByTo } from './routeTree.gen' +${typeAssertions} +export type Check = Expect> +`, + ), + ).toEqual([]) + }, 30_000) + + test('`to` of a route is the route, not its own pathless layout', async () => { + const root = await appWithRoutes([ + 'foo.tsx', + 'foo/_auth.tsx', + 'foo/_auth/bar.tsx', + ]) + await generate(root) + + expect( + await typeErrorsOf( + root, + 'src/checks.ts', + `import type { FileRoutesByTo } from './routeTree.gen' +${typeAssertions} +export type Check = Expect> +`, + ), + ).toEqual([]) + }, 30_000) +}) + +// (Through the router's public lookup by full path on `typeof routeTree`; +// the tree's own type names are free.) +describe('routes by full path', () => { + test('the full path `/` is the index route, not a pathless layout with only a lazy file', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/index.tsx': fileRoute('/'), + 'src/routes/_auth.lazy.tsx': lazyFileRoute('/_auth'), + 'src/routes/_auth/login.tsx': fileRoute('/_auth/login'), + }) + await generate(root) + + expect( + await typeErrorsOf( + root, + 'src/checks.ts', + `import type { RouteByPath } from '@tanstack/router-core' +import type { routeTree } from './routeTree.gen' +${typeAssertions} +export type Check = Expect['id'], '/'>> +`, + ), + ).toEqual([]) + }, 30_000) +}) diff --git a/packages/router-generator/tests/known-bugs.test.ts b/packages/router-generator/tests/known-bugs.test.ts new file mode 100644 index 0000000000..31ef71eb15 --- /dev/null +++ b/packages/router-generator/tests/known-bugs.test.ts @@ -0,0 +1,147 @@ +/** + * Known route generator bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ +import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { parseSync } from 'vite' +import { describe, expect, test } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { Generator, getConfig } from '../src' +import { recordDirectoryInputs } from './consumer-inputs' +import { routeIdOf } from './route-id' +import { routesOf } from './route-tree' + +/** + * Runs the generator on an app with a root route and `routes/moved.tsx` + * holding `source`, like after moving a route file to `/moved`. Returns the + * route file as the generator wrote it, the routes of the route tree (route + * id to file) and the warnings. + */ +async function generateMovedRoute( + source: string, + otherFiles: Record = {}, +) { + const root = await mkdtemp(path.join(runDirectory(), 'tsr-known-bugs-')) + try { + await mkdir(path.join(root, 'routes')) + await writeFile( + path.join(root, 'routes/__root.tsx'), + `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute()`, + ) + await writeFile(path.join(root, 'routes/moved.tsx'), source) + for (const [file, content] of Object.entries(otherFiles)) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), content) + } + const config = getConfig({ + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + // Same filesystem as the app, so the generator can rename its temp files + tmpDir: path.join(root, '.tanstack/tmp'), + }) + await recordDirectoryInputs(root, config.generatedRouteTree) + let error: unknown + const { diagnostics, result: routes } = await captureDiagnostics( + async () => { + try { + await new Generator({ config, root }).run() + return await routesOf(config.generatedRouteTree) + } catch (caught) { + error = caught + return undefined + } + }, + ) + return { + error, + written: await readFile(path.join(root, 'routes/moved.tsx'), 'utf8'), + routes, + diagnostics, + root, + file: path.join(root, 'routes/moved.tsx'), + } + } finally { + await rm(root, { recursive: true, force: true }) + } +} + +// (What Start learns of a route's option keys from the generator, which +// decides whether a route is server-only, is tested through Start's builds: +// start-plugin-core tests/known-bugs-route-options.test.ts.) + +describe('route files without a Route export', () => { + // A file without a Route export is left out of the route tree, with a + // warning naming it. + test.each(['export const helper = 1', 'const helper = 1\nexport { helper }'])( + 'a route file without a Route export is left out with a warning: %s', + async (code) => { + const { routes, diagnostics, file, root } = await generateMovedRoute(code) + expect(routes).toEqual({ __root__: 'routes/__root.tsx' }) + // (a warning: the run goes on, so no error; an info or log line is + // not one, SPEC §5.7) + expectDiagnostic(diagnostics, { + severity: 'warning', + file, + root, + }) + }, + ) +}) + +describe('route constructor imports', () => { + // Control for the route constructor pin below (same harness). + test('a moved route gets the id of its new path', async () => { + const { written, error } = + await generateMovedRoute(`import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/old')({})`) + expect(await routeIdOf(written)).toBe('/moved') + expect(error).toBeUndefined() + }) + + // Bug: the route constructor call is recognized by its callee name, apart + // from its import: an aliased import (`createFileRoute as route`) is not + // recognized. + // Impact: the route keeps its old id when its file moves. + test.fails( + 'a moved route with an aliased import of the constructor gets the id of its new path', + async () => { + const { written, error } = + await generateMovedRoute(`import { createFileRoute as route } from '@tanstack/react-router' +export const Route = route('/old')({})`) + expect(await routeIdOf(written)).toBe('/moved') + expect(error).toBeUndefined() + }, + ) + + // Bug: same root cause as above, for `createFileRoute` imported from a + // module of the app (a wrapper re-exporting it): no import from the + // router package names it, so the generator prepends one, next to the + // user's import of the same name. + // Source: router-generator/src/transform/transform.ts:502-565 + // (`normalizeRouteImports` adds the import when no import of the router + // package owns the constructor); fuzzing, 7 unmodified files of real apps. + // Impact: the written route file declares `createFileRoute` twice and no + // longer parses, so the app fails to build. + test.fails( + 'a moved route importing createFileRoute from a module of the app stays a valid module', + async () => { + const { written, error } = await generateMovedRoute( + `import { createFileRoute } from '../lib/router' +export const Route = createFileRoute('/old')({})`, + { + 'lib/router.ts': `export { createFileRoute } from '@tanstack/react-router'`, + }, + ) + const { errors } = parseSync('route.tsx', written, { + sourceType: 'module', + showSemanticErrors: true, + }) + expect(errors.map((error) => error.message)).toEqual([]) + expect(error).toBeUndefined() + }, + ) +}) diff --git a/packages/router-generator/tests/owned-edits.ts b/packages/router-generator/tests/owned-edits.ts new file mode 100644 index 0000000000..08dcc82882 --- /dev/null +++ b/packages/router-generator/tests/owned-edits.ts @@ -0,0 +1,159 @@ +/** + * Shared test helper: what the generator may change in a route file it + * keeps up (SPEC J1.1, J1.2). + * + * The generator owns the route id argument of the `Route` constructor call + * and the constructor's callee (`createFileRoute` / `createLazyFileRoute`), + * and it may add, move or drop the constructor's binding. How it does that + * to the import statements is free (SPEC J1.2): it may write a new import + * or edit, merge, split, reorder or reprint any import statement. What the + * imports bind is the user's: every binding keeps its imported name, local + * name, source module, type/value meaning and import attributes, and every + * side-effect import stays. A value import of a route constructor under its + * own name from a router package may stay or go (the edit may have made it + * unused, J1.2); an aliased one, or one from another module, is the user's. + * Everything outside the import statements keeps its exact bytes: other + * statements, comments, formatting and line endings. The quote character and + * printing of the edited argument are free. + * + * `expectOnlyOwnedEdits(before, after)` asserts exactly that; the caller + * checks the outcome of the edit itself (`routeCallOf`: the constructor and + * the id the file now has) and that the file still evaluates. + */ +import { parseSync } from 'vite' +import { expect } from 'vitest' +import { routeCallSpansOf } from './route-id' + +/** The router packages route files import their constructors from. */ +const routerPackages = /^@tanstack\/(?:react|solid|vue)-router$/ + +/** The route constructors the generator may add, switch or drop. */ +const constructors = new Set(['createFileRoute', 'createLazyFileRoute']) + +type Node = Record + +/** A marker that occurs in no source. */ +const owned = '\u0000' + +function importsOf(code: string, fileName: string) { + const { program } = parseSync(fileName, code) + return (program.body as Array).filter( + (statement) => statement.type === 'ImportDeclaration', + ) +} + +function nameOf(node: Node) { + return (node.type === 'Identifier' ? node.name : node.value) as string +} + +/** + * What the import statements of `code` bind, one entry per binding + * (` as from `, `* as ` for a namespace, + * `type ` in front of type-only ones) and per side-effect import + * (`import `), each with the statement's import attributes; without + * value imports of a route constructor under its own name from a router + * package. Sorted, without duplicates. + */ +function bindingsOf(code: string, fileName: string) { + const bindings = new Set() + for (const statement of importsOf(code, fileName)) { + const source = statement.source.value as string + const attributes = ((statement.attributes ?? []) as Array) + .map((attribute) => `${nameOf(attribute.key)}: ${attribute.value.value}`) + .sort() + const from = `${source}${attributes.length ? ` with { ${attributes.join(', ')} }` : ''}` + const specifiers = statement.specifiers as Array + if (specifiers.length === 0) { + bindings.add(`import ${from}`) + } + for (const specifier of specifiers) { + const type = + statement.importKind === 'type' || specifier.importKind === 'type' + ? 'type ' + : '' + const local = specifier.local.name as string + if (specifier.type === 'ImportNamespaceSpecifier') { + bindings.add(`${type}* as ${local} from ${from}`) + } else if (specifier.type === 'ImportDefaultSpecifier') { + bindings.add(`${type}default as ${local} from ${from}`) + } else { + const imported = nameOf(specifier.imported) + if ( + !type && + local === imported && + constructors.has(imported) && + routerPackages.test(source) + ) { + continue + } + bindings.add(`${type}${imported} as ${local} from ${from}`) + } + } + } + return [...bindings].sort() +} + +/** + * `code` with the spans the generator owns replaced by markers, and without + * the lines that held nothing but import statements (the import statements + * are compared by what they bind). Blank lines next to those lines, or at + * the start of the file, go too: a generator that deletes exactly an import + * statement leaves its line break and the blanks around it (J1.2 pins the + * bytes outside the import statements, not the blank lines between them). + */ +function unownedText(code: string, fileName: string) { + const spans: Array<[number, number, string]> = importsOf(code, fileName).map( + (statement) => [statement.start, statement.end, 'import'], + ) + const call = routeCallSpansOf(code, fileName) + spans.push([...call.callee, 'constructor']) + if (call.id) { + spans.push([...call.id, 'id']) + } + spans.sort((a, b) => a[0] - b[0]) + let text = '' + let last = 0 + for (const [start, end, kind] of spans) { + text += code.slice(last, start) + owned + (kind === 'import' ? '' : kind) + last = end + } + text += code.slice(last) + const lines = text.split(/(?<=\n|\r(?!\n))/) + const blank = (line: string) => line.replaceAll(owned, '').trim() === '' + let kept = '' + for (let index = 0; index < lines.length; ) { + if (!blank(lines[index]!)) { + kept += lines[index++] + continue + } + // A run of blank lines and lines holding import statements only + const start = index + while (index < lines.length && blank(lines[index]!)) { + index++ + } + const run = lines.slice(start, index) + if (start > 0 && !run.some((line) => line.includes(owned))) { + kept += run.join('') + } + } + return kept +} + +/** + * Asserts that `after` (a route file as the generator left it) differs from + * `before` only where the generator may edit it: see the module comment. + */ +export function expectOnlyOwnedEdits( + before: string, + after: string, + fileName = 'route.tsx', +) { + expect( + unownedText(after, fileName), + 'the code outside the import statements the generator does not own', + ).toBe(unownedText(before, fileName)) + expect( + bindingsOf(after, fileName), + 'what the import statements bind (other than the route constructor)', + ).toEqual(bindingsOf(before, fileName)) +} diff --git a/packages/router-generator/tests/real-router-cases.ts b/packages/router-generator/tests/real-router-cases.ts new file mode 100644 index 0000000000..fb9a9fd9fd --- /dev/null +++ b/packages/router-generator/tests/real-router-cases.ts @@ -0,0 +1,227 @@ +/** + * Shared test data: the apps whose route trees real-router.test.ts and + * real-router-frameworks.test.ts check through the real router (runtime), + * and integration/route-types.test.ts through the real TypeScript compiler + * (types, J1.13). Helpers: real-router.ts. + */ +import { + index, + layout, + physical, + rootRoute as virtualRootRoute, + route as virtualRoute, +} from '@tanstack/virtual-file-routes' +import { rootRoute } from './app' +import { page, pagesApp, routes, sfc } from './real-router' +import type { Case } from './real-router' + +/** Route shapes of file names and of a virtual route config (React). */ +export const shapeCases: Array = [ + { + name: 'flat, directory, layout, pathless, group, lazy and param routes', + files: { + 'src/routes/__root.tsx': rootRoute(), + ...routes([ + 'index.tsx', + 'about.tsx', + 'about.lazy.tsx', + 'contact.lazy.tsx', + 'posts.tsx', + 'posts.index.tsx', + 'posts.$postId.tsx', + 'posts_.$postId.edit.tsx', + 'blog/route.tsx', + 'blog/index.tsx', + 'blog/$slug.tsx', + '_auth.tsx', + '_auth/login.tsx', + '_auth/_admin.tsx', + '_auth/_admin/users.tsx', + '(marketing)/pricing.tsx', + '(legal)/terms.tsx', + '{-$locale}/help.tsx', + 'files.$.tsx', + '[_]internal.tsx', + 'docs.[guide].tsx', + 'settings/_layout.tsx', + 'settings/_layout/profile.tsx', + ]), + }, + expected: { + __root__: ['/', null], + '/': ['/', '__root__'], + '/about': ['/about', '__root__'], + '/contact': ['/contact', '__root__'], + '/posts': ['/posts', '__root__'], + '/posts/': ['/posts/', '/posts'], + '/posts/$postId': ['/posts/$postId', '/posts'], + '/posts_/$postId/edit': ['/posts/$postId/edit', '__root__'], + '/blog': ['/blog', '__root__'], + '/blog/': ['/blog/', '/blog'], + '/blog/$slug': ['/blog/$slug', '/blog'], + '/_auth': ['/', '__root__'], + '/_auth/login': ['/login', '/_auth'], + '/_auth/_admin': ['/', '/_auth'], + '/_auth/_admin/users': ['/users', '/_auth/_admin'], + '/(marketing)/pricing': ['/pricing', '__root__'], + '/(legal)/terms': ['/terms', '__root__'], + '/{-$locale}/help': ['/{-$locale}/help', '__root__'], + '/files/$': ['/files/$', '__root__'], + '/_internal': ['/_internal', '__root__'], + '/docs/guide': ['/docs/guide', '__root__'], + '/settings/_layout': ['/settings', '__root__'], + '/settings/_layout/profile': ['/settings/profile', '/settings/_layout'], + }, + visits: { + '/': '/', + '/about': '/about', + '/contact': '/contact', + '/posts': '/posts/', + '/posts/1': '/posts/$postId', + '/posts/1/edit': '/posts_/$postId/edit', + '/blog/hello': '/blog/$slug', + '/login': '/_auth/login', + '/users': '/_auth/_admin/users', + '/pricing': '/(marketing)/pricing', + '/terms': '/(legal)/terms', + '/help': '/{-$locale}/help', + '/fr/help': '/{-$locale}/help', + '/files/a/b': '/files/$', + '/_internal': '/_internal', + '/docs/guide': '/docs/guide', + '/settings/profile': '/settings/_layout/profile', + }, + }, + { + name: 'a virtual route config with layouts, an index and a physical mount', + files: { + 'src/routes/root.tsx': rootRoute(), + ...routes([ + 'home.tsx', + 'posts/layout.tsx', + 'posts/list.tsx', + 'posts/detail.tsx', + 'auth-layout.tsx', + 'login.tsx', + 'legacy/about.tsx', + 'legacy/index.tsx', + ]), + }, + config: { + virtualRouteConfig: virtualRootRoute('root.tsx', [ + index('home.tsx'), + virtualRoute('/posts', 'posts/layout.tsx', [ + index('posts/list.tsx'), + virtualRoute('$postId', 'posts/detail.tsx'), + ]), + layout('auth', 'auth-layout.tsx', [ + virtualRoute('/login', 'login.tsx'), + ]), + physical('/legacy', 'legacy'), + ]), + }, + expected: { + __root__: ['/', null], + '/': ['/', '__root__'], + '/posts': ['/posts', '__root__'], + '/posts/': ['/posts/', '/posts'], + '/posts/$postId': ['/posts/$postId', '/posts'], + '/_auth': ['/', '__root__'], + '/_auth/login': ['/login', '/_auth'], + '/legacy/about': ['/legacy/about', '__root__'], + '/legacy/': ['/legacy/', '__root__'], + }, + visits: { + '/': '/', + '/posts': '/posts/', + '/posts/1': '/posts/$postId', + '/login': '/_auth/login', + '/legacy/about': '/legacy/about', + '/legacy': '/legacy/', + }, + }, +] + +// A layout route file in a route group directory: `(group)` folders are +// left out of the URL (file-naming-conventions.md:15) and a `route.tsx` +// file is the route file at its directory's path (:18), so +// `(marketing)/route.tsx` is a layout adding no path segment, like a +// pathless layout (maintained since #4629, fixture +// tests/generator/path-above-route-in-group). +export const groupLayout: Case = { + name: 'a route group layout', + files: { + 'src/routes/__root.tsx': page('react', 'createRootRoute', 'root', true), + 'src/routes/(marketing)/route.tsx': page( + 'react', + 'createFileRoute', + 'marketing', + true, + ), + 'src/routes/(marketing)/pricing.tsx': page( + 'react', + 'createFileRoute', + 'pricing', + ), + }, + expected: { + __root__: ['/', null], + '/(marketing)': ['/', '__root__'], + '/(marketing)/pricing': ['/pricing', '/(marketing)'], + }, + visits: { '/pricing': '/(marketing)/pricing' }, + pages: { '/pricing': ['root', 'marketing', 'pricing'] }, +} + +/** Apps of each framework rendering their pages. */ +export const frameworkCases: Array = [ + { + name: 'a Vue app with route files and component pieces', + config: { target: 'vue' }, + files: { + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/__root.component.vue': sfc('root'), + ...routes( + [ + 'index.ts', + 'posts.ts', + 'posts.$postId.ts', + '_auth.ts', + '_auth/login.ts', + ], + 'vue', + ), + 'src/routes/index.component.vue': sfc('home'), + 'src/routes/posts.component.vue': sfc('posts'), + 'src/routes/posts.$postId.component.vue': sfc('post'), + 'src/routes/_auth.component.vue': sfc('auth'), + 'src/routes/_auth/login.component.vue': sfc('login'), + // A route with a component piece and no route file + 'src/routes/about.component.vue': sfc('about'), + }, + expected: { + __root__: ['/', null], + '/': ['/', '__root__'], + '/about': ['/about', '__root__'], + '/posts': ['/posts', '__root__'], + '/posts/$postId': ['/posts/$postId', '/posts'], + '/_auth': ['/', '__root__'], + '/_auth/login': ['/login', '/_auth'], + }, + visits: { + '/': '/', + '/about': '/about', + '/posts': '/posts', + '/posts/1': '/posts/$postId', + '/login': '/_auth/login', + }, + pages: { + '/': ['root', 'home'], + '/about': ['root', 'about'], + '/posts/1': ['root', 'posts', 'post'], + '/login': ['root', 'auth', 'login'], + }, + }, + pagesApp('react'), + pagesApp('solid'), +] diff --git a/packages/router-generator/tests/real-router-frameworks.test.ts b/packages/router-generator/tests/real-router-frameworks.test.ts new file mode 100644 index 0000000000..7fa791c803 --- /dev/null +++ b/packages/router-generator/tests/real-router-frameworks.test.ts @@ -0,0 +1,18 @@ +/** + * Generated route trees of React, Solid and Vue apps loaded by the real + * router: the pages render with each framework's server renderer (React with + * react-dom, Solid with solid-js/web, Vue with its server renderer and + * single-file components). The trees' types are checked in + * integration/route-types.test.ts. Apps: real-router-cases.ts. + */ +import { describe, test } from 'vitest' +import { checkApp } from './real-router' +import { frameworkCases } from './real-router-cases' + +describe('the real router on the route trees of each framework', () => { + test.each(frameworkCases)( + '$name', + (testCase) => checkApp(testCase, { types: false }), + 60_000, + ) +}) diff --git a/packages/router-generator/tests/real-router.test.ts b/packages/router-generator/tests/real-router.test.ts new file mode 100644 index 0000000000..363477fda5 --- /dev/null +++ b/packages/router-generator/tests/real-router.test.ts @@ -0,0 +1,78 @@ +/** + * Generated route trees loaded by the real router: the app's router package + * builds a router from the tree (`createRouter`), and each route gets the id, + * full path and parent its file name or virtual route config gives it; URLs + * match the expected routes and pages render (React with react-dom). The + * trees' types (J1.13) are checked against the same routes in + * integration/route-types.test.ts. Apps: real-router-cases.ts; helpers: + * real-router.ts. + */ +import { describe, test } from 'vitest' +import { checkApp, page } from './real-router' +import { groupLayout, shapeCases } from './real-router-cases' + +// (the frameworks' pages: real-router-frameworks.test.ts) +describe('the real router on a generated route tree', () => { + test.each(shapeCases)( + '$name', + (testCase) => checkApp(testCase, { types: false }), + 60_000, + ) + + test( + 'the layout route of a route group directory adds no path segment and renders around its children', + () => checkApp(groupLayout, { types: false }), + 60_000, + ) + + // Bug: a pathless layout with only a lazy route file + // (`settings/_layout.lazy.tsx`, no `settings/_layout.tsx`) gets no `path` + // in the route tree, so the router drops the `/settings` prefix its + // directory gives it: the child matches `/profile`, not + // `/settings/profile`. The tree's types say `/settings/profile`. Lazy-only + // route files are supported (guide/code-splitting.md:222-224: a virtual + // route anchors the code-split files; SPEC J1.8). Same bug as the G1 pin + // in route-paths.test.ts, checked here with matching, rendering and types. + // Source: src/generator.ts (the `path:` option of `createUpdateRoutes`: + // printed only for non-pathless nodes and nodes typed `pathless_layout`; + // a layout without a route file is typed `static`). + // Impact: the pages under such a layout are served at the wrong URL, and + // typed links to them lead nowhere. + test.fails( + 'a pathless layout with only a lazy route file keeps its directory path', + () => + checkApp({ + name: 'a lazy-only pathless layout', + files: { + 'src/routes/__root.tsx': page( + 'react', + 'createRootRoute', + 'root', + true, + ), + 'src/routes/settings/_layout.lazy.tsx': page( + 'react', + 'createLazyFileRoute', + 'settings', + true, + ), + 'src/routes/settings/_layout/profile.tsx': page( + 'react', + 'createFileRoute', + 'profile', + ), + }, + expected: { + __root__: ['/', null], + '/settings/_layout': ['/settings', '__root__'], + '/settings/_layout/profile': [ + '/settings/profile', + '/settings/_layout', + ], + }, + visits: { '/settings/profile': '/settings/_layout/profile' }, + pages: { '/settings/profile': ['root', 'settings', 'profile'] }, + }), + 60_000, + ) +}) diff --git a/packages/router-generator/tests/real-router.ts b/packages/router-generator/tests/real-router.ts new file mode 100644 index 0000000000..e72aa51517 --- /dev/null +++ b/packages/router-generator/tests/real-router.ts @@ -0,0 +1,234 @@ +/** + * Shared helper of the real-router tests: generates an app, loads its route + * tree with the real router (route-tree.ts) and checks ids, full paths, + * parents, matching, rendered pages and the tree's types against literal + * expectations. + */ +import { expect } from 'vitest' +import { createApp, fileRoute, generate, lazyFileRoute } from './app' +import { withRouteTree } from './route-tree' +import { typeAssertions, typeErrorsOf } from './type-check' +import type { Config } from '../src' + +/** Route files whose ids the generator fixes. */ +export const routes = ( + files: Array, + target: Config['target'] = 'react', +) => + Object.fromEntries( + files.map((file) => [ + `src/routes/${file}`, + file.includes('.lazy.') + ? lazyFileRoute('/wrong', '{}', target) + : fileRoute('/wrong', '{}', target), + ]), + ) + +/** A Vue single-file component rendering `text`, and its child routes. */ +export const sfc = (text: string) => ` + + +` + +/** + * A route file for `target` (React or Solid) whose component renders + * `

text

` and, with `outlet`, its child routes; `constructor` is + * `createRootRoute`, `createFileRoute` or `createLazyFileRoute` (whose id + * the generator fixes). + */ +export const page = ( + target: 'react' | 'solid', + constructor: string, + text: string, + outlet = false, +) => `${target === 'solid' ? '/** @jsxImportSource solid-js */\n' : ''}import { Outlet, ${constructor} } from '@tanstack/${target}-router' + +export const Route = ${constructor === 'createRootRoute' ? constructor : `${constructor}('/wrong')`}({ + component: () => ( + <> +

${text}

+ ${outlet ? '' : ''} + + ), +}) +` + +/** + * An app for `target` whose routes render pages: a root layout, an index, a + * route with a lazy component, a lazy-only route, a route with a child, and + * a pathless layout with a child. + */ +export const pagesApp = (target: 'react' | 'solid'): Case => ({ + name: `a ${target} app rendering its pages`, + config: { target }, + files: { + 'src/routes/__root.tsx': page(target, 'createRootRoute', 'root', true), + 'src/routes/index.tsx': page(target, 'createFileRoute', 'home'), + 'src/routes/about.tsx': fileRoute('/wrong', '{}', target), + 'src/routes/about.lazy.tsx': page(target, 'createLazyFileRoute', 'about'), + 'src/routes/contact.lazy.tsx': page( + target, + 'createLazyFileRoute', + 'contact', + ), + 'src/routes/posts.tsx': page(target, 'createFileRoute', 'posts', true), + 'src/routes/posts.$postId.tsx': page(target, 'createFileRoute', 'post'), + 'src/routes/_auth.tsx': page(target, 'createFileRoute', 'auth', true), + 'src/routes/_auth/login.tsx': page(target, 'createFileRoute', 'login'), + }, + expected: { + __root__: ['/', null], + '/': ['/', '__root__'], + '/about': ['/about', '__root__'], + '/contact': ['/contact', '__root__'], + '/posts': ['/posts', '__root__'], + '/posts/$postId': ['/posts/$postId', '/posts'], + '/_auth': ['/', '__root__'], + '/_auth/login': ['/login', '/_auth'], + }, + visits: { + '/': '/', + '/about': '/about', + '/contact': '/contact', + '/posts/1': '/posts/$postId', + '/login': '/_auth/login', + }, + pages: { + '/': ['root', 'home'], + '/about': ['root', 'about'], + '/contact': ['root', 'contact'], + '/posts/1': ['root', 'posts', 'post'], + '/login': ['root', 'auth', 'login'], + }, + // (React: the types of the same routes are checked by the first case of + // integration/route-types.test.ts) + types: target === 'solid', +}) + +export interface Case { + name: string + files: Record + config?: Partial + /** Route id to its full path and its parent's id (null for the root). */ + expected: Record + /** URL to the id of the deepest route the router matches for it. */ + visits: Record + /** URL to the texts of the paragraphs its page renders, in order. */ + pages?: Record> + /** False when other cases already check the types of the same routes. */ + types?: boolean +} + +/** Types for Vue single-file component imports, as in a Vue app. */ +const vueShim = `declare module '*.vue' { + const component: unknown + export default component +} +` + +/** The texts of the `

` elements of server-rendered `html`, in order. */ +const paragraphs = (html: string) => + [...html.matchAll(/]*>([^<]*)<\/p>/g)].map((match) => match[1]) + +/** + * Generates the app of a case and checks the router over its route tree + * (`runtime`) and the tree's types (`types`) against the expected routes. + */ +export async function checkApp( + { files, config, expected, visits, pages }: Case, + { runtime = true, types = true, client = false } = {}, +) { + const root = await createApp({ ...files, 'src/vue-shim.d.ts': vueShim }) + const { generatedRouteTree } = await generate(root, config) + + if (runtime) { + await checkRouter(generatedRouteTree, { expected, visits, pages }, client) + } + if (types) { + await checkTypes(root, expected) + } +} + +/** Checks the router over the route tree at `treeFile`. */ +async function checkRouter( + treeFile: string, + { expected, visits, pages }: Pick, + client: boolean, +) { + await withRouteTree(treeFile, async (tree) => { + const { router } = tree + expect( + Object.fromEntries( + Object.values(router.routesById).map((route) => [ + route.id, + [route.fullPath, route.parentRoute?.id ?? null], + ]), + ), + ).toEqual(expected) + expect( + Object.fromEntries( + Object.keys(visits).map((url) => [ + url, + router.matchRoutes(url).at(-1)?.routeId, + ]), + ), + ).toEqual(visits) + for (const [url, texts] of Object.entries(pages ?? {})) { + expect(paragraphs(await tree.renderAt(url))).toEqual(texts) + if (client) { + expect(paragraphs(await tree.renderClientAt(url, texts))).toEqual(texts) + } + } + }) +} + +/** + * Checks the types of the route tree of the app at `root`: the same route + * ids, and for each route the same full path and parent as `expected`. + */ +async function checkTypes(root: string, expected: Case['expected']) { + expect( + await typeErrorsOf( + root, + 'src/checks.ts', + `/// +${routeTypeChecks('./routeTree.gen', expected)}`, + ), + ).toEqual([]) +} + +/** + * A module that type-checks only if the route tree `tree` (an import + * specifier) types the routes of `expected` (route id to full path and + * parent id) alike: the same route ids, and for each route the same full + * path and parent. The routes are read through the router's public type + * API on `typeof routeTree` (`RouteIds`, `RouteById`), not through the + * names of the types the tree declares (free, SPEC §5.1). + */ +export function routeTypeChecks( + tree: string, + expected: Record]>, +) { + const ids = Object.keys(expected) + const checks = ids.map((id, i) => { + const [fullPath, parent] = expected[id]! + const route = `RouteById` + const actual = `[${JSON.stringify(id)}, ${route}['fullPath'], ${parent === null ? 'null' : `${route}['parentRoute']['id']`}]` + const wanted = JSON.stringify([id, fullPath, parent]) + // (the assignment names the types of a route that differ) + return `export type Check${i} = Expect> +export const check${i}: ${wanted} = null as unknown as ${actual}` + }) + return `import type { RouteById, RouteIds } from '@tanstack/router-core' +import type { routeTree } from ${JSON.stringify(tree)} +${typeAssertions} +type Tree = typeof routeTree +export type Ids = Expect, ${ids.map((id) => JSON.stringify(id)).join(' | ')}>> +${checks.join('\n')} +` +} diff --git a/packages/router-generator/tests/route-file-upkeep.test.ts b/packages/router-generator/tests/route-file-upkeep.test.ts new file mode 100644 index 0000000000..1ad40d6fb2 --- /dev/null +++ b/packages/router-generator/tests/route-file-upkeep.test.ts @@ -0,0 +1,760 @@ +/** + * Route file upkeep through full generator runs: the generator gives each + * route file the route id of its path and the route constructor of its kind + * (`createLazyFileRoute` for `.lazy` files, `createFileRoute` otherwise), + * imported from the router package, and leaves everything else as the user + * wrote it. Read back from disk and evaluated. + * + * What the generator may change is checked by `expectOnlyOwnedEdits` + * (owned-edits.ts): the id argument, the constructor callee and the import + * statements, as long as every other binding they hold stays (SPEC J1.2). + * An unused import of the other route constructor may be removed or kept + * (SPEC J1.2). + */ +import path from 'node:path' +import { afterEach, describe, expect, test, vi } from 'vitest' +import { + diagnosticsOf, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { createApp, generate, read, rootRoute } from './app' +import { expectOnlyOwnedEdits } from './owned-edits' +import { routeCallOf } from './route-id' +import { evaluateModule, routesOf, withRouteTree } from './route-tree' +import type { Config } from '../src' + +afterEach(() => { + vi.restoreAllMocks() +}) + +const routerPackage = '@tanstack/react-router' +const router = `'${routerPackage}'` + +/** + * Runs the generator on an app with a root route, `src/routes/` + * holding `source` and `otherFiles` (paths relative to the app root). + * Returns the file as the generator left it, the route + * tree's routes (route id to file) and the warnings; or the error of a run + * that fails. + */ +async function upkeep( + file: string, + source: string, + config: Partial = {}, + otherFiles: Record = {}, +) { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + [`src/routes/${file}`]: source, + ...otherFiles, + }) + let error: Error | undefined + let routes: Record | undefined + const { diagnostics } = await captureDiagnostics(async () => { + try { + const { generatedRouteTree } = await generate(root, { + disableLogging: false, + ...config, + }) + routes = await routesOf(generatedRouteTree) + } catch (e) { + error = e as Error + } + }) + return { + root, + file: path.join(root, 'src/routes', file), + written: await read(root, `src/routes/${file}`), + routes, + diagnostics, + error, + } +} + +/** + * Asserts the upkeep of a route file written from `source`: it evaluates + * with the real router (a binding declared twice does not), its Route is + * a route of the router package's kind for `createdWith`, created with + * `createdWith` (bound to the router package export under any local name or + * through a namespace import) and `id`, and it changed only where the + * generator may edit it (owned-edits.ts). + */ +async function expectRouteFile( + written: string, + { + id, + createdWith = 'createFileRoute', + source, + fileName, + }: { + id: string + createdWith?: 'createFileRoute' | 'createLazyFileRoute' + source: string + fileName?: string + }, +) { + const { exports, router: routerExports } = await evaluateModule( + written, + fileName, + ) + expect(exports.Route).toBeInstanceOf( + createdWith === 'createLazyFileRoute' + ? routerExports.LazyRoute + : routerExports.Route, + ) + expect(routeCallOf(written, fileName)).toEqual({ + constructor: createdWith, + id, + }) + expectOnlyOwnedEdits(source, written, fileName) +} + +describe('route ids the generator fixes', () => { + test.each([ + { + name: 'options wrapped in `as any`', + call: `createFileRoute('/old')({ component: Page } as any)`, + }, + { + name: 'options wrapped in `satisfies`', + call: `createFileRoute('/old')({ component: Page } satisfies object)`, + }, + { + name: 'a double-quoted id', + call: `createFileRoute("/old")({ component: Page })`, + }, + // (a template literal id: replaced or reported, below) + ])('a route file with $name gets its id fixed', async ({ call }) => { + const source = `import { createFileRoute } from ${router} + +const Page = () => null +export const Route = ${call} +` + const { written, routes } = await upkeep('new.tsx', source) + + await expectRouteFile(written, { id: '/new', source }) + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + '/new': 'routes/new.tsx', + }) + }) + + test.each([ + { + name: 'an aliased Route export', + body: `const NewRoute = createFileRoute('/old')({}) +export { NewRoute as Route } +`, + }, + { + name: 'an export list of a Route declared before', + body: `const Route = createFileRoute('/old')({}) +export { Route } +`, + }, + { + // (one route per route file, SPEC §2.2, J2.1: the other call is an + // ordinary function call with a path-like string argument) + name: 'another call with a path argument before it', + body: `const otherPath = encodeURI('/other') +export const Route = createFileRoute('/old')({}) +export const other = otherPath +`, + }, + ])( + 'a route file with $name gets the id of its Route fixed', + async ({ body }) => { + const source = `import { createFileRoute } from ${router}\n\n${body}` + const { written } = await upkeep('new.tsx', source) + + await expectRouteFile(written, { id: '/new', source }) + }, + ) + + // Source: TanStack/router#7341. In a `.ts` file, `value` is a type + // assertion and `(value: T) => value` a generic arrow function, not JSX. + test('a .ts route file with angle-bracket type assertions gets its id fixed', async () => { + const source = `import { createFileRoute } from ${router} +const identity = (value: T) => value +export const Route = createFileRoute('/old')({ + loader: () => identity(1), +}) +` + const { written, routes } = await upkeep('new.ts', source) + + await expectRouteFile(written, { id: '/new', source, fileName: 'new.ts' }) + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + '/new': 'routes/new.ts', + }) + }) +}) + +describe('root route files', () => { + test.each([ + { + name: 'createRootRoute', + source: `import { createRootRoute } from ${router} + +export const Route = createRootRoute({}) +`, + }, + { + name: 'createRootRouteWithContext', + source: `import { createRootRouteWithContext } from ${router} + +interface RouterContext { + user?: string +} + +export const Route = createRootRouteWithContext()({}) +`, + }, + { + name: 'an export list', + source: `import { createRootRoute } from ${router} + +const Route = createRootRoute() + +export { Route } +`, + }, + ])( + 'a root route file created with $name is left as it is', + async ({ source }) => { + const root = await createApp({ 'src/routes/__root.tsx': source }) + const { generatedRouteTree } = await generate(root) + + expect(await read(root, 'src/routes/__root.tsx')).toBe(source) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + }) + }, + ) +}) + +describe('route constructors', () => { + test.each([ + { + name: 'only the lazy constructor imported', + source: `import { createLazyFileRoute } from ${router} + +export const Route = createLazyFileRoute('/new')({}) +`, + }, + { + name: 'a semicolon-terminated import', + source: `import { createLazyFileRoute } from ${router}; + +export const Route = createLazyFileRoute('/old')({}); +`, + }, + { + name: 'a type specifier in the import', + source: `import { type LinkProps, createLazyFileRoute } from ${router} + +export type Props = LinkProps +export const Route = createLazyFileRoute('/old')({}) +`, + }, + ])( + 'a route file created with createLazyFileRoute gets createFileRoute, with $name', + async ({ source }) => { + const { written } = await upkeep('new.tsx', source) + + // (a type import stays a type import: expectOnlyOwnedEdits) + await expectRouteFile(written, { id: '/new', source }) + }, + ) + + test('a lazy route file with a multi-line import of createFileRoute gets createLazyFileRoute', async () => { + const source = `import { + Link, + createFileRoute, +} from ${router} + +export const Route = createFileRoute('/new')({ + component: () => Link, +}) +` + const { written } = await upkeep('new.lazy.tsx', source) + + await expectRouteFile(written, { + id: '/new', + createdWith: 'createLazyFileRoute', + source, + }) + }) + + test.each([ + { + name: 'no router import', + lazy: false, + source: `export const Route = createFileRoute('/new')({})\n`, + }, + { + name: 'a stale import of the other constructor', + lazy: false, + source: `import { createFileRoute } from ${router} +import { createLazyFileRoute } from ${router} +export const Route = createFileRoute('/new')({}) +`, + }, + { + name: 'a stale import of the other constructor next to another import', + lazy: false, + source: `import { Link, createFileRoute, createLazyFileRoute } from ${router} +export const link = Link +export const Route = createFileRoute('/new')({}) +`, + }, + { + name: 'only the other constructor imported', + lazy: false, + source: `import { createLazyFileRoute } from ${router} +export const Route = createFileRoute('/new')({}) +`, + }, + { + name: 'the lazy constructor imported and createFileRoute called', + lazy: true, + source: `import { createLazyFileRoute } from ${router} +export const Route = createFileRoute('/new')({}) +`, + }, + ])( + 'a route file whose id is right gets the right constructor, with $name', + async ({ lazy, source }) => { + const createdWith = lazy ? 'createLazyFileRoute' : 'createFileRoute' + const { written } = await upkeep( + lazy ? 'new.lazy.tsx' : 'new.tsx', + source, + ) + + await expectRouteFile(written, { id: '/new', createdWith, source }) + }, + ) +}) + +describe('missing route constructor imports', () => { + test.each([ + { + name: 'LF line endings', + source: "// a\nexport const Route = createFileRoute('/old')({})\n", + }, + { + name: 'CRLF line endings', + source: "// a\r\nexport const Route = createFileRoute('/old')({})\r\n", + }, + { + name: 'a single line', + source: "export const Route = createFileRoute('/old')({})", + }, + { + name: 'an import of another package', + source: `import { useState } from 'react' + +export const state = useState +export const Route = createFileRoute('/old')({}) +`, + }, + ])( + 'a route file without the constructor import gets it, with $name', + async ({ source }) => { + const { written } = await upkeep('new.tsx', source) + + await expectRouteFile(written, { id: '/new', source }) + }, + ) + + test.each([ + { + name: 'an aliased import of the constructor', + imports: `import { createFileRoute as cfr } from ${router}`, + uses: 'cfr', + }, + { + // (both aliases of the same export stay bound; a generator that + // dropped one passed the other cases) + name: 'two aliases of another router export', + imports: `import { Link as Primary, Link as Secondary } from ${router}`, + uses: 'Primary, Secondary', + }, + { + // The constructor cannot join a namespace import + // (`import * as Router, { ... }` does not parse). + name: 'a namespace import', + imports: `import * as Router from ${router} +import { Link } from ${router}`, + uses: 'Router.Link, Link', + }, + { + name: 'a namespace import, in a file using semicolons', + imports: `import * as Router from ${router};`, + uses: 'Router', + }, + ])( + 'a route file calling createFileRoute next to $name gets it bound once', + async ({ imports, uses }) => { + const source = `${imports} +export const uses = [${uses}] +export const Route = createFileRoute('/old')({}) +` + const { written } = await upkeep('new.tsx', source) + + await expectRouteFile(written, { id: '/new', source }) + }, + ) + + test.each([ + { + name: 'an inline type specifier in a declaration with the other constructor', + source: `import { type LinkProps, createLazyFileRoute } from ${router} +import { createFileRoute } from ${router} +export type Props = LinkProps +export const Route = createFileRoute('/old')({}) +`, + }, + { + name: 'a type-only declaration next to a missing constructor import', + source: `import type { LinkProps } from ${router} +export type Props = LinkProps +export const Route = createFileRoute('/old')({}) +`, + }, + ])('type imports stay type-only: $name', async ({ source }) => { + const { written } = await upkeep('new.tsx', source) + + // (expectOnlyOwnedEdits: `LinkProps` is still imported as a type) + await expectRouteFile(written, { id: '/new', source }) + }) +}) + +describe('stale imports of the other constructor', () => { + test.each([ + { + name: 'CRLF line endings', + source: [ + `import { createFileRoute } from ${router}`, + `import { createLazyFileRoute } from ${router}`, + '', + "export const Route = createFileRoute('/old')({})", + ].join('\r\n'), + }, + { + // (BOM-free: SPEC §2.1 selects BOM-free UTF-8 sources.) + name: 'astral characters before them and in the route call', + source: [ + '// 😀', + `import { createLazyFileRoute } from ${router}`, + `import { createFileRoute } from ${router}`, + "export const Route = createFileRoute(/* 🚀 */ '/old')({})", + ].join('\n'), + }, + { + name: 'trailing whitespace and a blank line after the stale import', + source: `import { createFileRoute } from ${router} +import { createLazyFileRoute } from ${router} \t + +export const Route = createFileRoute('/old')({})`, + }, + { + name: 'the stale import on the line of another import', + source: `import { createLazyFileRoute } from ${router}; import { createFileRoute } from ${router} +export const Route = createFileRoute('/old')({})`, + }, + { + name: 'semicolon-terminated imports', + source: `import { Link, createLazyFileRoute } from ${router}; +import { createFileRoute } from ${router}; +export const Route = createFileRoute('/old')({}) +export const link = Link`, + }, + { + name: 'an import the upkeep does not need to change', + source: `import {Link} from ${router} +import { createFileRoute, createLazyFileRoute } from ${router} +export const link = Link +export const Route = createFileRoute('/old')({})`, + }, + { + name: 'an aliased import of the constructor', + source: `import { Link, createLazyFileRoute } from ${router} +import { createFileRoute as cfr } from ${router} +export const uses = [Link, cfr] +export const Route = createFileRoute('/old')({})`, + }, + ])('a route file with $name gets its id fixed', async ({ source }) => { + const { written } = await upkeep('new.tsx', source) + + await expectRouteFile(written, { id: '/new', source }) + }) +}) + +// Recognition is by binding, not spelling (SPEC G15): a `createFileRoute` +// the file declares itself or imports from another module is the user's, +// with its own semantics; one shadowing the router's in an inner scope is +// left alone while the file's Route is kept up. (The missing-import repair +// of a Route whose constructor is not bound at all: "missing route +// constructor imports" above.) +describe('look-alike route constructors', () => { + /** + * An app's own `createFileRoute`: the router's, giving every route a + * pending component. + */ + const factory = `import { createFileRoute as routerFileRoute } from ${router} + +export const createFileRoute = (id: any) => (options: any) => + routerFileRoute(id)({ pendingComponent: () => 'loading', ...options }) +` + + // Bug: the generator recognises route constructors by name: a route file + // whose `createFileRoute` is the app's own (declared in the file or + // imported from another module of the app) gets the router package's + // instead (an import from './-factory' is rebound to the router package; + // a declared one gets a router import next to it), and the id argument of + // the app's call is rewritten. + // Source: src/transform/transform.ts `isRouteConstructor` (the route call + // is recognised by the callee's name, without its binding's provenance; + // the factory import is then repaired as if it were missing). + // Impact: an app wrapping the route constructor under the same name (to + // give its routes defaults) silently loses the wrapper in that route file + // (here: no pending component), or the file stops compiling (a binding + // declared twice). + test.fails.each([ + { + name: 'declared in the file', + source: `${factory.replace('export const', 'const')} +export const Route = createFileRoute('/old')({}) +`, + }, + { + name: 'imported from another module of the app', + source: `import { createFileRoute } from './-factory' + +export const Route = createFileRoute('/old')({}) +`, + }, + ])( + 'a createFileRoute $name keeps its meaning: the file is left as it is, or reported', + async ({ source }) => { + const { root, file, written, routes, diagnostics, error } = await upkeep( + 'new.tsx', + source, + {}, + { 'src/routes/-factory.ts': factory }, + ) + + expect(written).toBe(source) + if (routes?.['/new'] === 'routes/new.tsx') { + // (the route is the app's constructor's: with its pending component) + await withRouteTree( + path.join(root, 'src/routeTree.gen.ts'), + ({ router: liveRouter }) => { + expect( + liveRouter.routesById['/new']!.options.pendingComponent, + ).toBeTypeOf('function') + }, + ) + return + } + expectDiagnostic([...diagnosticsOf(error), ...diagnostics], { + severity: ['warning', 'error'], + file, + root, + }) + }, + ) + + test('a createFileRoute shadowing the router one in an inner scope is left alone while the Route is kept up', async () => { + const source = `import { createFileRoute } from ${router} + +function localRoute() { + const createFileRoute = (id: string) => (options: object) => ({ id, options }) + return createFileRoute('/other')({}) +} +export const local = localRoute() +export const Route = createFileRoute('/old')({}) +` + const { written } = await upkeep('new.tsx', source) + + // (the inner call keeps its bytes: expectOnlyOwnedEdits) + await expectRouteFile(written, { id: '/new', source }) + const { exports } = await evaluateModule(written) + expect(exports.local.id).toBe('/other') + }) +}) + +describe('route files the generator does not rewrite', () => { + // The route comes from an app module (excluded from routing by its `-` + // prefix) the generator does not keep up: the route file is left as it + // is and its route is registered, or the file is reported by name. + test.each([ + { + name: 'a Route from another module', + source: `import { postsRoute } from './-posts-route' +export const Route = postsRoute +`, + helper: [ + 'src/routes/-posts-route.tsx', + `import { createFileRoute } from ${router} + +export const postsRoute = createFileRoute('/new')({ + component: () => 'new page', +}) +`, + ] as const, + }, + { + name: 'a Route made by a route factory of the app', + source: `import { makeRoute } from './-make-route' +export const Route = makeRoute()({ component: () => 'new page' }) +`, + helper: [ + 'src/routes/-make-route.tsx', + `import { createFileRoute } from ${router} + +export const makeRoute = () => createFileRoute('/new') +`, + ] as const, + }, + ])( + '$name is left as it is and registered, or reported by name', + async ({ source, helper: [helperFile, helperSource] }) => { + const { root, file, written, routes, diagnostics, error } = await upkeep( + 'new.tsx', + source, + {}, + { [helperFile]: helperSource }, + ) + + expect(written).toBe(source) + expect(await read(root, helperFile)).toBe(helperSource) + if (routes?.['/new'] === 'routes/new.tsx') { + await withRouteTree( + path.join(root, 'src/routeTree.gen.ts'), + async ({ renderAt }) => { + expect(await renderAt('/new')).toContain('new page') + }, + ) + return + } + expectDiagnostic([...diagnosticsOf(error), ...diagnostics], { + severity: ['warning', 'error'], + file, + root, + }) + }, + ) + + // A route id that is not a string literal: replacing it with the right + // literal (everything else as owned-edits.ts allows) and an actionable + // diagnostic naming the file (a failed run or a warning; the file then + // stays as it is) are both correct (SPEC J1.1). + test.each([ + { + name: 'a template literal id', + source: `import { createFileRoute } from ${router} +const Page = () => null +export const Route = createFileRoute(\`/old\`)({ component: Page }) +`, + }, + { + name: 'an id read from a variable', + source: `import { createFileRoute } from ${router} +const routeId = '/old' +export const Route = createFileRoute(routeId)({}) +`, + }, + { + name: 'an interpolated template literal id', + source: `import { createFileRoute } from ${router} +const x = 'old' +export const Route = createFileRoute(\`/\${x}\`)({}) +`, + }, + ])( + 'a route file with $name gets the literal id or is reported by name', + async ({ source }) => { + const { root, file, written, routes, diagnostics, error } = await upkeep( + 'new.tsx', + source, + ) + + if (routeCallOf(written).id === '/new') { + await expectRouteFile(written, { id: '/new', source }) + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + '/new': 'routes/new.tsx', + }) + } else { + expectDiagnostic([...diagnosticsOf(error), ...diagnostics], { + severity: ['warning', 'error'], + file, + root, + }) + expect(written).toBe(source) + } + }, + ) + + // A malformed route call (a never-fail-silently control, not a supported + // input: the router's types reject options passed to the constructor + // directly, TS2345). Either the user is told which file, by a failed run + // or by a warning (the file then stays as it is), or the call is repaired + // into the curried call with the route's id, keeping its options. + test.each([ + { + name: 'options passed to createFileRoute directly', + constructor: 'createFileRoute', + source: `import { createFileRoute } from ${router} +export const Route = createFileRoute({ component: () => null }) +`, + }, + { + name: 'options passed to createLazyFileRoute directly', + constructor: 'createLazyFileRoute', + fileName: 'new.lazy.tsx', + source: `import { createLazyFileRoute } from ${router} +export const Route = createLazyFileRoute({ component: () => null }) +`, + }, + ] as const)( + 'a route file with $name is reported by name or repaired', + async ({ source, constructor, fileName = 'new.tsx' }) => { + const { root, file, written, routes, diagnostics, error } = await upkeep( + fileName, + source, + ) + + if (!error && written !== source) { + // (repaired: the same file with the curried call, as far as the + // generator's edits go) + await expectRouteFile(written, { + id: '/new', + createdWith: constructor, + source: source.replace( + `${constructor}({`, + `${constructor}('/new')({`, + ), + fileName, + }) + const { exports } = await evaluateModule(written, fileName) + expect(exports.Route.options.component()).toBeNull() + expect(routes).toEqual({ + __root__: 'routes/__root.tsx', + // (a lazy-only route is created by the tree) + '/new': + constructor === 'createLazyFileRoute' ? null : 'routes/new.tsx', + }) + return + } + expectDiagnostic([...diagnosticsOf(error), ...diagnostics], { + severity: ['warning', 'error'], + file, + root, + }) + }, + ) +}) diff --git a/packages/router-generator/tests/route-id.ts b/packages/router-generator/tests/route-id.ts new file mode 100644 index 0000000000..7019294949 --- /dev/null +++ b/packages/router-generator/tests/route-id.ts @@ -0,0 +1,197 @@ +/** + * Shared test helper: the route constructor call a route file exports as + * `Route`, read from the file's syntax tree (Oxc, Vite's parser). + * + * The route id a file route passes to `createFileRoute` is used by the + * types only (`FileRoutesByPath`); at runtime the router takes ids from the + * route tree. Upkeep of that argument is therefore checked on its parsed + * value, not by running the file. What the file does at runtime is checked + * by loading the route tree with the real router (route-tree.ts). + */ +import { parseSync } from 'vite' + +/** The router packages a route file may import its route constructor from. */ +const routerPackages = /^@tanstack\/(?:react|solid|vue)-router$/ + +/** The route constructor call a route file's `Route` export is. */ +export interface RouteCall { + /** + * The router package export the called constructor is bound to + * (`createFileRoute`, `createLazyFileRoute`, `createRootRoute`, …), or + * undefined when the callee is not bound to a router package import. + */ + constructor: string | undefined + /** The value of the string literal the constructor gets, if any. */ + id: string | undefined +} + +type Node = Record + +/** `node` without the TypeScript wrappers and parentheses around it. */ +function unwrap(node: Node | null | undefined): Node | undefined { + let current = node ?? undefined + while ( + current && + [ + 'TSAsExpression', + 'TSSatisfiesExpression', + 'TSNonNullExpression', + 'TSTypeAssertion', + 'ParenthesizedExpression', + ].includes(current.type) + ) { + current = current.expression + } + return current +} + +/** The value of a string literal or a template literal without expressions. */ +function stringValue(node: Node | undefined) { + if (node?.type === 'Literal' && typeof node.value === 'string') { + return node.value + } + if (node?.type === 'TemplateLiteral' && node.expressions.length === 0) { + return node.quasis[0].value.cooked as string + } + return undefined +} + +/** The name of an identifier or string module export name. */ +function nameOf(node: Node) { + return (node.type === 'Identifier' ? node.name : node.value) as string +} + +/** + * Reads the route constructor call that `code` (a route file) exports as + * `Route`: `export const Route = createFileRoute('/id')({ ... })` or a + * declaration exported under that name, with any TypeScript wrappers. Fails + * when the file does not parse or exports no such `Route`. + */ +export function routeCallOf(code: string, fileName = 'route.tsx'): RouteCall { + const { constructor, id } = findRouteCall(code, fileName) + return { constructor, id } +} + +/** Where a route file's route constructor call is in its source. */ +export interface RouteCallSpans { + /** The callee of the constructor call (`createFileRoute`, `R.createFileRoute`). */ + callee: [start: number, end: number] + /** The constructor's first argument (the route id), if it has one. */ + id: [start: number, end: number] | undefined +} + +/** + * The source spans of the callee and the id argument of the route + * constructor call `code` exports as `Route` (see `routeCallOf`). + */ +export function routeCallSpansOf( + code: string, + fileName = 'route.tsx', +): RouteCallSpans { + const { callee, idArgument } = findRouteCall(code, fileName) + return { + callee: [callee.start, callee.end], + id: idArgument && [idArgument.start, idArgument.end], + } +} + +function findRouteCall(code: string, fileName: string) { + const { program, errors } = parseSync(fileName, code) + if (errors.length) { + throw new Error(errors.map((error) => error.message).join('\n')) + } + + /** Local name to the router package export it is bound to. */ + const bindings = new Map() + /** Local names of namespace imports of a router package. */ + const namespaces = new Set() + /** Top-level variable initializers, by name. */ + const initializers = new Map() + /** The local name exported as `Route`. */ + let exported: string | undefined + + const declare = (declaration: Node | null | undefined) => { + if (declaration?.type === 'VariableDeclaration') { + for (const declarator of declaration.declarations) { + if (declarator.id.type === 'Identifier') { + initializers.set(declarator.id.name, declarator.init) + } + } + } + } + for (const statement of program.body as Array) { + if (statement.type === 'ImportDeclaration') { + if ( + !routerPackages.test(statement.source.value) || + statement.importKind === 'type' + ) { + continue + } + for (const specifier of statement.specifiers) { + if (specifier.type === 'ImportNamespaceSpecifier') { + namespaces.add(specifier.local.name) + } else if ( + specifier.type === 'ImportSpecifier' && + specifier.importKind !== 'type' + ) { + bindings.set(specifier.local.name, nameOf(specifier.imported)) + } + } + } else if (statement.type === 'VariableDeclaration') { + declare(statement) + } else if (statement.type === 'ExportNamedDeclaration') { + declare(statement.declaration) + if ( + statement.declaration?.type === 'VariableDeclaration' && + statement.declaration.declarations.some( + (declarator: Node) => + declarator.id.type === 'Identifier' && + declarator.id.name === 'Route', + ) + ) { + exported = 'Route' + } + if (!statement.source) { + for (const specifier of statement.specifiers) { + if (nameOf(specifier.exported) === 'Route') { + exported = nameOf(specifier.local) + } + } + } + } + } + + const route = exported === undefined ? undefined : initializers.get(exported) + const call = unwrap(route) + if (call?.type !== 'CallExpression') { + throw new Error('The route file exports no Route created by a call') + } + // `createFileRoute('/id')(options)`, or `createRootRoute(options)` + const factory = unwrap(call.callee) + const constructorCall = factory?.type === 'CallExpression' ? factory : call + const callee = unwrap(constructorCall.callee) + let constructor: string | undefined + if (callee?.type === 'Identifier') { + constructor = bindings.get(callee.name) + } else if ( + callee?.type === 'MemberExpression' && + !callee.computed && + callee.object.type === 'Identifier' && + namespaces.has(callee.object.name) + ) { + constructor = callee.property.name + } + const idArgument: Node | undefined = + constructorCall === call ? undefined : constructorCall.arguments[0] + return { + constructor, + id: stringValue(unwrap(idArgument)), + callee: constructorCall.callee as Node, + idArgument, + } +} + +/** The route id a route file passes to its route constructor. */ +export function routeIdOf(code: string): Promise { + return Promise.resolve(routeCallOf(code).id) +} diff --git a/packages/router-generator/tests/route-paths.test.ts b/packages/router-generator/tests/route-paths.test.ts new file mode 100644 index 0000000000..aa6fd6e3b9 --- /dev/null +++ b/packages/router-generator/tests/route-paths.test.ts @@ -0,0 +1,789 @@ +/** + * The URLs routes get from their file names and virtual route configs: + * escaped underscores (`[_]`), literal underscores in virtual paths, route + * groups, pathless layouts, and token and param validation, read from the + * evaluated route tree. + */ +import { describe, expect, test } from 'vitest' +import { + captureThrow, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + index, + layout, + physical, + rootRoute as virtualRootRoute, + route as virtualRoute, +} from '@tanstack/virtual-file-routes' +import { createApp, fileRoute, generate, lazyFileRoute, rootRoute } from './app' +import { checkApp, page } from './real-router' +import { matchesOf, routesOf, urlsOf } from './route-tree' +import type { Config } from '../src' + +/** An app with a root route and a route file for each of `files`. */ +async function appWithRoutes(files: Array) { + const routeFiles: Record = { + 'src/routes/__root.tsx': rootRoute(), + } + for (const file of files) { + routeFiles[`src/routes/${file}`] = fileRoute('/wrong') + } + return createApp(routeFiles) +} + +describe('underscores', () => { + test('an escaped leading underscore after the first segment of a flat route file name stays in the URL', async () => { + const root = await appWithRoutes([ + 'foo.[_]bar.tsx', + 'posts.tsx', + 'posts.a.[_]b.tsx', + ]) + const { generatedRouteTree } = await generate(root) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/foo/_bar': '/foo/_bar', + '/posts': '/posts', + '/posts/a/_b': '/posts/a/_b', + }) + }) + + test('a virtual route path with an underscore after its first segment keeps it in the URL', async () => { + const root = await appWithRoutes([ + 'foobar.tsx', + 'deep.tsx', + 'sub/index.tsx', + ]) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/foo/_bar', 'foobar.tsx'), + virtualRoute('/x/y/_z', 'deep.tsx'), + physical('/api/_v1', 'sub'), + ]), + }) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/foo/_bar': '/foo/_bar', + '/x/y/_z': '/x/y/_z', + '/api/_v1/': '/api/_v1/', + }) + }) + + test('escaped underscores in a physical directory mounted under a virtual route with a literal underscore stay in the URLs', async () => { + const root = await appWithRoutes([ + 'foo.tsx', + 'phys/[_]hello.tsx', + 'phys/blog[_].tsx', + 'phys/[_]q/w.tsx', + 'phys/index.tsx', + ]) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/_foo', 'foo.tsx', [physical('/_p', 'phys')]), + ]), + }) + + const urls = await urlsOf(generatedRouteTree) + const routes = await routesOf(generatedRouteTree) + expect( + Object.fromEntries( + Object.entries(routes).map(([id, file]) => [file, urls[id]]), + ), + ).toEqual({ + 'routes/__root.tsx': '/', + 'routes/foo.tsx': '/_foo', + 'routes/phys/[_]hello.tsx': '/_foo/_p/_hello', + 'routes/phys/blog[_].tsx': '/_foo/_p/blog_', + 'routes/phys/[_]q/w.tsx': '/_foo/_p/_q/w', + 'routes/phys/index.tsx': '/_foo/_p/', + }) + }) + + test('virtual layouts and an index under a virtual route with a literal underscore', async () => { + const root = await appWithRoutes([ + 'foo.tsx', + 'lay.tsx', + 'inner.tsx', + 'fooindex.tsx', + ]) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/_foo', 'foo.tsx', [ + layout('lay', 'lay.tsx', [virtualRoute('/inner', 'inner.tsx')]), + index('fooindex.tsx'), + ]), + ]), + }) + + const urls = await urlsOf(generatedRouteTree) + const routes = await routesOf(generatedRouteTree) + expect( + Object.fromEntries( + Object.entries(routes).map(([id, file]) => [file, urls[id]]), + ), + ).toEqual({ + 'routes/__root.tsx': '/', + 'routes/foo.tsx': '/_foo', + 'routes/lay.tsx': '/_foo', + 'routes/inner.tsx': '/_foo/inner', + 'routes/fooindex.tsx': '/_foo/', + }) + }) + + test('a pathless layout under a route with an escaped leading underscore adds no path segment', async () => { + const root = await appWithRoutes([ + '[_]api.tsx', + '[_]api/_auth.tsx', + '[_]api/_auth/users.tsx', + ]) + const { generatedRouteTree } = await generate(root) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/_api': '/_api', + '/_api/_auth': '/_api', + '/_api/_auth/users': '/_api/users', + }) + }) + + // Escapes and un-nesting in directory route files under pathless + // layouts (file-naming-conventions.md: `_` prefix pathless, `_` suffix + // un-nesting, `[x]` escapes); ported from the helper tests of utils.ts. + test('escaped and trailing underscores under pathless layouts keep or drop their underscores as escaped', async () => { + const root = await appWithRoutes([ + '_layout.tsx', + '_layout/[_][_]foo.tsx', + '_layout/bar_/index.tsx', + '_layout/[_]baz[_]/index.tsx', + '[_]a/bar[_]/[_baz_]/index.tsx', + '[_]auth/_admin.tsx', + '[_]auth/_admin/dashboard.tsx', + ]) + const { generatedRouteTree } = await generate(root) + + const urls = await urlsOf(generatedRouteTree) + const routes = await routesOf(generatedRouteTree) + expect( + Object.fromEntries( + Object.entries(routes).map(([id, file]) => [file, urls[id]]), + ), + ).toEqual({ + 'routes/__root.tsx': '/', + 'routes/_layout.tsx': '/', + 'routes/_layout/[_][_]foo.tsx': '/__foo', + 'routes/_layout/bar_/index.tsx': '/bar/', + 'routes/_layout/[_]baz[_]/index.tsx': '/_baz_/', + 'routes/[_]a/bar[_]/[_baz_]/index.tsx': '/_a/bar_/_baz_/', + 'routes/[_]auth/_admin.tsx': '/_auth', + 'routes/[_]auth/_admin/dashboard.tsx': '/_auth/dashboard', + }) + }) +}) + +describe('virtual route paths', () => { + test('virtual route paths and physical mount prefixes without a leading slash get the same URLs', async () => { + const root = await appWithRoutes(['x.tsx', 'dir/index.tsx']) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('docs/intro', 'x.tsx'), + physical('api/v1', 'dir'), + ]), + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/docs/intro': 'routes/x.tsx', + '/api/v1/': 'routes/dir/index.tsx', + }) + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/docs/intro': '/docs/intro', + '/api/v1/': '/api/v1/', + }) + }) + + // In a virtual route path a dot is a literal character, and a bracket + // escape stands for its content (no file-route separators apply). + test('dots and bracket escapes in virtual route paths are literal characters of the URL', async () => { + const root = await appWithRoutes(['a.tsx', 'b.tsx']) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/files.json', 'a.tsx'), + virtualRoute('/pathless[.]layout', 'b.tsx'), + ]), + }) + + const urls = await urlsOf(generatedRouteTree) + const routes = await routesOf(generatedRouteTree) + expect( + Object.fromEntries( + Object.entries(routes).map(([id, file]) => [file, urls[id]]), + ), + ).toEqual({ + 'routes/__root.tsx': '/', + 'routes/a.tsx': '/files.json', + 'routes/b.tsx': '/pathless.layout', + }) + }) + + // A virtual route config built with `path.join` on Windows has backslash + // separators in its file paths. + test('virtual route files given with Windows path separators are imported', async () => { + const root = await appWithRoutes(['docs/intro.tsx', 'docs/index.tsx']) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/intro', 'docs\\intro.tsx'), + index('docs\\index.tsx'), + ]), + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/intro': 'routes/docs/intro.tsx', + '/': 'routes/docs/index.tsx', + }) + }) +}) + +describe('layouts and groups', () => { + test('a route group layout adds no path segment', async () => { + const root = await appWithRoutes([ + '(auth)/route.tsx', + '(auth)/login.tsx', + 'shop.tsx', + 'shop/(account)/route.tsx', + 'shop/(account)/orders.tsx', + ]) + const { generatedRouteTree } = await generate(root) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/(auth)': '/', + '/(auth)/login': '/login', + '/shop': '/shop', + '/shop/(account)': '/shop', + '/shop/(account)/orders': '/shop/orders', + }) + }) + + // Control for the pins below (same harness, no index route). + test('a pathless layout without child routes yet is added to the route tree', async () => { + const root = await appWithRoutes(['about.tsx', '_auth.tsx']) + const { generatedRouteTree } = await generate(root) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/about': 'routes/about.tsx', + '/_auth': 'routes/_auth.tsx', + }) + }) + + // Bug: a pathless layout file without children yet (`_auth.tsx` or + // `_auth.lazy.tsx`) next to the index route fails the generator with + // "Conflicting configuration paths were found" for `/` (the layout's full + // path is `/`, like the index route's), although the layout matches no URL + // of its own. A childless pathless layout is a valid, if useless, route + // (SPEC J1.15; routing/file-naming-conventions.md:35). + // Source: src/utils.ts:1101-1125 (`checkRouteFullPathUniqueness` compares + // the inferred full paths of all routes, pathless layouts included). + // Impact: creating `_auth.tsx` before its first child route stops route + // generation for the whole app. + test.fails.each([ + { name: '_auth.tsx', file: '_auth.tsx', constructor: 'createFileRoute' }, + { + name: '_auth.lazy.tsx', + file: '_auth.lazy.tsx', + constructor: 'createLazyFileRoute', + }, + ])( + 'a pathless layout without child routes yet ($name) next to the index route is added to the route tree', + ({ file, constructor }) => + checkApp({ + name: `a childless ${file} next to the index route`, + files: { + 'src/routes/__root.tsx': page( + 'react', + 'createRootRoute', + 'root', + true, + ), + 'src/routes/index.tsx': page('react', 'createFileRoute', 'home'), + [`src/routes/${file}`]: page('react', constructor, 'auth', true), + }, + expected: { + __root__: ['/', null], + '/': ['/', '__root__'], + '/_auth': ['/', '__root__'], + }, + visits: { '/': '/' }, + pages: { '/': ['root', 'home'] }, + }), + 60_000, + ) + + // A pathless layout under a route that exists only as a lazy route file + // (`posts.lazy.tsx`, no `posts.tsx`) nests under the lazy-only route's + // virtual anchor (guide/code-splitting.md:222-224; SPEC J1.14). Control for + // the pin below. + test( + 'a pathless layout under a route with only a lazy route file nests under that route', + () => + checkApp( + { + name: 'a pathless layout under a lazy-only route', + files: { + 'src/routes/__root.tsx': page( + 'react', + 'createRootRoute', + 'root', + true, + ), + 'src/routes/posts.lazy.tsx': page( + 'react', + 'createLazyFileRoute', + 'posts', + true, + ), + 'src/routes/posts/_layout.tsx': page( + 'react', + 'createFileRoute', + 'layout', + true, + ), + 'src/routes/posts/_layout/child.tsx': page( + 'react', + 'createFileRoute', + 'child', + ), + }, + expected: { + __root__: ['/', null], + '/posts': ['/posts', '__root__'], + '/posts/_layout': ['/posts', '/posts'], + '/posts/_layout/child': ['/posts/child', '/posts/_layout'], + }, + visits: { '/posts/child': '/posts/_layout/child' }, + pages: { '/posts/child': ['root', 'posts', 'layout', 'child'] }, + }, + // (the types of the same shapes: the pin below) + { types: false }, + ), + 60_000, + ) + + // Bug (SPEC J1.14): a pathless layout one directory below a lazy-only route + // (`app/posts.lazy.tsx`, no `app/posts.tsx`, and + // `app/posts/drafts/_layout.tsx` with children) is attached to the next + // real ancestor (`/app`) instead of to the lazy-only route's virtual anchor + // `/app/posts`, so `/app/posts/drafts/child` renders without the + // `/app/posts` page around it (same rule as the control above: + // guide/code-splitting.md:222-224; SPEC J1.14). Distinct from the pin of a + // lazy-only pathless layout losing its directory path. + // Source: src/generator.ts:1561-1606 (`isPathlessLayoutWithPath`: the + // search for the layout's parent skips virtual routes, which include the + // anchors of lazy-only routes). + // Impact: the lazy-only route's component (its layout) and its loaders do + // not wrap the pages under such a layout. + test.fails( + 'a pathless layout in a directory under a route with only a lazy route file nests under that route', + () => + checkApp({ + name: 'a pathless layout in a directory under a lazy-only route', + files: { + 'src/routes/__root.tsx': page( + 'react', + 'createRootRoute', + 'root', + true, + ), + 'src/routes/app.tsx': page('react', 'createFileRoute', 'app', true), + 'src/routes/app/posts.lazy.tsx': page( + 'react', + 'createLazyFileRoute', + 'posts', + true, + ), + 'src/routes/app/posts/drafts/_layout.tsx': page( + 'react', + 'createFileRoute', + 'layout', + true, + ), + 'src/routes/app/posts/drafts/_layout/child.tsx': page( + 'react', + 'createFileRoute', + 'child', + ), + }, + expected: { + __root__: ['/', null], + '/app': ['/app', '__root__'], + '/app/posts': ['/app/posts', '/app'], + '/app/posts/drafts/_layout': ['/app/posts/drafts', '/app/posts'], + '/app/posts/drafts/_layout/child': [ + '/app/posts/drafts/child', + '/app/posts/drafts/_layout', + ], + }, + visits: { + '/app/posts/drafts/child': '/app/posts/drafts/_layout/child', + }, + pages: { + '/app/posts/drafts/child': [ + 'root', + 'app', + 'posts', + 'layout', + 'child', + ], + }, + }), + 60_000, + ) + + // A layout with a piece file only (no route file) still adds no path + // segment, and is no page of its own (a layout given `path: '/'` makes the + // router match the layout itself at `/`). + test('a pathless layout with only a Vue component piece in a route group has no path', async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/(group)/_layout.component.vue': `\n`, + 'src/routes/(group)/_layout/inner.ts': fileRoute( + '/(group)/_layout/inner', + '{}', + 'vue', + ), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/(group)/_layout': '/', + '/(group)/_layout/inner': '/inner', + }) + // (the layout is no page: the router does not match it at `/`) + expect(await matchesOf(generatedRouteTree, '/')).not.toContain( + '/(group)/_layout', + ) + }) + + // Bug: a pathless layout with a lazy route file only (`foo/_auth.lazy.tsx`, + // no `foo/_auth.tsx`) or a Vue piece only (`foo/_layout.component.vue`) + // becomes a route without a file whose node is typed `static`, and the + // route tree prints a `path` only for non-pathless nodes and for nodes + // typed `pathless_layout` (src/generator.ts, the `path:` option of + // `createUpdateRoutes`), so the layout loses the `/foo` prefix it carries + // when nothing above it is a route. The route tree's types still say + // `/foo/bar`. A layout with a route file (`foo/_auth.tsx`) is right. + // Impact: the child route matches `/bar` instead of `/foo/bar`, and + // links typed `/foo/bar` lead nowhere. Unlike the case of SPEC J1.14 (a + // pathless layout with a route file under a lazy-only route: which route + // is its parent), here the URL disagrees with the generated types. + // Source: mutation testing. + test.fails.each<{ + name: string + target: 'react' | 'vue' + files: Record + child: string + }>([ + { + name: 'a lazy route file', + target: 'react', + files: { + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/foo/_auth.lazy.tsx': lazyFileRoute('/foo/_auth'), + 'src/routes/foo/_auth/bar.tsx': fileRoute('/foo/_auth/bar'), + }, + child: '/foo/_auth/bar', + }, + { + name: 'a Vue component piece', + target: 'vue', + files: { + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/foo/_layout.component.vue': `\n`, + 'src/routes/foo/_layout/bar.ts': fileRoute( + '/foo/_layout/bar', + '{}', + 'vue', + ), + }, + child: '/foo/_layout/bar', + }, + ])( + 'a pathless layout with only $name under a path keeps the path in the URLs of its children', + async ({ target, files, child }) => { + const root = await createApp(files) + const { generatedRouteTree } = await generate(root, { target }) + + expect((await urlsOf(generatedRouteTree))[child]).toBe('/foo/bar') + }, + ) + + // Control for the pin above (same harness). + test('a pathless layout with a route file under a path keeps the path in the URLs of its children', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/foo/_auth.tsx': fileRoute('/foo/_auth'), + 'src/routes/foo/_auth/bar.tsx': fileRoute('/foo/_auth/bar'), + }) + const { generatedRouteTree } = await generate(root) + + expect((await urlsOf(generatedRouteTree))['/foo/_auth/bar']).toBe( + '/foo/bar', + ) + }) + + test('two sections with grandchildren give a valid route tree without formatting', async () => { + const root = await appWithRoutes([ + 'a.tsx', + 'a.b.tsx', + 'a.b.c.tsx', + 'd.tsx', + 'd.e.tsx', + 'd.e.f.tsx', + ]) + const { generatedRouteTree } = await generate(root, { + enableRouteTreeFormatting: false, + }) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/a': '/a', + '/a/b': '/a/b', + '/a/b/c': '/a/b/c', + '/d': '/d', + '/d/e': '/d/e', + '/d/e/f': '/d/e/f', + }) + }) +}) + +describe('conflicting routes', () => { + // (Files are named absolute or project-relative, telling same-named files + // apart, SPEC J1.7, §5.7.) + test('routes with the same URL fail the generator with an error naming both files', async () => { + const root = await appWithRoutes(['index.tsx', '_auth/index.tsx']) + + const error = await captureThrow(() => generate(root)) + const files = ['src/routes/index.tsx', 'src/routes/_auth/index.tsx'] + for (const file of files) { + expectDiagnostic(error, { + severity: 'error', + file, + root, + }) + } + }) + + // The docs' example of a physical directory merged at the current level + // (virtual-file-routes.md, "Merging Physical Routes at Current Level"): an + // empty path prefix is no conflict by itself. + test.each([ + { name: 'a directory only', mount: physical('features') }, + { name: 'an empty path prefix', mount: physical('', 'features') }, + ])( + 'a physical directory mounted with $name merges its routes at the current level', + async ({ mount }) => { + const root = await appWithRoutes([ + 'about.tsx', + 'features/index.tsx', + 'features/contact.tsx', + ]) + const { generatedRouteTree } = await generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/about', 'about.tsx'), + mount, + ]), + }) + + const urls = await urlsOf(generatedRouteTree) + const routes = await routesOf(generatedRouteTree) + expect( + Object.fromEntries( + Object.entries(routes).map(([id, file]) => [file, urls[id]]), + ), + ).toEqual({ + 'routes/__root.tsx': '/', + 'routes/about.tsx': '/about', + 'routes/features/index.tsx': '/', + 'routes/features/contact.tsx': '/contact', + }) + }, + ) + + test('a route of a directory merged at the current level with the path of a virtual route fails the generator with an error naming both files', async () => { + const root = await appWithRoutes(['about.tsx', 'features/about.tsx']) + + const error = await captureThrow(() => + generate(root, { + virtualRouteConfig: virtualRootRoute('__root.tsx', [ + virtualRoute('/about', 'about.tsx'), + physical('', 'features'), + ]), + }), + ) + const files = ['src/routes/about.tsx', 'src/routes/features/about.tsx'] + for (const file of files) { + expectDiagnostic(error, { + severity: 'error', + file, + root, + }) + } + }) + + // (A layout route file at the root of a directory merged at the current + // level, `physical('', 'merged')` with `merged/route.tsx`: not tested; the + // spec, J1.7, leaves virtual route configs the docs do not describe open.) +}) + +describe('route names', () => { + test('routes whose names differ only by a leading @ get their own routes', async () => { + const root = await appWithRoutes(['@me.tsx', 'me.tsx']) + const { generatedRouteTree } = await generate(root) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/@me': 'routes/@me.tsx', + '/me': 'routes/me.tsx', + }) + }) + + test('a route file name with a space gets a route with the space in its URL', async () => { + const root = await appWithRoutes(['about us.tsx']) + const { generatedRouteTree } = await generate(root) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/about us': '/about us', + }) + }) + + // Control: the test above (same harness, a name with a space). + + // Bug: the route tree writes route file paths and route ids into + // single-quoted strings unescaped, so a route file whose name contains an + // apostrophe ends the string: the route tree does not parse and the run + // fails ("';' expected"). + // Source: src/utils.ts:1196 (`buildImportString`: `from '${source}'`), + // src/generator.ts:703-706 (`id: '${node.path}'`, `path: '...'`). + // Impact: an app with, e.g., `what's-new.tsx` gets no route tree until + // the file is renamed. + test.fails( + 'a route file name with an apostrophe gets a route with it in its URL', + async () => { + const root = await appWithRoutes(["what's-new.tsx"]) + const { generatedRouteTree } = await generate(root) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + "/what's-new": "/what's-new", + }) + }, + ) + + // Control: "routes whose names differ only by a leading @ get their own + // routes" above (same harness, two names the route tree tells apart). + + // Bug: routes whose paths differ only in characters that are not valid in + // an identifier (`-`, `_`, `$`, a space) or in letter case get the same + // variable in the route tree, which then declares it twice and fails to + // parse ("Identifier has already been declared"). + // Source: src/utils.ts (routePathToVariable / getResolvedRouteNodeVariableName: + // no deduplication of the generated names). + // Impact: an app with, e.g., `about-us.tsx` and `aboutUs.tsx` fails to + // build until one of the files is renamed. + test.fails.each([ + { files: ['about-us.tsx', 'aboutUs.tsx'], ids: ['/about-us', '/aboutUs'] }, + { + files: ['blog.tsx', 'blog/_layout.tsx', 'blog/layout.tsx'], + ids: ['/blog', '/blog/_layout', '/blog/layout'], + }, + { + files: ['users.tsx', 'users/$id.tsx', 'users/id.tsx'], + ids: ['/users', '/users/$id', '/users/id'], + }, + { files: ['a b.tsx', 'ab.tsx'], ids: ['/a b', '/ab'] }, + ])('routes $ids get their own routes', async ({ files, ids }) => { + const root = await appWithRoutes(files) + const { generatedRouteTree } = await generate(root) + + expect(Object.keys(await routesOf(generatedRouteTree)).sort()).toEqual( + ['__root__', ...ids].sort(), + ) + }) +}) + +describe('token options', () => { + test.each([ + { + name: 'a JSON regex with the g flag', + routeToken: { regex: 'layout', flags: 'g' }, + }, + { name: 'a RegExp with the g flag', routeToken: /layout/g }, + ] satisfies Array & { name: string }>)( + 'a routeToken that is $name matches every layout file', + async ({ name: _name, ...config }) => { + const files = ['a', 'b', 'c', 'd'].flatMap((dir) => [ + `${dir}/layout.tsx`, + `${dir}/x.tsx`, + ]) + const root = await appWithRoutes(files) + const { generatedRouteTree } = await generate(root, config) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + ...Object.fromEntries( + ['a', 'b', 'c', 'd'].flatMap((dir) => [ + [`/${dir}`, `routes/${dir}/layout.tsx`], + [`/${dir}/x`, `routes/${dir}/x.tsx`], + ]), + ), + }) + }, + ) + + test('an indexToken that is a JSON regex with the g flag matches every index file', async () => { + const root = await appWithRoutes(['a/home.tsx', 'b/home.tsx', 'c/home.tsx']) + const { generatedRouteTree } = await generate(root, { + indexToken: { regex: 'home', flags: 'g' }, + }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/a/': 'routes/a/home.tsx', + '/b/': 'routes/b/home.tsx', + '/c/': 'routes/c/home.tsx', + }) + }) + + test.each([ + { + name: 'a JSON regex with the i flag', + indexToken: { regex: 'home', flags: 'i' }, + }, + { name: 'a RegExp with the i flag', indexToken: /home/i }, + ] satisfies Array & { name: string }>)( + 'an indexToken that is $name matches index files whatever their case', + async ({ name: _name, ...config }) => { + const root = await appWithRoutes(['a/Home.tsx', 'b/HOME.tsx']) + const { generatedRouteTree } = await generate(root, config) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/a/': 'routes/a/Home.tsx', + '/b/': 'routes/b/HOME.tsx', + }) + }, + ) +}) + +// (Warnings about param names that are no identifiers, e.g. `$user-name`: +// neither required nor forbidden, SPEC J1.12; not tested. The routes of +// such files: the invalid-param-names fixture, generator.test.ts.) + +// (The route tree types of these shapes, FileRoutesByTo and +// routes by full path: integration/route-types.test.ts.) diff --git a/packages/router-generator/tests/route-pieces.test.ts b/packages/router-generator/tests/route-pieces.test.ts new file mode 100644 index 0000000000..37ea099596 --- /dev/null +++ b/packages/router-generator/tests/route-pieces.test.ts @@ -0,0 +1,357 @@ +/** + * Route piece files: Vue single-file components named after a route and a + * component option (`posts.component.vue`, `__root.errorComponent.vue`, …) + * become that option of the route, loaded lazily from the file's default + * export. The generator never writes to them. Checked with the real router + * and real Vue: each option, once the router loaded the route, renders the + * single-file component (compiled by the Vue plugin of a real Vite server). + */ +import { afterEach, describe, expect, test, vi } from 'vitest' +import { createSSRApp } from 'vue' +import { renderToString } from 'vue/server-renderer' +import { createApp, fileRoute, generate, read, rootRoute } from './app' +import { routeIdOf } from './route-id' +import { evaluateModule, routesOf, urlsOf, withRouteTree } from './route-tree' + +afterEach(() => { + vi.restoreAllMocks() +}) + +/** A Vue single-file component rendering `text`. */ +const sfc = (text: string) => ` + + +` + +/** The texts of the `

` elements of server-rendered `html`, joined. */ +const textOf = (html: string) => + [...html.matchAll(/

([^<]*)<\/p>/g)].map((match) => match[1]).join(' ') + +/** The component options a route may have. */ +const componentOptions = [ + 'component', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', +] as const + +/** + * The text each component option of each route renders, by route id, once + * the router loaded the route (its lazy route file and components). Piece + * files load lazily: the app that loaded the route tree has loaded none of + * them before a route is loaded. + */ +function piecesOf(treeFile: string) { + return withRouteTree(treeFile, async ({ router, render, loadedFiles }) => { + expect( + loadedFiles().filter((file) => file.endsWith('.vue')), + 'the piece files loaded with the route tree, before any route is loaded', + ).toEqual([]) + const pieces: Record> = {} + for (const route of Object.values(router.routesById)) { + await router.loadRouteChunk(route) + pieces[route.id] = {} + for (const option of componentOptions) { + if (route.options[option]) { + pieces[route.id]![option] = textOf( + await render(route.options[option]), + ) + } + } + } + return pieces + }) +} + +describe('Vue piece files', () => { + test('pieces of routes and of the root route are lazy components of their default export, and are left untouched', async () => { + const files = { + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/__root.component.vue': sfc('root'), + 'src/routes/__root.notFoundComponent.vue': sfc('root not found'), + 'src/routes/__root.errorComponent.vue': sfc('root error'), + 'src/routes/__root.pendingComponent.vue': sfc('root pending'), + 'src/routes/index.ts': fileRoute('/', '{}', 'vue'), + 'src/routes/index.component.vue': sfc('index'), + 'src/routes/posts.ts': fileRoute('/posts', '{}', 'vue'), + 'src/routes/posts.pendingComponent.vue': sfc('posts pending'), + 'src/routes/posts.errorComponent.vue': sfc('posts error'), + 'src/routes/posts.notFoundComponent.vue': sfc('posts not found'), + 'src/routes/posts.$postId.ts': fileRoute('/posts/$postId', '{}', 'vue'), + 'src/routes/posts.$postId.component.vue': sfc('post'), + 'src/routes/posts.$postId.errorComponent.vue': sfc('post error'), + 'src/routes/settings.ts': fileRoute('/settings', '{}', 'vue'), + 'src/routes/settings.pendingComponent.vue': sfc('settings pending'), + // A route with only a piece file and no route file + 'src/routes/about.component.vue': sfc('about'), + } + const root = await createApp(files) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.ts', + '/': 'routes/index.ts', + '/about': null, + '/posts': 'routes/posts.ts', + '/posts/$postId': 'routes/posts.$postId.ts', + '/settings': 'routes/settings.ts', + }) + expect(await piecesOf(generatedRouteTree)).toEqual({ + __root__: { + component: 'root', + notFoundComponent: 'root not found', + errorComponent: 'root error', + pendingComponent: 'root pending', + }, + '/': { component: 'index' }, + '/about': { component: 'about' }, + '/posts': { + pendingComponent: 'posts pending', + errorComponent: 'posts error', + notFoundComponent: 'posts not found', + }, + '/posts/$postId': { component: 'post', errorComponent: 'post error' }, + '/settings': { pendingComponent: 'settings pending' }, + }) + for (const [file, content] of Object.entries(files)) { + expect(await read(root, file)).toBe(content) + } + }) + + test('with disableTypes, pieces of routes and of the root route are lazy components in a JavaScript route tree', async () => { + const root = await createApp({ + 'src/routes/__root.js': rootRoute('vue'), + 'src/routes/__root.component.vue': sfc('root'), + 'src/routes/index.js': fileRoute('/', '{}', 'vue'), + 'src/routes/index.component.vue': sfc('index'), + }) + const { generatedRouteTree } = await generate(root, { + target: 'vue', + disableTypes: true, + }) + + expect(generatedRouteTree.endsWith('.js')).toBe(true) + expect(await piecesOf(generatedRouteTree)).toEqual({ + __root__: { component: 'root' }, + '/': { component: 'index' }, + }) + }) + + test('a component piece of a route with child routes leaves the children under the route', async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/posts.ts': fileRoute('/posts', '{}', 'vue'), + 'src/routes/posts.component.vue': sfc('posts'), + 'src/routes/posts.$postId.ts': fileRoute('/posts/$postId', '{}', 'vue'), + 'src/routes/posts.$postId.edit.ts': fileRoute( + '/posts/$postId/edit', + '{}', + 'vue', + ), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.ts', + '/posts': 'routes/posts.ts', + '/posts/$postId': 'routes/posts.$postId.ts', + '/posts/$postId/edit': 'routes/posts.$postId.edit.ts', + }) + expect((await piecesOf(generatedRouteTree))['/posts']).toEqual({ + component: 'posts', + }) + }) + + // A `.lazy` route file is a piece of its route too, and may come first (a + // scan for the pieces the route tree needs `lazyRouteComponent` for that + // stopped at the first route with any piece made the tree call it without + // importing it). + test('a route with a lazy route file next to a route with a component piece both get their lazy parts', async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/about.ts': fileRoute('/about', '{}', 'vue'), + 'src/routes/about.lazy.ts': `import { h } from 'vue' +import { createLazyFileRoute } from '@tanstack/vue-router' + +export const Route = createLazyFileRoute('/about')({ + component: () => h('p', 'about lazy'), +}) +`, + 'src/routes/posts.ts': fileRoute('/posts', '{}', 'vue'), + 'src/routes/posts.component.vue': sfc('posts'), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await piecesOf(generatedRouteTree)).toEqual({ + __root__: {}, + '/about': { component: 'about lazy' }, + '/posts': { component: 'posts' }, + }) + }) + + // Bug: the route file of a directory route is `route.ts` (the default + // `routeToken`), but a piece file next to it (`posts/route.component.vue`) + // keeps the `route` segment: route nodes strip only one suffix per file + // (src/filesystem/physical/getRouteNodes.ts, `suffixToStrip ?? + // lastRouteSegment`), the piece suffix here, so the piece belongs to a + // route `/posts/route` of its own. Flat files (`posts.component.vue`) and + // index pieces (`posts.index.component.vue`) work. + // Impact: in a Vue app with directory routes, the layout's component + // piece is a page at `/posts/route` instead of the `/posts` layout's + // component. + // Source: mutation testing. + test.fails( + 'a component piece of a directory route (route.component.vue) is the component of the route', + async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/posts/route.ts': fileRoute('/posts', '{}', 'vue'), + 'src/routes/posts/route.component.vue': sfc('posts'), + 'src/routes/posts/index.ts': fileRoute('/posts/', '{}', 'vue'), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await urlsOf(generatedRouteTree)).toEqual({ + __root__: '/', + '/posts': '/posts', + '/posts/': '/posts/', + }) + expect((await piecesOf(generatedRouteTree))['/posts']).toEqual({ + component: 'posts', + }) + }, + ) + + // Bug: a `.lazy.vue` route file is wired as the route's lazy route + // (`.lazy(() => import('./routes/about.lazy.vue').then((d) => d.default))`, + // src/generator.ts, the `lazyComponentNode` branch), but a single-file + // component's default export is a component, not a lazy route: the router + // reads the lazy route's `options` (router-core load-client.ts), which the + // component does not have, so loading the route fails. + // Impact: a Vue app with a `.lazy.vue` route file fails when the route + // loads (low: the documented Vue piece is `.component.vue`). A + // `.lazy.vue` file is the lazily loaded component of its route (SPEC + // J1.17). + // Source: mutation testing. + test.fails( + 'a .lazy.vue route file is the lazily loaded component of the route', + async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/about.ts': fileRoute('/about', '{}', 'vue'), + 'src/routes/about.lazy.vue': sfc('about'), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + await withRouteTree(generatedRouteTree, async (tree) => { + // (lazily: the app does not load it before the route renders) + expect(tree.loadedFiles()).not.toContain('routes/about.lazy.vue') + expect(textOf(await tree.renderAt('/about'))).toBe('about') + }) + }, + ) + + // Bug: when only the root route has piece files, the route tree calls + // `lazyRouteComponent` without importing it, and fails to load with + // "ReferenceError: lazyRouteComponent is not defined". + // Source: src/generator.ts:652-680 (the runtime import is added for the + // pieces of non-root routes only). + // Impact: a Vue app whose only piece file is, e.g., `__root.component.vue` + // fails to start. + test.fails( + 'pieces of the root route only are lazy components of their default export', + async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/__root.component.vue': sfc('root'), + 'src/routes/index.ts': fileRoute('/', '{}', 'vue'), + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await piecesOf(generatedRouteTree)).toEqual({ + __root__: { component: 'root' }, + '/': {}, + }) + }, + ) +}) + +describe('empty files', () => { + test.each([ + 'posts.component.vue', + 'posts.errorComponent.vue', + 'posts.pendingComponent.vue', + 'posts.notFoundComponent.vue', + 'posts.loader.ts', + ])( + 'an empty piece file %s is left empty and unused, and the routes still generate', + async (file) => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/posts.ts': fileRoute('/posts', '{}', 'vue'), + [`src/routes/${file}`]: '', + }) + const { generatedRouteTree } = await generate(root, { target: 'vue' }) + + expect(await read(root, `src/routes/${file}`)).toBe('') + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.ts', + '/posts': 'routes/posts.ts', + }) + // The routes load and render (whatever the generator did with the + // empty file: an attached piece must load and render too). + await piecesOf(generatedRouteTree) + await withRouteTree(generatedRouteTree, ({ renderAt }) => + renderAt('/posts'), + ) + }, + ) + + // Bug: an empty `.lazy.vue` file is scaffolded like a `.lazy.tsx` file: + // the generator writes TypeScript route code (`import { h } from 'vue'`, + // `createLazyFileRoute(...)`) into the single-file component, which no + // Vue compiler accepts (src/generator.ts, scaffolding of empty route + // files; the other Vue pieces are left empty, the rows above). + // Impact: creating an empty `about.lazy.vue` in a Vue app turns it into a + // file that fails to compile (low). + // Source: mutation testing. + test.fails( + 'an empty .lazy.vue route file is not filled with TypeScript route code', + async () => { + const root = await createApp({ + 'src/routes/__root.ts': rootRoute('vue'), + 'src/routes/about.ts': fileRoute('/about', '{}', 'vue'), + 'src/routes/about.lazy.vue': '', + }) + await generate(root, { target: 'vue' }) + + const content = await read(root, 'src/routes/about.lazy.vue') + // Empty, or a single-file component the Vue plugin compiles to a + // component that renders. + if (content !== '') { + const { exports } = await evaluateModule(content, 'about.lazy.vue') + await renderToString(createSSRApp(exports.default)) + } + }, + ) + + test('an empty pathless layout file is scaffolded and added to the route tree', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': rootRoute(), + 'src/routes/_auth.tsx': '', + }) + const { generatedRouteTree } = await generate(root) + + expect(await routeIdOf(await read(root, 'src/routes/_auth.tsx'))).toBe( + '/_auth', + ) + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/_auth': 'routes/_auth.tsx', + }) + }) +}) diff --git a/packages/router-generator/tests/route-tree.ts b/packages/router-generator/tests/route-tree.ts new file mode 100644 index 0000000000..42bdb17a52 --- /dev/null +++ b/packages/router-generator/tests/route-tree.ts @@ -0,0 +1,429 @@ +/** + * A public generator consumer: Vite resolves the app's explicit public + * runtime/renderer imports. Fixture source identities are compared with their + * real exports; no dependency layout or runner module inventory is inspected. + * A public Vite transform hook observes requests for fixture-owned files only. + */ +import { mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { randomUUID } from 'node:crypto' +import { createServer, createServerModuleRunner, parseSync } from 'vite' +import { openDiagnosticChannel } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { runDirectory } from '@tanstack/compiler-test-utils/run-directory' +import { inputsOf, recordInputs } from './consumer-inputs' +import type { PluginOption } from 'vite' +import type { createClientConsumer as CreateClientConsumer } from './consumer-client' + +const nodeModules = path.resolve(import.meta.dirname, '../node_modules') + +/** Imports chosen from fixture INPUTS, never from generated imports or dist paths. */ +function frameworkOf(files: Record) { + const sources = Object.values(files).join('\n') + if (sources.includes('@tanstack/solid-router')) { + return 'solid' + } + if ( + sources.includes('@tanstack/vue-router') || + Object.keys(files).some((file) => file.endsWith('.vue')) + ) { + return 'vue' + } + return 'react' +} + +/** A normal app entry with explicit public package imports, in the same runner. */ +function consumerSource(framework: string) { + const render = + framework === 'react' + ? `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +export const render = (Component, props = {}) => renderToString(createElement(Component, props))` + : framework === 'vue' + ? `import { createSSRApp, h } from 'vue' +import { renderToString } from 'vue/server-renderer' +export const render = (Component, props = {}) => renderToString(createSSRApp({ render: () => h(Component, props) }))` + : `import { renderToStringAsync, createComponent } from 'solid-js/web' +export const render = (Component, props = {}) => renderToStringAsync(() => createComponent(Component, props))` + return `export * as runtime from '@tanstack/${framework}-router'\n${render}` +} + +async function withModule( + file: string, + use: (loaded: { + exports: Record + runtime: Record + framework: string + sources: Map> + loadedFiles: () => Array + import: (file: string) => Promise> + render: (Component: any, props?: object) => Promise + imports: Array<{ file: string; specifier: string; importer: string }> + }) => Promise | T, +): Promise { + const realFile = await realpath(file) + const { root, files, target: framework } = inputsOf(realFile) + // In-repository fixtures already resolve the package's dependencies from + // their parent. Only standalone temporary apps need their own link. + const fromPackage = path.relative(path.dirname(nodeModules), root) + if (fromPackage.startsWith('..') || path.isAbsolute(fromPackage)) { + await symlink( + nodeModules, + path.join(root, 'node_modules'), + 'junction', + ).catch((error: NodeJS.ErrnoException) => { + if (error.code !== 'EEXIST') { + throw error + } + }) + } + const requested = new Set() + const printedRequests = new Map>() + const imports: Array<{ file: string; specifier: string; importer: string }> = + [] + const plugins: Array = [ + { + name: 'generator-consumer:fixture-requests', + enforce: 'pre', + async resolveId(specifier, importer) { + if ( + !importer || + (!specifier.startsWith('.') && !path.isAbsolute(specifier)) + ) { + return + } + const resolved = await this.resolve(specifier, importer, { + skipSelf: true, + }) + if (resolved) { + const file = resolved.id.split('?')[0]! + if ( + file in files && + printedRequests.get(importer.split('?')[0]!)?.has(specifier) + ) { + imports.push({ file, specifier, importer: importer.split('?')[0]! }) + } + } + return resolved + }, + transform(code, id) { + const file = id.split('?')[0]! + if (file in files) { + requested.add(file) + } else if ( + file.startsWith(root + path.sep) && + !file.includes('/node_modules/') && + /\.[cm]?[jt]sx?$/.test(file) + ) { + // Distinguish source imports from Vite's subsequent canonical-id + // requests. Oxc decodes literals; Vite still resolves every edge. + const specifiers = new Set() + const visit = (node: any): void => { + if (!node || typeof node !== 'object') { + return + } + if ( + [ + 'ImportDeclaration', + 'ExportNamedDeclaration', + 'ExportAllDeclaration', + 'ImportExpression', + ].includes(node.type) && + typeof node.source?.value === 'string' + ) { + specifiers.add(node.source.value) + } + for (const child of Object.values(node)) { + if (Array.isArray(child)) { + child.forEach(visit) + } else if (child && typeof child === 'object') { + visit(child) + } + } + } + visit(parseSync(file, code).program) + printedRequests.set(file, specifiers) + } + }, + }, + ] + if (framework === 'vue') { + const { default: vue } = await import('@vitejs/plugin-vue') + plugins.push(vue()) + } + if (framework === 'solid') { + const { default: solid } = await import('vite-plugin-solid') + plugins.push(solid({ ssr: true })) + } + const entry = path.join(path.dirname(file), `.consumer-${randomUUID()}.ts`) + await writeFile(entry, consumerSource(framework)) + const channel = openDiagnosticChannel() + const server = await createServer({ + root, + configFile: false, + // The app's own: Vite's default, the `node_modules/.vite` of an app + // without a package.json, is this package's (the app links its + // `node_modules`) + cacheDir: path.join(root, '.vite'), + envDir: false, + appType: 'custom', + customLogger: channel.viteLogger(), + clearScreen: false, + plugins, + server: { middlewareMode: true, hmr: false, watch: null, ws: false }, + optimizeDeps: { noDiscovery: true, include: [] }, + ssr: framework === 'solid' ? {} : { external: true }, + }) + const runner = createServerModuleRunner(server.environments.ssr, { + hmr: false, + }) + try { + const consumer = await runner.import(entry) + const exports = await runner.import(realFile) + const sources = new Map>() + // Import only fixture files the app already requested. This cannot eagerly + // pull in a lazy source, and a generated facade can never own its identity. + for (const source of [...requested]) { + sources.set(source, await runner.import(source)) + } + return await use({ + exports, + runtime: consumer.runtime, + framework, + sources, + imports, + loadedFiles: () => [...requested].sort(), + import: (source) => runner.import(source), + render: consumer.render, + }) + } finally { + await runner.close() + await server.close() + channel.close() + await rm(entry, { force: true }) + } +} + +export async function evaluateModule(code: string, fileName = 'route.tsx') { + const root = await mkdtemp(path.join(runDirectory(), 'tsr-module-')) + try { + const file = path.join(root, fileName) + await writeFile(file, code) + recordInputs(root, { [fileName]: code }, frameworkOf({ [fileName]: code })) + return await withModule(file, ({ exports, runtime }) => ({ + exports, + router: runtime, + })) + } finally { + await rm(root, { recursive: true, force: true }) + } +} + +export interface RouterRoute { + id: string + fullPath: string + path?: string + parentRoute?: RouterRoute + options: Record +} + +export interface LoadedRouteTree { + router: { + routeTree: RouterRoute + routesById: Record + matchRoutes: (pathname: string) => Array<{ routeId: string }> + [key: string]: any + } + routerPackage: Record + framework: string + fileOf: (routeId: string) => string | null + /** Fixture-owned modules requested by the real host, relative to the tree. */ + loadedFiles: () => Array + import: (file: string) => Promise> + render: (component: unknown) => Promise + renderClientAt: ( + url: string, + expectedParagraphs: Array, + ) => Promise + renderAt: (url: string) => Promise + imports: Array<{ file: string; specifier: string; importer: string }> +} + +export function withRouteTree( + treeFile: string, + use: (tree: LoadedRouteTree) => Promise | T, +): Promise { + return withModule( + treeFile, + async ({ + exports, + runtime, + framework, + sources, + loadedFiles, + import: importFile, + render, + imports, + }) => { + const { routeTree } = exports + const router: LoadedRouteTree['router'] = runtime.createRouter({ + routeTree, + history: runtime.createMemoryHistory(), + }) + const treeDir = path.dirname(await realpath(treeFile)) + const relative = (file: string) => + path.relative(treeDir, file).replaceAll(path.sep, '/') + const fileOf = (id: string) => { + const route = router.routesById[id] + if (!route) { + throw new Error(`The router has no route ${id}`) + } + const owners = [...sources].filter( + ([, module]) => module.Route === route, + ) + if (owners.length > 1) { + throw new Error( + `Ambiguous fixture Route identity: ${owners.map(([file]) => relative(file)).join(', ')}`, + ) + } + return owners.length ? relative(owners[0]![0]) : null + } + let client: Awaited> | undefined + try { + return await use({ + router, + routerPackage: runtime, + framework, + fileOf, + imports, + loadedFiles: () => loadedFiles().map(relative).sort(), + import: importFile, + render: async (component) => { + // Ask the router to load its option, rather than reaching into the + // lazy wrapper. loadRouteChunk's componentType is a public argument. + for (const route of Object.values(router.routesById)) { + for (const option of [ + 'component', + 'errorComponent', + 'pendingComponent', + 'notFoundComponent', + ]) { + if (route.options[option] === component) { + await router.loadRouteChunk( + route, + option === 'errorComponent' || + option === 'notFoundComponent' + ? option + : undefined, + ) + } + } + } + return render(component) + }, + renderClientAt: async (url, expectedParagraphs) => { + const { createClientConsumer } = await import('./consumer-client') + client ??= await createClientConsumer(treeFile, framework) + return client.renderAt(url, expectedParagraphs) + }, + renderAt: async (url) => { + const pageRouter = runtime.createRouter({ + routeTree, + history: runtime.createMemoryHistory({ initialEntries: [url] }), + }) + await pageRouter.load() + return render(runtime.RouterProvider, { router: pageRouter }) + }, + }) + } finally { + await client?.close() + } + }, + ) +} + +/** + * The routes of the router built from the generated route tree at + * `treeFile`: route id (`__root__` for the root route) to the file whose + * `Route` the route is, relative to the tree (null for a route the tree + * creates itself, such as a route with only a lazy route file). + */ +export function routesOf( + treeFile: string, +): Promise> { + return withRouteTree(treeFile, ({ router, fileOf }) => + Object.fromEntries( + Object.keys(router.routesById).map((id) => [id, fileOf(id)]), + ), + ) +} + +/** + * The full path (the URL path it matches, with its parents') of each route + * of the router built from the generated route tree at `treeFile`, by route + * id. + */ +export function urlsOf(treeFile: string): Promise> { + return withRouteTree(treeFile, ({ router }) => + Object.fromEntries( + Object.values(router.routesById).map((route) => [ + route.id, + route.fullPath, + ]), + ), + ) +} + +/** + * The ids of the routes the router built from the generated route tree at + * `treeFile` matches for `pathname`, the root route first. + */ +export function matchesOf( + treeFile: string, + pathname: string, +): Promise> { + return withRouteTree(treeFile, ({ router }) => + router.matchRoutes(pathname).map((match) => match.routeId), + ) +} + +/** A route of the router, as an app observes it. */ +export interface ObservedRoute { + /** The URL path it matches, with its parents'. */ + fullPath: string + /** Its parent route's id; null for the root route. */ + parent: string | null + /** The file whose `Route` it is (relative to the tree); null if none. */ + file: string | null + /** + * The app files that load only once the router loads the route + * (`loadRouteChunk`): its lazy route file and lazy components. + */ + lazy: Array +} + +/** + * The routes of the router built from the generated route tree at + * `treeFile`, by route id: full path, parent, route file, and the app files + * that load lazily with the route (routes are loaded in route id order; a + * route's lazy files are those no route loaded before). Only fixture-owned files participate; generated support filenames and + * placement are free. + */ +export function observeRouteTree( + treeFile: string, +): Promise> { + return withRouteTree(treeFile, async ({ router, fileOf, loadedFiles }) => { + const observed: Record = {} + for (const id of Object.keys(router.routesById).sort()) { + const route = router.routesById[id]! + const before = new Set(loadedFiles()) + await router.loadRouteChunk(route) + observed[id] = { + fullPath: route.fullPath, + parent: route.parentRoute?.id ?? null, + file: fileOf(id), + lazy: loadedFiles().filter((file) => !before.has(file)), + } + } + return observed + }) +} diff --git a/packages/router-generator/tests/template.test.ts b/packages/router-generator/tests/template.test.ts index 745604b4ec..037eb69120 100644 --- a/packages/router-generator/tests/template.test.ts +++ b/packages/router-generator/tests/template.test.ts @@ -1,37 +1,167 @@ +/** + * Scaffolds of new, empty route files (SPEC J1.3): each becomes a working + * route of its target, checked through the real router and the target's own + * server renderer (route-tree.ts): the root route renders its child routes, + * every route renders something (what is free), and the files follow + * `quoteStyle` and `semicolons`. + */ +import { parseSync } from 'vite' import { describe, expect, it } from 'vitest' -import { getTargetTemplate } from '../src/template' +import { createApp, generate, read } from './app' +import { routeCallOf, routeCallSpansOf } from './route-id' +import { routesOf, withRouteTree } from './route-tree' -describe('template', () => { - it('escapes quoted route paths in React route templates', () => { - const template = getTargetTemplate({ target: 'react' } as never) +/** The text of server-rendered `html`: its text nodes, joined. */ +const textOf = (html: string) => + html + .replace(//gs, '') + .replace(/<[^>]*>/g, '') + .trim() - expect(template.route.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createFileRoute(${JSON.stringify('/say-"hi"')})(`, - ) - expect(template.lazyRoute.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createLazyFileRoute(${JSON.stringify('/say-"hi"')})(`, - ) - }) +// A new, empty route, lazy route or root route file is scaffolded into a +// working route for each target: the file creates its Route with the right +// constructor and id, its component renders something, and the root +// route's component renders the child route's. +describe.each(['react', 'solid', 'vue'] as const)( + 'scaffolded %s routes', + (target) => { + it('empty root, route and lazy route files become routes whose components render', async () => { + const root = await createApp({ + 'src/routes/__root.tsx': '', + 'src/routes/posts.tsx': '', + 'src/routes/about.lazy.tsx': '', + 'src/routes/{-$locale}/contact.tsx': '', + 'src/routes/{-$locale}/help.lazy.tsx': '', + }) + const { generatedRouteTree } = await generate(root, { target }) - it('escapes quoted route paths in Solid route templates', () => { - const template = getTargetTemplate({ target: 'solid' } as never) + const scaffolded = async (file: string) => + routeCallOf(await read(root, `src/routes/${file}`)) + const pages = { + '/posts': ['posts.tsx', '/posts', 'createFileRoute'], + '/about': ['about.lazy.tsx', '/about', 'createLazyFileRoute'], + '/fr/contact': [ + '{-$locale}/contact.tsx', + '/{-$locale}/contact', + 'createFileRoute', + ], + '/help': [ + '{-$locale}/help.lazy.tsx', + '/{-$locale}/help', + 'createLazyFileRoute', + ], + } as const + for (const [file, id, constructor] of Object.values(pages)) { + expect(await scaffolded(file)).toEqual({ constructor, id }) + } + expect(await routesOf(generatedRouteTree)).toEqual({ + __root__: 'routes/__root.tsx', + '/posts': 'routes/posts.tsx', + '/about': null, + '/{-$locale}/contact': 'routes/{-$locale}/contact.tsx', + '/{-$locale}/help': null, + }) - expect(template.route.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createFileRoute(${JSON.stringify('/say-"hi"')})(`, - ) - expect(template.lazyRoute.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createLazyFileRoute(${JSON.stringify('/say-"hi"')})(`, - ) - }) + await withRouteTree(generatedRouteTree, async (tree) => { + const rootModule = await tree.import(`${root}/src/routes/__root.tsx`) + expect(rootModule.Route).toBe(tree.router.routeTree) + expect(rootModule.Route.isRoot).toBe(true) + for (const [url, [, id]] of Object.entries(pages)) { + const route = tree.router.routesById[id]! + await tree.router.loadRouteChunk(route) + const page = textOf(await tree.render(route.options.component)) + expect(page, id).not.toBe('') + // (the root route's component renders its child route's) + expect(textOf(await tree.renderAt(url)), url).toContain(page) + } + }) + }, 30_000) - it('escapes quoted route paths in Vue route templates', () => { - const template = getTargetTemplate({ target: 'vue' } as never) + // The docs (file-based-routing.md, `quoteStyle` and `semicolons`): "when + // you first create a new route, those files will be formatted with the + // quote style you specify" / "with semicolons". The route id argument + // is the generator's edit of the file (SPEC J1.2: its quote character + // is free), so it is left out. + it.each([ + { quoteStyle: 'single', semicolons: false }, + { quoteStyle: 'double', semicolons: true }, + ] as const)( + 'scaffolded files follow quoteStyle $quoteStyle and semicolons $semicolons', + async ({ quoteStyle, semicolons }) => { + const files = ['__root.tsx', 'posts.tsx', 'about.lazy.tsx'] + const root = await createApp( + Object.fromEntries(files.map((file) => [`src/routes/${file}`, ''])), + ) + await generate(root, { target, quoteStyle, semicolons }) - expect(template.route.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createFileRoute(${JSON.stringify('/say-"hi"')})(`, + for (const file of files) { + const code = await read(root, `src/routes/${file}`) + const style = codeStyle(code) + expect(style.quotes, file).toEqual([ + quoteStyle === 'single' ? "'" : '"', + ]) + expect(style.statements).toBeGreaterThan(0) + expect(style.withSemicolon).toBe(semicolons ? style.statements : 0) + } + }, ) - expect(template.lazyRoute.imports.tsrExportStart(`/say-"hi"`)).toBe( - `export const Route = createLazyFileRoute(${JSON.stringify('/say-"hi"')})(`, - ) - }) -}) + }, +) + +/** + * The quote characters of the string literals of `code` without quote + * characters in them (a formatter may quote the others either way to avoid + * escapes; JSX attribute values and the route id argument aside), and how + * many of its statements that end with a semicolon in a file using them + * (imports, expressions, returns, variable declarations outside loop heads) + * there are, and end with one. + */ +function codeStyle(code: string) { + const { program, errors } = parseSync('route.tsx', code) + expect(errors).toEqual([]) + const id = routeCallSpansOf(code).id + const quotes = new Set() + let statements = 0 + let withSemicolon = 0 + const visit = (node: unknown, parent?: Record): void => { + if (Array.isArray(node)) { + node.forEach((child) => visit(child, parent)) + return + } + if (!node || typeof node !== 'object') { + return + } + const record = node as Record + if (record.type === 'JSXAttribute') { + return + } + if ( + record.type === 'Literal' && + typeof record.value === 'string' && + !/["']/.test(record.value) && + !(id && record.start >= id[0] && record.end <= id[1]) + ) { + quotes.add(String(record.raw)[0]!) + } + if ( + [ + 'ImportDeclaration', + 'ExpressionStatement', + 'ReturnStatement', + 'VariableDeclaration', + ].includes(record.type) && + !(parent?.type ?? '').startsWith('For') && + parent?.type !== 'ExportNamedDeclaration' + ) { + statements++ + if (code.slice(record.start, record.end).endsWith(';')) { + withSemicolon++ + } + } + for (const value of Object.values(record)) { + visit(value, record) + } + } + visit(program) + return { quotes: [...quotes], statements, withSemicolon } +} diff --git a/packages/router-generator/tests/transform.test.ts b/packages/router-generator/tests/transform.test.ts deleted file mode 100644 index 2267599c15..0000000000 --- a/packages/router-generator/tests/transform.test.ts +++ /dev/null @@ -1,657 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { transform } from '../src/transform/transform' -import type { RouteNode } from '../src/types' - -function makeNode( - fsRouteType: RouteNode['_fsRouteType'] = 'static', -): RouteNode { - return { - filePath: '/test.tsx', - fullPath: '/test.tsx', - variableName: 'TestRoute', - _fsRouteType: fsRouteType, - } -} - -function transformToNewRoute(source: string, node = makeNode()) { - return transform({ - source, - ctx: { target: 'react', routeId: '/new', lazy: false }, - node, - }) -} - -describe('transform', () => { - it('reads and rewrites the route constructor, id and options through parentheses', () => { - const node = makeNode() - const result = transformToNewRoute( - [ - "import { createLazyFileRoute } from '@tanstack/react-router'", - "export const Route = (createLazyFileRoute)(('/old'))(({ component: Page, server: {} }))", - ].join('\n'), - node, - ) - - expect(result).toEqual({ - result: 'modified', - output: [ - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = (createFileRoute)(('/new'))(({ component: Page, server: {} }))", - ].join('\n'), - }) - expect(node.createFileRouteProps).toEqual(new Set(['component', 'server'])) - }) - - it('updates parenthesized route calls without changing their surrounding source', () => { - const result = transform({ - source: - "import { createFileRoute } from '@tanstack/react-router'; export const Route = ((createFileRoute('/old'))({}));", - ctx: { target: 'react', routeId: '/new', lazy: false }, - node: makeNode(), - }) - expect(result.result).toBe('modified') - if (result.result === 'modified') { - expect(result.output).toContain("((createFileRoute('/new'))({}))") - } - }) - - it('does not treat root route exports as missing Route exports', async () => { - const result = await transform({ - source: [ - "import { createRootRoute } from '@tanstack/react-router'", - '', - 'export const Route = createRootRoute()({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/', - lazy: false, - }, - node: makeNode('__root'), - }) - - expect(result.result).toBe('not-modified') - }) - - it('does not treat createRootRouteWithContext exports as missing Route exports', async () => { - const result = await transform({ - source: [ - "import { createRootRouteWithContext } from '@tanstack/react-router'", - '', - 'interface RouterContext {}', - '', - 'export const Route = createRootRouteWithContext()({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/', - lazy: false, - }, - node: makeNode('__root'), - }) - - expect(result.result).toBe('not-modified') - }) - - it('does not treat createRootRoute exported via export { Route } as missing Route exports', async () => { - const result = await transform({ - source: [ - "import { createRootRoute } from '@tanstack/react-router'", - '', - 'const Route = createRootRoute()({})', - '', - 'export { Route }', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/', - lazy: false, - }, - node: makeNode('__root'), - }) - - expect(result.result).toBe('not-modified') - }) - - it('returns an error result for parse failures', async () => { - const result = await transform({ - source: "export const Route = createFileRoute('/broken')(", - ctx: { - target: 'react', - routeId: '/broken', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('error') - }) - - it('rewrites an aliased exported Route binding', async () => { - const node = makeNode() - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - "const MyRoute = createFileRoute('/old')({ component: Component })", - '', - 'export { MyRoute as Route }', - '', - 'function Component() {', - ' return null', - '}', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node, - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain("createFileRoute('/new')") - expect(node.createFileRouteProps).toEqual(new Set(['component'])) - }) - - it('removes imports cleanly with CRLF line endings', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - "import { createLazyFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/old')({})", - ].join('\r\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toBe( - [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/new')({})", - ].join('\r\n'), - ) - }) - - it('preserves import formatting when only renaming the route constructor', async () => { - const result = await transform({ - source: [ - 'import {', - ' Link,', - ' createFileRoute,', - `} from '@tanstack/react-router'`, - '', - "export const Route = createFileRoute('/old')({})", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: true, - }, - node: makeNode('lazy'), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toBe( - [ - 'import {', - ' Link,', - ' createLazyFileRoute,', - `} from '@tanstack/react-router'`, - '', - "export const Route = createLazyFileRoute('/new')({})", - ].join('\n'), - ) - }) - - it('adds the missing constructor import with the file line ending', async () => { - const result = await transform({ - source: [ - "import { Link } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/old')({})", - ].join('\r\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toBe( - [ - "import { Link, createFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/new')({})", - ].join('\r\n'), - ) - }) - - it('ignores non-exported route constructor calls in the same file', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - "const OtherRoute = createFileRoute('/other')({})", - "export const Route = createFileRoute('/old')({})", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain( - "const OtherRoute = createFileRoute('/other')({})", - ) - expect(result.output).toContain( - "export const Route = createFileRoute('/new')({})", - ) - }) - - it('returns an error for unsupported route id expressions', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - 'const routeId = getRouteId()', - 'export const Route = createFileRoute(routeId)({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('error') - if (result.result !== 'error') { - throw new Error(`expected error result, got ${result.result}`) - } - expect(String(result.error)).toContain( - 'expected route id to be a string literal or plain template literal', - ) - }) - - it('returns a distinct error for malformed direct createFileRoute calls', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - 'export const Route = createFileRoute({ component: Home })', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('error') - if (result.result !== 'error') { - throw new Error(`expected error result, got ${result.result}`) - } - expect(String(result.error)).toContain( - "expected Route export in /new to use createFileRoute('/path')({...}) or createLazyFileRoute('/path')({...})", - ) - }) - - it('returns a distinct error for malformed direct createLazyFileRoute calls', async () => { - const result = await transform({ - source: [ - "import { createLazyFileRoute } from '@tanstack/react-router'", - '', - 'export const Route = createLazyFileRoute({ component: Home })', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: true, - }, - node: makeNode('lazy'), - }) - - expect(result.result).toBe('error') - if (result.result !== 'error') { - throw new Error(`expected error result, got ${result.result}`) - } - expect(String(result.error)).toContain( - "expected Route export in /new to use createFileRoute('/path')({...}) or createLazyFileRoute('/path')({...})", - ) - }) - - it('preserves double-quote route IDs', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - 'export const Route = createFileRoute("/old")({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain('createFileRoute("/new")') - }) - - it('preserves template-literal route IDs', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - 'export const Route = createFileRoute(`/old`)({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain('createFileRoute(`/new`)') - }) - - it('rewrites createLazyFileRoute to createFileRoute when lazy changes', async () => { - const result = await transform({ - source: [ - "import { createLazyFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createLazyFileRoute('/test')({})", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/test', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain("createFileRoute('/test')") - expect(result.output).not.toContain('createLazyFileRoute') - }) - - it('handles export { Route } with a separate const declaration', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - "const Route = createFileRoute('/old')({})", - '', - 'export { Route }', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain("createFileRoute('/new')") - }) - - it('returns an error for multiple exported route calls', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createFileRoute('/a')({})", - '', - "const AltRoute = createFileRoute('/b')({})", - 'export { AltRoute as Route }', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('error') - if (result.result !== 'error') { - throw new Error(`expected error result, got ${result.result}`) - } - expect(String(result.error)).toContain( - 'expected exactly one createFileRoute/createLazyFileRoute call', - ) - }) - - it('prepends a new import when no target-module import exists', async () => { - const result = await transform({ - source: [ - "import { useState } from 'react'", - '', - "export const Route = createFileRoute('/old')({})", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toBe( - [ - "import { createFileRoute } from '@tanstack/react-router'", - "import { useState } from 'react'", - '', - "export const Route = createFileRoute('/new')({})", - ].join('\n'), - ) - }) - - it('returns not-modified for a non-route-constructor call', async () => { - const result = await transform({ - source: [ - "import { createFileRoute } from '@tanstack/react-router'", - '', - 'export const Route = someOtherFactory()({})', - ].join('\n'), - ctx: { - target: 'react', - routeId: '/test', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('not-modified') - }) - - it('preserves semicolons in normalized imports', async () => { - const result = await transform({ - source: [ - "import { createLazyFileRoute } from '@tanstack/react-router';", - '', - "export const Route = createLazyFileRoute('/old')({});", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain( - "import { createFileRoute } from '@tanstack/react-router';", - ) - expect(result.output).not.toContain('createLazyFileRoute') - }) - - it('preserves type import specifiers when normalizing route imports', async () => { - const result = await transform({ - source: [ - "import { type LinkProps, createLazyFileRoute } from '@tanstack/react-router'", - '', - "export const Route = createLazyFileRoute('/old')({})", - ].join('\n'), - ctx: { - target: 'react', - routeId: '/new', - lazy: false, - }, - node: makeNode(), - }) - - expect(result.result).toBe('modified') - if (result.result !== 'modified') { - throw new Error(`expected modified result, got ${result.result}`) - } - expect(result.output).toContain( - "import { type LinkProps, createFileRoute } from '@tanstack/react-router'", - ) - expect(result.output).not.toContain('createLazyFileRoute') - }) - - // The recorded option keys drive prerendering and server-only route pruning. - it('records identifier and string-literal option keys, not computed or spread ones', () => { - const node = makeNode() - const result = transformToNewRoute( - [ - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = createFileRoute('/new')({ 'component': Page, [key]: load, ...rest, server: {} })", - ].join('\n'), - node, - ) - - expect(result).toEqual({ result: 'not-modified' }) - expect(node.createFileRouteProps).toEqual(new Set(['component', 'server'])) - }) -}) - -// The generator writes its output back over the user's route file, so every -// byte outside the route id and the router import must survive unchanged. -describe('transform preserves the rest of the route file', () => { - it('edits the right spans after a BOM and astral characters', () => { - const result = transformToNewRoute( - [ - '\uFEFF// 😀', - "import { createLazyFileRoute } from '@tanstack/react-router'", - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = createFileRoute(/* 🚀 */ '/old')({})", - ].join('\n'), - ) - - expect(result).toEqual({ - result: 'modified', - output: [ - '\uFEFF// 😀', - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = createFileRoute(/* 🚀 */ '/new')({})", - ].join('\n'), - }) - }) - - it.each([ - { - name: 'a default import', - imports: "import Router from '@tanstack/react-router'", - expected: - "import Router, { createFileRoute } from '@tanstack/react-router'", - }, - { - name: 'an aliased import of the constructor', - imports: - "import { createFileRoute as cfr } from '@tanstack/react-router'", - expected: - "import { createFileRoute as cfr, createFileRoute } from '@tanstack/react-router'", - }, - { - // The constructor goes into the named import, never the namespace one. - name: 'a namespace import', - imports: [ - "import * as Router from '@tanstack/react-router'", - "import { Link } from '@tanstack/react-router'", - ].join('\n'), - expected: [ - "import * as Router from '@tanstack/react-router'", - "import { Link, createFileRoute } from '@tanstack/react-router'", - ].join('\n'), - }, - ])('adds the missing constructor next to $name', ({ imports, expected }) => { - const route = "export const Route = createFileRoute('/old')({})" - - expect(transformToNewRoute(`${imports}\n${route}`)).toEqual({ - result: 'modified', - output: `${expected}\n${route.replace('/old', '/new')}`, - }) - }) - - it('updates only the Route declarator of a multi-declarator export', () => { - const result = transformToNewRoute( - [ - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = createFileRoute('/old')({}), path = '/old'", - ].join('\n'), - ) - - expect(result).toEqual({ - result: 'modified', - output: [ - "import { createFileRoute } from '@tanstack/react-router'", - "export const Route = createFileRoute('/new')({}), path = '/old'", - ].join('\n'), - }) - }) -}) diff --git a/packages/router-generator/tests/type-check.ts b/packages/router-generator/tests/type-check.ts new file mode 100644 index 0000000000..73816bfbf1 --- /dev/null +++ b/packages/router-generator/tests/type-check.ts @@ -0,0 +1,105 @@ +/** + * Shared test helper: type-checks an app with the real TypeScript compiler + * and the real router package types, like `tsc --noEmit` in a project. + */ +import { symlink, writeFile } from 'node:fs/promises' +import path from 'node:path' +import ts from 'typescript' + +/** The packages this package's tests may use (the router packages, React). */ +const nodeModules = path.resolve(import.meta.dirname, '../node_modules') + +/** The program of the last check. */ +let previousProgram: ts.Program | undefined + +/** + * A strict program over `rootNames` and the modules they import, resolving + * packages from the nearest `node_modules` (in a test app: this package's + * dependencies). + */ +function createProgram( + rootNames: Array, + lib = ['lib.es2022.d.ts', 'lib.dom.d.ts'], +) { + const program = ts.createProgram({ + rootNames, + options: { + strict: true, + noEmit: true, + skipLibCheck: true, + jsx: ts.JsxEmit.ReactJSX, + module: ts.ModuleKind.ESNext, + moduleResolution: ts.ModuleResolutionKind.Bundler, + target: ts.ScriptTarget.ES2022, + lib, + types: [], + }, + // (the package type definitions of the previous check are reused) + oldProgram: previousProgram, + }) + previousProgram = program + return program +} + +function messageOf(diagnostic: ts.Diagnostic) { + return ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n') +} + +/** + * Writes `code` to `file` (path relative to the app root) and type-checks it, + * with the modules it imports (such as the route tree and the route files), + * in a strict project resolving packages from this package's dependencies. + * Returns the type errors, each as `: `. + */ +export async function typeErrorsOf(root: string, file: string, code: string) { + await symlink(nodeModules, path.join(root, 'node_modules'), 'junction').catch( + (error: NodeJS.ErrnoException) => { + if (error.code !== 'EEXIST') { + throw error + } + }, + ) + await writeFile(path.join(root, file), code) + const program = createProgram([path.join(root, file)]) + return ts + .getPreEmitDiagnostics(program) + .map((diagnostic) => + diagnostic.file + ? `${path.relative(root, diagnostic.file.fileName)}: ${messageOf(diagnostic)}` + : messageOf(diagnostic), + ) +} + +/** + * Type-checks the given modules (absolute paths) in one program, with the + * modules they import, like `typeErrorsOf`, but reports only the errors in + * the given modules themselves (not in the modules they import), by module. + */ +export function typeErrorsOfModules(files: Array, lib?: Array) { + const program = createProgram(files, lib) + const errors = new Map>() + for (const file of files) { + const sourceFile = program.getSourceFile(file) + errors.set( + file, + sourceFile + ? [ + ...program.getSyntacticDiagnostics(sourceFile), + ...program.getSemanticDiagnostics(sourceFile), + ].map(messageOf) + : ['not found'], + ) + } + return errors +} + +/** + * Type-level assertions for checked code: `Expect>` is a type + * error unless A and B are the same type. + */ +export const typeAssertions = `type Equal = + (() => T extends A ? 1 : 2) extends () => T extends B ? 1 : 2 + ? true + : false +type Expect = T +` diff --git a/packages/router-generator/tests/utils.test.ts b/packages/router-generator/tests/utils.test.ts deleted file mode 100644 index 504dacc0e6..0000000000 --- a/packages/router-generator/tests/utils.test.ts +++ /dev/null @@ -1,1072 +0,0 @@ -import { describe, expect, it, vi } from 'vitest' -import { - RoutePrefixMap, - cleanPath, - createLiteralRoutePathSegmentMetadata, - createRoutePathSegmentMetadata, - createRouteNodesByFullPath, - createRouteNodesByTo, - createTokenRegex, - determineInitialRoutePath, - determineInitialRoutePathFromExplicitPath, - hasEscapedLeadingUnderscore, - hasEscapedTrailingUnderscore, - inferFullPath, - isSegmentPathless, - mergeImportDeclarations, - multiSortBy, - removeExt, - removeLayoutSegmentsAndUnderscoresWithEscape, - removeLayoutSegmentsWithEscape, - removeLeadingUnderscores, - removeTrailingUnderscores, - removeUnderscores, - removeUnderscoresWithEscape, - routePathToVariable, - sortRouteNodes, -} from '../src/utils' -import type { ImportDeclaration, RouteNode } from '../src/types' - -describe('cleanPath', () => { - it('keeps path with leading slash and trailing slash', () => { - expect(cleanPath('/test/')).toBe('/test/') - }) -}) - -describe('inferFullPath', () => { - it('returns "/" for pathless layouts under root', () => { - const node = { - routePath: '/_layout-a1', - originalRoutePath: '/_layout-a1', - cleanedPath: '', - _fsRouteType: 'pathless_layout', - } as unknown as RouteNode - - // This avoids inferred fullPath "" which breaks match.fullPath unions - expect(inferFullPath(node)).toBe('/') - }) - - it('preserves escaped leading underscores after removing pathless ancestors', () => { - const node = { - routePath: '/_layout/_foo', - originalRoutePath: '/_layout/[_]foo', - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/_foo') - }) - - it('preserves multiple escaped leading underscores after removing pathless ancestors', () => { - const node = { - routePath: '/_layout/__foo', - originalRoutePath: '/_layout/[__foo]', - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/__foo') - }) - - it('preserves explicit literal leading underscores on index routes after removing pathless ancestors', () => { - const parent = { - routePath: '/_layout', - } as unknown as RouteNode - const node = { - routePath: '/_layout/_nested/', - originalRoutePath: '/_layout/_nested/', - _routePathSegmentMetadata: createLiteralRoutePathSegmentMetadata( - '/_layout/_nested', - parent, - true, - ), - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/_nested/') - }) - - it('removes pathless index route segments when they are not marked literal', () => { - const node = { - routePath: '/_layout/_nested/', - originalRoutePath: '/_layout/_nested/', - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/') - }) - - it('preserves escaped trailing underscores on index routes', () => { - const node = { - routePath: '/_layout/foo_/', - originalRoutePath: '/_layout/foo[_]/', - _routePathSegmentMetadata: createRoutePathSegmentMetadata( - '/_layout/foo_/', - '/_layout/foo[_]/', - ), - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/foo_/') - }) - - it('removes unescaped trailing underscores on index routes', () => { - const node = { - routePath: '/_layout/foo_/', - originalRoutePath: '/_layout/foo_/', - } as unknown as RouteNode - - expect(inferFullPath(node)).toBe('/foo/') - }) -}) - -describe('createRoutePathSegmentMetadata', () => { - it('preserves escaped trailing underscores on index routes', () => { - const metadata = createRoutePathSegmentMetadata('/foo_/', '/foo[_]/') - - expect(metadata).toHaveLength(3) - expect(metadata?.[1]).toEqual({ literalTrailingUnderscore: true }) - }) - - it('preserves mixed escaped leading and trailing underscores', () => { - const metadata = createRoutePathSegmentMetadata('/_foo_/', '/[_]foo[_]/') - - expect(metadata).toHaveLength(3) - expect(metadata?.[1]).toEqual({ - literalLeadingUnderscore: true, - literalTrailingUnderscore: true, - }) - }) - - it('tracks multiple literal underscore segments independently', () => { - const metadata = createRoutePathSegmentMetadata( - '/_foo/bar_/_baz_/', - '/[_]foo/bar[_]/[_baz_]/', - ) - - expect(metadata).toHaveLength(5) - expect(metadata?.[1]).toEqual({ literalLeadingUnderscore: true }) - expect(metadata?.[2]).toEqual({ literalTrailingUnderscore: true }) - expect(metadata?.[3]).toEqual({ - literalLeadingUnderscore: true, - literalTrailingUnderscore: true, - }) - }) -}) - -describe('createRouteNodesByTo', () => { - const createRoute = ( - overrides: Partial & { routePath: string }, - ): RouteNode => ({ - filePath: 'test.tsx', - fullPath: overrides.routePath, - variableName: 'Test', - _fsRouteType: 'static', - cleanedPath: overrides.routePath.endsWith('/') - ? '/' - : overrides.routePath.split('/').at(-1), - ...overrides, - }) - - it('prefers index routes over pathless layouts for duplicate public to paths', () => { - const pathlessRoute = createRoute({ - routePath: '/livestock/$farmId/medicine/_form', - _fsRouteType: 'pathless_layout', - variableName: 'Pathless', - }) - const indexRoute = createRoute({ - routePath: '/livestock/$farmId/medicine/', - cleanedPath: '/', - variableName: 'Index', - }) - - const map = createRouteNodesByTo([pathlessRoute, indexRoute]) - - expect(map.get('/livestock/$farmId/medicine')).toBe(indexRoute) - }) -}) - -describe('createRouteNodesByFullPath', () => { - const createRoute = ( - overrides: Partial & { routePath: string }, - ): RouteNode => ({ - filePath: 'test.tsx', - fullPath: overrides.routePath, - variableName: 'Test', - _fsRouteType: 'static', - cleanedPath: overrides.routePath.endsWith('/') - ? '/' - : overrides.routePath.split('/').at(-1), - ...overrides, - }) - - it('prefers concrete routes over pathless layouts for duplicate full paths', () => { - const concreteRoute = createRoute({ - routePath: '/livestock/$farmId/medicine', - variableName: 'Concrete', - }) - const pathlessRoute = createRoute({ - routePath: '/livestock/$farmId/medicine/_form', - _fsRouteType: 'pathless_layout', - variableName: 'Pathless', - }) - - const map = createRouteNodesByFullPath([concreteRoute, pathlessRoute]) - - expect(map.get('/livestock/$farmId/medicine')).toBe(concreteRoute) - }) -}) - -describe('determineInitialRoutePath', () => { - it('removes dots and adds slashes', () => { - expect(determineInitialRoutePath('test.test')).toStrictEqual({ - routePath: '/test/test', - originalRoutePath: '/test/test', - }) - }) - - it('keeps leading slash', () => { - expect(determineInitialRoutePath('/test.test')).toStrictEqual({ - routePath: '/test/test', - originalRoutePath: '/test/test', - }) - }) - - it('keeps trailing slash', () => { - expect(determineInitialRoutePath('test.test/')).toStrictEqual({ - routePath: '/test/test/', - originalRoutePath: '/test/test/', - }) - }) - - it('removes dots and adds slashes with leading and trailing slashes', () => { - expect(determineInitialRoutePath('/test.test/')).toStrictEqual({ - routePath: '/test/test/', - originalRoutePath: '/test/test/', - }) - }) - - it("returns '/' if path is empty", () => { - expect(determineInitialRoutePath('')).toStrictEqual({ - routePath: '/', - originalRoutePath: '/', - }) - }) - - it("returns '/' if path is '.'", () => { - expect(determineInitialRoutePath('.')).toStrictEqual({ - routePath: '/', - originalRoutePath: '/', - }) - }) - - it("returns '/' if path is './'", () => { - expect(determineInitialRoutePath('./')).toStrictEqual({ - routePath: '/', - originalRoutePath: '/', - }) - }) - - it('errors on disallowed escaped character', () => { - const consoleSpy = vi.spyOn(console, 'error') - - expect(() => determineInitialRoutePath('/a[/]')).toThrowError() - - expect(consoleSpy).toBeCalledWith( - 'Error: Disallowed character "/" found in square brackets in route path "/a[/]".\n' + - 'You cannot use any of the following characters in square brackets: /, \\, ?, #, :, *, <, >, |, !, $, %\n' + - 'Please remove and/or replace them.', - ) - - consoleSpy.mockRestore() - }) - - it('escapes characters correctly', () => { - expect(determineInitialRoutePath('/a[.]')).toStrictEqual({ - routePath: '/a.', - originalRoutePath: '/a[.]', - }) - }) - - it('should handle trailing underscores correctly', () => { - expect(determineInitialRoutePath('a_')).toStrictEqual({ - routePath: `/a_`, - originalRoutePath: '/a_', - }) - - expect(determineInitialRoutePath('a_.route')).toStrictEqual({ - routePath: `/a_/route`, - originalRoutePath: '/a_/route', - }) - - expect(determineInitialRoutePath('a_.b.c')).toStrictEqual({ - routePath: `/a_/b/c`, - originalRoutePath: '/a_/b/c', - }) - - expect(determineInitialRoutePath('a.b_.c.d')).toStrictEqual({ - routePath: `/a/b_/c/d`, - originalRoutePath: '/a/b_/c/d', - }) - - expect(determineInitialRoutePath('a_.route.b')).toStrictEqual({ - routePath: `/a_/route/b`, - originalRoutePath: '/a_/route/b', - }) - }) -}) - -describe('determineInitialRoutePathFromExplicitPath', () => { - it('preserves dots as literal route path characters', () => { - expect( - determineInitialRoutePathFromExplicitPath('pathless.layout'), - ).toStrictEqual({ - routePath: '/pathless.layout', - originalRoutePath: '/pathless.layout', - }) - }) - - it('resolves bracket escapes without applying file-route separators', () => { - expect( - determineInitialRoutePathFromExplicitPath('pathless[.]layout'), - ).toStrictEqual({ - routePath: '/pathless.layout', - originalRoutePath: '/pathless[.]layout', - }) - }) -}) - -describe('multiSortBy', () => { - it('sorts by single accessor', () => { - const arr = [{ v: 3 }, { v: 1 }, { v: 2 }] - const result = multiSortBy(arr, [(d) => d.v]) - expect(result.map((d) => d.v)).toEqual([1, 2, 3]) - }) - - it('sorts by multiple accessors', () => { - const arr = [ - { a: 2, b: 1 }, - { a: 1, b: 2 }, - { a: 1, b: 1 }, - ] - const result = multiSortBy(arr, [(d) => d.a, (d) => d.b]) - expect(result).toEqual([ - { a: 1, b: 1 }, - { a: 1, b: 2 }, - { a: 2, b: 1 }, - ]) - }) - - it('preserves original order for equal elements', () => { - const arr = [ - { a: 1, id: 'first' }, - { a: 1, id: 'second' }, - { a: 1, id: 'third' }, - ] - const result = multiSortBy(arr, [(d) => d.a]) - expect(result.map((d) => d.id)).toEqual(['first', 'second', 'third']) - }) - - it('handles undefined values', () => { - const arr = [{ v: 1 }, { v: undefined }, { v: 2 }] - const result = multiSortBy(arr, [(d) => d.v]) - // undefined sorts to end - expect(result.map((d) => d.v)).toEqual([1, 2, undefined]) - }) - - it('handles empty array', () => { - const result = multiSortBy([], [(d) => d]) - expect(result).toEqual([]) - }) - - it('handles single element array', () => { - const result = multiSortBy([{ v: 1 }], [(d) => d.v]) - expect(result).toEqual([{ v: 1 }]) - }) - - it('uses default accessor when none provided', () => { - const arr = [3, 1, 2] - const result = multiSortBy(arr) - expect(result).toEqual([1, 2, 3]) - }) - - it('sorts strings correctly', () => { - const arr = [{ s: 'c' }, { s: 'a' }, { s: 'b' }] - const result = multiSortBy(arr, [(d) => d.s]) - expect(result.map((d) => d.s)).toEqual(['a', 'b', 'c']) - }) - - it('handles negative numbers in accessors for reverse sort', () => { - const arr = [{ v: 1 }, { v: 3 }, { v: 2 }] - const result = multiSortBy(arr, [(d) => -d.v]) - expect(result.map((d) => d.v)).toEqual([3, 2, 1]) - }) -}) - -describe('multiSortBy', () => { - it('sorts by multiple criteria', () => { - const data = [ - { routePath: '/test/1/2/index', f: 'b' }, - { routePath: '/test/1', f: 'b' }, - { routePath: '/test/1/2/3/4/index', f: 'b' }, - { routePath: '/test/1/2/3', f: 'b' }, - { routePath: '/test/1/2/3/index', f: 'b' }, - { routePath: '/test/1/2', f: 'b' }, - { routePath: '/test/1/2/3/4', f: 'b' }, - ] - - const sorted = multiSortBy(data, [ - (d) => (d.routePath.includes('1') ? -1 : 1), - (d) => d.routePath.split('/').length, - (d) => (d.routePath.endsWith('index') ? -1 : 1), - (d) => d, - ]) - - expect(sorted).toEqual([ - { routePath: '/test/1', f: 'b' }, - { routePath: '/test/1/2', f: 'b' }, - { routePath: '/test/1/2/index', f: 'b' }, - { routePath: '/test/1/2/3', f: 'b' }, - { routePath: '/test/1/2/3/index', f: 'b' }, - { routePath: '/test/1/2/3/4', f: 'b' }, - { routePath: '/test/1/2/3/4/index', f: 'b' }, - ]) - }) -}) - -describe('removeExt', () => { - it('removes extension', () => { - expect(removeExt('test.ts')).toBe('test') - }) - - it('does not remove extension if no extension', () => { - expect(removeExt('test')).toBe('test') - }) - - it('removes extension with multiple dots', () => { - expect(removeExt('test.test.ts')).toBe('test.test') - }) - - it('removes extension with leading dot', () => { - expect(removeExt('.test.ts')).toBe('.test') - }) - - it('removes extension when in a route path', () => { - expect(removeExt('/test/test.ts')).toBe('/test/test') - }) - - it('keeps extension when addExtensions is true', () => { - expect(removeExt('test.tsx', true)).toBe('test.tsx') - }) - - it('keeps extension with route path when addExtensions is true', () => { - expect(removeExt('/routes/__root.tsx', true)).toBe('/routes/__root.tsx') - }) - - it('replaces extension when addExtensions is a dot-prefixed string', () => { - expect(removeExt('test.tsx', '.js')).toBe('test.js') - }) - - it('replaces extension with route path when addExtensions is a string', () => { - expect(removeExt('/routes/__root.tsx', '.js')).toBe('/routes/__root.js') - }) - - it('replaces extension with multiple dots when addExtensions is a string', () => { - expect(removeExt('test.lazy.tsx', '.js')).toBe('test.lazy.js') - }) - - it('returns unchanged when no extension and addExtensions is a string', () => { - expect(removeExt('test', '.js')).toBe('test') - }) -}) - -describe('removeUnderscores', () => { - it('removes leading underscore', () => { - expect(removeUnderscores('_test')).toBe('test') - }) - - it('removes trailing underscore', () => { - expect(removeUnderscores('test_')).toBe('test') - }) - - it('removes leading and trailing underscores', () => { - expect(removeUnderscores('_test_')).toBe('test') - }) -}) - -describe('removeLeadingUnderscores', () => { - it('removes leading underscore when not routeToken', () => { - expect(removeLeadingUnderscores('_test', 'route')).toBe('test') - - expect(removeLeadingUnderscores('/_test/abc/route/_d', 'route')).toBe( - '/test/abc/route/d', - ) - - expect(removeLeadingUnderscores('/_test_/abc/_route_/d_/_e', 'route')).toBe( - '/test_/abc/route_/d_/e', - ) - - expect( - removeLeadingUnderscores('/_test_/abc/_route_/d_/_e', '_route_'), - ).toBe('/test_/abc/_route_/d_/e') - - expect( - removeLeadingUnderscores('/_test_/abc/_route_/d_/_e', 'route_'), - ).toBe('/test_/abc/route_/d_/e') - }) -}) - -describe('removeTrailingUnderscores', () => { - it('removes trailing underscore when not routeToken', () => { - expect(removeTrailingUnderscores('test_', 'route')).toBe('test') - - expect(removeTrailingUnderscores('/_test_/abc_/route/_d', 'route')).toBe( - '/_test/abc/route/_d', - ) - - expect( - removeTrailingUnderscores('/_test_/abc/_route_/d_/_e', 'route'), - ).toBe('/_test/abc/_route/d/_e') - - expect( - removeTrailingUnderscores('/_test_/abc/_route_/d_/_e', '_route_'), - ).toBe('/_test/abc/_route_/d/_e') - - expect( - removeTrailingUnderscores('/_test_/abc/_route_/d_/_e', '_route'), - ).toBe('/_test/abc/_route/d/_e') - }) -}) - -describe('hasEscapedLeadingUnderscore', () => { - it('returns true for [_] prefix pattern', () => { - expect(hasEscapedLeadingUnderscore('[_]layout')).toBe(true) - expect(hasEscapedLeadingUnderscore('[_]foo')).toBe(true) - expect(hasEscapedLeadingUnderscore('[_]')).toBe(true) - }) - - it('returns true for fully escaped segment starting with underscore', () => { - expect(hasEscapedLeadingUnderscore('[_layout]')).toBe(true) - expect(hasEscapedLeadingUnderscore('[_foo]')).toBe(true) - expect(hasEscapedLeadingUnderscore('[__foo]')).toBe(true) - expect(hasEscapedLeadingUnderscore('[_1nd3x]')).toBe(true) - expect(hasEscapedLeadingUnderscore('[_]')).toBe(true) - }) - - it('returns false for non-escaped leading underscore', () => { - expect(hasEscapedLeadingUnderscore('_layout')).toBe(false) - expect(hasEscapedLeadingUnderscore('_foo')).toBe(false) - }) - - it('returns false for segments without leading underscore', () => { - expect(hasEscapedLeadingUnderscore('layout')).toBe(false) - expect(hasEscapedLeadingUnderscore('[layout]')).toBe(false) - expect(hasEscapedLeadingUnderscore('foo[_]')).toBe(false) - }) - - it('returns false for partial escapes with nested brackets', () => { - expect(hasEscapedLeadingUnderscore('[_foo[bar]')).toBe(false) - expect(hasEscapedLeadingUnderscore('[_foo]bar]')).toBe(false) - }) -}) - -describe('hasEscapedTrailingUnderscore', () => { - it('returns true for [_] suffix pattern', () => { - expect(hasEscapedTrailingUnderscore('blog[_]')).toBe(true) - expect(hasEscapedTrailingUnderscore('foo[_]')).toBe(true) - expect(hasEscapedTrailingUnderscore('[_]')).toBe(true) - }) - - it('returns true for fully escaped segment ending with underscore', () => { - expect(hasEscapedTrailingUnderscore('[blog_]')).toBe(true) - expect(hasEscapedTrailingUnderscore('[foo_]')).toBe(true) - expect(hasEscapedTrailingUnderscore('[foo__]')).toBe(true) - expect(hasEscapedTrailingUnderscore('[_r0ut3_]')).toBe(true) - expect(hasEscapedTrailingUnderscore('[_]')).toBe(true) - }) - - it('returns false for non-escaped trailing underscore', () => { - expect(hasEscapedTrailingUnderscore('blog_')).toBe(false) - expect(hasEscapedTrailingUnderscore('foo_')).toBe(false) - }) - - it('returns false for segments without trailing underscore', () => { - expect(hasEscapedTrailingUnderscore('blog')).toBe(false) - expect(hasEscapedTrailingUnderscore('[blog]')).toBe(false) - expect(hasEscapedTrailingUnderscore('[_]foo')).toBe(false) - }) - - it('returns false for partial escapes with nested brackets', () => { - expect(hasEscapedTrailingUnderscore('[foo[bar]_]')).toBe(false) - expect(hasEscapedTrailingUnderscore('[foo]bar_]')).toBe(false) - }) -}) - -describe('isSegmentPathless', () => { - it('returns true for non-escaped leading underscore', () => { - expect(isSegmentPathless('_layout', '_layout')).toBe(true) - expect(isSegmentPathless('_foo', '_foo')).toBe(true) - }) - - it('returns false for escaped leading underscore with [_] prefix', () => { - expect(isSegmentPathless('_layout', '[_]layout')).toBe(false) - expect(isSegmentPathless('_foo', '[_]foo')).toBe(false) - }) - - it('returns false for fully escaped segment', () => { - expect(isSegmentPathless('_layout', '[_layout]')).toBe(false) - expect(isSegmentPathless('__layout', '[__layout]')).toBe(false) - expect(isSegmentPathless('_1nd3x', '[_1nd3x]')).toBe(false) - }) - - it('returns false for segments not starting with underscore', () => { - expect(isSegmentPathless('layout', 'layout')).toBe(false) - expect(isSegmentPathless('foo', '[foo]')).toBe(false) - }) -}) - -describe('removeUnderscoresWithEscape', () => { - it('removes non-escaped leading underscores', () => { - expect(removeUnderscoresWithEscape('/_layout', '/_layout')).toBe('/layout') - expect(removeUnderscoresWithEscape('/_foo/_bar', '/_foo/_bar')).toBe( - '/foo/bar', - ) - }) - - it('removes non-escaped trailing underscores', () => { - expect(removeUnderscoresWithEscape('/blog_', '/blog_')).toBe('/blog') - expect(removeUnderscoresWithEscape('/foo_/bar_', '/foo_/bar_')).toBe( - '/foo/bar', - ) - }) - - it('preserves escaped leading underscores with [_] prefix', () => { - expect(removeUnderscoresWithEscape('/_layout', '/[_]layout')).toBe( - '/_layout', - ) - expect(removeUnderscoresWithEscape('/_foo', '/[_]foo')).toBe('/_foo') - }) - - it('preserves escaped trailing underscores with [_] suffix', () => { - expect(removeUnderscoresWithEscape('/blog_', '/blog[_]')).toBe('/blog_') - expect(removeUnderscoresWithEscape('/foo_', '/foo[_]')).toBe('/foo_') - }) - - it('preserves fully escaped segments with underscores', () => { - expect(removeUnderscoresWithEscape('/_layout', '/[_layout]')).toBe( - '/_layout', - ) - expect(removeUnderscoresWithEscape('/_r0ut3_', '/[_r0ut3_]')).toBe( - '/_r0ut3_', - ) - }) - - it('handles mixed escaped and non-escaped underscores', () => { - expect( - removeUnderscoresWithEscape('/_foo/_bar_/baz_', '/_foo/[_]bar_/baz[_]'), - ).toBe('/foo/_bar/baz_') - }) - - it('falls back to removeUnderscores when no originalPath', () => { - expect(removeUnderscoresWithEscape('/_foo_')).toBe('/foo') - expect(removeUnderscoresWithEscape('/_foo_', undefined)).toBe('/foo') - }) - - it('returns empty string for empty/undefined routePath', () => { - expect(removeUnderscoresWithEscape(undefined)).toBe('') - expect(removeUnderscoresWithEscape('')).toBe('') - }) -}) - -describe('removeLayoutSegmentsWithEscape', () => { - it('removes non-escaped layout segments', () => { - expect(removeLayoutSegmentsWithEscape('/_layout/foo', '/_layout/foo')).toBe( - '/foo', - ) - expect( - removeLayoutSegmentsWithEscape( - '/_auth/_admin/dashboard', - '/_auth/_admin/dashboard', - ), - ).toBe('/dashboard') - }) - - it('preserves escaped layout segments with [_] prefix', () => { - expect( - removeLayoutSegmentsWithEscape('/_layout/foo', '/[_]layout/foo'), - ).toBe('/_layout/foo') - expect( - removeLayoutSegmentsWithEscape('/_auth/dashboard', '/[_]auth/dashboard'), - ).toBe('/_auth/dashboard') - }) - - it('preserves fully escaped segments starting with underscore', () => { - expect( - removeLayoutSegmentsWithEscape('/_layout/foo', '/[_layout]/foo'), - ).toBe('/_layout/foo') - expect(removeLayoutSegmentsWithEscape('/_1nd3x/bar', '/[_1nd3x]/bar')).toBe( - '/_1nd3x/bar', - ) - }) - - it('handles mixed escaped and non-escaped layout segments', () => { - expect( - removeLayoutSegmentsWithEscape( - '/_auth/_admin/dashboard', - '/[_]auth/_admin/dashboard', - ), - ).toBe('/_auth/dashboard') - expect( - removeLayoutSegmentsWithEscape('/_foo/_bar/_baz', '/_foo/[_bar]/_baz'), - ).toBe('/_bar') - }) - - it('falls back to removeLayoutSegments when no originalPath', () => { - expect(removeLayoutSegmentsWithEscape('/_foo/bar/_baz')).toBe('/bar') - expect(removeLayoutSegmentsWithEscape('/_foo/bar/_baz', undefined)).toBe( - '/bar', - ) - }) - - it('handles root path', () => { - expect(removeLayoutSegmentsWithEscape('/')).toBe('/') - expect(removeLayoutSegmentsWithEscape()).toBe('/') - }) -}) - -describe('removeLayoutSegmentsAndUnderscoresWithEscape', () => { - it('removes layout segments and preserves escaped underscores in remaining segments', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/_foo', - '/_layout/[_]foo', - ), - ).toBe('/_foo') - }) - - it('removes multiple layout segments before escaped underscores', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/_nested/_foo', - '/_layout/_nested/[_]foo', - ), - ).toBe('/_foo') - }) - - it('preserves multiple escaped leading underscores in remaining segments', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/__foo', - '/_layout/[__foo]', - ), - ).toBe('/__foo') - - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/__foo', - '/_layout/[_][_]foo', - ), - ).toBe('/__foo') - }) - - it('removes non-escaped underscores from remaining segments', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/foo_/bar_', - '/_layout/foo_/bar_', - ), - ).toBe('/foo/bar') - }) - - it('preserves escaped trailing underscores after removing pathless ancestors', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/foo_/', - '/_layout/foo[_]/', - ), - ).toBe('/foo_/') - }) - - it('preserves mixed escaped leading and trailing underscores after removing pathless ancestors', () => { - expect( - removeLayoutSegmentsAndUnderscoresWithEscape( - '/_layout/_foo_/', - '/_layout/[_]foo[_]/', - ), - ).toBe('/_foo_/') - }) -}) - -describe('routePathToVariable', () => { - it.each([ - ['/test/$/index', 'TestSplatIndex'], - ['/test/$', 'TestSplat'], - ['/test/$/', 'TestSplat'], - ['/test/index', 'TestIndex'], - ['/test', 'Test'], - ['/test/', 'Test'], - ['/r0ut3', 'R0ut3'], - ])(`converts "%s" to "%s"`, (routePath, expected) => { - expect(routePathToVariable(routePath)).toBe(expected) - }) -}) - -describe('mergeImportDeclarations', () => { - it('merges imports with the same source but different specifiers', () => { - const imports: Array = [ - { source: 'moduleA', specifiers: [{ imported: 'A' }] }, - { source: 'moduleA', specifiers: [{ imported: 'B' }] }, - ] - - const result = mergeImportDeclarations(imports) - - expect(result).toEqual([ - { - source: 'moduleA', - specifiers: [{ imported: 'A' }, { imported: 'B' }], - }, - ]) - }) - - it('merges imports with overlapping specifiers', () => { - const imports: Array = [ - { source: 'moduleA', specifiers: [{ imported: 'A' }] }, - { source: 'moduleA', specifiers: [{ imported: 'A' }, { imported: 'B' }] }, - ] - - const result = mergeImportDeclarations(imports) - - expect(result).toEqual([ - { - source: 'moduleA', - specifiers: [{ imported: 'A' }, { imported: 'B' }], - }, - ]) - }) - - it('does not merge imports with mixed import kinds for the same source', () => { - const imports: Array = [ - { - source: 'moduleA', - importKind: 'type', - specifiers: [{ imported: 'A' }], - }, - { source: 'moduleA', specifiers: [{ imported: 'B' }] }, - ] - - const result = mergeImportDeclarations(imports) - - expect(result).toEqual([ - { - source: 'moduleA', - importKind: 'type', - specifiers: [{ imported: 'A' }], - }, - { source: 'moduleA', specifiers: [{ imported: 'B' }] }, - ]) - }) - - it('removes duplicate specifiers', () => { - const imports: Array = [ - { source: 'moduleA', specifiers: [{ imported: 'A' }] }, - { source: 'moduleA', specifiers: [{ imported: 'A' }] }, - ] - - const result = mergeImportDeclarations(imports) - - expect(result).toEqual([ - { - source: 'moduleA', - specifiers: [{ imported: 'A' }], - }, - ]) - }) -}) - -describe('RoutePrefixMap', () => { - const createRoute = ( - overrides: Partial & { routePath: string }, - ): RouteNode => ({ - filePath: 'test.tsx', - fullPath: overrides.routePath, - variableName: 'Test', - _fsRouteType: 'static', - ...overrides, - }) - - describe('constructor', () => { - it('indexes routes by path', () => { - const routes = [ - createRoute({ routePath: '/users' }), - createRoute({ routePath: '/users/profile' }), - ] - const map = new RoutePrefixMap(routes) - - expect(map.has('/users')).toBe(true) - expect(map.has('/users/profile')).toBe(true) - expect(map.has('/posts')).toBe(false) - }) - - it('skips root path /__root', () => { - const routes = [createRoute({ routePath: '/__root' })] - const map = new RoutePrefixMap(routes) - - expect(map.has('/__root')).toBe(false) - }) - - it('skips empty/undefined routePaths', () => { - const routes = [createRoute({ routePath: '' })] - const map = new RoutePrefixMap(routes) - - expect(map.has('')).toBe(false) - }) - - it('tracks layout routes separately', () => { - const routes = [ - createRoute({ routePath: '/app', _fsRouteType: 'layout' }), - createRoute({ routePath: '/admin', _fsRouteType: 'pathless_layout' }), - createRoute({ routePath: '/users', _fsRouteType: 'static' }), - ] - const map = new RoutePrefixMap(routes) - - // all indexed - expect(map.has('/app')).toBe(true) - expect(map.has('/admin')).toBe(true) - expect(map.has('/users')).toBe(true) - }) - }) - - describe('get', () => { - it('returns route by exact path', () => { - const route = createRoute({ routePath: '/users' }) - const map = new RoutePrefixMap([route]) - - expect(map.get('/users')).toBe(route) - expect(map.get('/other')).toBeUndefined() - }) - }) - - describe('findParent', () => { - it('returns null for root path', () => { - const map = new RoutePrefixMap([]) - - expect(map.findParent('/')).toBeNull() - }) - - it('returns null for empty path', () => { - const map = new RoutePrefixMap([]) - - expect(map.findParent('')).toBeNull() - }) - - it('finds immediate parent', () => { - const parent = createRoute({ routePath: '/users' }) - const map = new RoutePrefixMap([parent]) - - expect(map.findParent('/users/profile')).toBe(parent) - }) - - it('finds ancestor when immediate parent missing', () => { - const grandparent = createRoute({ routePath: '/users' }) - const map = new RoutePrefixMap([grandparent]) - - expect(map.findParent('/users/settings/profile')).toBe(grandparent) - }) - - it('finds closest ancestor with multiple levels', () => { - const grandparent = createRoute({ routePath: '/users' }) - const parent = createRoute({ routePath: '/users/settings' }) - const map = new RoutePrefixMap([grandparent, parent]) - - expect(map.findParent('/users/settings/profile')).toBe(parent) - }) - - it('returns null when no parent exists', () => { - const map = new RoutePrefixMap([createRoute({ routePath: '/posts' })]) - - expect(map.findParent('/users/profile')).toBeNull() - }) - - it('does not return self as parent', () => { - const route = createRoute({ routePath: '/users' }) - const map = new RoutePrefixMap([route]) - - expect(map.findParent('/users')).toBeNull() - }) - }) -}) - -describe('sortRouteNodes', () => { - const indexTokenSegmentRegex = createTokenRegex('index', { type: 'segment' }) - - const node = (routePath: string): RouteNode => - ({ routePath }) as unknown as RouteNode - - const sortPaths = (routePaths: Array): Array => - sortRouteNodes(routePaths.map(node), indexTokenSegmentRegex).map( - (n) => n.routePath, - ) - - /** Every distinct ordering of `arr` (Heap-free recursive permutation). */ - function permutations(arr: Array): Array> { - if (arr.length <= 1) { - return [arr] - } - const result: Array> = [] - arr.forEach((item, i) => { - const rest = [...arr.slice(0, i), ...arr.slice(i + 1)] - for (const perm of permutations(rest)) { - result.push([item, ...perm]) - } - }) - return result - } - - it('orders tied siblings by routePath', () => { - // Same segment count, both non-index: they tie on every key before routePath. - const expected = ['/account/beta-features', '/account/busy-guard'] - expect( - sortPaths(['/account/busy-guard', '/account/beta-features']), - ).toEqual(expected) - expect( - sortPaths(['/account/beta-features', '/account/busy-guard']), - ).toEqual(expected) - }) - - it('applies root, segment-count and index precedence before the routePath tiebreaker', () => { - const sorted = sortPaths([ - '/posts', - '/account/busy-guard', - '/index', - '/__root', - '/account/beta-features', - '/about', - '/posts/index', - ]) - - expect(sorted).toEqual([ - '/__root', // root always first - '/index', // depth 1, index segment before non-index - '/about', // depth 1, non-index, routePath tiebreak - '/posts', // depth 1, non-index, routePath tiebreak - '/posts/index', // depth 2, index segment before non-index - '/account/beta-features', // depth 2, non-index, routePath tiebreak - '/account/busy-guard', // depth 2, non-index, routePath tiebreak - ]) - }) - - it('is deterministic for every input permutation (stable sort)', () => { - // Includes several sets that tie on all keys before routePath (the two - // `/account/*` leaves, `/about` vs `/posts`) — exactly the case that the - // former whole-object tiebreaker left in an engine- and input-order- - // dependent order. `sortRouteNodes` must map every permutation to the - // same output. - const routePaths = [ - '/__root', - '/index', - '/about', - '/posts', - '/account/beta-features', - '/account/busy-guard', - ] - - const reference = sortPaths(routePaths) - - for (const permutation of permutations(routePaths)) { - expect(sortPaths(permutation)).toEqual(reference) - } - }) -}) diff --git a/packages/router-generator/tests/validate-route-params.test.ts b/packages/router-generator/tests/validate-route-params.test.ts deleted file mode 100644 index 14b61adc3d..0000000000 --- a/packages/router-generator/tests/validate-route-params.test.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { join } from 'node:path' -import { afterAll, describe, expect, it, vi } from 'vitest' -import { Generator, getConfig } from '../src' - -describe('validateRouteParams via generator', () => { - const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) - afterAll(() => { - warnSpy.mockRestore() - }) - - it('should warn for invalid param names when running the generator', async () => { - const folderName = 'invalid-param-names' - const dir = join(process.cwd(), 'tests', 'generator', folderName) - - const config = getConfig({ - disableLogging: false, // Enable logging to capture warnings - routesDirectory: dir + '/routes', - generatedRouteTree: dir + '/routeTree.gen.ts', - }) - - const generator = new Generator({ config, root: dir }) - await generator.run() - - // Should have warned about invalid params: $123 and $user-name - expect(warnSpy).toHaveBeenCalledWith( - expect.stringContaining('Invalid param name'), - ) - expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('123')) - expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('user-name')) - - // Should NOT have warned about $validParam - expect(warnSpy).not.toHaveBeenCalledWith( - expect.stringContaining('validParam'), - ) - }) -}) diff --git a/packages/router-generator/vite.config.ts b/packages/router-generator/vite.config.ts index 5e305866b6..0f8c5e389c 100644 --- a/packages/router-generator/vite.config.ts +++ b/packages/router-generator/vite.config.ts @@ -1,13 +1,57 @@ -import { defineConfig, mergeConfig } from 'vitest/config' +import { configDefaults, defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/vite-config' import packageJson from './package.json' +// Under Vitest: no file cache of jiti, which loads the route configuration +// files of the apps for the generator (virtual route configs). Its cache is +// the `node_modules/.cache` of the working directory: this package's. No +// outcome change. +if (process.env.VITEST) { + process.env.JITI_FS_CACHE ??= 'false' +} + const config = defineConfig({ test: { name: packageJson.name, dir: './tests', watch: false, - typecheck: { enabled: true }, + // At most 4 test processes per Vitest run: each + // runs real bundlers, dev servers and its own browser, and Nx runs several + // packages' tiers at once. More workers add swap and load flakes, not + // speed. `--maxWorkers` on the command line still overrides it. + maxWorkers: 4, + reporters: ['default', '@tanstack/compiler-test-utils/budget-reporter'], + globalSetup: ['@tanstack/compiler-test-utils/run-directory'], + setupFiles: ['@tanstack/compiler-test-utils/pins-setup'], + // Test files share a worker's modules (the router packages, Vite): every + // test works in its own temporary app and restores its spies and env + // stubs, and the route tree helpers share Vite servers only where they + // forget the app's modules first. + isolate: false, + projects: [ + { + // Fast tier (`test:unit`): generator runs, route trees loaded by the + // real router in a Vite server in middleware mode, type checks. + extends: true, + test: { + name: 'unit', + exclude: [...configDefaults.exclude, 'integration/**'], + }, + }, + { + // Slow tier (`test:integration`): one TypeScript program per + // generated route tree (the trees augment the router's types + // globally, so they cannot share one). + extends: true, + test: { + name: 'integration', + include: ['integration/**/*.test.ts'], + typecheck: { enabled: false }, + testTimeout: 30_000, + hookTimeout: 30_000, + }, + }, + ], }, }) diff --git a/packages/router-plugin/AGENTS.md b/packages/router-plugin/AGENTS.md index e954110819..4ce1534a53 100644 --- a/packages/router-plugin/AGENTS.md +++ b/packages/router-plugin/AGENTS.md @@ -1,7 +1,12 @@ # Router bundler plugin -- Preserve one initialization of shared module state across reference and split chunks. Shared extraction includes transitive dependencies and whole destructured declarations; never extract `Route` or bindings that depend on it. The invariant suite in `tests/code-splitter.test.ts` covers these contracts. -- `handleRouteUpdate` is stringified and injected into app modules. Keep runtime dependencies inside the function or explicitly emit them; extracting a helper to plugin module scope breaks the generated function. `tests/handle-route-update.test.ts` executes that emitted code. -- Route HMR rebuilds indexes, clears `resolvePathCache`, replaces lazy-chunk ownership, and refreshes active routes while preserving Fast Refresh component identities. Keep these steps coordinated when adding derived state. -- For code-splitting changes, add inputs under `tests/code-splitter/test-files//`. Regenerate and review reference, virtual, and shared snapshots for every grouping in [`tests/code-splitter.test.ts`](tests/code-splitter.test.ts). -- Check [`tests/constants.ts`](tests/constants.ts) for framework coverage: the snapshot matrix currently covers React and Solid only. Validate affected Vue behavior in Vue router e2e apps. +- Code splitting must not change what a route does. The route module and its split chunks share one instance of every module-level value: `Route` and any state created at module load exist once, and every chunk sees the same object. Which bindings the splitter shares, copies or leaves in the entry is an implementation choice; tests assert values, identity and init counts, never placement. +- Every option configured for splitting must end up split. When a pattern the user can change prevents it, the option keeps working in the entry and the build warns once, naming the file. When the limitation is ours, it is a bug to fix, not a warning. +- `handleRouteUpdate` is stringified and injected into app modules. Keep runtime dependencies inside the function or explicitly emit them; extracting a helper to plugin module scope breaks the generated function. +- Route HMR rebuilds indexes, clears `resolvePathCache`, replaces lazy-chunk ownership, and refreshes active routes while preserving component identities (React, Solid and Vue). Keep these steps coordinated when adding derived state. +- Tests run in two tiers. `test:unit` (fast tier, the inner loop) runs `tests/**` in process; a Vite dev server in middleware mode is allowed. `test:integration` (slow tier) runs `tests/integration/**`: every test that starts a real build (`build`, `buildAndRun`), an Rsbuild dev server or watch compiler, a child Node process or a browser page (`openRouteHmrPage`). Put such tests under `tests/integration/`; a file with tests of both kinds is split by test into files of the same name in both directories. Run both tiers before handing back. +- Test code-splitting changes by behaviour: load the route with `loadRoute` from `tests/route-app.ts` (a real Vite dev server with the public plugins; the route runs in a real browser page), and assert what users see (rendered output, loader results, init counts). Outcomes the bundler decides (dead code, chunk contents, `sideEffects` / `@__PURE__` hints) are asserted in a real build with `build` from `tests/build-harness.ts`, per bundler. Do not add output snapshots. +- Run behavioural tests for React, Solid and Vue through the `targetFramework` option of the test helpers. +- Test what the page shows after a route file edit with `openRouteHmrPage` (`tests/route-hmr-page.ts`): a real dev server with the framework's plugin, a real browser page and the real HMR client. Never copy bundler, HMR-client or React Refresh logic into tests. There is no in-process HMR model: test route HMR with `openRouteHmrPage`. +- To run one test file or `-t` filter quickly, the slow-tier load gate and the test budgets: [compiler-test-utils/AGENTS.md](../compiler-test-utils/AGENTS.md). +- What these tests are, the spec they cite (`J4.12`, `G3`, `§5.7`) and the known bugs: [compiler-test-utils/oracle/README.md](../compiler-test-utils/oracle/README.md). diff --git a/packages/router-plugin/CHANGELOG.md b/packages/router-plugin/CHANGELOG.md index 5b18ae7e6a..72e6351d3e 100644 --- a/packages/router-plugin/CHANGELOG.md +++ b/packages/router-plugin/CHANGELOG.md @@ -1,44 +1,5 @@ # @tanstack/router-plugin -## 1.169.0 - -### Minor Changes - -- [#8855](https://github.com/TanStack/router/pull/8855) [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6) - Require Node `^20.19.0 || >=22.12.0` (was `>=20.19`), so the CommonJS builds can load ESM-only dependencies through `require(esm)`. Node 21 and Node 22.0–22.11 do not enable it by default, so they are no longer supported. - -- [#8851](https://github.com/TanStack/router/pull/8851) [`d250819`](https://github.com/TanStack/router/commit/d25081952dd04a5f5a44db7c8df5cbbf50fad054) - Require Vite 6 or later: the `vite` peer range is now `>=6.0.0`. Vite 5 is no longer supported. - -### Patch Changes - -- [`1ba19a0`](https://github.com/TanStack/router/commit/1ba19a04456983ee0f8adffd038b6b1194441e15) - fix: webpack and Rspack production builds no longer put the code splitter's "will not be code-split" warning, with the route file's absolute path, into the client bundle when the build process's `NODE_ENV` isn't `production`. The bundler's mode decides, and a config without `mode` counts as production, as it does for webpack and Rspack. The warning still prints in the build output. - -- [#8852](https://github.com/TanStack/router/pull/8852) [`94f36c4`](https://github.com/TanStack/router/commit/94f36c4a9ecf3062b326a8eb772e73b00c0644d9) - The esbuild plugin now throws when `autoCodeSplitting` is enabled, and `TanStackRouterCodeSplitterEsbuild` throws, instead of silently bundling every route without splitting. Route generation with esbuild is unchanged. - -- [#8856](https://github.com/TanStack/router/pull/8856) [`533ca27`](https://github.com/TanStack/router/commit/533ca2704452f36c5fef5c5fe084554d9b5db1ab) - Remove the undocumented `plugin.hmr.style` option and the `HmrOptions` type. Each bundler entry now picks its own HMR runtime: the webpack and Rspack entries already forced `'webpack'`, and on Vite, `'webpack'` broke route HMR. - -- [#8853](https://github.com/TanStack/router/pull/8853) [`13b6256`](https://github.com/TanStack/router/commit/13b625683030ea4ab359495ecda570e05e472587) - Remove internal code-splitter APIs: the `codeSplittingOptions.compilerPlugins` option, and the root-entry exports `unpluginRouterCodeSplitterFactory`, `getObjectPropertyKeyName`, `CodeSplitCompilerPlugin`, `ReferenceRouteCompilerPlugin`, `ReferenceRouteCompilerPluginContext` and `VirtualRouteSplitNodeCompilerPluginContext`. - -- [#8860](https://github.com/TanStack/router/pull/8860) [`b5e2ac9`](https://github.com/TanStack/router/commit/b5e2ac9c4cee4c5c6f464adc6cfddcddf6c84171) - Source maps of split routes now point at the route file. On webpack and Rspack (including Rsbuild), a split component or shared code mapped to the wrong line, because unplugin's loader dropped the router plugin's map; `unplugin` now requires `^3.5.0`, which keeps it. The maps of split and shared modules also name the route file itself instead of its `?tsr-split` / `?tsr-shared` module id, so debuggers bind breakpoints set in the route file. - -- [#8870](https://github.com/TanStack/router/pull/8870) [`f420d4a`](https://github.com/TanStack/router/commit/f420d4a6dacfaa81d306b7bbc9af8f1010d1a1bc) - Vite route HMR now writes `import.meta.hot.accept(` out instead of calling it through a `hot` alias. Vite only treats a module as a hot boundary when the call is spelled out, so an edit of a route file no framework plugin accepts (a `.ts` route file, or an app without `@vitejs/plugin-react`) reloaded the page instead of updating the route in place. With React HMR, a route file that declares its own top-level `hot` binding no longer fails to compile with `Duplicate declaration "hot"`. - -- Updated dependencies [[`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ad5b3b7`](https://github.com/TanStack/router/commit/ad5b3b7a0990eed7351d672ea6695d341108e0d6), [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69)]: - - @tanstack/router-generator@1.168.0 - - @tanstack/router-utils@1.163.0 - -## 1.168.48 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/#`) instead of relative file links that break once packages are installed. - -- [#8737](https://github.com/TanStack/router/pull/8737) [`647cb73`](https://github.com/TanStack/router/commit/647cb737a5622813d276d6042766692ca5ae67ed) - Remove the `enableRouteGeneration` option. Route generation now always runs, so `autoCodeSplitting` always has the route metadata it needs. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`689a7c5`](https://github.com/TanStack/router/commit/689a7c5419de68bce0aaaef72b9a36f115ea1398)]: - - @tanstack/react-router@1.170.46 - - @tanstack/router-core@1.171.39 - - @tanstack/router-generator@1.167.46 - ## 1.168.47 ### Patch Changes diff --git a/packages/router-plugin/eslint.config.js b/packages/router-plugin/eslint.config.js index 8ce6ad05fc..b36eb28ada 100644 --- a/packages/router-plugin/eslint.config.js +++ b/packages/router-plugin/eslint.config.js @@ -2,4 +2,11 @@ import rootConfig from '../../eslint.config.js' -export default [...rootConfig] +export default [ + ...rootConfig, + { + // Route files the tests copy into their apps, outside the TypeScript + // project (tsconfig.json) + ignores: ['tests/**/test-files/**'], + }, +] diff --git a/packages/router-plugin/package.json b/packages/router-plugin/package.json index b681bb61a2..e7fb2b69e8 100644 --- a/packages/router-plugin/package.json +++ b/packages/router-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-plugin", - "version": "1.169.0", + "version": "1.168.47", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -26,10 +26,12 @@ "scripts": { "clean": "rimraf ./dist && rimraf ./coverage", "clean:snapshots": "rimraf **/*snapshot* --glob", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit", - "test:unit": "vitest", - "test:unit:dev": "vitest --watch", - "test:eslint": "eslint ./src", + "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit && pnpm test:integration", + "test:unit": "vitest --project unit", + "test:unit:dev": "vitest --project unit --watch", + "test:integration": "vitest --project integration --project integration-pages", + "test:integration:smoke": "vitest --project integration integration/build-production.test.ts -t \"vite.*a production react client bundle has no dev-only code|autoCodeSplitting: true. has no dev-only code\"", + "test:eslint": "eslint ./src ./tests", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", @@ -114,7 +116,7 @@ "!skills/_artifacts" ], "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": ">=20.19" }, "dependencies": { "@babel/core": "catalog:", @@ -124,31 +126,50 @@ "@tanstack/router-generator": "workspace:*", "@tanstack/router-utils": "workspace:*", "chokidar": "catalog:", - "unplugin": "^3.5.0", + "unplugin": "^3.3.0", "zod": "catalog:" }, "devDependencies": { "@rsbuild/core": "catalog:", + "@rsbuild/plugin-babel": "^1.1.2", + "@rsbuild/plugin-react": "^2.0.0", + "@rsbuild/plugin-solid": "^1.2.2", + "@rsbuild/plugin-vue": "^1.2.7", + "@rsbuild/plugin-vue-jsx": "^2.0.0", + "@emotion/react": "^11.14.0", "@types/babel__core": "^7.20.5", "@types/babel__template": "^7.4.4", "@types/node": ">=20", + "@tanstack/compiler-test-utils": "workspace:*", "@tanstack/vite-config": "catalog:", + "@vitejs/plugin-react": "catalog:", + "@vitejs/plugin-vue-jsx": "catalog:", "vitest": "catalog:", - "jsdom": "catalog:", "react": "catalog:", "react-dom": "catalog:", + "react-error-boundary": "^6.1.6", "@types/react": "catalog:", "@types/react-dom": "catalog:", - "prettier": "^3.9.6", "@arethetypeswrong/cli": "catalog:", "publint": "catalog:", "rimraf": "catalog:", - "webpack": "^5.104.1" + "webpack": "^5.104.1", + "webpack-dev-server": "^5.2.4", + "@babel/preset-typescript": "^7.28.5", + "@rolldown/plugin-babel": "^0.2.0", + "@tanstack/solid-router": "workspace:*", + "@tanstack/vue-router": "workspace:*", + "babel-loader": "^10.0.0", + "babel-plugin-react-compiler": "^1.0.0", + "babel-preset-solid": "^1.9.10", + "solid-js": "catalog:", + "vite-plugin-solid": "catalog:", + "vue": "catalog:" }, "peerDependencies": { "@rsbuild/core": ">=1.0.2 || ^2.0.0", "@tanstack/react-router": "workspace:^", - "vite": ">=6.0.0", + "vite": ">=5.0.0 || >=6.0.0 || >=7.0.0 || >=8.0.0", "vite-plugin-solid": "^2.11.10 || ^3.0.0-0", "webpack": ">=5.92.0" }, diff --git a/packages/router-plugin/skills/router-plugin/SKILL.md b/packages/router-plugin/skills/router-plugin/SKILL.md index 5353b7e8c0..a4cb79f55b 100644 --- a/packages/router-plugin/skills/router-plugin/SKILL.md +++ b/packages/router-plugin/skills/router-plugin/SKILL.md @@ -91,13 +91,12 @@ esbuild.build({ plugins: [ tanstackRouter({ target: 'react', + autoCodeSplitting: true, }), ], }) ``` -> Automatic code splitting is not available with esbuild: the plugin throws when `autoCodeSplitting` is `true`. Use manual code splitting (`.lazy.tsx` files) or another bundler to split routes. - ## Configuration Options ### Core Options diff --git a/packages/router-plugin/src/core/code-splitter/compilers.ts b/packages/router-plugin/src/core/code-splitter/compilers.ts index 0cd783a58a..89cdae41ad 100644 --- a/packages/router-plugin/src/core/code-splitter/compilers.ts +++ b/packages/router-plugin/src/core/code-splitter/compilers.ts @@ -364,7 +364,6 @@ function removeSharedDeclarations(ast: t.File, sharedBindings: Set) { export function compileCodeSplitReferenceRoute( opts: ParseAstOptions & CompileCodeSplitReferenceRouteOptions & { - isProduction?: boolean compilerPlugins?: Array }, ): GeneratorResult | null { @@ -848,9 +847,8 @@ export function compileCodeSplitReferenceRoute( ) console.warn(warningMessage) - // Development builds log it in the page too. The bundler's mode decides, - // not the build process's NODE_ENV, which webpack never sets. - if (!opts.isProduction) { + // append this warning to the file using a template + if (process.env.NODE_ENV !== 'production') { const warningTemplate = template.statement( `console.warn(${JSON.stringify(warningMessage)})`, )() @@ -1287,8 +1285,7 @@ export function compileCodeSplitVirtualRoute( const result = generateFromAst(ast, { sourceMaps: true, - // Name the route file, not this module's `?tsr-*` id. - sourceFileName: removeSplitSearchParamFromFilename(opts.filename), + sourceFileName: opts.filename, filename: opts.filename, }) @@ -1379,8 +1376,7 @@ export function compileCodeSplitSharedRoute( const result = generateFromAst(ast, { sourceMaps: true, - // Name the route file, not this module's `?tsr-*` id. - sourceFileName: removeSplitSearchParamFromFilename(opts.filename), + sourceFileName: opts.filename, filename: opts.filename, }) diff --git a/packages/router-plugin/src/core/code-splitter/plugins.ts b/packages/router-plugin/src/core/code-splitter/plugins.ts index 94444c1aec..1e8ada32b5 100644 --- a/packages/router-plugin/src/core/code-splitter/plugins.ts +++ b/packages/router-plugin/src/core/code-splitter/plugins.ts @@ -1,7 +1,6 @@ import type babel from '@babel/core' import type * as t from '@babel/types' -import type { Config, DeletableNodes } from '../config' -import type { HmrStyle } from '../hmr' +import type { Config, DeletableNodes, HmrStyle } from '../config' import type { CodeSplitGroupings } from '../constants' import type { SplitNodeMeta } from './types' diff --git a/packages/router-plugin/src/core/code-splitter/plugins/framework-plugins.ts b/packages/router-plugin/src/core/code-splitter/plugins/framework-plugins.ts index cf4b150807..a0351ad210 100644 --- a/packages/router-plugin/src/core/code-splitter/plugins/framework-plugins.ts +++ b/packages/router-plugin/src/core/code-splitter/plugins/framework-plugins.ts @@ -2,8 +2,7 @@ import { createReactRefreshIgnoredRouteExportsPlugin } from './react-refresh-ign import { createReactRefreshRouteComponentsPlugin } from './react-refresh-route-components' import { createReactStableHmrSplitRouteComponentsPlugin } from './react-stable-hmr-split-route-components' import type { CodeSplitCompilerPlugin } from '../plugins' -import type { Config } from '../../config' -import type { HmrStyle } from '../../hmr' +import type { Config, HmrStyle } from '../../config' export function getFrameworkHmrCompilerPlugins(opts: { targetFramework: Config['target'] diff --git a/packages/router-plugin/src/core/code-splitter/plugins/react-refresh-ignored-route-exports.ts b/packages/router-plugin/src/core/code-splitter/plugins/react-refresh-ignored-route-exports.ts index f951d863b3..cc2be62034 100644 --- a/packages/router-plugin/src/core/code-splitter/plugins/react-refresh-ignored-route-exports.ts +++ b/packages/router-plugin/src/core/code-splitter/plugins/react-refresh-ignored-route-exports.ts @@ -5,8 +5,9 @@ import type { ReferenceRouteCompilerPlugin } from '../plugins' const buildReactRefreshIgnoredRouteExportsStatements = template.statements( ` -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} +const hot = import.meta.hot +if (hot && typeof window !== 'undefined') { + hot.data ??= {} const tsrReactRefresh = window.__TSR_REACT_REFRESH__ ??= (() => { const ignoredExportsById = new Map() const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports diff --git a/packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts b/packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts index f67a189f40..99448f452a 100644 --- a/packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts +++ b/packages/router-plugin/src/core/code-splitter/plugins/react-stable-hmr-split-route-components.ts @@ -1,7 +1,7 @@ import * as template from '@babel/template' import * as t from '@babel/types' import { getUniqueProgramIdentifier } from '../../utils' -import type { HmrStyle } from '../../hmr' +import type { HmrStyle } from '../../config' import type { ReferenceRouteCompilerPlugin } from '../plugins' function capitalizeIdentifier(str: string) { diff --git a/packages/router-plugin/src/core/config.ts b/packages/router-plugin/src/core/config.ts index 6c11241a01..8366f78e80 100644 --- a/packages/router-plugin/src/core/config.ts +++ b/packages/router-plugin/src/core/config.ts @@ -9,6 +9,7 @@ import type { RouteIds, } from '@tanstack/router-core' import type { CodeSplitGroupings } from './constants' +import type { CodeSplitCompilerPlugin } from './code-splitter/plugins' export const splitGroupingsSchema = z .array( @@ -70,6 +71,25 @@ export type CodeSplittingOptions = { * @default true */ addHmr?: boolean + + /** + * Internal compiler plugins used by framework integrations. + * @internal + */ + compilerPlugins?: Array +} + +export type HmrStyle = 'vite' | 'webpack' + +export type HmrOptions = { + /** + * Selects the HMR runtime style to emit code for. + * - `'vite'` (default): ESM `import.meta.hot` with Vite accept-callback semantics. + * - `'webpack'`: `import.meta.webpackHot` with webpack / Rspack `module.hot` re-execution semantics. + * + * Bundler-specific plugin entries (e.g. `rspack.ts`, `webpack.ts`) set this explicitly. + */ + style?: HmrStyle } const codeSplittingOptionsSchema = z.object({ @@ -96,6 +116,11 @@ export const configSchema = generatorConfigSchema.extend({ .optional(), plugin: z .object({ + hmr: z + .object({ + style: z.enum(['vite', 'webpack']).optional(), + }) + .optional(), vite: z .object({ environmentName: z.string().optional(), diff --git a/packages/router-plugin/src/core/hmr/index.ts b/packages/router-plugin/src/core/hmr/index.ts index b3c8545851..4e60f015a1 100644 --- a/packages/router-plugin/src/core/hmr/index.ts +++ b/packages/router-plugin/src/core/hmr/index.ts @@ -1,5 +1,5 @@ export { createRouteHmrStatement } from './select-adapter' -export type { CreateRouteHmrStatementOpts, HmrStyle } from './select-adapter' +export type { CreateRouteHmrStatementOpts } from './select-adapter' export { createViteHmrStatement } from './vite-adapter' export { createWebpackHmrStatement } from './webpack-adapter' export { getHandleRouteUpdateCode } from './handle-route-update' diff --git a/packages/router-plugin/src/core/hmr/select-adapter.ts b/packages/router-plugin/src/core/hmr/select-adapter.ts index 5ad2646970..60395a1534 100644 --- a/packages/router-plugin/src/core/hmr/select-adapter.ts +++ b/packages/router-plugin/src/core/hmr/select-adapter.ts @@ -1,16 +1,8 @@ import { createViteHmrStatement } from './vite-adapter' import { createWebpackHmrStatement } from './webpack-adapter' -import type { Config } from '../config' +import type { Config, HmrStyle } from '../config' import type * as t from '@babel/types' -/** - * The HMR runtime to emit code for: - * - `'vite'`: ESM `import.meta.hot` with Vite accept-callback semantics. - * - `'webpack'`: `import.meta.webpackHot` with webpack / Rspack `module.hot` - * re-execution semantics. - */ -export type HmrStyle = 'vite' | 'webpack' - export type CreateRouteHmrStatementOpts = { hmrStyle: HmrStyle targetFramework: Config['target'] @@ -18,9 +10,9 @@ export type CreateRouteHmrStatementOpts = { } /** - * Dispatches to the HMR adapter of the bundler the plugin runs in. `hmrStyle` - * comes from the bundler-specific plugin entry (e.g. `rspack.ts` → - * `'webpack'`), not from user config. + * Dispatches to the configured HMR adapter. `hmrStyle` is set explicitly by + * the bundler-specific plugin entry (e.g. `rspack.ts` → `'webpack'`), so there + * is no runtime inference based on config string shapes. */ export function createRouteHmrStatement( stableRouteOptionKeys: Array, diff --git a/packages/router-plugin/src/core/hmr/vite-adapter.ts b/packages/router-plugin/src/core/hmr/vite-adapter.ts index 5357c45acf..ba8d42a80a 100644 --- a/packages/router-plugin/src/core/hmr/vite-adapter.ts +++ b/packages/router-plugin/src/core/hmr/vite-adapter.ts @@ -4,9 +4,7 @@ import type * as t from '@babel/types' /** * Emits HMR accept code for Vite / native ESM HMR: `import.meta.hot.accept` - * with a callback that receives the freshly re-imported module. Vite makes the - * module a hot boundary only when the code spells `import.meta.hot.accept(` - * out, so the call must not go through an alias. + * with a callback that receives the freshly re-imported module. * * `targetFramework` is currently unused — Vite's framework-specific fast-refresh * plugins handle component body patching via their own accept boundaries — but @@ -28,7 +26,8 @@ export function createViteHmrStatement( template.statement( ` if (import.meta.hot) { - const hotData = import.meta.hot.data ??= {} + const hot = import.meta.hot + const hotData = hot.data ??= {} const handleRouteUpdate = ${handleRouteUpdateCode} const initialRouteId = ${routeIdFallback} ?? hotData['tsr-route-id'] if (initialRouteId) { @@ -42,7 +41,7 @@ if (import.meta.hot) { handleRouteUpdate(initialRouteId, Route) hotData['tsr-route-update-handled'] = Route } - import.meta.hot.accept((newModule) => { + hot.accept((newModule) => { if (Route && newModule && newModule.Route) { const routeId = hotData['tsr-route-id'] ?? ${routeIdFallback} if (routeId) { diff --git a/packages/router-plugin/src/core/router-code-splitter-plugin.ts b/packages/router-plugin/src/core/router-code-splitter-plugin.ts index ecc7607d59..596bd6e012 100644 --- a/packages/router-plugin/src/core/router-code-splitter-plugin.ts +++ b/packages/router-plugin/src/core/router-code-splitter-plugin.ts @@ -24,8 +24,7 @@ import { createRouterPluginContext } from './router-plugin-context' import type { CodeSplitGroupings, SplitRouteIdentNodes } from './constants' import type { GetRoutesByFileMapResultValue } from '@tanstack/router-generator' import type { CodeSplitCompilerPlugin } from './code-splitter/plugins' -import type { Config } from './config' -import type { HmrStyle } from './hmr' +import type { Config, HmrStyle } from './config' import type { RouterPluginContext } from './router-plugin-context' import type { UnpluginFactory, @@ -81,11 +80,11 @@ const TRANSFORMATION_PLUGINS_BY_FRAMEWORK: Record< export function createRouterCodeSplitterPlugin( options: Partial Config)> | undefined = {}, routerPluginContext: RouterPluginContext, - hmrStyle: HmrStyle = 'vite', ): ReturnType Config)> | undefined>> { let ROOT: string = process.cwd() let userConfig: Config let addHmr: boolean + let hmrStyle: HmrStyle let compilerPlugins: Array let virtualRouteCompilerPlugins: Array @@ -99,12 +98,16 @@ export function createRouterCodeSplitterPlugin( } addHmr = (userConfig.codeSplittingOptions?.addHmr ?? true) && !isProduction - compilerPlugins = addHmr - ? (getFrameworkHmrCompilerPlugins({ - targetFramework: userConfig.target, - hmrStyle, - }) ?? []) - : [] + hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite' + compilerPlugins = [ + ...(addHmr + ? (getFrameworkHmrCompilerPlugins({ + targetFramework: userConfig.target, + hmrStyle, + }) ?? []) + : []), + ...(userConfig.codeSplittingOptions?.compilerPlugins ?? []), + ] virtualRouteCompilerPlugins = compilerPlugins.filter( (plugin) => plugin.onVirtualRouteSplitNode, ) @@ -182,7 +185,6 @@ export function createRouterCodeSplitterPlugin( targetFramework: userConfig.target, filename: id, id, - isProduction, deleteNodes: userConfig.codeSplittingOptions?.deleteNodes ? new Set(userConfig.codeSplittingOptions.deleteNodes) : undefined, @@ -328,13 +330,13 @@ export function createRouterCodeSplitterPlugin( }, rspack(compiler) { - isProduction = (compiler.options.mode ?? 'production') === 'production' + isProduction = compiler.options.mode === 'production' ROOT = process.cwd() initUserConfig() }, webpack(compiler) { - isProduction = (compiler.options.mode ?? 'production') === 'production' + isProduction = compiler.options.mode === 'production' ROOT = process.cwd() initUserConfig() }, diff --git a/packages/router-plugin/src/core/router-composed-plugin.ts b/packages/router-plugin/src/core/router-composed-plugin.ts index 5bcaaf8da9..c778e4e8d4 100644 --- a/packages/router-plugin/src/core/router-composed-plugin.ts +++ b/packages/router-plugin/src/core/router-composed-plugin.ts @@ -4,7 +4,6 @@ import { createRouterCodeSplitterPlugin } from './router-code-splitter-plugin' import { createRouterHmrPlugin } from './router-hmr-plugin' import { createRouterPluginContext } from './router-plugin-context' import type { Config } from './config' -import type { HmrStyle } from './hmr' import type { RspackCompiler, UnpluginFactory, @@ -31,18 +30,13 @@ function applyRspackInlineCssDefaultDefinePlugin(compiler: RspackCompiler) { export const unpluginRouterComposedFactory: UnpluginFactory< Partial Config)> | undefined -> = (options = {}, meta) => { +> = (options = {}, _meta) => { const ROOT: string = process.cwd() const userConfig = getConfig( (typeof options === 'function' ? options() : options) as Partial, ROOT, ) const routerPluginContext = createRouterPluginContext() - // webpack and Rspack share webpack's `import.meta.webpackHot` HMR API. - const hmrStyle: HmrStyle = - meta.framework === 'webpack' || meta.framework === 'rspack' - ? 'webpack' - : 'vite' const getPlugin = (plugin: ReturnType>) => { if (!Array.isArray(plugin)) { @@ -55,7 +49,7 @@ export const unpluginRouterComposedFactory: UnpluginFactory< createRouterGeneratorPlugin(options, routerPluginContext), ) const routerCodeSplitter = getPlugin( - createRouterCodeSplitterPlugin(options, routerPluginContext, hmrStyle), + createRouterCodeSplitterPlugin(options, routerPluginContext), ) const result = [ @@ -95,7 +89,7 @@ export const unpluginRouterComposedFactory: UnpluginFactory< if (!isProduction && !userConfig.autoCodeSplitting) { const routerHmr = getPlugin( - createRouterHmrPlugin(options, routerPluginContext, hmrStyle), + createRouterHmrPlugin(options, routerPluginContext), ) result.push(...routerHmr) } diff --git a/packages/router-plugin/src/core/router-hmr-plugin.ts b/packages/router-plugin/src/core/router-hmr-plugin.ts index 3f14a38be5..e1dc01a43b 100644 --- a/packages/router-plugin/src/core/router-hmr-plugin.ts +++ b/packages/router-plugin/src/core/router-hmr-plugin.ts @@ -7,7 +7,6 @@ import { getConfig } from './config' import { createRouterPluginContext } from './router-plugin-context' import type { UnpluginFactory } from 'unplugin' import type { Config } from './config' -import type { HmrStyle } from './hmr' import type { RouterPluginContext } from './router-plugin-context' /** @@ -19,7 +18,6 @@ import type { RouterPluginContext } from './router-plugin-context' export function createRouterHmrPlugin( options: Partial Config)> | undefined = {}, routerPluginContext: RouterPluginContext, - hmrStyle: HmrStyle = 'vite', ): ReturnType | undefined>> { let ROOT: string = process.cwd() @@ -49,6 +47,8 @@ export function createRouterHmrPlugin( if (debug) console.info('Adding HMR handling to route ', normalizedId) + const hmrStyle = userConfig.plugin?.hmr?.style ?? 'vite' + if (userConfig.target === 'react') { const compilerPlugins = getFrameworkHmrCompilerPlugins({ targetFramework: 'react', diff --git a/packages/router-plugin/src/esbuild.ts b/packages/router-plugin/src/esbuild.ts index e2c184bb3d..650082964d 100644 --- a/packages/router-plugin/src/esbuild.ts +++ b/packages/router-plugin/src/esbuild.ts @@ -1,6 +1,7 @@ import { createEsbuildPlugin } from 'unplugin' -import { configSchema, getConfig } from './core/config' +import { configSchema } from './core/config' +import { createRouterCodeSplitterPlugin } from './core/router-code-splitter-plugin' import { createRouterGeneratorPlugin } from './core/router-generator-plugin' import { unpluginRouterComposedFactory } from './core/router-composed-plugin' import { createRouterPluginContext } from './core/router-plugin-context' @@ -12,20 +13,6 @@ type RouterPluginOptions = Partial Config)> | undefined const defaultRouterPluginContext = createRouterPluginContext() -const ESBUILD_SPLITTING_ERROR = - '@tanstack/router-plugin: route code splitting (`autoCodeSplitting`) is not supported with esbuild. ' + - 'Use the generator alone (`TanStackRouterGeneratorEsbuild`), or set `autoCodeSplitting: false`.' - -function refuseSplitting(options: RouterPluginOptions) { - const config = - typeof options === 'function' - ? options() - : getConfig(options ?? {}, process.cwd()) - if (config.autoCodeSplitting) { - throw new Error(ESBUILD_SPLITTING_ERROR) - } -} - /** * @example * ```ts @@ -46,14 +33,22 @@ const TanStackRouterGeneratorEsbuild = ( } /** - * Route code splitting is not available with esbuild: this entry refuses - * clearly. + * @example + * ```ts + * export default { + * plugins: [TanStackRouterCodeSplitterEsbuild()], + * // ... + * } + * ``` */ const TanStackRouterCodeSplitterEsbuild = ( - _options?: RouterPluginOptions, - _routerPluginContext?: RouterPluginContext, -): never => { - throw new Error(ESBUILD_SPLITTING_ERROR) + options?: RouterPluginOptions, + routerPluginContext?: RouterPluginContext, +) => { + const pluginContext = routerPluginContext ?? defaultRouterPluginContext + return createEsbuildPlugin((pluginOptions: RouterPluginOptions) => + createRouterCodeSplitterPlugin(pluginOptions, pluginContext), + )(options) } /** @@ -65,10 +60,7 @@ const TanStackRouterCodeSplitterEsbuild = ( * } * ``` */ -const TanStackRouterEsbuild = (options: RouterPluginOptions = {}) => { - refuseSplitting(options) - return createEsbuildPlugin(unpluginRouterComposedFactory)(options) -} +const TanStackRouterEsbuild = createEsbuildPlugin(unpluginRouterComposedFactory) const tanstackRouter = TanStackRouterEsbuild export default TanStackRouterEsbuild diff --git a/packages/router-plugin/src/index.ts b/packages/router-plugin/src/index.ts index c892c32671..6a6ad158bb 100644 --- a/packages/router-plugin/src/index.ts +++ b/packages/router-plugin/src/index.ts @@ -1,4 +1,5 @@ export { configSchema, getConfig } from './core/config' +export { unpluginRouterCodeSplitterFactory } from './core/router-code-splitter-plugin' export { unpluginRouterGeneratorFactory } from './core/router-generator-plugin' export { createRouterPluginContext } from './core/router-plugin-context' export type { @@ -7,8 +8,16 @@ export type { ConfigOutput, CodeSplittingOptions, DeletableNodes, + HmrOptions, } from './core/config' export type { RouterPluginContext } from './core/router-plugin-context' +export { getObjectPropertyKeyName } from './core/utils' +export type { + CodeSplitCompilerPlugin, + ReferenceRouteCompilerPlugin, + ReferenceRouteCompilerPluginContext, + VirtualRouteSplitNodeCompilerPluginContext, +} from './core/code-splitter/plugins' export { tsrSplit, splitRouteIdentNodes, diff --git a/packages/router-plugin/src/rspack.ts b/packages/router-plugin/src/rspack.ts index 6020179cce..a31bde74af 100644 --- a/packages/router-plugin/src/rspack.ts +++ b/packages/router-plugin/src/rspack.ts @@ -12,6 +12,35 @@ type RspackRouterPluginOptions = Partial | (() => Partial) const defaultRouterPluginContext = createRouterPluginContext() +/** + * Rspack uses webpack-compatible `module.hot` / `import.meta.webpackHot` HMR. + * Force `plugin.hmr.style = 'webpack'` so the router HMR adapter emits + * `module.hot`-style accept/dispose code instead of Vite's callback-receive + * variant, regardless of what the user passes (or doesn't pass). + */ +function withWebpackHmrStyle( + options: RspackRouterPluginOptions | undefined, +): RspackRouterPluginOptions { + const mergeHmrStyle = ( + config: Partial | undefined, + ): Partial => ({ + ...config, + plugin: { + ...config?.plugin, + hmr: { + ...config?.plugin?.hmr, + style: 'webpack', + }, + }, + }) + + if (typeof options === 'function') { + return () => mergeHmrStyle(options()) + } + + return mergeHmrStyle(options) +} + /** * @example * ```ts @@ -39,9 +68,6 @@ const TanStackRouterGeneratorRspack = ( } /** - * Rspack uses webpack-compatible `import.meta.webpackHot` HMR, which the - * code splitter emits for it. - * * @example * ```ts * export default defineConfig({ @@ -61,9 +87,10 @@ const TanStackRouterCodeSplitterRspack = ( const pluginContext = routerPluginContext ?? defaultRouterPluginContext return createRspackPlugin((pluginOptions) => createRouterCodeSplitterPlugin( - pluginOptions as Partial Config)> | undefined, + withWebpackHmrStyle( + pluginOptions as RspackRouterPluginOptions | undefined, + ) as Partial Config)>, pluginContext, - 'webpack', ), )(options) } @@ -82,7 +109,13 @@ const TanStackRouterCodeSplitterRspack = ( * ``` */ const TanStackRouterRspack = /* #__PURE__ */ createRspackPlugin( - unpluginRouterComposedFactory, + (options, meta) => + unpluginRouterComposedFactory( + withWebpackHmrStyle( + options as RspackRouterPluginOptions | undefined, + ) as Partial Config)>, + meta, + ), ) const tanstackRouter = TanStackRouterRspack export default TanStackRouterRspack diff --git a/packages/router-plugin/src/webpack.ts b/packages/router-plugin/src/webpack.ts index 9a0063fd6f..712372565e 100644 --- a/packages/router-plugin/src/webpack.ts +++ b/packages/router-plugin/src/webpack.ts @@ -10,6 +10,26 @@ import type { RouterPluginContext } from './core/router-plugin-context' const defaultRouterPluginContext = createRouterPluginContext() +/** + * Webpack uses `module.hot` / `import.meta.webpackHot` HMR. Force + * `plugin.hmr.style = 'webpack'` so the router HMR adapter emits the correct + * accept/dispose shape regardless of user config. + */ +function withWebpackHmrStyle( + options: Partial | undefined, +): Partial { + return { + ...options, + plugin: { + ...options?.plugin, + hmr: { + ...options?.plugin?.hmr, + style: 'webpack', + }, + }, + } +} + /** * @example * ```ts @@ -30,8 +50,6 @@ const TanStackRouterGeneratorWebpack = ( } /** - * Route HMR in development goes through `import.meta.webpackHot`. - * * @example * ```ts * export default { @@ -46,7 +64,10 @@ const TanStackRouterCodeSplitterWebpack = ( ) => { const pluginContext = routerPluginContext ?? defaultRouterPluginContext return createWebpackPlugin((pluginOptions: Partial | undefined) => - createRouterCodeSplitterPlugin(pluginOptions, pluginContext, 'webpack'), + createRouterCodeSplitterPlugin( + withWebpackHmrStyle(pluginOptions), + pluginContext, + ), )(options) } @@ -60,7 +81,11 @@ const TanStackRouterCodeSplitterWebpack = ( * ``` */ const TanStackRouterWebpack = /* #__PURE__ */ createWebpackPlugin( - unpluginRouterComposedFactory, + (options, meta) => + unpluginRouterComposedFactory( + withWebpackHmrStyle(options as Partial | undefined), + meta, + ), ) const tanstackRouter = TanStackRouterWebpack diff --git a/packages/router-plugin/tests/add-hmr.test.ts b/packages/router-plugin/tests/add-hmr.test.ts deleted file mode 100644 index 0d89832f3b..0000000000 --- a/packages/router-plugin/tests/add-hmr.test.ts +++ /dev/null @@ -1,377 +0,0 @@ -import { - mkdir, - mkdtemp, - readFile, - readdir, - rm, - writeFile, -} from 'node:fs/promises' -import path from 'node:path' -import { createServer } from 'vite' -import { describe, expect, it } from 'vitest' - -import { compileCodeSplitReferenceRoute } from '../src/core/code-splitter/compilers' -import { defaultCodeSplitGroupings } from '../src/core/constants' -import { getFrameworkHmrCompilerPlugins } from '../src/core/code-splitter/plugins/framework-plugins' -import { createRouteHmrStatement } from '../src/core/hmr' -import { frameworks } from './constants' -import { formatSnapshot } from './format-snapshot' - -function getFrameworkDir(framework: string) { - const files = path.resolve(__dirname, `./add-hmr/test-files/${framework}`) - const snapshots = path.resolve(__dirname, `./add-hmr/snapshots/${framework}`) - return { files, snapshots } -} - -describe('add-hmr works', () => { - describe.each(frameworks)('FRAMEWORK=%s', async (framework) => { - const dirs = getFrameworkDir(framework) - const filenames = await readdir(dirs.files) - - it.each(filenames)( - `should add hmr in "reference" for "%s"`, - async (filename) => { - const file = await readFile(path.join(dirs.files, filename)) - const code = file.toString() - - const compileResult = compileCodeSplitReferenceRoute({ - code, - filename, - id: filename, - addHmr: true, - codeSplitGroupings: defaultCodeSplitGroupings, - targetFramework: framework, - compilerPlugins: getFrameworkHmrCompilerPlugins({ - targetFramework: framework, - }), - }) - - await expect( - await formatSnapshot(compileResult?.code || code, filename), - ).toMatchFileSnapshot( - path.join(dirs.snapshots, filename.replace('.tsx', '@true.tsx')), - ) - }, - ) - - it.each(filenames)( - `should NOT add hmr in "reference" for "%s"`, - async (filename) => { - const file = await readFile(path.join(dirs.files, filename)) - const code = file.toString() - - const compileResult = compileCodeSplitReferenceRoute({ - code, - filename, - id: filename, - addHmr: false, - codeSplitGroupings: defaultCodeSplitGroupings, - targetFramework: framework, - }) - - await expect( - await formatSnapshot(compileResult?.code || code, filename), - ).toMatchFileSnapshot( - path.join(dirs.snapshots, filename.replace('.tsx', '@false.tsx')), - ) - }, - ) - }) - - it('supports configurable webpackHot HMR code generation', async () => { - const filename = 'arrow-function.tsx' - const framework = 'react' - const file = await readFile( - path.join(getFrameworkDir(framework).files, filename), - ) - const code = file.toString() - - const compileResult = compileCodeSplitReferenceRoute({ - code, - filename, - id: filename, - addHmr: true, - hmrStyle: 'webpack', - codeSplitGroupings: defaultCodeSplitGroupings, - targetFramework: framework, - compilerPlugins: getFrameworkHmrCompilerPlugins({ - targetFramework: framework, - hmrStyle: 'webpack', - }), - }) - - await expect( - await formatSnapshot(compileResult?.code || code, filename), - ).toMatchFileSnapshot( - path.join( - getFrameworkDir(framework).snapshots, - filename.replace('.tsx', '@webpack-hot.tsx'), - ), - ) - }) - - it('supports configurable webpackHot unsplittable HMR generation', async () => { - const statement = createRouteHmrStatement([], { - hmrStyle: 'webpack', - targetFramework: 'react', - }) - const output = JSON.stringify(statement) - - expect(output).toContain('webpackHot') - expect(output).not.toContain('import.meta.hot') - expect(output).toContain('oldHasShellComponent') - }) - - it('supports configurable Vite unsplittable HMR generation', async () => { - const statement = createRouteHmrStatement([], { - hmrStyle: 'vite', - targetFramework: 'react', - }) - const output = JSON.stringify(statement) - - expect(output).toContain('MetaProperty') - expect(output).toContain('hot') - expect(output).not.toContain('webpackHot') - expect(output).toContain('newModule') - }) - - it('generates lazy reset and scoped route refresh without route context mutation', async () => { - const filename = 'arrow-function.tsx' - const framework = 'react' - const file = await readFile( - path.join(getFrameworkDir(framework).files, filename), - ) - const code = file.toString() - const compileResult = compileCodeSplitReferenceRoute({ - code, - filename, - id: filename, - addHmr: true, - codeSplitGroupings: defaultCodeSplitGroupings, - targetFramework: framework, - compilerPlugins: getFrameworkHmrCompilerPlugins({ - targetFramework: framework, - }), - }) - if (!compileResult) { - throw new Error('Expected the reference route to be transformed') - } - const output = compileResult.code - - expect(output).toContain( - 'router._replaceRouteChunk(oldRoute, newRoute.lazyFn);', - ) - expect(output).toContain('void router._refreshRoute?.();') - expect(output).not.toContain('__routeContext') - }) - - it('uses a generated route id fallback for Vite HMR', async () => { - const statement = createRouteHmrStatement([], { - hmrStyle: 'vite', - targetFramework: 'react', - routeId: '/posts', - }) - const output = JSON.stringify(statement) - - expect(output).toContain('tsr-route-id') - expect(output).toContain('/posts') - }) - - it('prefers the current generated route id over stale Vite hot data', async () => { - const statement = createRouteHmrStatement([], { - hmrStyle: 'vite', - targetFramework: 'react', - routeId: '/current-route', - }) - const output = JSON.stringify(statement) - - expect(output).toContain('"name":"initialRouteId"') - expect(output).toContain( - '"operator":"??","left":{"type":"StringLiteral","value":"/current-route"', - ) - expect(output).toContain('"object":{"type":"Identifier","name":"hotData"}') - }) - - it('normalizes the generated root route id for Vite HMR', async () => { - const statement = createRouteHmrStatement([], { - hmrStyle: 'vite', - targetFramework: 'react', - routeId: '/__root', - }) - const output = JSON.stringify(statement) - - expect(output).toContain('__root__') - expect(output).not.toContain('/__root') - }) -}) - -/** - * Starts a Vite dev server with the router plugin (and no framework plugin) - * for an app made of `files`, connects an HMR client to it the way the - * browser's `/@vite/client` does, and requests the app's modules from - * `main.ts` on, as a page would. - */ -async function startDevApp( - files: Record, - options: { autoCodeSplitting: boolean }, -) { - // Keep the app inside the package so runtime imports resolve. - const root = await mkdtemp(path.join(__dirname, '.add-hmr-')) - await mkdir(path.join(root, 'routes')) - const allFiles: Record = { - 'index.html': '', - 'main.ts': `import { createRouter } from '@tanstack/react-router' -import { routeTree } from './routeTree.gen' -export const router = createRouter({ routeTree }) -`, - 'routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({}) -`, - ...files, - } - for (const [file, code] of Object.entries(allFiles)) { - await writeFile(path.join(root, file), code) - } - const { tanstackRouter } = await import('../src/vite') - const server = await createServer({ - root, - configFile: false, - logLevel: 'silent', - server: { port: 0, strictPort: false }, - // A dependency optimisation would reload the page on its own. - optimizeDeps: { noDiscovery: true, include: [] }, - plugins: [ - tanstackRouter({ - target: 'react', - routesDirectory: './routes', - generatedRouteTree: './routeTree.gen.ts', - autoCodeSplitting: options.autoCodeSplitting, - }), - ], - }) - const close = async () => { - await server.close() - await rm(root, { recursive: true, force: true }) - } - try { - await server.listen() - const origin = server.resolvedUrls!.local[0]!.replace(/\/$/, '') - const messages: Array<{ type: string }> = [] - const socket = new WebSocket( - `${origin.replace('http', 'ws')}/?token=${server.config.webSocketToken}`, - 'vite-hmr', - ) - socket.addEventListener('message', (event) => { - messages.push(JSON.parse(String(event.data))) - }) - await new Promise((resolve, reject) => { - socket.addEventListener('open', resolve) - socket.addEventListener('error', reject) - }) - const statuses: Record = {} - const served: Record = {} - const queue = ['/main.ts'] - while (queue.length > 0) { - const url = queue.shift()! - if (url in statuses) { - continue - } - const response = await fetch(origin + url) - statuses[url] = response.status - const code = await response.text() - served[url] = code - // Static imports of the app's own modules - for (const [, imported] of code.matchAll( - /^import\s[^'"]*?["'](\/(?!@|node_modules)[^"'?]+)["']/gm, - )) { - queue.push(imported!) - } - } - return { - statuses, - served, - /** Writes `code` to `file`; resolves with Vite's first reaction. */ - async edit(file: string, code: string) { - const seen = messages.length - await writeFile(path.join(root, file), code) - const deadline = Date.now() + 10_000 - while (Date.now() < deadline) { - const reaction = messages - .slice(seen) - .find( - (message) => - message.type === 'update' || message.type === 'full-reload', - ) - if (reaction) { - return reaction.type - } - await new Promise((resolve) => setTimeout(resolve, 50)) - } - return 'nothing' - }, - async close() { - socket.close() - await close() - }, - } - } catch (error) { - await close() - throw error - } -} - -describe('route HMR in a Vite dev server', () => { - // Vite makes a module a hot boundary only when its code spells - // `import.meta.hot.accept(` out. Route modules no framework plugin accepts - // (a `.ts` route file, or an app without `@vitejs/plugin-react`) reloaded - // the page on every edit. - it.each([ - { - name: 'a .ts route file', - file: 'routes/index.ts', - code: `import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ loader: () => 'data v1' }) -`, - autoCodeSplitting: true, - }, - { - name: 'a route component, without a framework plugin', - file: 'routes/index.tsx', - code: `import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ component: () =>

page v1

}) -`, - autoCodeSplitting: false, - }, - ])( - 'an edit of $name is a hot update, not a page reload', - async ({ file, code, autoCodeSplitting }) => { - const app = await startDevApp({ [file]: code }, { autoCodeSplitting }) - try { - expect(app.statuses[`/${file}`]).toBe(200) - expect(await app.edit(file, code.replace('v1', 'v2'))).toBe('update') - } finally { - await app.close() - } - }, - 30_000, - ) - - it('serves a route file with a binding named hot', async () => { - const app = await startDevApp( - { - 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' -const hot = 'hot' -export const Route = createFileRoute('/')({ component: () =>

{hot}

}) -`, - }, - // Unsplit, so the binding stays in the module the HMR code goes into - { autoCodeSplitting: false }, - ) - try { - expect(app.statuses['/routes/index.tsx']).toBe(200) - expect(app.served['/routes/index.tsx']).toMatch(/const hot = ["']hot["']/) - } finally { - await app.close() - } - }, 30_000) -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx deleted file mode 100644 index 994c89e7b2..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@false.tsx +++ /dev/null @@ -1,10 +0,0 @@ -const $$splitComponentImporter = () => - import('arrow-function.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx deleted file mode 100644 index e45f8b634a..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@true.tsx +++ /dev/null @@ -1,115 +0,0 @@ -const $$splitComponentImporter = () => - import('arrow-function.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -const TSRSplitComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: TSRSplitComponent, -}) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('arrow-function.tsx', ['Route']) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx deleted file mode 100644 index eb655d0287..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/arrow-function@webpack-hot.tsx +++ /dev/null @@ -1,107 +0,0 @@ -const $$splitComponentImporter = () => - import('arrow-function.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -const TSRSplitComponent = (() => { - const hot = import.meta.webpackHot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.webpackHot) { - ;(import.meta.webpackHot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: TSRSplitComponent, -}) -if (import.meta.webpackHot) { - const hot = import.meta.webpackHot - const hotData = (hot.data ??= {}) - const routeId = - hotData['tsr-route-id'] ?? - Route.id ?? - (Route.isRoot ? '__root__' : undefined) - if (routeId) { - hotData['tsr-route-id'] = routeId - } - const existingRoute = - typeof window !== 'undefined' && routeId - ? window.__TSR_ROUTER__?.routesById?.[routeId] - : undefined - if (routeId && existingRoute && existingRoute !== Route) { - ;(function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - })(routeId, Route) - try { - const tsrReactRefreshUtils = - typeof __react_refresh_utils__ !== 'undefined' - ? __react_refresh_utils__ - : undefined - const tsrEnqueueUpdate = - tsrReactRefreshUtils && - typeof tsrReactRefreshUtils.enqueueUpdate === 'function' - ? tsrReactRefreshUtils.enqueueUpdate - : undefined - if (tsrEnqueueUpdate) { - tsrEnqueueUpdate(() => {}) - } - } catch (_err) {} - } - hot.dispose((data) => { - if (routeId) { - data['tsr-route-id'] = routeId - } - }) - hot.accept() -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx deleted file mode 100644 index e0b52f6ad6..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@false.tsx +++ /dev/null @@ -1,17 +0,0 @@ -const $$splitComponentImporter = () => - import('createFileRoute-lowercase-components.tsx?tsr-split=component') -const $$splitErrorComponentImporter = () => - import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent') -import { lazyRouteComponent } from '@tanstack/react-router' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/lowercase-components')({ - pendingComponent: pendingComponent, - errorComponent: lazyRouteComponent( - $$splitErrorComponentImporter, - 'errorComponent', - ), - component: lazyRouteComponent($$splitComponentImporter, 'component'), -}) -function pendingComponent() { - return
Pending
-} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx deleted file mode 100644 index 441852d762..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createFileRoute-lowercase-components@true.tsx +++ /dev/null @@ -1,134 +0,0 @@ -const $$splitComponentImporter = () => - import('createFileRoute-lowercase-components.tsx?tsr-split=component') -const $$splitErrorComponentImporter = () => - import('createFileRoute-lowercase-components.tsx?tsr-split=errorComponent') -import { lazyRouteComponent } from '@tanstack/react-router' -import { createFileRoute } from '@tanstack/react-router' -const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:errorComponent'] ?? - lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = - TSRSplitErrorComponent -} -const TSRSplitComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -export const Route = createFileRoute('/lowercase-components')({ - pendingComponent: TSRPendingComponent, - errorComponent: TSRSplitErrorComponent, - component: TSRSplitComponent, -}) -function TSRPendingComponent() { - return
Pending
-} -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set( - 'createFileRoute-lowercase-components.tsx', - ['Route'], - ) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx deleted file mode 100644 index 7e3ad124ae..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@false.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ component: () =>
root hmr
}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx deleted file mode 100644 index f45186bdd9..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-inline-component@true.tsx +++ /dev/null @@ -1,100 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -const TSRComponent = () =>
root hmr
-export const Route = createRootRoute({ component: TSRComponent }) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set( - 'createRootRoute-inline-component.tsx', - ['Route'], - ) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx deleted file mode 100644 index 6fac4df1f1..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@false.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ - shellComponent: shellComponent, - pendingComponent: pendingComponent, - errorComponent: errorComponent, - component: component, -}) -function shellComponent({ children }: { children: React.ReactNode }) { - return {children} -} -function pendingComponent() { - return
Pending
-} -function errorComponent() { - return
Error
-} -function component() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx deleted file mode 100644 index f9a6875fe7..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute-lowercase-components@true.tsx +++ /dev/null @@ -1,116 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ - shellComponent: TSRShellComponent, - pendingComponent: TSRPendingComponent, - errorComponent: TSRErrorComponent, - component: TSRComponent, -}) -function TSRShellComponent({ children }: { children: React.ReactNode }) { - return {children} -} -function TSRPendingComponent() { - return
Pending
-} -function TSRErrorComponent() { - return
Error
-} -function TSRComponent() { - return
Hello
-} -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set( - 'createRootRoute-lowercase-components.tsx', - ['Route'], - ) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx deleted file mode 100644 index 5c779d9876..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@false.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ component: RootComponent }) -function RootComponent() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx deleted file mode 100644 index 3bde5adf5c..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRoute@true.tsx +++ /dev/null @@ -1,99 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ component: RootComponent }) -function RootComponent() { - return
Hello
-} -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('createRootRoute.tsx', ['Route']) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx deleted file mode 100644 index 43f27087a6..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@false.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import * as React from 'react' -import { createRootRouteWithContext } from '@tanstack/react-router' -interface MyRouterContext { - auth: boolean -} -export const Route = createRootRouteWithContext()({ - component: RootComponent, -}) -function RootComponent() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx deleted file mode 100644 index c96d6f01a5..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/createRootRouteWithContext-type-args@true.tsx +++ /dev/null @@ -1,107 +0,0 @@ -import * as React from 'react' -import { createRootRouteWithContext } from '@tanstack/react-router' -interface MyRouterContext { - auth: boolean -} -export const Route = createRootRouteWithContext()({ - component: RootComponent, -}) -function RootComponent() { - return
Hello
-} -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set( - 'createRootRouteWithContext-type-args.tsx', - ['Route'], - ) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx deleted file mode 100644 index 112fded569..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@false.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import thing from 'thing' -export function test() { - const { - foo: { - bar: { destructured }, - }, - } = thing - return destructured -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx deleted file mode 100644 index 112fded569..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/destructuring@true.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import thing from 'thing' -export function test() { - const { - foo: { - bar: { destructured }, - }, - } = thing - return destructured -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx deleted file mode 100644 index 8109a89624..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@false.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ component: undefined }) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx deleted file mode 100644 index 99674604fa..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/explicit-undefined-component@true.tsx +++ /dev/null @@ -1,98 +0,0 @@ -import React from 'react' -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ component: undefined }) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('explicit-undefined-component.tsx', [ - 'Route', - ]) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx deleted file mode 100644 index e2b672f7b8..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@false.tsx +++ /dev/null @@ -1,10 +0,0 @@ -const $$splitComponentImporter = () => - import('function-declaration.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx deleted file mode 100644 index 614c38c954..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/function-declaration@true.tsx +++ /dev/null @@ -1,115 +0,0 @@ -const $$splitComponentImporter = () => - import('function-declaration.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -const TSRSplitComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: TSRSplitComponent, -}) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('function-declaration.tsx', ['Route']) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx deleted file mode 100644 index 456134aadc..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@false.tsx +++ /dev/null @@ -1,16 +0,0 @@ -const $$splitErrorComponentImporter = () => - import('multi-component.tsx?tsr-split=errorComponent') -const $$splitComponentImporter = () => - import('multi-component.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), - errorComponent: lazyRouteComponent( - $$splitErrorComponentImporter, - 'errorComponent', - ), -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx deleted file mode 100644 index 871bf352e0..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/multi-component@true.tsx +++ /dev/null @@ -1,130 +0,0 @@ -const $$splitErrorComponentImporter = () => - import('multi-component.tsx?tsr-split=errorComponent') -const $$splitComponentImporter = () => - import('multi-component.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -const TSRSplitComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:errorComponent'] ?? - lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = - TSRSplitErrorComponent -} -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: TSRSplitComponent, - errorComponent: TSRSplitErrorComponent, -}) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('multi-component.tsx', ['Route']) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx deleted file mode 100644 index cfb23b03d2..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@false.tsx +++ /dev/null @@ -1,16 +0,0 @@ -const $$splitErrorComponentImporter = () => - import('string-literal-keys.tsx?tsr-split=errorComponent') -const $$splitComponentImporter = () => - import('string-literal-keys.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), - errorComponent: lazyRouteComponent( - $$splitErrorComponentImporter, - 'errorComponent', - ), -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx deleted file mode 100644 index 6d5b2a1fd3..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/react/string-literal-keys@true.tsx +++ /dev/null @@ -1,130 +0,0 @@ -const $$splitErrorComponentImporter = () => - import('string-literal-keys.tsx?tsr-split=errorComponent') -const $$splitComponentImporter = () => - import('string-literal-keys.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/react-router' -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' -const TSRSplitComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:component'] ?? - lazyRouteComponent($$splitComponentImporter, 'component') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:component'] = - TSRSplitComponent -} -const TSRSplitErrorComponent = (() => { - const hot = import.meta.hot - const hotData = hot ? (hot.data ??= {}) : undefined - return ( - hotData?.['tsr-split-component:errorComponent'] ?? - lazyRouteComponent($$splitErrorComponentImporter, 'errorComponent') - ) -})() -if (import.meta.hot) { - ;(import.meta.hot.data ??= {})['tsr-split-component:errorComponent'] = - TSRSplitErrorComponent -} -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: TSRSplitComponent, - errorComponent: TSRSplitErrorComponent, -}) -if (import.meta.hot && typeof window !== 'undefined') { - import.meta.hot.data ??= {} - const tsrReactRefresh = (window.__TSR_REACT_REFRESH__ ??= (() => { - const ignoredExportsById = new Map() - const previousGetIgnoredExports = window.__getReactRefreshIgnoredExports - window.__getReactRefreshIgnoredExports = (ctx) => { - const ignoredExports = previousGetIgnoredExports?.(ctx) ?? [] - const moduleIgnored = ignoredExportsById.get(ctx.id) ?? [] - return [...ignoredExports, ...moduleIgnored] - } - return { ignoredExportsById } - })()) - tsrReactRefresh.ignoredExportsById.set('string-literal-keys.tsx', ['Route']) -} -export function TSRFastRefreshAnchor() { - return null -} -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [ - 'component', - 'shellComponent', - 'pendingComponent', - 'errorComponent', - 'notFoundComponent', - ] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx deleted file mode 100644 index 10bedc87f0..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@false.tsx +++ /dev/null @@ -1,9 +0,0 @@ -const $$splitComponentImporter = () => - import('arrow-function.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/solid-router' -import { createFileRoute } from '@tanstack/solid-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), -}) diff --git a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx b/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx deleted file mode 100644 index bc531f9000..0000000000 --- a/packages/router-plugin/tests/add-hmr/snapshots/solid/arrow-function@true.tsx +++ /dev/null @@ -1,79 +0,0 @@ -const $$splitComponentImporter = () => - import('arrow-function.tsx?tsr-split=component') -import { lazyRouteComponent } from '@tanstack/solid-router' -import { createFileRoute } from '@tanstack/solid-router' -import { fetchPosts } from '../posts' -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: lazyRouteComponent($$splitComponentImporter, 'component'), -}) -if (import.meta.hot) { - const hotData = (import.meta.hot.data ??= {}) - const handleRouteUpdate = function handleRouteUpdate(routeId, newRoute) { - const router = window.__TSR_ROUTER__ - const oldRoute = router.routesById[routeId] - if (!oldRoute) { - return - } - const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']) - const generatedRouteOptions = {} - generatedRouteOptionKeys.forEach((key) => { - if (key in oldRoute.options) { - generatedRouteOptions[key] = oldRoute.options[key] - } - }) - const oldHasShellComponent = 'shellComponent' in oldRoute.options - const newHasShellComponent = 'shellComponent' in newRoute.options - const preserveComponentIdentity = - oldHasShellComponent === newHasShellComponent - const componentKeys = [] - if (preserveComponentIdentity) { - componentKeys.forEach((key) => { - if (key in oldRoute.options && key in newRoute.options) { - newRoute.options[key] = oldRoute.options[key] - } - }) - } - const nextOptions = { ...newRoute.options, ...generatedRouteOptions } - oldRoute.options = nextOptions - oldRoute.update(nextOptions) - router._replaceRouteChunk(oldRoute, newRoute.lazyFn) - router.setRoutes(router.buildRouteTree()) - syncHotRouteExport(oldRoute) - router.resolvePathCache.clear() - void router._refreshRoute?.() - function syncHotRouteExport(liveRoute) { - newRoute.options = liveRoute.options - newRoute.parentRoute = liveRoute.parentRoute - newRoute._path = liveRoute._path - newRoute._id = liveRoute._id - newRoute._fullPath = liveRoute._fullPath - newRoute._to = liveRoute._to - } - } - const initialRouteId = Route.id ?? hotData['tsr-route-id'] - if (initialRouteId) { - hotData['tsr-route-id'] = initialRouteId - } - const existingRoute = - typeof window !== 'undefined' && initialRouteId - ? window.__TSR_ROUTER__?.routesById?.[initialRouteId] - : undefined - if (initialRouteId && existingRoute && existingRoute !== Route) { - handleRouteUpdate(initialRouteId, Route) - hotData['tsr-route-update-handled'] = Route - } - import.meta.hot.accept((newModule) => { - if (Route && newModule && newModule.Route) { - const routeId = hotData['tsr-route-id'] ?? Route.id - if (routeId) { - hotData['tsr-route-id'] = routeId - } - if (hotData['tsr-route-update-handled'] === newModule.Route) { - delete hotData['tsr-route-update-handled'] - return - } - handleRouteUpdate(routeId, newModule.Route) - } - }) -} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/arrow-function.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/arrow-function.tsx deleted file mode 100644 index 0328934dbb..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/arrow-function.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as React from 'react' -import { createFileRoute, Link, Outlet } from '@tanstack/react-router' -import { fetchPosts } from '../posts' - -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: PostsComponent, -}) - -const PostsComponent = () => { - const posts = Route.useLoaderData() - - return ( -
-
    - {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( - (post) => { - return ( -
  • - -
    {post.title.substring(0, 20)}
    - -
  • - ) - }, - )} -
-
- -
- ) -} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/createFileRoute-lowercase-components.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/createFileRoute-lowercase-components.tsx deleted file mode 100644 index a09f8d24e2..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/createFileRoute-lowercase-components.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/lowercase-components')({ - pendingComponent: pendingComponent, - errorComponent: errorComponent, - component: component, -}) - -function pendingComponent() { - return
Pending
-} - -function errorComponent() { - return
Error
-} - -function component() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-inline-component.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-inline-component.tsx deleted file mode 100644 index 5daf018617..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-inline-component.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: () =>
root hmr
, -}) diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-lowercase-components.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-lowercase-components.tsx deleted file mode 100644 index 20c9a07798..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute-lowercase-components.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - shellComponent: shellComponent, - pendingComponent: pendingComponent, - errorComponent: errorComponent, - component: component, -}) - -function shellComponent({ children }: { children: React.ReactNode }) { - return {children} -} - -function pendingComponent() { - return
Pending
-} - -function errorComponent() { - return
Error
-} - -function component() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute.tsx deleted file mode 100644 index e967791f8d..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRoute.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import * as React from 'react' -import { createRootRoute } from '@tanstack/react-router' - -export const Route = createRootRoute({ - component: RootComponent, -}) - -function RootComponent() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRouteWithContext-type-args.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/createRootRouteWithContext-type-args.tsx deleted file mode 100644 index 0feadacab5..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/createRootRouteWithContext-type-args.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import * as React from 'react' -import { createRootRouteWithContext } from '@tanstack/react-router' - -interface MyRouterContext { - auth: boolean -} - -export const Route = createRootRouteWithContext()({ - component: RootComponent, -}) - -function RootComponent() { - return
Hello
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/destructuring.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/destructuring.tsx deleted file mode 100644 index d80f17484f..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/destructuring.tsx +++ /dev/null @@ -1,11 +0,0 @@ -import thing from 'thing' - -export function test() { - const { - foo: { - bar: { destructured }, - }, - } = thing - - return destructured -} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/explicit-undefined-component.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/explicit-undefined-component.tsx deleted file mode 100644 index 4fdd9d1c68..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/explicit-undefined-component.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import React from 'react' -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/')({ - component: undefined, -}) diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/function-declaration.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/function-declaration.tsx deleted file mode 100644 index 4f6bc57977..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/function-declaration.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as React from 'react' -import { createFileRoute, Link, Outlet } from '@tanstack/react-router' -import { fetchPosts } from '../posts' - -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: PostsComponent, -}) - -function PostsComponent() { - const posts = Route.useLoaderData() - - return ( -
-
    - {[...posts, { id: 'i-do-not-exist', title: 'Non-existent Post' }]?.map( - (post) => { - return ( -
  • - -
    {post.title.substring(0, 20)}
    - -
  • - ) - }, - )} -
-
- -
- ) -} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/multi-component.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/multi-component.tsx deleted file mode 100644 index 317a771a9e..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/multi-component.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' - -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: PostsComponent, - errorComponent: PostsErrorComponent, -}) - -function PostsComponent() { - const posts = Route.useLoaderData() - - return
{posts.length} posts
-} - -function PostsErrorComponent() { - return
Error loading posts
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/react/string-literal-keys.tsx b/packages/router-plugin/tests/add-hmr/test-files/react/string-literal-keys.tsx deleted file mode 100644 index f7bacde84b..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/react/string-literal-keys.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import * as React from 'react' -import { createFileRoute } from '@tanstack/react-router' -import { fetchPosts } from '../posts' - -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - 'component': PostsComponent, - 'errorComponent': PostsErrorComponent, -}) - -function PostsComponent() { - const posts = Route.useLoaderData() - - return
{posts.length} posts
-} - -function PostsErrorComponent() { - return
Error loading posts
-} diff --git a/packages/router-plugin/tests/add-hmr/test-files/solid/arrow-function.tsx b/packages/router-plugin/tests/add-hmr/test-files/solid/arrow-function.tsx deleted file mode 100644 index 0f38e61bfe..0000000000 --- a/packages/router-plugin/tests/add-hmr/test-files/solid/arrow-function.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import * as Solid from 'solid-js' -import { createFileRoute, Link, Outlet } from '@tanstack/solid-router' -import { fetchPosts } from '../posts' - -export const Route = createFileRoute('/posts')({ - loader: fetchPosts, - component: PostsComponent, -}) - -const PostsComponent = () => { - const posts = Route.useLoaderData() - - return ( -
-
    - - {(post) => { - return ( -
  • - -
    {post.title.substring(0, 20)}
    - -
  • - ) - }} -
    -
-
- -
- ) -} diff --git a/packages/router-plugin/tests/build-harness.ts b/packages/router-plugin/tests/build-harness.ts new file mode 100644 index 0000000000..228cb693df --- /dev/null +++ b/packages/router-plugin/tests/build-harness.ts @@ -0,0 +1,584 @@ +/** + * Real-build harness of the router plugin: builds an app with the router + * plugin of a bundler through the shared build harness + * (`@tanstack/compiler-test-utils/build-harness`). The temporary apps stand + * in for apps in this directory (`@tanstack/compiler-test-utils/ + * app-directory`), so their imports resolve to this package's dependencies. + * Each app has its own package.json, without a `sideEffects` field unless + * the test sets one (`sideEffects`), so its modules count as side-effectful; + * only `packageJson: null` makes it inherit this package's + * (`"sideEffects": false`). + * + * Each framework builds with its own JSX compiler, the way its apps do. On + * Vite, the framework's Vite plugin (`@vitejs/plugin-react`, + * `vite-plugin-solid`, `@vitejs/plugin-vue-jsx`) unless the test gives it. + * On webpack and Rspack, which have no framework plugins, the loader an app + * configures: React with the bundler's TypeScript/JSX transform (SWC or the + * harness's loader, `@tanstack/compiler-test-utils/build-harness`), Solid + * with `babel-preset-solid`, Vue with Vue's Babel JSX plugin + * (`@vue/babel-plugin-jsx`, the one `@vitejs/plugin-vue-jsx` runs), both + * through `babel-loader`. Rsbuild apps (`buildWithRsbuild`) add + * `@rsbuild/plugin-react`. + */ +import { writeFile } from 'node:fs/promises' +import { createRequire } from 'node:module' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { + BuildError, + bundleApp, + chunksOfStats, + createApp, + describeBuild, + parsedModules, + pluginNames, + recordParsedModules, + statsDiagnostics, + statsMessages, + statsOptions, + withBuildEnvironment, +} from '@tanstack/compiler-test-utils/build-harness' +import { mergeRsbuildConfig } from '@rsbuild/core' +import { pluginReact } from '@rsbuild/plugin-react' +import { onTestFinished } from '@tanstack/compiler-test-utils/test-scope' +import type { + App, + AppInfo, + AppOptions, + BuildEnv, + BuildResult, + BundleOptions, + Bundler, + EmittedChunk, + StatsJson, +} from '@tanstack/compiler-test-utils/build-harness' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { RsbuildConfig, RsbuildPlugin } from '@rsbuild/core' +import type { CodeSplittingOptions, Config } from '../src/vite' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) +const require = createRequire(import.meta.url) + +export type RouterPluginOptions = Partial + +/** A framework the router plugin targets. */ +export type Framework = 'react' | 'solid' | 'vue' + +export const frameworks: ReadonlyArray = ['react', 'solid', 'vue'] + +/** Imports `createFileRoute` from the router package of `framework`. */ +export function routeHead(framework: Framework = 'react') { + return `import { createFileRoute } from '@tanstack/${framework}-router'\n` +} + +/** An empty root route of the router package of `framework`. */ +export function rootRouteOf(framework: Framework = 'react') { + return `import { createRootRoute } from '@tanstack/${framework}-router' +export const Route = createRootRoute({}) +` +} + +export const rootRoute = rootRouteOf('react') + +/** + * SSR entry: re-exports the index route's `Route` (what an app's route tree + * imports of a route module, so the route module's other exports do not + * ship for it) next to `render(component)`, which preloads a component and + * renders it to a string. A test that needs another export of a route + * module re-exports it by name. + */ +export const ssrRenderEntry = `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +export { Route } from './routes/index' +export async function render(component: any) { + await component.preload?.() + return renderToString(createElement(component)) +} +` + +/** + * Client entry: re-exports the index route's `Route` (as the SSR entry) + * next to `mount(component)`, which preloads a component and renders it + * into `#root` synchronously. + */ +export const clientMountEntry = `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +export { Route } from './routes/index' +export async function mount(component: any) { + await component.preload?.() + const root = createRoot(document.getElementById('root')!) + flushSync(() => root.render(createElement(component))) +} +` + +/** `render` and `mount` entries (see above) of each framework. */ +const entries: Record> = { + react: { ssr: ssrRenderEntry, client: clientMountEntry }, + solid: { + ssr: `import { createComponent } from 'solid-js' +import { renderToString } from 'solid-js/web' +export { Route } from './routes/index' +export async function render(component: any) { + await component.preload?.() + return renderToString(() => createComponent(component, {})) +} +`, + client: `import { createComponent } from 'solid-js' +import { render } from 'solid-js/web' +export { Route } from './routes/index' +export async function mount(component: any) { + await component.preload?.() + render(() => createComponent(component, {}), document.getElementById('root')!) +} +`, + }, + vue: { + ssr: `import { createSSRApp, h } from 'vue' +import { renderToString } from 'vue/server-renderer' +export { Route } from './routes/index' +export async function render(component: any) { + await component.preload?.() + return renderToString(createSSRApp({ render: () => h(component) })) +} +`, + client: `import { createApp, h } from 'vue' +export { Route } from './routes/index' +export async function mount(component: any) { + await component.preload?.() + createApp({ render: () => h(component) }).mount('#root') +} +`, + }, +} + +/** + * Files of a one-route app: the root route, `route` as `routes/index.tsx` + * and the render (`ssr`) or mount (`client`) entry of `framework` (default + * React); `files` adds or replaces files. + */ +export function routeApp( + route: string, + options: { + env?: BuildEnv + files?: Record + framework?: Framework + } = {}, +): Record { + const framework = options.framework ?? 'react' + return { + 'routes/__root.tsx': rootRouteOf(framework), + 'routes/index.tsx': route, + 'entry.ts': entries[framework][options.env ?? 'ssr'], + ...options.files, + } +} + +/** + * Builds an app with the router plugin of the bundler: file-based routes in + * `routes/`, `framework` (default React, also the plugin's `target`), code + * splitting on, HMR off; `pluginOptions` overrides these. `files` holds the + * routes and the entry (see `routeApp`). `routerPlugins` creates the router + * plugins from the harness's plugin options instead of the bundler's + * `tanstackRouter` (e.g. other entry points). A framework plugin of Vite + * that `routerPlugins` already gives (by its name) is not added again. + */ +export async function build( + options: Omit & { + pluginOptions?: RouterPluginOptions + framework?: Framework + routerPlugins?: (config: RouterPluginOptions) => Array + }, +): Promise { + const { + pluginOptions = {}, + framework = 'react', + routerPlugins: createRouterPlugins, + ...bundleOptions + } = options + const tanstackRouter = (await routerPlugins[options.bundler]()) as ( + config: RouterPluginOptions, + ) => unknown + const frameworkBuild = await frameworkBuilds[framework](options) + return bundleApp({ + dir: harnessDir, + registerCleanup: onTestFinished, + ...frameworkBuild.target, + ...bundleOptions, + plugins: { + [options.bundler]: (app: AppInfo) => { + const config: RouterPluginOptions = { + target: framework, + autoCodeSplitting: true, + ...pluginOptions, + // The webpack, Rspack and esbuild adapters resolve these against + // the working directory + routesDirectory: path.resolve( + app.root, + pluginOptions.routesDirectory ?? 'routes', + ), + generatedRouteTree: path.resolve( + app.root, + pluginOptions.generatedRouteTree ?? 'routeTree.gen.ts', + ), + codeSplittingOptions: { + addHmr: false, + ...pluginOptions.codeSplittingOptions, + }, + } + const router = createRouterPlugins?.(config) ?? [tanstackRouter(config)] + const given = pluginNames(router) + const all = [ + ...router, + ...frameworkBuild + .plugins(app) + .filter( + (plugin) => + !pluginNames([plugin]).some((name) => given.includes(name)), + ), + ] + if (all.length === 1) { + return all[0] + } + if (options.bundler === 'vite') { + return all + } + if (options.bundler === 'esbuild') { + throw new Error('esbuild: one plugin per build') + } + // webpack and Rspack: one plugin applying them all + type WebpackPlugin = { apply: (compiler: unknown) => void } + return { + apply(compiler: unknown) { + for (const plugin of all) { + ;(plugin as WebpackPlugin).apply(compiler) + } + }, + } + }, + }, + }) +} + +const routerPlugins: Record Promise> = { + vite: async () => (await import('../src/vite')).tanstackRouter, + rspack: async () => (await import('../src/rspack')).tanstackRouter, + webpack: async () => (await import('../src/webpack')).tanstackRouter, + esbuild: async () => (await import('../src/esbuild')).tanstackRouter, +} + +/** + * A rule of webpack or Rspack compiling the app's TypeScript and JSX with + * Babel (`babel-loader`): the TypeScript preset, then the framework's JSX + * `presets` or `plugins`. + */ +function babelRule(babel: { + presets?: Array + plugins?: Array +}) { + return { + test: /\.(?:[cm]?tsx?|jsx)$/, + exclude: /node_modules/, + loader: require.resolve('babel-loader'), + options: { + babelrc: false, + configFile: false, + presets: [ + [ + require.resolve('@babel/preset-typescript'), + { isTSX: true, allExtensions: true }, + ], + ...(babel.presets ?? []), + ], + plugins: babel.plugins ?? [], + }, + } +} + +interface FrameworkBuild { + /** Bundle options of the framework (JSX compilation). */ + target: Pick + /** Bundler plugins of the framework, after the router plugin. */ + plugins: (app: AppInfo) => Array +} + +const frameworkBuilds: Record< + Framework, + (options: { bundler: Bundler; env?: BuildEnv }) => Promise +> = { + react: async ({ bundler }) => { + if (bundler === 'vite') { + const { default: react } = await import('@vitejs/plugin-react') + return { target: {}, plugins: () => [react()] } + } + return { target: {}, plugins: () => [] } + }, + vue: async ({ bundler }) => { + if (bundler === 'vite') { + const { default: vueJsx } = await import('@vitejs/plugin-vue-jsx') + return { target: {}, plugins: () => [vueJsx()] } + } + if (bundler === 'esbuild') { + throw new Error('The build harness has no Vue JSX for esbuild') + } + // Vue's Babel JSX plugin, the one `@vitejs/plugin-vue-jsx` (and + // `@rsbuild/plugin-vue-jsx`) run, through `babel-loader`, as Vue's docs + // configure a webpack app + return { + target: { + sourceRules: [ + babelRule({ + plugins: [ + createRequire(require.resolve('@vitejs/plugin-vue-jsx')).resolve( + '@vue/babel-plugin-jsx', + ), + ], + }), + ], + }, + plugins: () => [], + } + }, + solid: async ({ bundler, env = 'ssr' }) => { + if (bundler === 'vite') { + const { default: solid } = await import('vite-plugin-solid') + // `ssr`: SSR builds compile for the server (hydratable, as in + // SolidStart apps) + return { target: {}, plugins: () => [solid({ ssr: true })] } + } + if (bundler === 'esbuild') { + throw new Error('The build harness has no Solid JSX for esbuild') + } + // Like `@rsbuild/plugin-solid`: the `solid` condition selects the JSX + // source of Solid packages, compiled for the environment with the app + return { + target: { + conditions: ['solid'], + sourceRules: [ + babelRule({ + presets: [ + [ + require.resolve('babel-preset-solid'), + { generate: env === 'ssr' ? 'ssr' : 'dom', hydratable: true }, + ], + ], + }), + ], + }, + plugins: () => [], + } + }, +} + +/** Global the Rsbuild app's entry assigns the exports of `entry.ts` to. */ +const rsbuildEntryGlobal = '__routerBuildHarnessEntry' + +/** + * Builds a React app for the client in production with Rsbuild, the way an + * Rsbuild app adds the router plugin (`tools.rspack.plugins`) next to + * `pluginReact()` (unless `rsbuildConfig.plugins` has it), with Rsbuild's + * defaults (TypeScript and JSX detection, chunk splitting, minifier). Only + * differences: no HTML page is emitted, and the output is ES modules + * (`output.module`) so that `run()` can load it in Node; what is split, and + * where, does not depend on that. `files` holds the routes and `entry.ts` + * (see `routeApp`). + */ +export async function buildWithRsbuild( + options: Pick & { + pluginOptions?: RouterPluginOptions + registerCleanup?: AppOptions['registerCleanup'] + /** + * `NODE_ENV` of the build process (default `production`, as the + * Rsbuild CLI sets it; `null` unsets it). + */ + nodeEnv?: string | null + /** + * Builds an app that already exists at this root (its files as they + * are; `files` is ignored) instead of writing a new one, e.g. to build + * the same app again with a persistent build cache. The caller owns the + * directory. + */ + root?: string + /** Rsbuild configuration merged over the harness's. */ + rsbuildConfig?: RsbuildConfig + }, +): Promise { + const { pluginOptions = {}, nodeEnv = 'production' } = options + const harnessEntry = `import * as entry from './entry' +;(globalThis as any).${rsbuildEntryGlobal} = entry +` + let app: App + if (options.root === undefined) { + app = await createApp({ + dir: harnessDir, + prefix: '.build-harness-rsbuild-', + registerCleanup: options.registerCleanup ?? onTestFinished, + packageJson: options.packageJson, + sideEffects: options.sideEffects, + files: { ...options.files, 'harness-entry.ts': harnessEntry }, + }) + } else { + await writeFile(path.join(options.root, 'harness-entry.ts'), harnessEntry) + app = { + root: options.root, + bundle: () => Promise.reject(new Error('not an app of the harness')), + dispose: () => Promise.resolve(), + } + } + try { + const { createRsbuild } = await import('@rsbuild/core') + const { tanstackRouter } = await import('../src/rspack') + const warnings: Array = [] + const errors: Array = [] + const consoleMessages: Array = [] + let output: { outDir: string; chunks: Array } | undefined + /** The evidence of the dangling-name check (`describeBuild`). */ + const parsed = parsedModules() + const outputPlugin: RsbuildPlugin = { + name: 'router-build-harness:outputs', + setup(api) { + api.onAfterEnvironmentCompile(({ stats, environment }) => { + if (!stats) { + errors.push('no compilation stats') + return + } + const json = stats.toJson(statsOptions) as StatsJson + warnings.push(...statsDiagnostics(json.warnings, 'warning')) + errors.push(...statsMessages(json.errors)) + output = { + outDir: environment.distPath, + chunks: chunksOfStats(json, { entry: 'index', extension: '.js' }), + } + }) + }, + } + const started = performance.now() + await withBuildEnvironment(nodeEnv, consoleMessages, async () => { + try { + const rsbuild = await createRsbuild({ + cwd: app.root, + loadEnv: false, + rsbuildConfig: mergeRsbuildConfig( + { + root: app.root, + mode: 'production', + logLevel: 'silent', + source: { entry: { index: './harness-entry.ts' } }, + output: { module: true }, + tools: { + htmlPlugin: false, + rspack: { + plugins: [ + recordParsedModules(parsed), + tanstackRouter({ + target: 'react', + autoCodeSplitting: true, + ...pluginOptions, + routesDirectory: path.resolve( + app.root, + pluginOptions.routesDirectory ?? 'routes', + ), + generatedRouteTree: path.resolve( + app.root, + pluginOptions.generatedRouteTree ?? 'routeTree.gen.ts', + ), + }), + ], + }, + }, + plugins: [ + ...(pluginNames(options.rsbuildConfig?.plugins).includes( + 'rsbuild:react', + ) + ? [] + : [pluginReact()]), + outputPlugin, + ], + }, + options.rsbuildConfig ?? {}, + ), + }) + await rsbuild.build() + } catch (error) { + throw new BuildError( + 'rspack', + errors.length + ? errors + : [error instanceof Error ? error.message : String(error)], + warnings, + ) + } + }) + if (errors.length || !output) { + throw new BuildError( + 'rspack', + errors.length ? errors : ['no output'], + warnings, + ) + } + return await describeBuild({ + bundler: 'rspack', + env: 'client', + mode: 'production', + root: app.root, + outDir: output.outDir, + chunks: output.chunks, + parsedModules: parsed, + warnings, + consoleMessages, + duration: performance.now() - started, + dispose: app.dispose, + entryGlobal: rsbuildEntryGlobal, + }) + } catch (error) { + await app.dispose() + throw error + } +} + +/** The groupings of `codeSplittingOptions.defaultBehavior` (public type). */ +export type CodeSplitGroupings = NonNullable< + CodeSplittingOptions['defaultBehavior'] +> + +/** + * Builds a small app with the real Vite plugin (code splitting on, default + * groupings unless `groupings` is given): `routes/index.tsx` holds `route`, + * and `entry.ts` re-exports the route module next to `render(component)`, + * which preloads a component and renders it to a string. `files` adds files + * or replaces `entry.ts`. The app directory name starts with `prefix`. Then + * imports the built entry in a separate Node process and returns the JSON + * value returned by `script`, which has the entry's exports in scope as + * `entry`. + * + * A production Vite SSR build, without minification. The app's + * `package.json` declares no side-effect hint, like an app's. + */ +export async function buildAndRun( + route: string, + script: string, + options: { + files?: Record + groupings?: CodeSplitGroupings + prefix?: string + } = {}, +) { + const app = await build({ + bundler: 'vite', + env: 'ssr', + minify: false, + prefix: options.prefix ?? '.regression-build-', + files: routeApp(route, { files: options.files }), + pluginOptions: options.groupings && { + codeSplittingOptions: { defaultBehavior: options.groupings }, + }, + }) + try { + return (await app.run(script)).result + } finally { + await app.dispose() + } +} + +/** Imports `createFileRoute` from the React router package. */ +export const head = routeHead('react') diff --git a/packages/router-plugin/tests/code-splitter-dead-code.test.ts b/packages/router-plugin/tests/code-splitter-dead-code.test.ts deleted file mode 100644 index 038f323caf..0000000000 --- a/packages/router-plugin/tests/code-splitter-dead-code.test.ts +++ /dev/null @@ -1,462 +0,0 @@ -import { describe, expect, it } from 'vitest' -import { - compileRouteModules, - declarationOf, - evaluateModule, - expectValidModules, - head, - importSources, - importedNames, - transformWithRouteHmrPlugin, -} from './regression-helpers' - -const sharedModule = 'route.tsx?tsr-shared=1' - -/** Whether a module declares `name` or imports it from the shared module. */ -function binds(module: string, name: string) { - return ( - declarationOf(name).test(module) || - importedNames(module, sharedModule).includes(name) - ) -} - -/** - * The reference module, compiled without and with React HMR: HMR rewrites the - * route options (hoisted components, refresh anchor) before dead code is - * removed, so the removal runs on a different program. - */ -function referenceModules(code: string) { - return { - reference: compileRouteModules(code).modules.reference!, - 'reference with HMR': compileRouteModules(code, { hmr: true }).modules - .reference!, - } -} - -/** - * Renders the split component the way an app loads it: the shared module (if - * any) and the reference module run first, then the component chunk, all - * linked to one instance of the shared module. A top-level statement may then - * reach the component by moving into its chunk or by staying in the - * reference module and writing to a shared binding. - */ -async function renderSplitComponent(modules: Record) { - const stubs: Record> = {} - if (modules.shared) { - stubs[sharedModule] = await evaluateModule(modules.shared) - } - await evaluateModule(modules.reference!, { - ...stubs, - '@tanstack/react-router': { - createFileRoute: () => (options: unknown) => ({ options }), - lazyRouteComponent: () => () => null, - }, - }) - const chunk = await evaluateModule(modules['virtual component']!, stubs) - return chunk.component!() -} - -describe('the reference module only drops code that splitting left unused', () => { - it.each([ - { - name: 'a store subscription that unsubscribes itself', - setup: `import { store } from './store' -const unsubscribe = store.subscribe(() => { - if (store.state.done) unsubscribe() -})`, - declared: ['unsubscribe'], - }, - { - name: 'mutually-referencing declarations', - setup: `import { createPersister } from './persist' -const persister = createPersister({ onRestore: () => restore() }) -function restore() { - persister.restore() -}`, - declared: ['persister', 'restore'], - }, - { - // Source: babel-dead-code-elimination dead-code-elimination.test.ts "only - // eliminates newly unreferenced identifiers", "unexported circular references" - // and "SCC with external caller used -> all preserved" - name: 'unused functions, one calling a helper of the split component', - setup: `function helper() { return 'helper' } -function unused() { return helper() } -function ping(): number { return pong() } -function pong(): number { return ping() }`, - component: '

{helper()}

', - declared: ['helper', 'unused', 'ping', 'pong'], - }, - ])( - 'keeps $name that nothing used before splitting', - async ({ setup, component = '
', declared }) => { - const code = `${head}${setup} -export const Route = createFileRoute('/')({ component: () => ${component} }) -` - const modules = referenceModules(code) - // The validator does not report references to undeclared names. A - // binding the split component reads may come from the shared module. - for (const [module, reference] of Object.entries(modules)) { - for (const name of declared) { - expect(binds(reference, name), `${module} binds ${name}`).toBe(true) - } - } - await expectValidModules(modules) - }, - ) - - // Source: babel-dead-code-elimination dead-code-elimination.test.ts "SCC dead - // code elimination" > "arrow functions in mutual recursion -> removed" - it('moves mutually recursive helpers only the component uses, and their imports, into its chunk', async () => { - const code = `${head}import { dep } from './dep' -const ping = (n: number): number => (n > 0 ? pong(n - 1) : 0) -const pong = function (n: number): number { return n > 0 ? ping(n - 1) : dep } -export const Route = createFileRoute('/')({ - loader: () => 'data', - component: () =>

{ping(3)}

, -}) -` - for (const reference of Object.values(referenceModules(code))) { - expect(reference).not.toMatch(declarationOf('ping')) - expect(reference).not.toMatch(declarationOf('pong')) - expect(importSources(reference)).not.toContain('./dep') - } - const { modules } = compileRouteModules(code) - expect(modules['virtual component']).toMatch(declarationOf('ping')) - expect(modules['virtual component']).toMatch(declarationOf('pong')) - await expectValidModules(modules) - }) - - // Source: Next.js ssg/getStaticProps/should-remove-re-exported-function-declarations-dependents-variables-functions-imports - it('keeps the import specifiers nothing used before splitting', async () => { - const { modules } = - compileRouteModules(`${head}import { used, preUnused } from 'bar' -const b = function apples() { return used } -export const Route = createFileRoute('/')({ - loader: () => 'data', - component: () =>

{b()}

, -}) -`) - expect(importedNames(modules.reference!, 'bar')).toEqual(['preUnused']) - expect(modules.reference).not.toContain('apples') - expect(modules['virtual component']).toMatch(declarationOf('b')) - expect(importedNames(modules['virtual component']!, 'bar')).toContain( - 'used', - ) - await expectValidModules(modules) - }) - - // Source: React Router route-chunks-test.ts "shared imports across chunks but - // not main chunk with shared side effect usage" - it('runs a top-level call only in the reference module, even when the chunks import its callee', async () => { - const { modules } = - compileRouteModules(`${head}import { shared } from './shared' -shared('side-effect-marker') -export const Route = createFileRoute('/')({ - component: () =>
{shared('component')}
, - errorComponent: () =>
{shared('error')}
, -}) -`) - expect(modules.reference).toContain('side-effect-marker') - expect(modules['virtual component']).not.toContain('side-effect-marker') - expect(modules['virtual errorComponent']).not.toContain( - 'side-effect-marker', - ) - await expectValidModules(modules) - }) - - // TypeScript erases type positions, so a declaration whose binding only - // appears in a type is still live code that runs when the route loads. - it.each([ - { - name: 'the reference module', - compile: (code: string) => compileRouteModules(code).modules.reference!, - }, - { - name: 'a route module compiled for HMR', - compile: (code: string) => transformWithRouteHmrPlugin(code), - }, - ])( - 'keeps a declaration only referenced from types in $name', - async ({ compile }) => { - const output = - compile(`${head}import { registerAnalytics } from './analytics' -const analytics = registerAnalytics('/posts') -declare module './analytics' { - interface Registry { - posts: typeof analytics - } -} -export const Route = createFileRoute('/posts')({ - component: () =>

posts

, -}) -`) - expect(output).toMatch(declarationOf('analytics')) - expect(output).toContain('registerAnalytics(') - await expectValidModules({ output }) - }, - ) -}) - -describe('code a split option needs moves with it', () => { - // Source: Qwik optimizer test.rs should_not_move_over_side_effects, - // example_drop_side_effects; Turbopack tree-shaker analyzer/route-kind - it.each([ - { - name: 'a compound component member assignment', - setup: `function Card({ children }) { return
{children}
} -Card.Title = function Title() { return

t

}`, - render: '', - rendered: '

t

', - }, - { - name: 'a registry filled by a top-level call', - setup: `const registry = new Map() -registry.set('a', 'A')`, - render: `

{registry.get('a')}

`, - rendered: '

A

', - }, - { - name: 'a compiled enum initializing a var', - setup: `var Kind: any -;(function (Kind: any) { - Kind['A'] = 'a' -})(Kind || (Kind = {}))`, - render: '

{Kind.A}

', - rendered: '

a

', - }, - ])( - 'renders a split component that relies on $name', - async ({ setup, render, rendered }) => { - const { modules } = compileRouteModules(`${head}${setup} -export const Route = createFileRoute('/')({ - component: () => ${render}, -}) -`) - await expectValidModules(modules) - expect(await renderSplitComponent(modules)).toBe(rendered) - }, - ) - - // Source: React Compiler hook-ref-callback.js and - // dont-memoize-primitive-function-call-non-escaping.js: a function shared by - // the loader and the split component declares a local it never reads. - it.each([ - { name: 'a call', initializer: 'track(id)' }, - { name: 'an optional call', initializer: 'track?.(id)' }, - ])( - 'keeps an unused local initialized by $name in a shared function', - async ({ initializer }) => { - const { modules } = - compileRouteModules(`${head}import { track } from './track' -function useShared(id) { - const unused = ${initializer} - return id -} -export const Route = createFileRoute('/')({ - loader: () => useShared('loader'), - component: () =>

{useShared('component')}

, -}) -`) - const calls: Array = [] - const shared = await evaluateModule(modules.shared!, { - './track': { track: (label: string) => calls.push(label) }, - }) - expect(shared.useShared!('render')).toBe('render') - expect(calls).toEqual(['render']) - }, - ) - - // Source: babel-dead-code-elimination dead-code-elimination.test.ts "object - // pattern" > "within function param" - it('keeps empty destructuring parameters of helpers moved into the chunk', async () => { - const { modules } = - compileRouteModules(`${head}function f(a: any, {}: any) { return a } -const g = (a: any, []: any) => a -export const Route = createFileRoute('/')({ - loader: () => 'data', - component: () =>

{f.length}{g.length}

, -}) -`) - const chunk = await evaluateModule(modules['virtual component']!) - expect(chunk.component!()).toBe('

22

') - }) - - // Source: React Router remove-exports-test.ts "iife with dependencies" - it('moves a component created by an IIFE with its dependencies and shares the helper the loader uses too', async () => { - const { modules, sharedBindings } = - compileRouteModules(`${head}import { removedLib } from 'removed-lib' -import { keptLib } from 'kept-lib' -import { sharedLib } from 'shared-lib' -const sharedUtil = (value?: unknown) => sharedLib(value) -const removedUtil = () => sharedUtil(removedLib()) -const keptUtil = () => sharedUtil(keptLib()) -const Page = (() => { - const message = removedUtil() - return () =>
{String(message)}
-})() -export const Route = createFileRoute('/')({ - loader: () => keptUtil(), - component: Page, -}) -`) - expect(sharedBindings).toEqual(['sharedUtil']) - expect(importSources(modules.reference!)).toEqual([ - '@tanstack/react-router', - 'kept-lib', - 'route.tsx?tsr-shared=1', - ]) - expect(modules.reference).not.toContain('removedUtil') - expect(importSources(modules['virtual component']!)).toEqual([ - 'removed-lib', - 'route.tsx?tsr-shared=1', - ]) - expect(modules['virtual component']).toMatch(declarationOf('Page')) - expect(importSources(modules.shared!)).toEqual(['shared-lib']) - await expectValidModules(modules) - }) - - // Source: React Router route-chunks-test.ts "isolated exported variable - // declarations sharing an export statement"; Next.js - // ssg/getStaticProps/should-remove-re-exported-variable-declarations-safe - it.each([ - { - name: 'plain declarators', - declarations: `const Page = () =>
{chunkMessage}
, - main = mainMessage`, - }, - { - name: 'destructured declarators', - declarations: `const { Page } = { Page: () =>
{chunkMessage}
}, - { main } = { main: mainMessage }`, - }, - ])( - 'gives each of the $name of one statement to the module that reads it', - async ({ declarations }) => { - const { modules, sharedBindings } = - compileRouteModules(`${head}import { chunkMessage, mainMessage } from './messages' -${declarations} -export const Route = createFileRoute('/')({ - loader: () => main, - component: Page, -}) -`) - expect(sharedBindings).toEqual([]) - expect(importedNames(modules.reference!, './messages')).toEqual([ - 'mainMessage', - ]) - expect(modules.reference).not.toMatch(/\bPage\b/) - expect( - importedNames(modules['virtual component']!, './messages'), - ).toEqual(['chunkMessage']) - expect(modules['virtual component']).not.toMatch(/\bmain\b/) - await expectValidModules(modules) - }, - ) - - // Source: React Router route-chunks-test.ts "exported variable declarations - // sharing an export statement" - it('shares a declarator that a sibling declarator reads', async () => { - const { modules, sharedBindings } = - compileRouteModules(`${head}import { sharedMessage } from './messages' -const Page = () =>
{sharedMessage}
, - Preview = Page -export const Route = createFileRoute('/')({ - loader: () => Preview.name, - component: Page, -}) -`) - expect(sharedBindings).toEqual(['Page']) - expect(modules.shared).toMatch(declarationOf('Page')) - expect(modules.reference).toMatch(declarationOf('Preview')) - expect(importedNames(modules.reference!, sharedModule)).toEqual(['Page']) - expect(modules.reference).not.toMatch(declarationOf('Page')) - expect(modules['virtual component']).not.toMatch(declarationOf('Page')) - await expectValidModules(modules) - }) -}) - -describe('var declarations nested in top-level statements', () => { - it.each([ - { - name: 'a for loop head', - setup: 'for (var value = 0; value < 3; value++) {}', - }, - { name: 'a for-of head', setup: "for (var value of ['a']) {}" }, - { - name: 'an if block', - setup: "if (typeof window === 'undefined') { var value = 'server' }", - }, - ])( - 'stay bound in every module when $name declares a binding the loader and the component read', - async ({ setup }) => { - const { modules } = compileRouteModules(`${head}${setup} -export const Route = createFileRoute('/')({ - loader: () => value, - component: () =>
{value}
, -}) -`) - // Known limitation on main: the statement runs in both modules instead - // of once in the shared module; only check that each module binds `value`. - for (const name of ['reference', 'virtual component']) { - expect(binds(modules[name]!, 'value'), `${name} binds value`).toBe(true) - } - await expectValidModules(modules) - }, - ) - - it('stay bound in the reference module when exported and read by the component', async () => { - const { modules } = - compileRouteModules(`${head}if (typeof window === 'undefined') { var flag = 'server' } -export { flag } -export const Route = createFileRoute('/')({ - component: () =>
{flag}
, -}) -`) - expect(binds(modules.reference!, 'flag')).toBe(true) - await expectValidModules(modules) - }) - - // Source: babel-dead-code-elimination dead-code-elimination.test.ts "variable" - // (var bindings declared inside nested statements) - it('follow the only option that reads them', async () => { - const { modules } = - compileRouteModules(`${head}import { compute, connect } from './lib' -if (typeof window !== 'undefined') { - var flag = compute() -} -for (var index = 0; index < 3; index++) {} -{ - var block = connect() -} -export const Route = createFileRoute('/')({ - loader: () => block, - component: () =>

{String(flag)}{index}

, -}) -`) - expect(modules.reference).not.toContain('compute()') - expect(modules.reference).toMatch(declarationOf('block')) - const chunk = modules['virtual component']! - expect(chunk).toMatch(declarationOf('flag')) - expect(chunk).toMatch(declarationOf('index')) - expect(chunk).not.toContain('connect()') - await expectValidModules(modules) - }) -}) - -describe('robustness', () => { - it('compiles a route with a long method chain', async () => { - // Builder APIs (schemas, query builders) produce deep left-nested calls - const chain = Array.from({ length: 200 }, (_, i) => `.add(${i})`).join('') - const { modules } = - compileRouteModules(`${head}import { builder } from './builder' -const schema = builder()${chain} -export const Route = createFileRoute('/')({ - loader: () => schema, - component: () =>
{String(schema)}
, -}) -`) - expect(modules.shared).toContain('.add(199)') - await expectValidModules(modules) - }) -}) diff --git a/packages/router-plugin/tests/code-splitter-imported-options.test.ts b/packages/router-plugin/tests/code-splitter-imported-options.test.ts new file mode 100644 index 0000000000..aea66eaf40 --- /dev/null +++ b/packages/router-plugin/tests/code-splitter-imported-options.test.ts @@ -0,0 +1,210 @@ +/** + * Route options the code splitter cannot read statically: an options + * object imported from another module, `createFileRoute('/x')(options)` + * with `import { options } from './x.options'` (SPEC J2.8, + * J2.14). The route keeps working through the real router; the compiler + * either splits the options correctly or tells the developer once, naming + * the file, or refuses the route with an error naming it; + * with `deleteNodes` (Start's client list) it either removes the server + * options (and what only they import) or tells the developer: never a + * silent non-split, never silently kept server options. A local options + * object is the control. + * + * The imported options are real source files of a real Vite dev server + * app (`routes/-x.options.tsx`, which no route registers, and the + * `admin-helper.ts` it imports), so a compiler that analyses imported + * modules can. The route runs in a real browser page (`./route-app`): what + * the client gets is what the page requests and evaluates. Whether the + * client build ships the server code: the real Start build twin, + * start-plugin-core tests/integration/start-compose-imported-options.test.ts. + */ +import { describe, expect, it } from 'vitest' +import { + diagnosticsOf, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { expectNoProblems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { expectValidModules, head, loadRoute } from './route-app' +import type { DeletableNodes } from '../src' +import type { RouteAppOptions } from './route-app' + +const localOptions = `${head}import { readSecret } from './admin-helper' +const options = { + component: () => 'MARK_X_PAGE', + loader: () => 'MARK_X_DATA', + server: { handlers: { GET: () => readSecret() } }, +} +export const Route = createFileRoute('/x')(options) +` + +/** Start's client list of `deleteNodes`. */ +const deleteNodes: Array = ['ssr', 'server', 'headers'] + +/** Loads the local-options route, its modules checked. */ +async function loadLocal(options: RouteAppOptions = {}) { + const route = await loadRoute(localOptions, { + files: { + 'admin-helper.ts': `export const readSecret = () => 'MARK_HELPER_SECRET'\n`, + }, + routeId: '/x', + ...options, + }) + await expectValidModules(route) + return route +} + +describe('route options held in a local object (control)', () => { + it('splits the component and keeps the route working, with nothing reported', async () => { + const route = await loadLocal() + expect(await route.isLazy('component')).toBe(true) + const [html, loaded] = await route.run<[string, unknown]>( + `return [await renderRoute(), await options.loader()]`, + ) + expect(html).toContain('MARK_X_PAGE') + expect(loaded).toBe('MARK_X_DATA') + // No warning or error on any channel of the dev server (info is free). + expectNoProblems(await route.diagnostics()) + }) + + it('removes the options of deleteNodes, and what only they import', async () => { + const route = await loadLocal({ deleteNodes }) + // Nothing that loads with the route module requests the helper only + // the removed `server` option read. + expect(await route.requested()).not.toContain('/admin-helper.ts') + const [server, html] = await route.run<[boolean, string]>( + `return ['server' in options, await renderRoute()]`, + ) + expect(server).toBe(false) + expect(html).toContain('MARK_X_PAGE') + }) +}) + +describe('route options imported from another module', () => { + const importedOptions = `${head}import { options } from './-x.options' +export const Route = createFileRoute('/x')(options) +` + const files = { + 'routes/-x.options.tsx': `import { readSecret } from '../admin-helper' +export const options = { + component: () => 'MARK_X_PAGE', + loader: () => 'MARK_X_DATA', + server: { handlers: { GET: () => readSecret() } }, +} +`, + 'admin-helper.ts': `export const readSecret = () => 'MARK_HELPER_SECRET'\n`, + } + + /** + * Serves the app in a real Vite dev server with the router plugin (with + * route HMR, as a dev server has it; `deleteNodes` given to the code + * splitter) and loads the route in the page. Returns what the page saw of + * the route (or the error compiling or loading it threw), the route file, + * and what the dev server reported on every channel. + */ + async function serve(nodes?: Array) { + const route = await loadRoute(importedOptions, { + filename: 'routes/x.tsx', + routeId: '/x', + hmr: true, + deleteNodes: nodes, + files, + }) + const file = route.host.file('routes/x.tsx') + let error: unknown + let seen: + | { html: string; loaded: unknown; split: boolean; server: boolean } + | undefined + try { + await route.transform() + seen = await route.run(`return { + html: await renderRoute(), + loaded: await options.loader(), + split: 'preload' in options.component, + server: 'server' in options, +}`) + } catch (caught) { + error = caught + } + return { + route, + file, + error, + seen, + diagnostics: [...diagnosticsOf(error), ...(await route.diagnostics())], + } + } + + /** + * A refusal is an error naming the route file (on any channel); otherwise + * the route works through the real router in the page. Returns whether it + * works. + */ + function expectWorkingOrRefused(served: Awaited>) { + const { route, seen, error, file, diagnostics } = served + if (error !== undefined || !seen) { + expectDiagnostic(diagnostics, { + severity: 'error', + file, + root: route.host.root, + }) + return false + } + expect(seen.html).toContain('MARK_X_PAGE') + expect(seen.loaded).toBe('MARK_X_DATA') + return true + } + + it('keep the route working through the real router, or are refused naming the route file', async () => { + expectWorkingOrRefused(await serve()) + }) + + // Bug: the code splitter resolves the route options only from an object + // literal of the route file (`resolveIdentifier`, compilers.ts): for an + // imported binding it finds nothing, leaves the route untouched and says + // nothing. + // Impact: the route's component is never split, with no word to the + // developer (SPEC J2.8: split correctly or report once naming the file). + it.fails('are split, or reported once naming the route file', async () => { + const served = await serve() + if (!expectWorkingOrRefused(served)) { + return + } + // Split: the route's component is the router's lazy component (its + // public `preload()`). + if (!served.seen!.split) { + expectDiagnostic(served.diagnostics, { + severity: 'warning', + file: served.file, + root: served.route.host.root, + times: 1, + }) + } + }) + + // Bug: same cause; with Start's client `deleteNodes` the `server` option + // (and `ssr`, `headers`) stays in the route module with the helper it + // imports, silently. + // Impact: server handlers and what they read ship to the client (SPEC + // J2.8 "never ships their ssr/server/headers silently", J2.14, J4.12). + it.fails( + 'lose the options of deleteNodes and what only they import, or are reported once naming the route file', + async () => { + const served = await serve(deleteNodes) + if (!expectWorkingOrRefused(served)) { + return + } + // What the page requests with the route module. + const kept = + served.seen!.server || + (await served.route.requested()).includes('/admin-helper.ts') + if (kept) { + expectDiagnostic(served.diagnostics, { + severity: 'warning', + file: served.file, + root: served.route.host.root, + times: 1, + }) + } + }, + ) +}) diff --git a/packages/router-plugin/tests/code-splitter-imports-exports.test.ts b/packages/router-plugin/tests/code-splitter-imports-exports.test.ts deleted file mode 100644 index e7c7a504d3..0000000000 --- a/packages/router-plugin/tests/code-splitter-imports-exports.test.ts +++ /dev/null @@ -1,359 +0,0 @@ -import { transformWithOxc } from 'vite' -import { describe, expect, it } from 'vitest' -import { - buildAndRun, - compileRouteModules, - componentChunk, - declarationOf, - evaluateModule, - expectValidModules, - exportedNames, - head, - importSources, - importedNames, - transformWithRouteHmrPlugin, -} from './regression-helpers' - -describe('each module imports only the specifiers it reads', () => { - // Source: React Router route-chunks-test.ts "functions referencing their own - // identifiers"; babel-dead-code-elimination dead-code-elimination.test.ts - // "import" > "mixed default and named" and "namespace" - it('splits default, named and namespace specifiers between the modules', async () => { - const { modules, sharedBindings } = - compileRouteModules(`${head}import defaultMessage, { targetMessage, otherMessage } from './messages' -import * as messages from './messages' -import other, * as ns from './other' -const getDefault = () => defaultMessage -const getTarget = () => targetMessage -const getOther = () => otherMessage -function getNamespaced() { - return messages.namespaced -} -export const Route = createFileRoute('/')({ - loader: () => [getOther(), other], - component: () =>
{getDefault()}{ns.x}
, - errorComponent: () =>
{getNamespaced()}
, - notFoundComponent: () =>
{getTarget()}
, -}) -`) - expect(sharedBindings).toEqual([]) - const imports = (module: string, source: string) => - importedNames(modules[module]!, source) - expect(imports('reference', './messages')).toEqual(['otherMessage']) - expect(imports('reference', './other')).toEqual(['default']) - expect(imports('virtual component', './messages')).toEqual(['default']) - expect(imports('virtual component', './other')).toEqual(['*']) - expect(imports('virtual errorComponent', './messages')).toEqual(['*']) - expect(imports('virtual notFoundComponent', './messages')).toEqual([ - 'targetMessage', - ]) - await expectValidModules(modules) - }) - - it('moves a specifier with a string name into the chunk', async () => { - const { modules } = - compileRouteModules(`${head}import { "kebab-name" as Kebab } from './icons' -export const Route = createFileRoute('/')({ - loader: () => 'data', - component: () => , -}) -`) - expect(importedNames(modules['virtual component']!, './icons')).toEqual([ - 'kebab-name', - ]) - expect(importSources(modules.reference!)).not.toContain('./icons') - await expectValidModules(modules) - }) - - // Source: babel-dead-code-elimination dead-code-elimination.test.ts "import" > - // "mixed default and named: none used" and "side-effect" - it('removes an import whose specifiers all moved instead of leaving a side-effect import', async () => { - const code = `${head}import a, { b } from 'pkg' -import './styles.css' -export const Route = createFileRoute('/')({ - loader: () => 'data', - component: () =>

{a}{b}

, -}) -` - const { modules } = compileRouteModules(code) - // React HMR rewrites the reference module before unused code is removed. - const hmrReference = compileRouteModules(code, { hmr: true }).modules - .reference! - for (const reference of [modules.reference!, hmrReference]) { - expect(importSources(reference)).toContain('./styles.css') - expect(importSources(reference)).not.toContain('pkg') - } - expect(importedNames(modules['virtual component']!, 'pkg')).toEqual([ - 'b', - 'default', - ]) - await expectValidModules(modules) - }) - - // With React's classic JSX runtime (`jsx: "react"` in tsconfig), JSX - // compiles to `React.createElement`, so a React import that the TypeScript - // code only uses in types must stay. - it.each([ - { name: 'split chunk', compile: componentChunk }, - { - name: 'route module compiled for HMR', - compile: (code: string) => transformWithRouteHmrPlugin(code), - }, - ])( - 'keeps the React import of the $name for classic JSX', - async ({ compile }) => { - const output = compile(`import * as React from 'react' -${head}function Page({ title = 'classic' }: { title?: React.ReactNode }) { - return

{title}

-} -export const Route = createFileRoute('/')({ component: Page }) -`) - const { code } = await transformWithOxc(output, 'module.tsx', { - jsx: { runtime: 'classic' }, - }) - expect(importedNames(code, 'react')).toEqual(['*']) - }, - ) -}) - -describe('exports of the route file', () => { - it.each([ - { name: 'as-is', exports: 'export { Foo }' }, - { name: 'renamed', exports: 'export { Foo as Bar }' }, - ])( - 'are not redeclared when they re-export an import $name', - async ({ exports }) => { - const { modules } = - compileRouteModules(`${head}import { Foo } from './foo' -${exports} -export const Route = createFileRoute('/')({ component: Page }) -function Page() { - return -} -`) - await expectValidModules(modules) - }, - ) - - it('are not redeclared when destructured next to a non-exported binding', async () => { - const { modules } = compileRouteModules(`${head}const { a, b } = getStuff() -export { a } -export const Route = createFileRoute('/')({ - component: () =>
{a}{b}
, -}) -`) - await expectValidModules(modules) - }) - - it.each([ - { name: 'function', declaration: 'function () {\n return null\n}' }, - { name: 'class', declaration: 'class {\n x = 1\n}' }, - ])( - 'keep an anonymous default-exported $name valid in every module', - async ({ declaration }) => { - const { modules } = compileRouteModules(`${head}const cache = new Map() -function Page() { - return
{cache.size}
-} -export const Route = createFileRoute('/')({ - loader: () => cache.get('x'), - component: Page, -}) -export default ${declaration} -`) - expect(Object.keys(modules)).toContain('shared') - await expectValidModules(modules) - }, - ) - - // Source: Next.js ssg/getStaticProps/issue-31855 and multi-declarator-export - it('are imported by the chunk when declared in one statement', async () => { - const { modules } = compileRouteModules(`${head}export const a = 1, - b = 2 -export const Route = createFileRoute('/')({ - component: () =>
{a + b}
, -}) -`) - expect(exportedNames(modules.reference!)).toEqual(['Route', 'a', 'b']) - const chunk = modules['virtual component']! - // From the route module, or from the shared module the route module - // re-exports them from. - expect( - [ - ...importedNames(chunk, 'route.tsx'), - ...importedNames(chunk, 'route.tsx?tsr-shared=1'), - ].sort(), - ).toEqual(['a', 'b']) - expect(chunk).not.toMatch(declarationOf('a')) - expect(chunk).not.toMatch(declarationOf('b')) - await expectValidModules(modules) - }) - - it('keep module-level re-exports in the reference module', async () => { - const { modules } = compileRouteModules(`${head}export * from './lib' -export * as lib from './lib' -export {} -const cache = new Map() -export const Route = createFileRoute('/')({ - loader: () => cache.size, - component: () =>
{cache.size}
, -}) -`) - expect(modules.reference).toMatch(/export \* from ['"]\.\/lib['"]/) - expect(modules.reference).toMatch(/export \* as lib from ['"]\.\/lib['"]/) - await expectValidModules(modules) - }) -}) - -describe('TypeScript-only syntax', () => { - it('erases type-only imports and exports from the split modules', async () => { - const { modules } = - compileRouteModules(`${head}import type { User } from './types' -import { type Settings, defaults } from './settings' -export type * from './types' -export type { User } -const current: User | Settings = defaults -export const Route = createFileRoute('/')({ - loader: () => current, - component: () =>
{String(current)}
, -}) -`) - expect(importedNames(modules['virtual component']!, './types')).toEqual([]) - expect(importedNames(modules.shared!, './types')).toEqual([]) - expect(importedNames(modules.shared!, './settings')).toEqual(['defaults']) - await expectValidModules(modules) - }) - - // Ambient declarations (`declare ...`) have no runtime binding: the - // environment provides the value (a + + +`, + ...files, + }, + config: { optimizeDeps: { include: prebundled } }, + plugins: ({ root }) => [ + tanstackRouter({ + target: 'react', + routesDirectory: './routes', + generatedRouteTree: './routeTree.gen.ts', + autoCodeSplitting: true, + ...(typeof pluginOptions === 'function' + ? pluginOptions(root) + : pluginOptions), + }), + react(), + ], + }) + // Where the state after the last settled edit begins in Vite's log + let settled = 0 + return { + root: server.root, + url: server.url!, + write: server.write, + rename: server.rename, + settle: async () => { + await server.settle() + settled = server.logs.length + }, + errors: () => + server.logs + .slice(settled) + .filter((log) => log.startsWith('error:')) + .map((log) => log.slice('error: '.length)), + close: server.close, + stop: server.stop, + // The dev server's merged channel: its logger and what the plugins it + // runs print (console, streams), which reaches the server's capture + diagnostics: () => + server.diagnostics.filter((diagnostic) => diagnostic.severity !== 'info'), + hmr: { + idle: () => server.idle(), + }, + } +} + +async function rsbuildApp( + files: Record, + symlinks: Record, + pluginOptions: GeneratorDevAppOptions['pluginOptions'] = {}, + printedTexts: () => Array, +): Promise { + const server = await createRsbuildDevServer({ + dir: harnessDir, + prefix: '.generator-dev-rsbuild-', + registerCleanup: onTestFinished, + browser: true, + entry: 'main.tsx', + symlinks, + files, + config: { html: { mountId: 'app' } }, + plugins: ({ root }) => [ + pluginReact(), + { + name: 'generator-dev-app', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push( + tanstackRouterRspack({ + target: 'react', + // The Rspack plugin resolves relative paths from the working + // directory + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + autoCodeSplitting: true, + ...(typeof pluginOptions === 'function' + ? pluginOptions(root) + : pluginOptions), + }), + ) + }) + }, + } satisfies RsbuildPlugin, + ], + }) + // What the test process printed and what the dev server's own capture + // received (the generator prints in the server's scope), since a mark + const mark = () => ({ + printed: printedTexts().length, + server: server.diagnostics.length, + }) + let logsBefore = mark() + const loggedSince = (since: ReturnType) => [ + ...printedTexts().slice(since.printed), + ...server.diagnostics + .slice(since.server) + .map((diagnostic) => diagnostic.text), + ] + return { + root: server.root, + url: server.url!, + write: async (written) => { + logsBefore = mark() + await server.write(written) + }, + rename: async (from, to) => { + logsBefore = mark() + await server.rename(from, to) + }, + settle: (settleOptions = {}) => + server.settle({ + ...settleOptions, + // The generator reports a route file it cannot handle, which no + // compile then reads + accept: (relative) => + loggedSince(logsBefore).some((log) => log.includes(relative)), + }), + errors: () => [...server.errors], + close: server.close, + stop: server.stop, + // The dev server's merged channel: its compilations, Rsbuild's logger and what the plugins it + // runs print (console, streams), which reaches the server's capture + diagnostics: () => + server.diagnostics.filter((diagnostic) => diagnostic.severity !== 'info'), + } +} + +/** A marker that occurs in no source (where an import statement was). */ +const owned = '\u0000' + +/** + * The path a route file's `createFileRoute(path)` call names (parsed), the + * file's code outside its import statements with that string literal left + * out (`rest`), and what the import statements bind (`imports`): the + * generator may write, edit, merge, reorder or reprint import statements + * (SPEC J1.2), so they are compared by their bindings, and the lines + * holding only import statements go, with the blank lines next to them or + * at the start of the file (where a removed import leaves its line break + * and blanks). The call is found by + * its binding, not its spelling: a local the file imports as + * `createFileRoute` (an alias included) or a member of a namespace import + * (`router.createFileRoute`); in a file that imports no such binding, a + * call of `createFileRoute` by that name. + */ +export function createFileRouteCall(code: string): { + path: string | undefined + rest: string + imports: Array +} { + const { program } = parseSync('route.tsx', code, { sourceType: 'module' }) + const locals = new Set() + const namespaces = new Set() + const imports = new Set() + const spans: Array<[number, number, string]> = [] + for (const statement of program.body as Array) { + if (statement.type !== 'ImportDeclaration') { + continue + } + spans.push([statement.start, statement.end, owned]) + const source = statement.source.value + if ((statement.specifiers ?? []).length === 0) { + imports.add(`import ${source}`) + } + for (const specifier of statement.specifiers ?? []) { + const type = + statement.importKind === 'type' || specifier.importKind === 'type' + ? 'type ' + : '' + const imported = + specifier.type === 'ImportNamespaceSpecifier' + ? '*' + : specifier.type === 'ImportDefaultSpecifier' + ? 'default' + : (specifier.imported?.name ?? specifier.imported?.value) + imports.add( + `${type}${imported} as ${specifier.local.name} from ${source}`, + ) + if ( + specifier.type === 'ImportSpecifier' && + (specifier.imported?.name ?? specifier.imported?.value) === + 'createFileRoute' + ) { + locals.add(specifier.local.name) + } else if (specifier.type === 'ImportNamespaceSpecifier') { + namespaces.add(specifier.local.name) + } + } + } + if (locals.size === 0 && namespaces.size === 0) { + locals.add('createFileRoute') + } + const isFactory = (callee: any) => + (callee?.type === 'Identifier' && locals.has(callee.name)) || + (callee?.type === 'MemberExpression' && + !callee.computed && + callee.object?.type === 'Identifier' && + namespaces.has(callee.object.name) && + callee.property?.name === 'createFileRoute') + let found: { value: string; start: number; end: number } | undefined + const visit = (node: unknown) => { + if (found || !node || typeof node !== 'object') { + return + } + if (Array.isArray(node)) { + node.forEach(visit) + return + } + const candidate = node as Record + if ( + candidate.type === 'CallExpression' && + isFactory(candidate.callee) && + candidate.arguments?.[0]?.type === 'Literal' && + typeof candidate.arguments[0].value === 'string' + ) { + const literal = candidate.arguments[0] + found = { value: literal.value, start: literal.start, end: literal.end } + return + } + for (const value of Object.values(candidate)) { + visit(value) + } + } + visit(program) + if (found) { + spans.push([found.start, found.end, '']) + } + spans.sort((a, b) => a[0] - b[0]) + let text = '' + let last = 0 + for (const [start, end, marker] of spans) { + text += code.slice(last, start) + marker + last = end + } + text += code.slice(last) + const lines = text.split(/(?<=\n|\r(?!\n))/) + const blank = (line: string) => line.replaceAll(owned, '').trim() === '' + let rest = '' + for (let index = 0; index < lines.length; ) { + if (!blank(lines[index]!)) { + rest += lines[index++] + continue + } + // A run of blank lines and lines holding import statements only + const start = index + while (index < lines.length && blank(lines[index]!)) { + index++ + } + const run = lines.slice(start, index) + if (start > 0 && !run.some((line) => line.includes(owned))) { + rest += run.join('') + } + } + return { path: found?.value, rest, imports: [...imports].sort() } +} + +/** + * Asserts that the route file at `relative` names `routePath` in its + * `createFileRoute()` call and is otherwise `expected` (the route file as + * written, whatever path it named): the same code outside the import + * statements, and imports binding the same names (`createFileRouteCall`). + */ +export async function expectRouteFile( + app: GeneratorDevApp, + relative: string, + routePath: string, + expected: string, +) { + const actual = createFileRouteCall(await app.read(relative)) + expect(actual.path, `the path ${relative} names`).toBe(routePath) + const written = createFileRouteCall(expected) + expect(actual.rest).toBe(written.rest) + expect(actual.imports).toEqual(written.imports) +} + +/** Whether each loaded script holds each text `scriptHolds` was asked for. */ +const scriptMarkers = new WeakMap>() + +/** + * Whether a script the page loaded holds the user's string `text`: a + * decoded string value of its code (`holdsMarker`), whatever its quoting, + * escaping or JSX compilation. Every script counts, wherever it is served + * from: a compiler's module may be served under `/node_modules/` or `/@fs/` + * too (SPEC §5.3), and the tools' own modules hold no user marker. + */ +export function scriptHolds( + script: { url: string; code: string }, + text: string, +) { + // (a loaded script, as `scripts()` returns it again, is read once per text) + let found = scriptMarkers.get(script) + if (!found) { + found = new Map() + scriptMarkers.set(script, found) + } + let holds = found.get(text) + if (holds === undefined) { + holds = holdsMarker(script.code, text) + found.set(text, holds) + } + return holds +} + +/** + * Asserts that the app loads the code rendering `text` (a route component's) + * only when it navigates to `pathname`: no script the page loaded at `from` + * holds it (`scriptHolds`), and the app shows it after navigating. + */ +export async function expectLoadedOnNavigation( + app: GeneratorDevApp, + from: { pathname: string; shows: string }, + pathname: string, + text: string, +) { + await app.visit(from.pathname, from.shows) + expect( + (await app.scripts()) + .filter((script) => scriptHolds(script, text)) + .map((script) => script.url), + `scripts loaded at ${from.pathname} containing ${text}`, + ).toEqual([]) + await app.navigate(pathname, text) + expect( + (await app.scripts()).some((script) => scriptHolds(script, text)), + `a script loaded on navigating to ${pathname} contains ${text}`, + ).toBe(true) +} diff --git a/packages/router-plugin/tests/generator-dev-scenarios.ts b/packages/router-plugin/tests/generator-dev-scenarios.ts new file mode 100644 index 0000000000..5bc35ce6fb --- /dev/null +++ b/packages/router-plugin/tests/generator-dev-scenarios.ts @@ -0,0 +1,685 @@ +/** + * Scenarios of the route generator on a running dev server, run per bundler + * by the integration files `dev-server-*.test.ts` (Vite) and + * `rsbuild-dev-server-*.test.ts` (Rsbuild), on a real page + * (`generator-dev-app.ts`): a route file created, renamed, moved or deleted + * while the dev server runs keeps its `createFileRoute(path)` in line with + * its location and the rest of the file untouched, the live router's routes + * follow the route files, and each route's component loads when the app + * navigates to it; edits of the routes a page shows, created ones included, + * are hot updates. + */ +import { writeFile } from 'node:fs/promises' +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { runPins } from '@tanstack/compiler-test-utils/pins' +import { + createFileRouteCall, + expectLoadedOnNavigation, + expectRouteFile, + generatorDevApp, + rootRoute, + route, + scriptHolds, +} from './generator-dev-app' +import type { + Bundler, + DiagnosticsMark, + GeneratorDevApp, + LiveRoute, +} from './generator-dev-app' + +const timeout = 30_000 + +const rootLive: LiveRoute = { id: '__root__', fullPath: '/', parent: undefined } + +/** A live route under the root route. */ +const live = (id: string, fullPath = id): LiveRoute => ({ + id, + fullPath, + parent: '__root__', +}) + +const index = { 'routes/index.tsx': route('/', 'MARK_INDEX') } +const atIndex = { pathname: '/', shows: 'MARK_INDEX' } + +/** + * Asserts that an edit of a route component the page shows appears in the + * page without a page load. + */ +async function expectHotUpdate( + app: GeneratorDevApp, + files: Record, + expected: string | RegExp, +) { + const loads = app.page.loads() + await app.edit(files) + await app.page.waitForText(expected, { selector: '#app' }) + expect(app.page.loads(), 'page loads').toBe(loads) +} + +/** + * Asserts that the app reported `file` (an error or a warning naming it) + * since `since`, through any real channel (`app.diagnostics`: the + * generator's console output, the dev server's logger or compile + * diagnostics; SPEC G5, §5.7). + */ +function expectReported( + app: GeneratorDevApp, + since: DiagnosticsMark, + file: string, +) { + expectDiagnostic(app.diagnostics(since), { + severity: ['error', 'warning'], + file, + root: app.root, + }) +} + +/** + * Asserts that the app reported no error since `since` (e.g. since the + * edit fixing a broken file: a report of the broken file before it is + * allowed, through any channel). + */ +function expectNoErrorsSince(app: GeneratorDevApp, since: DiagnosticsMark) { + expect( + findDiagnostics(app.diagnostics(since), { severity: 'error' }).map( + ({ text }) => text, + ), + ).toEqual([]) +} + +export function describeRouteFileUpkeep( + bundler: Bundler, + options: { + /** + * Pins the case of a route file created under a `physical()` mount + * outside the routes directory (the caller's file says why), instead of + * asserting it here. + */ + pinPhysicalMountCreation?: boolean + } = {}, +) { + describe(`route generator in ${bundler} dev`, () => { + // A route template whose component is a marker of its own. + test( + 'a created empty route file is scaffolded from the route template, joins the live routes and loads its component on navigation', + async () => { + const app = await generatorDevApp({ + bundler, + files: index, + pluginOptions: { + customScaffolding: { + routeTemplate: + '%%tsrImports%%\n\n%%tsrExportStart%%{\n component: () =>

MARK_SCAFFOLD

,\n}%%tsrExportEnd%%\n', + }, + }, + }) + await app.edit({ 'routes/posts.tsx': '' }) + + expect( + createFileRouteCall(await app.read('routes/posts.tsx')).path, + ).toBe('/posts') + await expectLoadedOnNavigation(app, atIndex, '/posts', 'MARK_SCAFFOLD') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/posts'), + ]) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + test( + 'a created route file with another path gets its own path, keeps its code, and loads its component on navigation', + async () => { + const app = await generatorDevApp({ bundler, files: index }) + await app.edit({ 'routes/posts.tsx': route('/wrong', 'MARK_POSTS') }) + + await expectRouteFile( + app, + 'routes/posts.tsx', + '/posts', + route('/wrong', 'MARK_POSTS'), + ) + await expectLoadedOnNavigation(app, atIndex, '/posts', 'MARK_POSTS') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/posts'), + ]) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + // Source: issues #4437 (rename), #4440 (Rsbuild). + test( + 'a renamed route file gets its new path and keeps its code, and the app serves it at that path only', + async () => { + const app = await generatorDevApp({ + bundler, + files: { + ...index, + 'routes/about.tsx': route('/about', 'MARK_ABOUT'), + }, + }) + await app.rename('routes/about.tsx', 'routes/info.tsx') + await app.settle() + + await expectRouteFile( + app, + 'routes/info.tsx', + '/info', + route('/about', 'MARK_ABOUT'), + ) + await expectLoadedOnNavigation(app, atIndex, '/info', 'MARK_ABOUT') + expect(await app.routes()).toEqual([rootLive, live('/'), live('/info')]) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + // Source: issue #4343 (moving a route file into a folder), #4389. + test( + 'a route file moved into a folder and renamed to its index gets each new path', + async () => { + const app = await generatorDevApp({ + bundler, + files: { ...index, 'routes/hi.tsx': route('/hi', 'MARK_HI') }, + }) + await app.rename('routes/hi.tsx', 'routes/test/hi.tsx') + await app.settle() + await expectRouteFile( + app, + 'routes/test/hi.tsx', + '/test/hi', + route('/hi', 'MARK_HI'), + ) + await expectLoadedOnNavigation(app, atIndex, '/test/hi', 'MARK_HI') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/test/hi'), + ]) + + await app.rename('routes/test/hi.tsx', 'routes/test/index.tsx') + await app.settle() + await expectRouteFile( + app, + 'routes/test/index.tsx', + '/test/', + route('/hi', 'MARK_HI'), + ) + await expectLoadedOnNavigation(app, atIndex, '/test/', 'MARK_HI') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/test/'), + ]) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + // Source: issues #4445, #4459 (deleted route file, Rsbuild). + test( + 'a deleted route file leaves the live routes', + async () => { + const app = await generatorDevApp({ + bundler, + files: { ...index, 'routes/bar.tsx': route('/bar', 'MARK_BAR') }, + }) + await app.visit('/bar', 'MARK_BAR') + await app.edit({ 'routes/bar.tsx': null }) + + await app.visit('/', 'MARK_INDEX') + expect(await app.routes()).toEqual([rootLive, live('/')]) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + // Source: #6775 (reload loop): the dev + // server settles (a bounded number of regenerations) and the page + // updates in place. + test( + 'an edit of a route component the page shows is a hot update, and the dev server settles', + async () => { + const app = await generatorDevApp({ bundler, files: index }) + await app.visit('/', 'MARK_INDEX') + await expectHotUpdate( + app, + { 'routes/index.tsx': route('/', 'MARK_EDITED') }, + 'MARK_EDITED', + ) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + // The route tree update that makes the app know a new route must not let + // the new route be served unsplit, however soon the app navigates to it. + // Source: review (a suspected race). + test( + 'a route created while the page runs, navigated to as soon as the live router has it, loads its component on navigation', + async () => { + const app = await generatorDevApp({ bundler, files: index }) + await app.visit('/', 'MARK_INDEX') + await app.write({ 'routes/posts.tsx': route('/posts', 'MARK_POSTS') }) + await app.page.page.waitForFunction( + () => !!(window as any).__APP_ROUTER__?.routesById['/posts'], + undefined, + { timeout: 20_000 }, + ) + expect( + (await app.scripts()) + .filter((script) => scriptHolds(script, 'MARK_POSTS')) + .map((script) => script.url), + ).toEqual([]) + await app.navigate('/posts', 'MARK_POSTS') + await app.settle() + // (the check sees the component's code once it loaded) + expect( + (await app.scripts()).some((script) => + scriptHolds(script, 'MARK_POSTS'), + ), + ).toBe(true) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + if (!options.pinPhysicalMountCreation) { + // Route files under a `physical()` mount outside the routes directory + // are delivered edits like route-directory files (SPEC J1.10). + test( + 'a route file created, edited and deleted under a physical() mount outside the routes directory reaches the live routes', + async () => { + await expectPhysicalMountRouteFile(bundler) + }, + timeout, + ) + } + }) +} + +/** + * Created route files the generator cannot handle yet, and edits of routes + * created or renamed while the page runs. + */ +export function describeCreatedRoutes( + bundler: Bundler, + options: { + /** + * Pins the cases of a route file created before it exports a valid + * `Route` (the caller's comment says why), instead of asserting them. + */ + pinCreatedBrokenRouteFiles?: boolean + } = {}, +) { + // A route created in dev joins HMR like the routes the server started + // with (the root route too). + describe(`created routes in ${bundler} dev`, () => { + test( + 'an edit of a created route the page shows is a hot update', + async () => { + const app = await generatorDevApp({ bundler, files: index }) + await app.edit({ 'routes/posts.tsx': route('/posts', 'MARK_POSTS') }) + await app.visit('/posts', 'MARK_POSTS') + await expectHotUpdate( + app, + { 'routes/posts.tsx': route('/posts', 'MARK_EDITED') }, + 'MARK_EDITED', + ) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + test( + 'an edit of a renamed route the page shows is a hot update', + async () => { + const app = await generatorDevApp({ + bundler, + files: { + ...index, + 'routes/about.tsx': route('/about', 'MARK_ABOUT'), + }, + }) + await app.rename('routes/about.tsx', 'routes/info.tsx') + await app.settle() + await app.visit('/info', 'MARK_ABOUT') + await expectHotUpdate( + app, + { 'routes/info.tsx': route('/info', 'MARK_EDITED') }, + 'MARK_EDITED', + ) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + + test( + 'an edit of the root route after a route was created is a hot update', + async () => { + const app = await generatorDevApp({ bundler, files: index }) + await app.edit({ 'routes/posts.tsx': route('/posts', 'MARK_POSTS') }) + await app.visit('/posts', 'MARK_POSTS') + await expectHotUpdate( + app, + { + 'routes/__root.tsx': rootRoute.replace( + 'MARK_ROOT', + 'MARK_ROOT_EDITED', + ), + }, + /MARK_ROOT_EDITED[\s\S]*MARK_POSTS/, + ) + expect(app.errors()).toEqual([]) + }, + timeout, + ) + }) + + // A route file the generator cannot + // handle is reported, the dev server keeps running, and fixing the file + // brings the route back. + describe(`route generator failures in ${bundler} dev`, () => { + test( + 'a route file broken by an edit is reported, and fixing it brings the route back', + async () => { + const app = await generatorDevApp({ + bundler, + files: { + ...index, + 'routes/posts.tsx': route('/posts', 'MARK_POSTS'), + }, + }) + const breaking = app.mark() + await app.edit({ 'routes/posts.tsx': 'export const Route = (' }) + expectReported(app, breaking, 'routes/posts.tsx') + + const fixing = app.mark() + await app.edit({ 'routes/posts.tsx': route('/posts', 'MARK_FIXED') }) + await expectLoadedOnNavigation(app, atIndex, '/posts', 'MARK_FIXED') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/posts'), + ]) + expectNoErrorsSince(app, fixing) + }, + timeout, + ) + + // With `COMPILER_TESTS_PINS=run`, pinned cases run as ordinary tests. + if (!options.pinCreatedBrokenRouteFiles || runPins) { + test.each(createdBrokenRouteFiles)( + 'a created route file the generator $name is reported, and fixing it adds the route', + async ({ initial }) => { + await expectCreatedBrokenRouteFileFixed(bundler, initial) + }, + timeout, + ) + } + }) +} + +/** Route files the generator cannot handle as they are first saved. */ +export const createdBrokenRouteFiles = [ + { name: 'cannot parse', initial: 'export const Route = (' }, + { + name: 'finds no Route export in', + initial: `import { createFileRoute } from '@tanstack/react-router'\n`, + }, +] + +/** + * Creates `routes/posts.tsx` as `initial`, which the generator reports and + * leaves out of the routes, then fixes it (with another path) and asserts + * that the route joins the live routes with its own path. `settleTimeout` + * guards the wait for the fix (see the Rsbuild pin). + */ +export async function expectCreatedBrokenRouteFileFixed( + bundler: Bundler, + initial: string, + settleTimeout?: number, +) { + const app = await generatorDevApp({ bundler, files: index }) + const creating = app.mark() + await app.edit({ 'routes/posts.tsx': initial }) + expectReported(app, creating, 'routes/posts.tsx') + await app.visit('/', 'MARK_INDEX') + expect(await app.routes()).toEqual([rootLive, live('/')]) + + // What the fix brings: only the reports from here on count (a report of + // the broken file, through any channel, is the one above). + const fixing = app.mark() + await app.write({ 'routes/posts.tsx': route('/wrong', 'MARK_POSTS') }) + await app.settle({ timeout: settleTimeout }) + await expectRouteFile( + app, + 'routes/posts.tsx', + '/posts', + route('/wrong', 'MARK_POSTS'), + ) + await expectLoadedOnNavigation(app, atIndex, '/posts', 'MARK_POSTS') + expect(await app.routes()).toEqual([rootLive, live('/'), live('/posts')]) + expectNoErrorsSince(app, fixing) +} + +/** + * An app with virtual routes mounting `features/` with `physical()` next to + * the routes directory: a route file created there (with another path), + * edited and deleted reaches the live routes each time. `settleTimeout` + * guards the wait for the creation (see the Rsbuild pin). + */ +export async function expectPhysicalMountRouteFile( + bundler: Bundler, + settleTimeout?: number, +) { + const app = await generatorDevApp({ + bundler, + links: ['@tanstack/virtual-file-routes'], + // A path relative to the root the plugin resolves it from (the Rspack + // plugin's: the working directory) + pluginOptions: (root) => ({ + virtualRouteConfig: + bundler === 'vite' + ? './routes.ts' + : path.relative(process.cwd(), path.join(root, 'routes.ts')), + }), + files: { + 'routes.ts': `import { index, physical, rootRoute } from '@tanstack/virtual-file-routes' +export const routes = rootRoute('__root.tsx', [ + index('index.tsx'), + physical('/feature', '../features'), +]) +`, + ...index, + 'features/a.tsx': route('/feature/a', 'MARK_A'), + }, + }) + await app.write({ 'features/b.tsx': route('/wrong', 'MARK_B') }) + await app.settle({ timeout: settleTimeout }) + await expectRouteFile( + app, + 'features/b.tsx', + '/feature/b', + route('/wrong', 'MARK_B'), + ) + await expectLoadedOnNavigation(app, atIndex, '/feature/b', 'MARK_B') + expect(await app.routes()).toEqual([ + rootLive, + live('/'), + live('/feature/a'), + live('/feature/b'), + ]) + + await expectHotUpdate( + app, + { 'features/b.tsx': route('/feature/b', 'MARK_B_EDITED') }, + 'MARK_B_EDITED', + ) + + await app.edit({ 'features/b.tsx': null }) + await app.visit('/', 'MARK_INDEX') + expect(await app.routes()).toEqual([rootLive, live('/'), live('/feature/a')]) + expect(app.errors()).toEqual([]) +} + +/** + * Edits of the virtual route config the generator reads (SPEC J1.10: the + * file `virtualRouteConfig` names, and `__virtual.ts` files, are delivered + * edits like route files), and the end of the generator's watching with the + * dev server that owns it. + */ +export function describeGeneratorWatching(bundler: Bundler) { + describe(`route generator watching in ${bundler} dev`, () => { + test( + 'closing the dev server stops the generator: a route file created afterwards is left as it is, and the route tree with it', + async () => { + await expectGeneratorStopsWithServer(bundler) + }, + timeout, + ) + }) +} + +/** + * Waits until the live router in the page has a route with `fullPath`; + * `timeout` only guards against an edit the generator never reacts to. + */ +async function waitForLiveRoute( + app: GeneratorDevApp, + fullPath: string, + timeout = 20_000, +) { + await app.page.page.waitForFunction( + (wanted) => + Object.values((window as any).__APP_ROUTER__?.routesById ?? {}).some( + (liveRoute: any) => liveRoute.fullPath === wanted, + ), + fullPath, + { timeout }, + ) +} + +/** A virtual route config module with a root route of `children`. */ +const virtualRouteConfig = (children: string) => + `import { index, rootRoute, route } from '@tanstack/virtual-file-routes' +export const routes = rootRoute('__root.tsx', [${children}]) +` + +/** + * An app whose routes come from a virtual route config file (`routes.ts`, + * path form): adding a route to the config while the dev server runs adds + * it to the live routes, and the app serves its page. + */ +export async function expectVirtualRouteConfigEdit(bundler: Bundler) { + const app = await generatorDevApp({ + bundler, + links: ['@tanstack/virtual-file-routes'], + // A path relative to the root the plugin resolves it from (the Rspack + // plugin's: the working directory) + pluginOptions: (root) => ({ + virtualRouteConfig: + bundler === 'vite' + ? './routes.ts' + : path.relative(process.cwd(), path.join(root, 'routes.ts')), + }), + files: { + 'routes.ts': virtualRouteConfig(`index('index.tsx')`), + ...index, + 'routes/contact.tsx': route('/contact', 'MARK_CONTACT'), + }, + }) + expect(await app.routes()).toEqual([rootLive, live('/')]) + + await app.write({ + 'routes.ts': virtualRouteConfig( + `index('index.tsx'), route('/contact', 'contact.tsx')`, + ), + }) + await waitForLiveRoute(app, '/contact') + await app.visit('/contact', 'MARK_CONTACT') + expect(await app.routes()).toEqual([rootLive, live('/'), live('/contact')]) +} + +/** A `__virtual.ts` subtree config of `children`. */ +const virtualSubtree = (children: string) => + `import { defineVirtualSubtreeConfig, index, route } from '@tanstack/virtual-file-routes' +export default defineVirtualSubtreeConfig([${children}]) +` + +/** + * An app whose `routes/posts/` directory is configured by a `__virtual.ts` + * file (routing/virtual-file-routes.md): adding a route to it while the dev + * server runs adds the route to the live routes, and the app serves its + * page. + */ +export async function expectVirtualSubtreeEdit(bundler: Bundler) { + const app = await generatorDevApp({ + bundler, + links: ['@tanstack/virtual-file-routes'], + files: { + ...index, + 'routes/posts/__virtual.ts': virtualSubtree(`index('home.tsx')`), + 'routes/posts/home.tsx': route('/posts/', 'MARK_HOME'), + 'routes/posts/details.tsx': route('/posts/$id', 'MARK_DETAILS'), + }, + }) + await app.visit('/posts/', 'MARK_HOME') + expect( + (await app.routes()).map((liveRoute) => liveRoute.fullPath), + ).not.toContain('/posts/$id') + + await app.write({ + 'routes/posts/__virtual.ts': virtualSubtree( + `index('home.tsx'), route('$id', 'details.tsx')`, + ), + }) + await waitForLiveRoute(app, '/posts/$id') + await app.visit('/posts/1', 'MARK_DETAILS') +} + +/** + * Closing the dev server stops the generator's watching (SPEC J1.10): a + * route file created afterwards is neither scaffolded nor added to the route + * tree. A route file the running generator sees first shows its watching + * was live. Nothing reacting cannot be awaited: the observation is bounded + * by `quietFor`, at least three times as long as the running generator + * took to scaffold that first file (a few hundred milliseconds in these + * harnesses), so a generator that is slower here is watched longer. + */ +export async function expectGeneratorStopsWithServer(bundler: Bundler) { + const quietFor = 1500 + const app = await generatorDevApp({ bundler, files: index }) + // (a route file the running generator sees: its watching is live) + const started = Date.now() + await app.edit({ 'routes/posts.tsx': '' }) + const reaction = Date.now() - started + expect(createFileRouteCall(await app.read('routes/posts.tsx')).path).toBe( + '/posts', + ) + const tree = await app.read('routeTree.gen.ts') + await app.stop() + await writeFile(path.join(app.root, 'routes/later.tsx'), '') + await new Promise((resolve) => + setTimeout(resolve, Math.max(quietFor, 3 * reaction)), + ) + expect( + await app.read('routes/later.tsx'), + 'a route file created after the dev server closed', + ).toBe('') + expect( + await app.read('routeTree.gen.ts'), + 'the route tree after the dev server closed', + ).toBe(tree) +} diff --git a/packages/router-plugin/tests/generator-watch-session.ts b/packages/router-plugin/tests/generator-watch-session.ts new file mode 100644 index 0000000000..502a2fe9c3 --- /dev/null +++ b/packages/router-plugin/tests/generator-watch-session.ts @@ -0,0 +1,245 @@ +/** + * The generator entries of webpack and Rspack in the compiler's own watch + * mode (`compiler.watch`, as webpack-dev-server and `--watch` use it), on a + * temporary app with file-based routes: what generator-watch-mode.test.ts + * (a compiler test) and a file-watcher control run. Waits + * are on the compiler's own build events. + */ +import { mkdir, rm, utimes, writeFile } from 'node:fs/promises' +import { createRequire } from 'node:module' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { createAppDirectory } from '@tanstack/compiler-test-utils/app-directory' +import { onTestFinished } from '@tanstack/compiler-test-utils/test-scope' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +export type WatchBundler = 'webpack' | 'rspack' + +/** One completed build of the watch session. */ +export interface Build { + error: string | undefined + errors: Array +} + +/** + * Waits until `check` holds, checking again at each change of what it reads + * and at least every 25 ms; `timeout` only guards against what never comes. + */ +export async function until( + check: () => boolean | Promise, + what: () => string, + next: () => Promise, + timeout = 20_000, +) { + const deadline = Date.now() + timeout + while (!(await check())) { + if (Date.now() > deadline) { + throw new Error(`${what()} within ${timeout} ms`) + } + let timer: ReturnType | undefined + await Promise.race([ + next(), + new Promise((resolve) => { + timer = setTimeout(resolve, 25) + }), + ]) + clearTimeout(timer) + } +} + +export interface WatchSession { + /** Absolute path of an app file. */ + file: (relative: string) => string + /** The completed builds so far. */ + builds: Array + /** Resolves at the next completed build. */ + waitForBuild: () => Promise + /** + * The routes of a router over the route tree of the last build, and the + * page it renders at `pathname` once loaded (when it has that route). + */ + run: (pathname: string) => Promise<{ routes: Array; html: string }> + /** Closes the watch session (idempotent). */ + close: () => Promise +} + +/** + * Starts a watch session of the bundler's generator entry on an app with a + * root route and its route tree, and waits for its first build. The session + * closes and the app is removed when the test ends. + */ +export async function startWatchSession( + bundler: WatchBundler, +): Promise { + const root = await createAppDirectory(harnessDir, '.generator-watch-') + let close: () => Promise = () => Promise.resolve() + onTestFinished(async () => { + await close() + await rm(root, { recursive: true, force: true }) + }) + const file = (relative: string) => path.join(root, relative) + await mkdir(file('routes'), { recursive: true }) + // An app package of its own: the generated route tree imports route + // files without extensions, which an ES module package (this test + // package's) resolves only with the generator's `addExtensions` + await writeFile(file('package.json'), '{}\n') + await writeFile( + file('routes/__root.js'), + `import { Outlet, createRootRoute } from '@tanstack/react-router' +import { createElement } from 'react' +export const Route = createRootRoute({ component: () => createElement('main', null, 'MARK_ROOT', createElement(Outlet)) }) +`, + ) + await writeFile( + file('main.js'), + `export { routeTree } from './routeTree.gen.js'\n`, + ) + const pluginOptions = { + target: 'react' as const, + routesDirectory: file('routes'), + generatedRouteTree: file('routeTree.gen.js'), + disableTypes: true, + disableLogging: true, + // A component the bundler compiles without a JSX loader + customScaffolding: { + routeTemplate: + "%%tsrImports%%\n\n%%tsrExportStart%%{\n component: () => 'MARK_SCAFFOLD',\n}%%tsrExportEnd%%\n", + }, + } + const config = { + context: root, + mode: 'development', + devtool: false, + target: 'node', + entry: './main.js', + output: { + path: file('dist'), + filename: 'main.cjs', + library: { type: 'commonjs2' }, + }, + externals: { + '@tanstack/react-router': 'commonjs @tanstack/react-router', + react: 'commonjs react', + }, + infrastructureLogging: { level: 'none' }, + stats: 'none', + } + const createCompiler = async (): Promise => { + if (bundler === 'webpack') { + const { default: webpack } = await import('webpack') + const { TanStackRouterGeneratorWebpack } = await import('../src/webpack') + return webpack({ + ...config, + plugins: [TanStackRouterGeneratorWebpack(pluginOptions)], + } as any) + } + const { rspack } = await import('@rsbuild/core') + const { TanStackRouterGeneratorRspack } = await import('../src/rspack') + return rspack({ + ...config, + plugins: [TanStackRouterGeneratorRspack(pluginOptions)], + } as any) + } + + // The app as a developer starts watching it: with its route tree, from a + // build (`compiler.run`), and no file changed in the last minute. The + // session's first build then changes no file, and nothing is new to the + // bundler's watcher (webpack rebuilds for files changed up to 2 s before + // it started watching), so no rebuild is pending when the test creates a + // route file. (A route file created while a rebuild runs the generator + // for the unchanged route tree is dropped: router-generator + // generator-dev.test.ts "events that arrive together", a pinned bug.) + const build = await createCompiler() + await new Promise((resolve, reject) => { + build.run((error: Error | null, stats: any) => { + build.close(() => { + if (error || stats?.hasErrors()) { + reject(error ?? new Error(String(stats.toString('errors-only')))) + } else { + resolve() + } + }) + }) + }) + + const minuteAgo = new Date(Date.now() - 60_000) + for (const name of [ + 'package.json', + 'routes', + 'routes/__root.js', + 'main.js', + 'routeTree.gen.js', + ]) { + await utimes(file(name), minuteAgo, minuteAgo) + } + + const compiler = await createCompiler() + const builds: Array = [] + let built = () => {} + let nextBuild = new Promise((resolve) => { + built = resolve + }) + const watching = compiler.watch( + { aggregateTimeout: 50 }, + (error: Error | null, stats: any) => { + builds.push({ + error: error ? String(error) : undefined, + errors: stats?.hasErrors() + ? stats + .toJson({ all: false, errors: true }) + .errors.map((entry: { message: string }) => entry.message) + : [], + }) + built() + nextBuild = new Promise((resolve) => { + built = resolve + }) + }, + ) + let closed = false + close = () => + closed + ? Promise.resolve() + : new Promise((resolve) => { + closed = true + watching.close(resolve) + }) + const waitForBuild = () => nextBuild + + const require = createRequire(file('main.js')) + const run = async (pathname: string) => { + const bundle = file('dist/main.cjs') + delete require.cache[bundle] + const { routeTree } = require(bundle) + const { + RouterProvider, + createMemoryHistory, + createRouter, + } = require('@tanstack/react-router') + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [pathname] }), + }) + const routes = Object.values(router.routesById) + .map((route: any) => `${route.id} < ${route.parentRoute?.id ?? ''}`) + .sort() + if (!(pathname in router.routesById)) { + return { routes, html: '' } + } + await router.load() + return { + routes, + html: renderToString(createElement(RouterProvider, { router })), + } + } + + await until( + () => builds.length > 0, + () => 'no first build', + waitForBuild, + ) + return { file, builds, waitForBuild, run, close: () => close() } +} diff --git a/packages/router-plugin/tests/handle-route-update.test.ts b/packages/router-plugin/tests/handle-route-update.test.ts deleted file mode 100644 index 9c8e239fe2..0000000000 --- a/packages/router-plugin/tests/handle-route-update.test.ts +++ /dev/null @@ -1,652 +0,0 @@ -// @vitest-environment jsdom - -import { - BaseRootRoute, - BaseRoute, - RouterCore, - createNonReactiveMutableStore, - createNonReactiveReadonlyStore, - trimPathRight, -} from '@tanstack/router-core' -import { describe, expect, it, onTestFinished, vi } from 'vitest' -import { Fragment, act, createElement } from 'react' -import { createPortal } from 'react-dom' -import { createRoot } from 'react-dom/client' -import { createMemoryHistory } from '../../history/src' -import { HeadContent } from '../../react-router/src/HeadContent' -import { RouterContextProvider } from '../../react-router/src/RouterProvider' -import { Scripts } from '../../react-router/src/Scripts' -import { Router as ReactRouter } from '../../react-router/src/router' -import { getHandleRouteUpdateCode } from '../src/core/hmr' -import type { AnyRoute, GetStoreConfig } from '@tanstack/router-core' - -vi.mock('@tanstack/router-core/isServer', async (importOriginal) => ({ - ...(await importOriginal()), - isServer: undefined, -})) - -const getStoreConfig: GetStoreConfig = () => ({ - createMutableStore: createNonReactiveMutableStore, - createReadonlyStore: createNonReactiveReadonlyStore, - batch: (fn) => fn(), -}) - -const getHandleRouteUpdate = () => { - return new Function(`return ${getHandleRouteUpdateCode([])}`)() as ( - routeId: string, - newRoute: AnyRoute, - ) => void -} - -function asAnyRoute(route: TRoute): TRoute & AnyRoute { - return route as unknown as TRoute & AnyRoute -} - -function createTestHistory() { - const location = { - href: '/', - pathname: '/', - search: '', - hash: '', - state: { __TSR_index: 0 }, - } - - return { - location, - length: 1, - subscribers: new Set(), - subscribe: () => () => {}, - push: () => {}, - replace: () => {}, - go: () => {}, - back: () => {}, - forward: () => {}, - canGoBack: () => false, - createHref: (href: string) => href, - block: () => () => {}, - flush: () => {}, - destroy: () => {}, - notify: () => {}, - } -} - -function createTestRouter(routeTree: TRouteTree) { - return new RouterCore( - { - routeTree: asAnyRoute(routeTree), - history: createTestHistory() as any, - isServer: true, - }, - getStoreConfig, - ) -} - -function createClientTestRouter( - routeTree: TRouteTree, - initialEntry: string, -) { - return new RouterCore( - { - routeTree: asAnyRoute(routeTree), - history: createMemoryHistory({ initialEntries: [initialEntry] }), - isServer: false, - origin: 'http://localhost', - }, - getStoreConfig, - ) -} - -function createReactClientTestRouter( - routeTree: TRouteTree, - initialEntry: string, -) { - return new ReactRouter({ - routeTree: asAnyRoute(routeTree), - history: createMemoryHistory({ initialEntries: [initialEntry] }), - isServer: false, - origin: 'http://localhost', - }) -} - -function withWindowRouter(router: RouterCore) { - const testWindow = globalThis.window as any - const hadOwnRouter = Object.prototype.hasOwnProperty.call( - testWindow, - '__TSR_ROUTER__', - ) - const previousRouter = testWindow.__TSR_ROUTER__ - testWindow.__TSR_ROUTER__ = router - - return () => { - if (hadOwnRouter) { - testWindow.__TSR_ROUTER__ = previousRouter - } else { - delete testWindow.__TSR_ROUTER__ - } - } -} - -function runHandleRouteUpdate( - router: RouterCore, - routeId: string, - newRoute: TRoute, -) { - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()(routeId, asAnyRoute(newRoute)) - } finally { - restoreWindow() - } -} - -function getProcessedTreeRouteForPath( - router: RouterCore, - path: string, -) { - return router.buildRouteTree().routesByPath[path]?.id -} - -describe('handleRouteUpdate', () => { - it('keeps routesByPath pointed at an index route when a pathless layout updates', () => { - const rootRoute = new BaseRootRoute({}) - const parentRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/livestock/$farmId/medicine', - }) - const pathlessRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(parentRoute), - id: '_form', - }) - const newRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(pathlessRoute), - path: 'new', - }) - const indexRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(parentRoute), - path: '/', - }) - const routeTree = rootRoute.addChildren([ - parentRoute.addChildren([ - pathlessRoute.addChildren([asAnyRoute(newRoute)]), - asAnyRoute(indexRoute), - ]), - ]) - const router = createTestRouter(routeTree) - const key = trimPathRight(indexRoute.fullPath) - - expect(router.routesByPath[key]?.id).toBe(indexRoute.id) - - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()( - pathlessRoute.id, - asAnyRoute(new BaseRoute({} as any)), - ) - } finally { - restoreWindow() - } - - expect(router.routesByPath[key]?.id).toBe(indexRoute.id) - expect(router.routesByPath[key]?.id).toBe( - getProcessedTreeRouteForPath(router, key), - ) - }) - - it('keeps an index route winning the trimmed path key when its parent updates', () => { - const rootRoute = new BaseRootRoute({}) - const parentRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/path', - }) - const indexRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(parentRoute), - path: '/', - }) - const routeTree = rootRoute.addChildren([ - parentRoute.addChildren([asAnyRoute(indexRoute)]), - ]) - const router = createTestRouter(routeTree) - const key = trimPathRight(indexRoute.fullPath) - - expect(router.routesByPath[key]?.id).toBe(indexRoute.id) - - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()( - parentRoute.id, - asAnyRoute(new BaseRoute({} as any)), - ) - } finally { - restoreWindow() - } - - expect(router.routesByPath[key]?.id).toBe(indexRoute.id) - expect(router.routesByPath[key]?.id).toBe( - getProcessedTreeRouteForPath(router, key), - ) - }) - - it('refreshes matching data when params.parse changes', () => { - const rootRoute = new BaseRootRoute({}) - const itemRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/items/$itemId', - params: { - parse: ({ itemId }: { itemId: string }) => { - return /^\d+$/.test(itemId) ? { itemId } : false - }, - }, - }) - const routeTree = rootRoute.addChildren([asAnyRoute(itemRoute)]) - const router = createTestRouter(routeTree) - - expect(router.getMatchedRoutes('/items/abc')[2]?.id).toBeUndefined() - - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()( - itemRoute.id, - asAnyRoute( - new BaseRoute({ - params: { - parse: ({ itemId }: { itemId: string }) => ({ itemId }), - }, - } as any), - ), - ) - } finally { - restoreWindow() - } - - expect(router.getMatchedRoutes('/items/abc')[2]?.id).toBe(itemRoute.id) - }) - - it('hydrates the hot module route export with generated route tree state', () => { - const rootRoute = new BaseRootRoute({}) - const itemRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/items/$itemId', - }) - const routeTree = rootRoute.addChildren([asAnyRoute(itemRoute)]) - const router = createTestRouter(routeTree) - const newRoute = new BaseRoute({} as any) - - expect((newRoute as any).to).toBeUndefined() - - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()(itemRoute.id, asAnyRoute(newRoute)) - } finally { - restoreWindow() - } - - expect(newRoute.id).toBe(itemRoute.id) - expect(newRoute.path).toBe(itemRoute.path) - expect(newRoute.fullPath).toBe(itemRoute.fullPath) - expect(newRoute.to).toBe(itemRoute.to) - expect((newRoute as any).parentRoute).toBe(rootRoute) - expect((newRoute as any).options).toBe((itemRoute as any).options) - }) - - it('clears lazy ownership and delegates rematerialization to the router', () => { - const rootRoute = new BaseRootRoute({}) - const itemRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/items/$itemId', - }) - const router = createTestRouter( - rootRoute.addChildren([asAnyRoute(itemRoute)]), - ) - const lazyOwner = Promise.resolve() - const refreshRoute = vi.fn(async () => {}) - ;(itemRoute as any)._lazy = lazyOwner - ;(router as any)._refreshRoute = refreshRoute - - expect((itemRoute as any)._lazy).toBe(lazyOwner) - - runHandleRouteUpdate(router, itemRoute.id, new BaseRoute({} as any)) - - expect((itemRoute as any)._lazy).toBeUndefined() - expect(refreshRoute).toHaveBeenCalledTimes(1) - expect(refreshRoute).toHaveBeenCalledWith() - }) - - it('uses a fresh source lazy importer without erasing an omitted one', () => { - const oldImporter = vi.fn(async () => ({ options: {} }) as any) - const newImporter = vi.fn(async () => ({ options: {} }) as any) - const rootRoute = new BaseRootRoute({}) - const itemRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/items/$itemId', - }).lazy(oldImporter) - const router = createTestRouter( - rootRoute.addChildren([asAnyRoute(itemRoute)]), - ) - - runHandleRouteUpdate( - router, - itemRoute.id, - new BaseRoute({} as any).lazy(newImporter), - ) - expect(itemRoute.lazyFn).toBe(newImporter) - - runHandleRouteUpdate(router, itemRoute.id, new BaseRoute({} as any)) - expect(itemRoute.lazyFn).toBe(newImporter) - }) - - it('removes stale loader data when a hot route removes its loader', async () => { - const rootRoute = new BaseRootRoute({}) - const hotRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/hot', - loader: () => 'stale loader data', - }) - const router = createClientTestRouter( - rootRoute.addChildren([asAnyRoute(hotRoute)]), - '/hot', - ) - await router.load() - - expect(router.state.matches.map((match) => match.routeId)).toEqual([ - rootRoute.id, - hotRoute.id, - ]) - expect(router.state.matches[1]!.loaderData).toBe('stale loader data') - - const restoreWindow = withWindowRouter(router) - try { - getHandleRouteUpdate()(hotRoute.id, asAnyRoute(new BaseRoute({} as any))) - await vi.waitFor(() => { - expect(router.state.matches.map((match) => match.routeId)).toEqual([ - rootRoute.id, - hotRoute.id, - ]) - expect(router.state.matches[1]!.loaderData).toBeUndefined() - }) - } finally { - restoreWindow() - } - }) - - it('keeps hot loader data when an older refresh settles later', async () => { - let resolveStaleRefresh!: (value: string) => void - const staleRefresh = new Promise((resolve) => { - resolveStaleRefresh = resolve - }) - const oldLoader = vi - .fn<() => string | Promise>() - .mockReturnValueOnce('initial') - .mockReturnValueOnce(staleRefresh) - const newLoader = vi.fn(() => 'hot') - const rootRoute = new BaseRootRoute({ loader: oldLoader }) - const router = createClientTestRouter(rootRoute, '/') - - await router.load() - expect(router.state.matches[0]?.loaderData).toBe('initial') - - const oldRefresh = router.invalidate() - await vi.waitFor(() => expect(oldLoader).toHaveBeenCalledTimes(2)) - - runHandleRouteUpdate( - router, - rootRoute.id, - new BaseRootRoute({ loader: newLoader }), - ) - - await vi.waitFor(() => { - expect(router.state.matches[0]?.loaderData).toBe('hot') - }) - - resolveStaleRefresh('stale') - await oldRefresh - - expect(newLoader).toHaveBeenCalledTimes(1) - expect(router.state.matches[0]!.routeId).toBe(rootRoute.id) - expect(router.state.matches[0]!.loaderData).toBe('hot') - }) - - it('does not cache an obsolete inactive preload that settles after a hot update', async () => { - let resolveOldLoader!: (value: string) => void - const oldLoaderResult = new Promise((resolve) => { - resolveOldLoader = resolve - }) - const oldLoader = vi.fn(() => oldLoaderResult) - const newLoader = vi.fn(() => 'hot') - const rootRoute = new BaseRootRoute({}) - const hotRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/hot', - loader: oldLoader, - preloadStaleTime: Infinity, - }) - const router = createClientTestRouter( - rootRoute.addChildren([asAnyRoute(hotRoute)]), - '/', - ) - - await router.load() - const preload = router.preloadRoute({ to: '/hot' }) - await vi.waitFor(() => expect(oldLoader).toHaveBeenCalledOnce()) - - runHandleRouteUpdate( - router, - hotRoute.id, - new BaseRoute({ loader: newLoader } as any), - ) - - resolveOldLoader('obsolete') - await preload - await router.navigate({ to: '/hot' }) - - expect(newLoader).toHaveBeenCalledOnce() - expect(router.state.matches.at(-1)?.loaderData).toBe('hot') - }) - - it('observes hot parser and route-context changes on the active route', async () => { - const rootRoute = new BaseRootRoute({}) - const itemRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/items/$itemId', - params: { - parse: ({ itemId }: { itemId: string }) => ({ - itemId, - parser: 'old', - }), - }, - context: () => ({ source: 'old' }), - }) - const router = createClientTestRouter( - rootRoute.addChildren([asAnyRoute(itemRoute)]), - '/items/abc', - ) - - await router.load() - expect(router.state.matches[1]!.routeId).toBe(itemRoute.id) - expect(router.state.matches[1]!.params).toEqual({ - itemId: 'abc', - parser: 'old', - }) - expect(router.state.matches[1]!.context).toMatchObject({ source: 'old' }) - - runHandleRouteUpdate( - router, - itemRoute.id, - new BaseRoute({ - params: { - parse: ({ itemId }: { itemId: string }) => ({ - itemId, - parser: 'new', - }), - }, - context: () => ({ source: 'new' }), - } as any), - ) - - await vi.waitFor(() => { - expect(router.state.matches[1]!.routeId).toBe(itemRoute.id) - expect(router.state.matches[1]!.params).toEqual({ - itemId: 'abc', - parser: 'new', - }) - expect(router.state.matches[1]!.context).toMatchObject({ source: 'new' }) - }) - }) - - it('rematerializes descendants when a parent route definition changes', async () => { - const rootRoute = new BaseRootRoute({}) - const parentRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/parent', - context: () => ({ source: 'old' }), - }) - const childRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(parentRoute), - path: '/child', - context: ({ context }) => ({ inheritedSource: context.source }), - }) - const router = createClientTestRouter( - rootRoute.addChildren([ - parentRoute.addChildren([asAnyRoute(childRoute)]), - ]), - '/parent/child', - ) - - await router.load() - expect(router.state.matches[2]?.context).toMatchObject({ - inheritedSource: 'old', - }) - - runHandleRouteUpdate( - router, - parentRoute.id, - new BaseRoute({ context: () => ({ source: 'new' }) } as any), - ) - - await vi.waitFor(() => { - expect(router.state.matches[2]?.context).toMatchObject({ - inheritedSource: 'new', - }) - }) - }) - - it('does not run removed loader or beforeLoad callbacks on a later visit', async () => { - const beforeLoad = vi.fn(() => ({ hotBeforeLoad: true })) - const loader = vi.fn(() => 'hot loader data') - const rootRoute = new BaseRootRoute({}) - const hotRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/hot', - beforeLoad, - loader, - staleTime: Infinity, - gcTime: Infinity, - }) - const otherRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/other', - }) - const router = createClientTestRouter( - rootRoute.addChildren([asAnyRoute(hotRoute), asAnyRoute(otherRoute)]), - '/hot', - ) - - await router.load() - await router.navigate({ to: '/other' }) - expect(beforeLoad).toHaveBeenCalledTimes(1) - expect(loader).toHaveBeenCalledTimes(1) - - runHandleRouteUpdate(router, hotRoute.id, new BaseRoute({} as any)) - await router.navigate({ to: '/hot' }) - - const match = router.state.matches.find( - (candidate) => candidate.routeId === hotRoute.id, - ) - expect(beforeLoad).toHaveBeenCalledTimes(1) - expect(loader).toHaveBeenCalledTimes(1) - expect(match).toBeDefined() - expect(match!.loaderData).toBeUndefined() - expect(match!.context).not.toHaveProperty('hotBeforeLoad') - }) - - it('removes rendered HeadContent and Scripts output after a hot update', async () => { - const rootRoute = new BaseRootRoute({}) - const hotRoute = new BaseRoute({ - getParentRoute: () => asAnyRoute(rootRoute), - path: '/hot', - head: () => ({ - meta: [{ title: 'hot title' }], - scripts: [{ src: '/hot-head.js' }], - }), - scripts: () => [{ src: '/hot-body.js' }], - }) - const router = createReactClientTestRouter( - rootRoute.addChildren([asAnyRoute(hotRoute)]), - '/hot', - ) - - await router.load() - expect(router.state.matches[1]!).toMatchObject({ - routeId: hotRoute.id, - meta: [{ title: 'hot title' }], - headScripts: [{ src: '/hot-head.js' }], - scripts: [{ src: '/hot-body.js' }], - }) - - const container = document.createElement('div') - document.body.appendChild(container) - const reactRoot = createRoot(container) - const previousActEnvironment = (globalThis as any).IS_REACT_ACT_ENVIRONMENT - ;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true - onTestFinished(() => { - if (previousActEnvironment === undefined) { - delete (globalThis as any).IS_REACT_ACT_ENVIRONMENT - } else { - ;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = previousActEnvironment - } - }) - onTestFinished(() => { - container.remove() - }) - onTestFinished(async () => { - await act(async () => { - reactRoot.unmount() - }) - }) - - await act(async () => { - reactRoot.render( - createElement(RouterContextProvider, { - router, - children: createElement( - Fragment, - null, - createPortal(createElement(HeadContent), document.head), - createElement(Scripts), - ), - }), - ) - }) - - expect(document.head.querySelector('title')?.textContent).toBe('hot title') - expect( - document.head.querySelector('script[src="/hot-head.js"]'), - ).not.toBeNull() - expect( - document.head.querySelector('script[src="/hot-body.js"]'), - ).not.toBeNull() - - await act(async () => { - runHandleRouteUpdate(router, hotRoute.id, new BaseRoute({} as any)) - await vi.waitFor(() => { - expect(router.state.matches[1]!.routeId).toBe(hotRoute.id) - expect(router.state.matches[1]!.meta).toBeUndefined() - expect(router.state.matches[1]!.headScripts).toBeUndefined() - expect(router.state.matches[1]!.scripts).toBeUndefined() - }) - }) - - expect(document.head.querySelector('title')).toBeNull() - expect(document.head.querySelector('script[src="/hot-head.js"]')).toBeNull() - expect(document.head.querySelector('script[src="/hot-body.js"]')).toBeNull() - }) -}) diff --git a/packages/router-plugin/tests/integration/build-cache.test.ts b/packages/router-plugin/tests/integration/build-cache.test.ts new file mode 100644 index 0000000000..da86e9aed4 --- /dev/null +++ b/packages/router-plugin/tests/integration/build-cache.test.ts @@ -0,0 +1,155 @@ +/** + * Persistent bundler caches (webpack's and Rspack's filesystem caches, + * Rsbuild's `performance.buildCache`) rebuild a split route as the first + * build did: the module state a loader and its split component share + * initialises once and both see one instance, on a fully cached rebuild and + * on a rebuild after an edit of an unrelated file (SPEC G3, G4, J2.4; §9: + * a regression test, not a pin). + */ +import { writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { describe, expect, onTestFinished, test } from 'vitest' +import { createApp } from '@tanstack/compiler-test-utils/build-harness' +import { buildWithRsbuild, routeApp, routeHead } from '../build-harness' +import type { BuildResult } from '@tanstack/compiler-test-utils/build-harness' + +const timeout = 120_000 + +/** The apps live next to the other harness apps, where imports resolve. */ +const appsDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..') + +/** + * A route whose loader and split component share module state that counts + * its own evaluations; the entry also imports an unrelated module. + */ +const files = (unrelatedVersion: number) => + routeApp( + `${routeHead()}const shared = { + inits: ((globalThis as any).__inits = ((globalThis as any).__inits ?? 0) + 1), +} +function Page() { + return

{'MARK_COMPONENT ' + shared.inits}

+} +export const Route = createFileRoute('/')({ + loader: () => shared, + component: Page, +}) +`, + { + env: 'client', + files: { + 'lib/unrelated.ts': `export const version = ${unrelatedVersion}\n`, + }, + }, + ) + +/** The entry of `routeApp`, also importing the unrelated module. */ +const withUnrelatedImport = (entry: string) => + `import './lib/unrelated'\n${entry}` + +const script = `await entry.mount(entry.Route.options.component) +return { inits: globalThis.__inits, loader: entry.Route.options.loader().inits }` + +/** The outcome every build (cold, cached, after an edit) must give. */ +async function expectOneSharedInstance(app: BuildResult) { + const run = await app.run(script) + expect({ + placement: app.where('MARK_COMPONENT'), + html: run.html, + ...(run.result as object), + }).toEqual({ + placement: 'lazy', + html: '

MARK_COMPONENT 1

', + inits: 1, + loader: 1, + }) +} + +/** The app files of the first build (version 1 of the unrelated module). */ +function initialFiles() { + const initial = files(1) + return { ...initial, 'entry.ts': withUnrelatedImport(initial['entry.ts']!) } +} + +describe.each(['rspack', 'webpack'] as const)('%s', (bundler) => { + test( + 'with a persistent filesystem cache, a cached rebuild and a rebuild after an unrelated edit keep one instance of the shared state', + async () => { + const { tanstackRouter } = await import(`../../src/${bundler}`) + const app = await createApp({ + dir: appsDir, + prefix: `.build-cache-${bundler}-`, + registerCleanup: onTestFinished, + files: initialFiles(), + }) + const cacheDirectory = path.join(app.root, '.bundler-cache') + const bundle = (outDir: string) => + app.bundle({ + bundler, + env: 'client', + outDir, + plugin: ({ root }) => + tanstackRouter({ + target: 'react', + autoCodeSplitting: true, + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + codeSplittingOptions: { addHmr: false }, + }), + configure: (options) => { + if (bundler === 'webpack') { + options.cache = { type: 'filesystem', cacheDirectory } + } else { + options.cache = true + options.experiments = { + ...(options.experiments as Record), + cache: { + type: 'persistent', + storage: { type: 'filesystem', directory: cacheDirectory }, + }, + } + } + }, + }) + await expectOneSharedInstance(await bundle('dist-cold')) + await expectOneSharedInstance(await bundle('dist-cached')) + await writeFile( + path.join(app.root, 'lib/unrelated.ts'), + files(2)['lib/unrelated.ts']!, + ) + await expectOneSharedInstance(await bundle('dist-edited')) + }, + timeout, + ) +}) + +test( + 'with Rsbuild build cache on, a cached rebuild and a rebuild after an unrelated edit keep one instance of the shared state', + async () => { + const app = await createApp({ + dir: appsDir, + prefix: '.build-cache-rsbuild-', + registerCleanup: onTestFinished, + files: initialFiles(), + }) + const cacheDirectory = path.join(app.root, '.rsbuild-cache') + const bundle = (distDir: string) => + buildWithRsbuild({ + root: app.root, + files: {}, + rsbuildConfig: { + output: { distPath: { root: distDir } }, + performance: { buildCache: { cacheDirectory } }, + }, + }) + await expectOneSharedInstance(await bundle('dist-cold')) + await expectOneSharedInstance(await bundle('dist-cached')) + await writeFile( + path.join(app.root, 'lib/unrelated.ts'), + files(2)['lib/unrelated.ts']!, + ) + await expectOneSharedInstance(await bundle('dist-edited')) + }, + timeout, +) diff --git a/packages/router-plugin/tests/integration/build-frameworks.test.ts b/packages/router-plugin/tests/integration/build-frameworks.test.ts new file mode 100644 index 0000000000..406ecd4494 --- /dev/null +++ b/packages/router-plugin/tests/integration/build-frameworks.test.ts @@ -0,0 +1,283 @@ +/** + * Real builds of a code-split route per bundler and framework: the split + * component loads lazily and renders, module state the route and the + * component share is initialised once, and the bundle holds only the + * target framework: by provenance (the packages the bundle's modules come + * from, as the bundler's own source maps record them, and the packages it + * leaves for the runtime to load), not by fingerprints of a framework's + * code. + */ +import { existsSync, readFileSync } from 'node:fs' +import path from 'node:path' +import { parseSync } from 'vite' +import { describe, expect, test } from 'vitest' +import { build, frameworks, routeApp, routeHead } from '../build-harness' +import type { + BuildEnv, + Bundler, +} from '@tanstack/compiler-test-utils/build-harness' +import type { Framework } from '../build-harness' + +const timeout = 120_000 + +const bundlers = ['vite', 'rspack', 'webpack'] as const + +/** Counts its own evaluations on `globalThis`. */ +const sharedModule = `export const shared = { + inits: ((globalThis as any).__sharedInits = ((globalThis as any).__sharedInits ?? 0) + 1), +} +` + +/** + * A route whose options and split component read an imported module's state + * and state the route file declares, each counting its evaluations. + */ +const route = ( + framework: Framework, +) => `${routeHead(framework)}import { shared } from '../shared' +const local = { + inits: ((globalThis as any).__localInits = ((globalThis as any).__localInits ?? 0) + 1), +} +function Page() { + return

{'MARK_COMPONENT ' + shared.inits + ' ' + local.inits}

+} +export const Route = createFileRoute('/')({ + staticData: { label: 'MARK_ROUTE', shared, local }, + component: Page, +}) +` + +/** The packages of each framework: its runtime and its router package. */ +const frameworkPackages: Record = { + react: /^(?:react|react-dom|scheduler|@tanstack\/react-[\w-]+)$/, + solid: /^(?:solid-js|@tanstack\/solid-[\w-]+)$/, + vue: /^(?:vue|@vue\/[\w-]+|@tanstack\/vue-[\w-]+)$/, +} + +/** The package an absolute module path belongs to (nearest package.json). */ +function packageOf(file: string): string | undefined { + const installed = [ + ...file.matchAll(/[\\/]node_modules[\\/]((?:@[^\\/]+[\\/])?[^\\/]+)[\\/]/g), + ].at(-1) + if (installed) { + return installed[1]!.replaceAll('\\', '/') + } + for (let dir = path.dirname(file); dir !== path.dirname(dir); ) { + const manifest = path.join(dir, 'package.json') + if (existsSync(manifest)) { + return (JSON.parse(readFileSync(manifest, 'utf8')) as { name?: string }) + .name + } + dir = path.dirname(dir) + } + return undefined +} + +/** The package name of a bare module request (`react-dom/client`: `react-dom`). */ +const requestedPackage = (request: string) => + /^(?:@[^/]+\/)?[^/.][^/]*/.exec(request)?.[0] + +/** + * The packages a bundle holds or loads: the package of every module its + * source maps name (the modules the bundler put in it), and of every bare + * module request it leaves for the runtime (an SSR build's external React: + * static and dynamic imports, `require` calls). + */ +function bundlePackages(app: Awaited>) { + const packages = new Set() + for (const chunk of app.chunks) { + const chunkDir = path.dirname(path.join(app.outDir, chunk.fileName)) + for (const source of chunk.map?.sources ?? []) { + // webpack and Rspack name sources `webpack:///./` + // from the app root; Vite relative to the chunk + const bundlerSource = /^webpack:\/\/[^/]*\/(.*)$/.exec(source) + const file = bundlerSource + ? path.resolve(app.root, bundlerSource[1]!.split('?')[0]!) + : path.resolve(chunkDir, source.split('?')[0]!) + const name = packageOf(file) + if (name) { + packages.add(name) + } + } + const { module, program } = parseSync('chunk.js', chunk.code, { + sourceType: 'module', + }) + const requests = [ + ...module.staticImports.map((entry) => entry.moduleRequest.value), + ...module.staticExports.flatMap((entry) => + entry.entries.flatMap((item) => + item.moduleRequest ? [item.moduleRequest.value] : [], + ), + ), + ] + const visit = (node: unknown) => { + if (!node || typeof node !== 'object') { + return + } + if (Array.isArray(node)) { + node.forEach(visit) + return + } + const value = node as Record + if ( + (value.type === 'ImportExpression' && + value.source?.type === 'Literal') || + (value.type === 'CallExpression' && + value.callee?.type === 'Identifier' && + value.callee.name === 'require' && + value.arguments?.[0]?.type === 'Literal') + ) { + const literal = value.source ?? value.arguments[0] + if (typeof literal.value === 'string') { + requests.push(literal.value) + } + } + for (const key of Object.keys(value)) { + visit(value[key]) + } + } + visit(program) + for (const request of requests) { + const name = requestedPackage(request) + if (name && !request.startsWith('node:')) { + packages.add(name) + } + } + } + return packages +} + +/** What a run returns: evaluations of each state, and what the route read. */ +const stateScript = `{ + inits: { shared: globalThis.__sharedInits, local: globalThis.__localInits }, + routeShared: { + shared: entry.Route.options.staticData.shared.inits, + local: entry.Route.options.staticData.local.inits, + }, +}` + +const builds = new Map>() + +/** Builds (once per bundler, framework and environment) and runs the app. */ +function cachedBuild(bundler: Bundler, framework: Framework, env: BuildEnv) { + const key = `${bundler}:${framework}:${env}` + let result = builds.get(key) + if (!result) { + result = buildRoute(bundler, framework, env) + builds.set(key, result) + } + return result +} + +async function buildRoute( + bundler: Bundler, + framework: Framework, + env: BuildEnv, +) { + const app = await build({ + bundler, + env, + framework, + // No outcome here depends on webpack's minifier (terser), which takes + // most of a webpack build: placement and evaluation counts of live code, + // the rendering, and which framework packages the bundle holds. + ...(bundler === 'webpack' && { minify: false }), + // The bundler's record of which modules it put in each chunk + sourcemap: true, + // Files outlive the test that built them; the result is all we keep + registerCleanup: undefined, + files: routeApp(route(framework), { + env, + framework, + files: { 'shared.ts': sharedModule }, + }), + }) + try { + const run = await app.run( + env === 'ssr' + ? `const html = await entry.render(entry.Route.options.component) +return { html, ...${stateScript} }` + : `await entry.mount(entry.Route.options.component) +return ${stateScript}`, + ) + const result = run.result as { + html?: string + inits: { shared: number; local: number } + routeShared: { shared: number; local: number } + } + return { + placement: { + route: app.where('MARK_ROUTE'), + component: app.where('MARK_COMPONENT'), + }, + html: env === 'ssr' ? result.html! : run.html!, + inits: result.inits, + routeShared: result.routeShared, + frameworks: (() => { + const packages = [...bundlePackages(app)] + return Object.fromEntries( + frameworks.map((name) => [ + name, + packages.filter((item) => frameworkPackages[name].test(item)), + ]), + ) as Record> + })(), + logs: run.logs, + } + } finally { + await app.dispose() + } +} + +describe.each(bundlers)('%s', (bundler) => { + describe.each(frameworks)('%s', (framework) => { + describe.each(['ssr', 'client'] as const)('%s build', (env) => { + test( + 'the split component loads lazily and renders', + async () => { + const result = await cachedBuild(bundler, framework, env) + expect(result.placement).toEqual({ + route: 'eager', + component: 'lazy', + }) + expect(result.html).toContain('MARK_COMPONENT 1 1') + }, + timeout, + ) + + test( + 'module state shared by the route and the component is initialised once', + async () => { + const result = await cachedBuild(bundler, framework, env) + expect(result.inits).toEqual({ shared: 1, local: 1 }) + expect(result.routeShared).toEqual({ shared: 1, local: 1 }) + }, + timeout, + ) + + test( + 'the bundle holds no other framework', + async () => { + const result = await cachedBuild(bundler, framework, env) + // The target framework's packages are there (the provenance is + // read), no other framework's + expect(result.frameworks[framework].length).toBeGreaterThan(0) + expect( + Object.fromEntries( + frameworks + .filter((name) => name !== framework) + .map((name) => [name, result.frameworks[name]]), + ), + ).toEqual( + Object.fromEntries( + frameworks + .filter((name) => name !== framework) + .map((name) => [name, []]), + ), + ) + }, + timeout, + ) + }) + }) +}) diff --git a/packages/router-plugin/tests/integration/build-harness.test.ts b/packages/router-plugin/tests/integration/build-harness.test.ts new file mode 100644 index 0000000000..1365fdd78f --- /dev/null +++ b/packages/router-plugin/tests/integration/build-harness.test.ts @@ -0,0 +1,134 @@ +/** + * Control tests of the router plugin's real-build harness (build-harness.ts): + * with each bundler's router plugin, a split component loads lazily and + * renders. The harness core has its own controls in `@tanstack/compiler-test-utils`. + */ +import { describe, expect, test } from 'vitest' +import { BuildError } from '@tanstack/compiler-test-utils/build-harness' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { build, buildWithRsbuild, head, routeApp } from '../build-harness' +import type { + BuildResult, + Bundler, +} from '@tanstack/compiler-test-utils/build-harness' + +const timeout = 60_000 + +const splitRoute = `${head}import { heavy } from '../heavy' +function Page() { + return

{heavy('MARK_COMPONENT')}

+} +export const Route = createFileRoute('/')({ + staticData: { label: 'MARK_ROUTE' }, + component: Page, +}) +` +const heavy = `export function heavy(label: string) { + return label +} +` + +async function buildSplitRoute(bundler: Bundler, env: 'ssr' | 'client') { + return describeSplitRoute( + await build({ + bundler, + env, + files: routeApp(splitRoute, { env, files: { 'heavy.ts': heavy } }), + }), + env, + ) +} + +async function describeSplitRoute(app: BuildResult, env: 'ssr' | 'client') { + const placement = { + route: app.where('MARK_ROUTE'), + component: app.where('MARK_COMPONENT'), + } + const run = await app.run( + env === 'ssr' + ? `return await entry.render(entry.Route.options.component)` + : `await entry.mount(entry.Route.options.component)`, + ) + return { + placement, + rendered: env === 'ssr' ? run.result : run.html, + } +} + +const splitRouteExpected = { + ssr: { + placement: { route: 'eager', component: 'lazy' }, + rendered: '

MARK_COMPONENT

', + }, + client: { + placement: { route: 'eager', component: 'lazy' }, + rendered: '

MARK_COMPONENT

', + }, +} + +// Vite and Rspack: the same harness call and outcome as the React cells of +// build-frameworks.test.ts (" react ssr/client build the split +// component loads lazily and renders"), which decide it. +// webpack here builds minified, as an app does (build-frameworks builds +// webpack unminified). +describe('router plugin with webpack', () => { + test.each(['ssr', 'client'] as const)( + 'loads a split component lazily and renders it (%s)', + async (env) => { + expect(await buildSplitRoute('webpack', env)).toEqual( + splitRouteExpected[env], + ) + }, + timeout, + ) +}) + +// Rsbuild with its production defaults and the router plugin of Rspack, +// as an Rsbuild app adds it. +test( + 'router plugin with Rsbuild loads a split component lazily and renders it (client)', + async () => { + const app = await buildWithRsbuild({ + files: routeApp(splitRoute, { + env: 'client', + files: { 'heavy.ts': heavy }, + }), + }) + expect(await describeSplitRoute(app, 'client')).toEqual( + splitRouteExpected.client, + ) + }, + timeout, +) + +// Bug: the esbuild adapter never runs the route generator in a build (its +// generator only initialises in `esbuild.config`; generation happens in +// `watchChange`), so the code splitter knows no route files and splits +// nothing. The code splitter's esbuild adapter also never initialises its +// config (no `esbuild` hook calls `initUserConfig`), so it would throw once +// it saw a route file. +// Splitting, or refusing (a build error), are both valid fixes (SPEC §1.3, J2.18); +// a warning on a successful unsplit build is not a refusal. +// Impact: `tanstackRouter({ autoCodeSplitting: true })` with esbuild bundles +// every route component into the entry, without telling the user. +test.fails.each(['ssr', 'client'] as const)( + 'router plugin with esbuild loads a split component lazily and renders it, or refuses the build (%s)', + async (env) => { + let app: BuildResult + try { + app = await build({ + bundler: 'esbuild', + env, + files: routeApp(splitRoute, { env, files: { 'heavy.ts': heavy } }), + }) + } catch (error) { + if (!(error instanceof BuildError)) { + throw error + } + expectDiagnostic(error, { severity: 'error' }) + return + } + expect(await describeSplitRoute(app, env)).toEqual(splitRouteExpected[env]) + }, + timeout, +) diff --git a/packages/router-plugin/tests/integration/build-production-webpack-unsplit.test.ts b/packages/router-plugin/tests/integration/build-production-webpack-unsplit.test.ts new file mode 100644 index 0000000000..36c7be20a6 --- /dev/null +++ b/packages/router-plugin/tests/integration/build-production-webpack-unsplit.test.ts @@ -0,0 +1,30 @@ +/** + * Production client bundles carry nothing of the dev server's additions + * (route HMR, React Refresh support): webpack with automatic code splitting + * off (pins). The checks and their oracles are in ../production-bundle.ts; + * the code-splitting rows are in build-production-webpack.test.ts, the + * other bundlers' rows in build-production.test.ts (one file per group, to + * keep each file within its time budget). + */ +import { describe, test } from 'vitest' +import { frameworks } from '../build-harness' +import { expectProductionClientBundle, timeout } from '../production-bundle' + +describe('webpack', () => { + // Bug: with automatic code splitting off, the composed router plugin adds + // the route HMR plugin unless `NODE_ENV` is `production` when the plugin + // is created (`router-composed-plugin.ts`), instead of following the + // bundler's mode; webpack and Rspack set `NODE_ENV` only inside the + // bundle. For every framework; the React row is also the pin of the + // control in known-bugs-route-hmr-production.test.ts. (Rspack: + // build-production.test.ts.) + // Impact: webpack/Rspack production bundles built from a shell without + // `NODE_ENV` ship the route HMR code of every route. + test.fails.each(frameworks)( + 'a production %s client bundle without code splitting has no dev-only code', + async (framework) => { + await expectProductionClientBundle('webpack', framework, false) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/build-production-webpack.test.ts b/packages/router-plugin/tests/integration/build-production-webpack.test.ts new file mode 100644 index 0000000000..78a30184d5 --- /dev/null +++ b/packages/router-plugin/tests/integration/build-production-webpack.test.ts @@ -0,0 +1,20 @@ +/** + * Production client bundles carry nothing of the dev server's additions + * (route HMR, React Refresh support): webpack. The checks and their oracles + * are in ../production-bundle.ts; the other bundlers' rows are in + * build-production.test.ts (one file per bundler group, to keep each file + * within its time budget). + */ +import { describe, test } from 'vitest' +import { frameworks } from '../build-harness' +import { expectProductionClientBundle, timeout } from '../production-bundle' + +describe('webpack', () => { + test.each(frameworks)( + 'a production %s client bundle has no dev-only code', + async (framework) => { + await expectProductionClientBundle('webpack', framework, true) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/build-production.test.ts b/packages/router-plugin/tests/integration/build-production.test.ts new file mode 100644 index 0000000000..5b0a64c8ed --- /dev/null +++ b/packages/router-plugin/tests/integration/build-production.test.ts @@ -0,0 +1,85 @@ +/** + * Production client bundles carry nothing of the dev server's additions + * (route HMR, React Refresh support): Vite, Rspack and Rsbuild. The checks + * and their oracles are in ../production-bundle.ts; webpack's rows are in + * build-production-webpack.test.ts (one file per bundler group, to keep each + * file within its time budget). + */ +import { describe, test } from 'vitest' +import { frameworks } from '../build-harness' +import { + expectProductionClientBundle, + routeShapes, + timeout, +} from '../production-bundle' + +describe.each(['vite', 'rspack'] as const)('%s', (bundler) => { + test.each(frameworks)( + 'a production %s client bundle has no dev-only code', + async (framework) => { + await expectProductionClientBundle(bundler, framework, true) + }, + timeout, + ) + + // Routes whose route HMR compile differs from the plain route's (SPEC + // J3.7, G7) + test.each( + routeShapes.filter(({ name }) => + [ + 'a route with lowercase components', + 'a root route', + 'a root route with context', + 'an explicitly undefined component', + ].includes(name), + ), + )( + 'a production client bundle of $name has no dev-only code', + async ({ route }) => { + await expectProductionClientBundle(bundler, 'react', true, route) + }, + timeout, + ) +}) + +// Rsbuild with its production defaults (React apps), the router plugin of +// Rspack added as an Rsbuild app adds it. +test.each([true, false])( + 'a production react client bundle (autoCodeSplitting: %s) has no dev-only code (rsbuild)', + async (autoCodeSplitting) => { + await expectProductionClientBundle('rsbuild', 'react', autoCodeSplitting) + }, + timeout, +) + +// The route HMR plugin also runs in these builds (it follows `NODE_ENV`, +// pinned for Rspack below); Vite drops the code `import.meta.hot` guards, +// and the export the React HMR compile adds ships only to a module that +// imports it, which the app (its route tree imports `Route`) does not +// (SPEC G9, J2.4). +test.each(frameworks)( + 'a production %s client bundle without code splitting has no dev-only code (vite)', + async (framework) => { + await expectProductionClientBundle('vite', framework, false) + }, + timeout, +) + +// Bug: with automatic code splitting off, the composed router plugin adds +// the route HMR plugin unless `NODE_ENV` is `production` when the plugin is +// created (`router-composed-plugin.ts`), instead of following the bundler's +// mode; webpack and Rspack set `NODE_ENV` only inside the bundle. For every +// framework; the React row is also the pin of the control in +// known-bugs-route-hmr-production.test.ts. (webpack: +// build-production-webpack.test.ts.) +// Impact: webpack/Rspack production bundles built from a shell without +// `NODE_ENV` ship the route HMR code of every route. +describe('rspack', () => { + test.fails.each(frameworks)( + 'a production %s client bundle without code splitting has no dev-only code', + async (framework) => { + await expectProductionClientBundle('rspack', framework, false) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/build-source-maps.test.ts b/packages/router-plugin/tests/integration/build-source-maps.test.ts new file mode 100644 index 0000000000..1888b3adcd --- /dev/null +++ b/packages/router-plugin/tests/integration/build-source-maps.test.ts @@ -0,0 +1,336 @@ +/** + * Source maps of real client builds point at the code the user wrote: an + * error thrown inside a split route component maps, through the emitted + * source map of the chunk it runs in, to the line (and, unminified, the + * column) of the throw in the route file, also when another plugin + * transformed the file before the router plugin (composed maps); so does a + * throw in code the splitter leaves in the route module or moves into a + * shared module. Map layout, `names`, granularity and the source names a + * map lists are free (SPEC G6, §5.14). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import { describe, expect, onTestFinished, test } from 'vitest' +import { originalFrameOf } from '@tanstack/compiler-test-utils/build-harness' +import { createPluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import { positionAt } from '@tanstack/compiler-test-utils/source-maps' +import { tanstackRouter as tanstackRouterVite } from '../../src/vite' +import { build, routeApp, routeHead } from '../build-harness' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' +import type { RouterPluginOptions } from '../build-harness' + +const appsDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..') + +const timeout = 60_000 + +const route = `${routeHead()}import { label } from '../lib/label' +const shared = { label } +function Page(): never { + throw new Error('MARK_PAGE_THROW ' + shared.label) +} +export const Route = createFileRoute('/')({ + loader: () => shared, + component: Page, +}) +` + +/** Mounts a component and returns the stack of the error it threw. */ +const mountEntry = `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +export * from './routes/index' +export async function mountError(component: any) { + await component.preload?.() + let stack: string | undefined + const root = createRoot(document.getElementById('root')!, { + onUncaughtError: (error: unknown) => { + stack = (error as Error).stack + }, + }) + flushSync(() => root.render(createElement(component))) + return stack +} +` + +/** + * Where the error of the route file's throw is created (its first + * `new Error(`, which a stack frame points at), by its offset in the + * route file as written: 1-based line and column, as `originalFrameOf` + * reports them. + */ +function thrownAt(code: string) { + const { line, column } = positionAt(code, code.indexOf('new Error(')) + return { line, column: column + 1 } +} + +/** + * Asserts that the innermost frame of `stack` in a chunk of `app` maps to + * the throw of `source` (`routes/index.tsx`): its line always, its column + * unless the build minified (minifiers map the throw to different tokens of + * the statement). + */ +function expectFrameAtThrow( + app: Parameters[0], + stack: unknown, + source: string, + { minify }: { minify: boolean }, +) { + const { file, line, column } = originalFrameOf(app, stack as string) ?? {} + const expected = thrownAt(source) + expect( + minify ? { file, line } : { file, line, column }, + `the frame of ${String(stack).split('\n')[1]?.trim()}`, + ).toEqual( + minify + ? { file: 'routes/index.tsx', line: expected.line } + : { file: 'routes/index.tsx', ...expected }, + ) +} + +const builds = [ + { name: 'minified', minify: true }, + { name: 'unminified', minify: false }, +] + +/** + * Builds the route for the client with source maps, mounts its split + * component, which throws, and maps the error's stack frame through the + * emitted source map. `routerPlugins` puts other plugins around the router + * plugin. + */ +async function expectThrowMapsToRouteFile( + bundler: Bundler, + options: { + minify: boolean + routerPlugins?: (config: RouterPluginOptions) => Array + }, +) { + const app = await build({ + bundler, + env: 'client', + minify: options.minify, + sourcemap: true, + routerPlugins: options.routerPlugins, + files: routeApp(route, { + env: 'client', + files: { + 'lib/label.ts': `export const label = 'MARK_LABEL'\n`, + 'entry.ts': mountEntry, + }, + }), + }) + expect(app.where('MARK_PAGE_THROW')).toBe('lazy') + const { result: stack } = await app.run( + 'return await entry.mountError(entry.Route.options.component)', + ) + expect(stack).toMatch(/MARK_PAGE_THROW MARK_LABEL/) + expectFrameAtThrow(app, stack, route, options) +} + +/** + * Throws from code the splitter leaves in the route module, and from code + * it moves into the module the route module and a chunk share. + */ +const moduleThrows = [ + { + name: 'the route module (an unsplit loader)', + route: `${routeHead()}function Page() { + return

page

+} +export const Route = createFileRoute('/')({ + loader: () => { + throw new Error('MARK_LOADER_THROW') + }, + component: Page, +}) +`, + marker: 'MARK_LOADER_THROW', + }, + { + name: 'a function the loader and the split component share', + route: `${routeHead()}import { label } from '../lib/label' +function fail(): never { + throw new Error('MARK_SHARED_THROW ' + label) +} +function Page() { + return

{typeof fail}

+} +export const Route = createFileRoute('/')({ + loader: () => fail(), + component: Page, +}) +`, + marker: 'MARK_SHARED_THROW', + }, +] + +/** + * Builds `source` for the client (unminified, with source maps), calls its + * loader, which throws `marker`, and maps the error's stack frame through + * the emitted source map to the throw's line and column in the route file. + */ +async function expectModuleThrowMapsToRouteFile( + bundler: Bundler, + source: string, + marker: string, +) { + if (bundler === 'vite') { + await expectModuleThrowMapsToRouteFileVite(source, marker) + return + } + const app = await build({ + bundler, + env: 'client', + minify: false, + sourcemap: true, + files: routeApp(source, { + env: 'client', + files: { + 'lib/label.ts': `export const label = 'MARK_LABEL'\n`, + 'entry.ts': `export * from './routes/index'\n`, + }, + }), + }) + const { result: stack } = await app.run( + `try { entry.Route.options.loader() } catch (error) { return error.stack }`, + ) + expect(stack).toMatch(marker) + expectFrameAtThrow(app, stack, source, { minify: false }) +} + +// Control for the pins below. +describe('vite', () => { + test.each(builds)( + 'a throw in a split component maps to its line in the route file ($name)', + (options) => expectThrowMapsToRouteFile('vite', options), + timeout, + ) + + // A plugin that transforms the route file before the router plugin (here + // Babel erasing TypeScript, with its own map): the maps compose, and the + // frame still resolves to the user's line and column. + test( + 'a throw in a split component maps to its line in the route file through the map of a plugin before the router plugin (unminified)', + async () => { + const [{ default: babel }, { tanstackRouter }] = await Promise.all([ + import('@rolldown/plugin-babel'), + import('../../src/vite'), + ]) + // @ts-expect-error -- the preset ships no type declarations + const { default: typescript } = await import('@babel/preset-typescript') + await expectThrowMapsToRouteFile('vite', { + minify: false, + routerPlugins: (config) => [ + babel({ + presets: [[typescript, { allExtensions: true, isTSX: true }]], + }), + tanstackRouter(config), + ], + }) + }, + timeout, + ) + + // Code the splitter leaves in the route module, and code it moves into the + // module the route module and a chunk share, map back the same way. + test.each(moduleThrows)( + 'a throw in $name maps to its line and column in the route file', + ({ route: source, marker }) => + expectModuleThrowMapsToRouteFile('vite', source, marker), + timeout, + ) +}) + +// Bug: unplugin's webpack and Rspack transform loaders drop the source map +// a plugin's `transform` returns when no earlier loader passed one in +// (`callback(null, res.code, map == null ? map : res.map || map)` in +// unplugin/dist/{webpack,rspack}/loaders/transform.mjs), and the router +// plugin's transform is the first loader of a route file. The bundler then +// maps the chunk to the code splitter's output instead of the route file. +// (On webpack the harness's own TypeScript loader composes the map it gets.) +// These rows flip once unplugin keeps the map: with a loader passing an +// identity map in front of unplugin's (so it returns the plugin's map), the +// four split-component rows pass (checked 2026-10-18). The route-module and +// shared-module rows fail the same way: the frame +// maps to the generated module's line, one above the throw's. +// Source: upstream (unplugin), not the router plugin. +// Impact: stack traces, devtools and error trackers point at lines of the +// generated split module (here line 3 instead of line 5 of the route file). +describe.each(['rspack', 'webpack'] as const)('%s', (bundler) => { + test.fails.each(builds)( + 'a throw in a split component maps to its line in the route file ($name)', + (options) => expectThrowMapsToRouteFile(bundler, options), + timeout, + ) + + test.fails.each(moduleThrows)( + 'a throw in $name maps to its line and column in the route file', + ({ route: source, marker }) => + expectModuleThrowMapsToRouteFile(bundler, source, marker), + timeout, + ) +}) + +/** + * `expectModuleThrowMapsToRouteFile` on Vite, through the public plugin host + * (`vite build` with the app's plugins): every chunk the build emits is + * read with the map it has, if any (a chunk with no mapping of its own, e.g. + * a facade re-exporting another chunk, may have none); the frame of the + * throw is resolved through the map of the chunk it names. + */ +async function expectModuleThrowMapsToRouteFileVite( + source: string, + marker: string, +) { + const host = await createPluginHost({ + dir: appsDir, + prefix: '.build-source-maps-', + registerCleanup: onTestFinished, + serve: false, + files: routeApp(source, { + env: 'client', + files: { + 'lib/label.ts': `export const label = 'MARK_LABEL'\n`, + 'entry.ts': `export * from './routes/index'\n`, + }, + }), + plugins: () => [ + tanstackRouterVite({ + target: 'react', + autoCodeSplitting: true, + routesDirectory: './routes', + generatedRouteTree: './routeTree.gen.ts', + }), + react(), + ], + }) + const built = await host.build({ + config: { + build: { + minify: false, + sourcemap: true, + rollupOptions: { + input: 'entry.ts', + preserveEntrySignatures: 'exports-only', + output: { entryFileNames: 'entry.mjs' }, + }, + }, + }, + }) + const app = await built.describe('client') + const { result: stack } = await app.run( + `try { entry.Route.options.loader() } catch (error) { return error.stack }`, + ) + expect(stack).toMatch(marker) + expectFrameAtThrow( + { + root: host.root, + outDir: built.environments.client!.outDir, + chunks: built.environments.client!.chunks, + }, + stack, + source, + { minify: false }, + ) +} diff --git a/packages/router-plugin/tests/integration/code-splitter-dead-code.test.ts b/packages/router-plugin/tests/integration/code-splitter-dead-code.test.ts new file mode 100644 index 0000000000..626abdb9ee --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-dead-code.test.ts @@ -0,0 +1,204 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/code-splitter-dead-code.test.ts. +import { describe, expect, it } from 'vitest' +import { build, clientMountEntry, head, routeApp } from '../build-harness' + +/** + * Which code a production client build drops is the bundler's decision: one + * app per bundler holds the route of every test below (`routes/index.tsx` + * and the routes the entry exports as `Route`), built once and run + * once per route. + */ +type BundlerName = 'vite' | 'rspack' | 'webpack' + +const unusedFunctions = `${head}function helper() { return 'helper' } +function unused() { return 'MARK_UNUSED_END' + helper() } +function ping(): number { return pong() + ('MARK_PING_END' + Math.random()).length } +function pong(): number { return ping() } +export const Route = createFileRoute('/')({ component: () =>

{helper()}

}) +` + +/** + * A route with a pragma whose split component calls `makeLabel` once + * unused (`marker`) and once for what it renders; `makeLabel` calls an + * effectful `format`. + */ +const annotatedRoute = ( + path: string, + annotation: string, + marker: string, +) => `/** @jsxImportSource @emotion/react */ +${head}import { format } from '../format' +${annotation}function makeLabel(text: string) { + return format(text) +} +export const Route = createFileRoute('${path}')({ + component: () => { + makeLabel('${marker}') + return

{makeLabel('used')}

+ }, +}) +` + +/** Routes besides `routes/index.tsx`, by the name the entry exports them. */ +const otherRoutes: Record> = { + vite: { + annotated: annotatedRoute( + '/annotated', + '/* #__NO_SIDE_EFFECTS__ */ ', + 'MARK_ANNOTATED_UNUSED_CALL', + ), + plain: annotatedRoute('/plain', '', 'MARK_PLAIN_UNUSED_CALL'), + }, + rspack: { + annotated: annotatedRoute( + '/annotated', + '/* #__NO_SIDE_EFFECTS__ */ ', + 'MARK_ANNOTATED_UNUSED_CALL', + ), + }, + // webpack's production minifier keeps an unused call of an annotated + // function even when nothing is split (`autoCodeSplitting: false`), in + // every spelling of the annotation: not an outcome of the router plugin. + webpack: {}, +} + +const markers = [ + 'MARK_UNUSED_END', + 'MARK_PING_END', + 'MARK_ANNOTATED_UNUSED_CALL', + 'MARK_PLAIN_UNUSED_CALL', +] + +/** Where each marker is and what each route's component renders, per bundler. */ +const results = new Map>() + +function appOf(bundler: BundlerName) { + let result = results.get(bundler) + if (!result) { + result = buildApp(bundler) + results.set(bundler, result) + } + return result +} + +async function buildApp(bundler: BundlerName) { + const others = otherRoutes[bundler] + const app = await build({ + bundler, + env: 'client', + // Files outlive the test that built them; the result is all we keep + registerCleanup: undefined, + files: routeApp(unusedFunctions, { + env: 'client', + files: { + // `format` has an effect: only the annotation lets a bundler drop a + // call of `makeLabel`. + 'format.ts': `export function format(text: string) { + ;(globalThis as any).formatted = ((globalThis as any).formatted ?? 0) + 1 + return text.toUpperCase() +} +`, + ...Object.fromEntries( + Object.entries(others).map(([name, route]) => [ + `routes/${name}.tsx`, + route, + ]), + ), + 'entry.ts': `${clientMountEntry}${Object.keys(others) + .map( + (name) => + `export { Route as ${name}Route } from './routes/${name}'\n`, + ) + .join('')}`, + }, + }), + }) + try { + const html: Record = {} + for (const name of ['', ...Object.keys(others)]) { + const run = await app.run( + `await entry.mount(entry.${name ? `${name}Route` : 'Route'}.options.component)`, + ) + html[name || 'index'] = run.html! + } + return { + where: Object.fromEntries( + markers.map((marker) => [marker, app.where(marker)]), + ), + html, + } + } finally { + await app.dispose() + } +} + +describe('the reference module only drops code that splitting left unused', () => { + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "only + // eliminates newly unreferenced identifiers", "unexported circular references" + // and "SCC with external caller used -> all preserved". Whether unused user + // code is kept or dropped is free, and unused code may name a binding its + // module no longer declares (SPEC G8: the bundlers + // delete it; the validator checks what Rolldown's tree-shaking keeps); + // every module stays valid and the split component still reaches its + // helper. + + // The other half of that rule: the unused functions (and any binding they + // name that their module no longer declares) do not reach a production + // client bundle. + it.each(['vite', 'rspack', 'webpack'] as const)( + 'drops unused functions, one calling a helper of the split component, from a production client build (%s)', + async (bundler) => { + const { where, html } = await appOf(bundler) + expect({ + unused: where.MARK_UNUSED_END, + ping: where.MARK_PING_END, + html: html.index, + }).toEqual({ + unused: 'nowhere', + ping: 'nowhere', + html: '

helper

', + }) + }, + 60_000, + ) +}) + +// Bundlers drop an unused call of a function annotated #__NO_SIDE_EFFECTS__, +// so the annotation must move with the function into whichever module the +// code splitter puts it in, also in a file whose pragma comment every +// emitted module repeats (SPEC G2, G12). Observed on the +// production client output: the unused call (and the effect it would run) +// is gone, the used one still renders. The emitted name of the function is +// free. +describe('a function annotated #__NO_SIDE_EFFECTS__', () => { + // Which calls a minifier drops is the bundler's decision: every bundler + // that honours the annotation (see `otherRoutes` for webpack). + it.each(['vite', 'rspack'] as const)( + 'loses its unused call and keeps rendering the used one in a production client build (%s)', + async (bundler) => { + const { where, html } = await appOf(bundler) + expect({ + unusedCall: where.MARK_ANNOTATED_UNUSED_CALL, + html: html.annotated, + }).toEqual({ + unusedCall: 'nowhere', + html: '

USED

', + }) + }, + 60_000, + ) + + // Control: without the annotation the effectful call stays (any bundler + // keeps a call with an effect; Vite stands for the others). + it('keeps the unused call without the annotation (vite)', async () => { + const { where, html } = await appOf('vite') + expect({ + unusedCall: where.MARK_PLAIN_UNUSED_CALL, + html: html.plain, + }).toEqual({ + unusedCall: expect.not.stringMatching(/^nowhere$/), + html: '

USED

', + }) + }, 60_000) +}) diff --git a/packages/router-plugin/tests/integration/code-splitter-determinism.test.ts b/packages/router-plugin/tests/integration/code-splitter-determinism.test.ts new file mode 100644 index 0000000000..b2af0d6086 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-determinism.test.ts @@ -0,0 +1,81 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/code-splitter-determinism.test.ts. +/** + * Code splitting does not depend on where the project lives (SPEC G4, + * relocation): the same app built in two directories (its files written in + * another order) splits the same way and runs the same in a browser. Each + * build must work on its own; emitted files, chunk names and bytes are free + * to differ (`@tanstack/compiler-test-utils/determinism`). + */ +import { expect, test } from 'vitest' +import { expectRelocatable } from '@tanstack/compiler-test-utils/determinism' +import { build, head, routeApp } from '../build-harness' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' + +const appFiles = routeApp( + `${head}import { format } from '../format' +function Page() { + return

{format('MARK_PAGE')}

+} +function Failure() { + return

MARK_FAILURE

+} +export const Route = createFileRoute('/')({ + loader: () => 'MARK_DATA', + errorComponent: Failure, + component: Page, +}) +`, + { + env: 'client', + files: { + 'format.ts': 'export const format = (text: string) => `[${text}]`\n', + }, + }, +) + +/** + * Builds the app in a directory named after `prefix` and runs it in a + * browser: the loader's data, the mounted page, and whether each option's + * code ships with the entry or on demand. + */ +async function buildIn(bundler: Bundler, prefix: string) { + const files = Object.entries(appFiles) + const app = await build({ + bundler, + env: 'client', + prefix, + // Write the files in another order at the second root + files: Object.fromEntries(prefix === prefixes[1] ? files.reverse() : files), + }) + const run = await app.run(`const data = await entry.Route.options.loader() +await entry.mount(entry.Route.options.component) +return data`) + return { + data: run.result, + html: run.html, + placement: { + page: app.where('MARK_PAGE'), + failure: app.where('MARK_FAILURE'), + data: app.where('MARK_DATA'), + }, + } +} + +const prefixes = ['.determinism-a-', '.determinism-another-longer-directory-'] + +test.each(['vite', 'rspack', 'webpack'] as const)( + 'the same app built in two directories splits and runs the same (%s)', + async (bundler) => { + await expectRelocatable(prefixes, (prefix) => buildIn(bundler, prefix), { + check: (observation) => { + expect(observation.data).toBe('MARK_DATA') + expect(observation.html).toContain('[MARK_PAGE]') + expect(observation.placement.page).toBe('lazy') + expect(observation.placement.failure).toBe('lazy') + }, + portable: (observation) => observation, + }) + }, + 120_000, +) diff --git a/packages/router-plugin/tests/integration/code-splitter-import-attributes.test.ts b/packages/router-plugin/tests/integration/code-splitter-import-attributes.test.ts new file mode 100644 index 0000000000..53e8dbd84b --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-import-attributes.test.ts @@ -0,0 +1,46 @@ +/** + * An import moved into a split chunk keeps its attributes (SPEC J2.16, + * J2.17): the bundler that compiles the chunk still applies them. + * Vite gives an import attribute no meaning (its dev server and build drop + * them), so this is judged with webpack, which honours `type: 'json'`: a + * `.txt` file holding JSON loads as JSON only through the attribute (without + * it, the build fails parsing the file as JavaScript). The deprecated + * `assert` form keeps working too. Fast-tier counterpart (the moved import + * keeps working in Vite): tests/code-splitter-imports-exports.test.ts. + */ +import { describe, expect, it } from 'vitest' +import { build, routeApp } from '../build-harness' +import { head } from '../route-app' + +describe('the attribute of an import moved into the chunk still applies (webpack)', () => { + it.each([ + { name: 'an import attribute', attribute: `with { type: 'json' }` }, + { name: 'an import assertion', attribute: `assert { type: 'json' }` }, + ])('$name', async ({ attribute }) => { + const app = await build({ + bundler: 'webpack', + env: 'ssr', + minify: false, + files: routeApp( + `${head}import data from '../data.txt' ${attribute} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{data.title}

, +}) +`, + { files: { 'data.txt': '{ "title": "from json" }' } }, + ), + }) + try { + expect( + ( + await app.run( + `return [entry.Route.options.loader(), await entry.render(entry.Route.options.component)]`, + ) + ).result, + ).toEqual(['data', '

from json

']) + } finally { + await app.dispose() + } + }) +}) diff --git a/packages/router-plugin/tests/integration/code-splitter-imports-exports.test.ts b/packages/router-plugin/tests/integration/code-splitter-imports-exports.test.ts new file mode 100644 index 0000000000..2aa8385ff6 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-imports-exports.test.ts @@ -0,0 +1,50 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/code-splitter-imports-exports.test.ts. +import { describe, expect, it } from 'vitest' +import { build, head, routeApp } from '../build-harness' + +describe('TypeScript-only syntax', () => { + // With `verbatimModuleSyntax`, TypeScript keeps `import { type Db } from + // './db'` as `import './db'`. A module a route file imports only for types + // need not load in the client (SPEC J2.5; same as the Start + // client in start-plugin-core known-bugs-start-compiler.test.ts "a + // server-only module imported only for a type specifier"). Only Vite reads + // the app's tsconfig in this harness. + describe('a module imported only for a type specifier, with verbatimModuleSyntax (vite)', () => { + const files = { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { verbatimModuleSyntax: true, jsx: 'react-jsx' }, + }), + 'db.ts': `;(globalThis as any).dbLoaded = 'MARK_DB_LOADED_END' +export type Db = { name: string } +`, + } + const route = `${head}import { type Db } from '../db' +function Page(props: { db?: Db }) { + return

{props.db ? props.db.name : 'page'}

+} +export const Route = createFileRoute('/')({ component: Page }) +` + + it('does not load in the client of a split route file, which renders', async () => { + const app = await build({ + bundler: 'vite', + env: 'client', + files: routeApp(route, { env: 'client', files }), + }) + const run = await app.run( + `await entry.mount(entry.Route.options.component) +return globalThis.dbLoaded ?? null`, + ) + expect({ + where: app.where('MARK_DB_LOADED_END'), + loaded: run.result, + html: run.html, + }).toEqual({ + where: 'nowhere', + loaded: null, + html: '

page

', + }) + }, 60_000) + }) +}) diff --git a/packages/router-plugin/tests/integration/code-splitter-module-state.test.ts b/packages/router-plugin/tests/integration/code-splitter-module-state.test.ts new file mode 100644 index 0000000000..95803eaf29 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-module-state.test.ts @@ -0,0 +1,75 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/code-splitter-module-state.test.ts. +import { describe, expect, it } from 'vitest' +import { buildAndRun, head, ssrRenderEntry } from '../build-harness' + +describe('split chunks keep the module state the route relies on', () => { + // Route files commonly export a store or helpers over private state next to + // the route and use them from the route component as well. + it('renders a split component using exported bindings over private state like the unsplit route', async () => { + const result = await buildAndRun( + `${head}const state = { count: 0 } +export function increment() { + return ++state.count +} +let renders = 0 +export function getRenders() { + return renders +} +const initial = 0 +export const store = { count: initial } +function Page() { + increment() + renders++ + store.count++ + return

{[state.count, getRenders(), store.count - initial].join('/')}

+} +export const Route = createFileRoute('/')({ component: Page }) +`, + `const component = entry.Route.options.component +return [await entry.render(component), await entry.render(component), entry.store.count]`, + // The app imports the exported store too + { + files: { + 'entry.ts': `${ssrRenderEntry}export { store } from './routes/index'\n`, + }, + }, + ) + // Known limitation on main: the chunk gets its own copy of `state` and + // `renders`, so callers of the exported functions are not checked here. + // Pinned in known-bugs-code-splitter.test.ts ("a binding read by an exported function"). + // `store.count` is 2: the chunk mutated the store the route module exports + expect(result).toEqual(['

1/1/1

', '

2/2/2

', 2]) + }, 30_000) + + // Source: #8504 (code-splitter-exported-bindings-identity.test.ts). + it('gives the split component the state the route file configures before it creates it', async () => { + const html = await buildAndRun( + `${head}import { configure, createStore } from '../store' +configure(5) +const store = createStore() +export function useCount() { + return store.count +} +function Page() { + return

{useCount()}

+} +export const Route = createFileRoute('/')({ component: Page }) +`, + `return await entry.render(entry.Route.options.component)`, + { + files: { + 'store.ts': `let initial = 0 +export function configure(count: number) { + initial = count +} +export function createStore() { + return { count: initial } +} +`, + }, + }, + ) + expect(html).toBe('

5

') + }, 30_000) +}) diff --git a/packages/router-plugin/tests/integration/code-splitter-plugin-pipeline.test.ts b/packages/router-plugin/tests/integration/code-splitter-plugin-pipeline.test.ts new file mode 100644 index 0000000000..e17f0278b6 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-plugin-pipeline.test.ts @@ -0,0 +1,115 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/code-splitter-plugin-pipeline(-routes).test.ts. +import { BuildError } from '@tanstack/compiler-test-utils/build-harness' +import { captureDiagnostics } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { + diagnosticsOf, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { expect, it } from 'vitest' +import { build, routeApp } from '../build-harness' + +// A route file that both imports and declares `Route` is invalid TypeScript +// (TS2440). A real build either fails with an error, or +// builds a page that renders; it never builds a page that breaks. The +// error is read on every channel the build reports through (the thrown +// error, the bundler's, the console: SPEC §5.7). Source: review of #8504. +it.each(['vite', 'rspack'] as const)( + 'a route file that imports and declares Route fails its build with an error, or renders (%s)', + async (bundler) => { + let outcome: string + const { result, diagnostics } = await captureDiagnostics(async () => { + try { + return { + app: await build({ + bundler, + env: 'client', + files: routeApp( + `import { createFileRoute } from '@tanstack/react-router' +import { Route } from '../other' +export const Route = createFileRoute('/')({ component: () =>

page

}) +`, + { + env: 'client', + files: { 'other.ts': 'export const Route = 1\n' }, + }, + ), + }), + } + } catch (error) { + if (error instanceof BuildError) { + return { error } + } + throw error + } + }) + if (result.app) { + outcome = String( + ( + await result.app.run( + `await entry.mount(entry.Route.options.component)`, + ) + ).html, + ) + } else { + const reported = [...diagnosticsOf(result.error), ...diagnostics] + outcome = + findDiagnostics(reported, { severity: 'error' }).length > 0 + ? 'refused with an error' + : `refused without an error:\n${reported.map((diagnostic) => diagnostic.text).join('\n')}` + } + expect([ + 'refused with an error', + '

page

', + ]).toContain(outcome) + }, + 60_000, +) + +// The Solid router cannot run in process (code-splitter-plugin-pipeline's +// Solid route is checked at compile level there): a real Vite build of a +// Solid route with its loader and component in groups of their own, run in +// Chromium. Both options load lazily, the loader gives its data and the +// component renders. (The other bundlers' Solid builds: +// build-frameworks.test.ts; the groupings are decided by the transform.) +it('splits the loader and the component of a Solid route into their own groups (vite)', async () => { + const app = await build({ + bundler: 'vite', + env: 'client', + framework: 'solid', + files: routeApp( + `import { createFileRoute } from '@tanstack/solid-router' +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: () => 'MARK_LOADER', + component: () =>
    {'MARK_COMPONENT'}
, +}) +`, + { env: 'client', framework: 'solid' }, + ), + }) + // The scripts the page loaded once the loader ran, before the component. + const run = await app.run(`const data = await entry.Route.options.loader() +const loaded = performance.getEntriesByType('resource').map((entry) => new URL(entry.name).pathname) +await entry.mount(entry.Route.options.component) +return { data, loaded }`) + const { data, loaded } = run.result as { data: string; loaded: Array } + const componentChunks = app.chunks + .filter((chunk) => chunk.code.includes('MARK_COMPONENT')) + .map((chunk) => chunk.fileName) + expect({ + loader: app.where('MARK_LOADER'), + component: app.where('MARK_COMPONENT'), + data, + componentLoadedWithLoader: componentChunks.filter((chunk) => + loaded.some((url) => url.endsWith(`/${chunk}`)), + ), + html: run.html, + }).toEqual({ + loader: 'lazy', + component: 'lazy', + data: 'MARK_LOADER', + componentLoadedWithLoader: [], + html: '
    MARK_COMPONENT
', + }) +}, 60_000) diff --git a/packages/router-plugin/tests/integration/code-splitter-pragmas.test.ts b/packages/router-plugin/tests/integration/code-splitter-pragmas.test.ts new file mode 100644 index 0000000000..e825714562 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-pragmas.test.ts @@ -0,0 +1,271 @@ +// Slow-tier half of this suite: what a route file's pragmas mean in a real +// project, decided by the project's own tools (its JSX transform, its +// framework's refresh runtime in a page). The in-process rows are in +// ../code-splitter-pragmas.test.ts (fast tier). +import { describe, expect, test } from 'vitest' +import { BuildError } from '@tanstack/compiler-test-utils/build-harness' +import { + diagnosticsOf, + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { build, frameworks, routeApp, routeHead } from '../build-harness' +import { openRouteHmrPage } from '../route-hmr-page' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' +import type { Framework } from '../build-harness' + +const timeout = 120_000 + +// SPEC J2.16: a chunk's JSX compiles under the runtime decision of +// its source file. What a pragma written after the imports means is the +// project's JSX transform's decision (Vite's Oxc reads leading pragmas only; +// Rspack's SWC reads a pragma above any top-level statement), and the split +// route must render as the untouched route does: the outcome is the computed +// colour of the styled element in a real browser, Emotion's `css` prop +// applied or left as a plain attribute. Leaving the component unsplit with a +// warning naming the file and the option is also fine (J2.8). +describe('a @jsxImportSource pragma written after the imports', () => { + const styledRoute = `${routeHead()}/** @jsxImportSource @emotion/react */ +function Page() { + return
MARK_STYLED
+} +export const Route = createFileRoute('/')({ component: Page }) +` + + /** + * Builds the route for the browser (split or untouched), mounts its + * component and reads the colour the element gets. + */ + async function styledColour(bundler: Bundler, autoCodeSplitting: boolean) { + const app = await build({ + bundler, + env: 'client', + pluginOptions: { autoCodeSplitting }, + files: routeApp(styledRoute, { env: 'client' }), + }) + const run = await app.run(`await entry.mount(entry.Route.options.component) +return getComputedStyle(document.getElementById('styled')).color`) + expect(run.html).toContain('MARK_STYLED') + return { app, colour: run.result as string } + } + + async function expectSplitRendersLikeUntouched( + bundler: Bundler, + untouchedStyled: boolean, + ) { + const untouched = await styledColour(bundler, false) + expect( + untouched.colour === 'rgb(255, 0, 0)', + `precondition: the project's JSX transform ${untouchedStyled ? 'reads' : 'ignores'} the pragma in the untouched file (colour ${untouched.colour})`, + ).toBe(untouchedStyled) + const split = await styledColour(bundler, true) + if (split.app.where('MARK_STYLED') !== 'lazy') { + expectDiagnostic([...split.app.warnings, ...split.app.consoleMessages], { + severity: 'warning', + file: 'routes/index.tsx', + root: split.app.root, + }) + } + expect(split.colour).toBe(untouched.colour) + } + + test( + 'means in the split route what it means in the untouched route (Rspack: SWC reads it)', + () => expectSplitRendersLikeUntouched('rspack', true), + timeout, + ) + + // Bug: the chunk of the split component starts with the pragma comment + // (the imports above it in the route file are gone from the chunk), so + // Oxc reads it there: the split component is styled by Emotion where the + // untouched route left the `css` prop as an attribute. Same bug as the + // fast-tier pin in ../code-splitter-pragmas.test.ts. + // Impact: with Vite 8, a route renders differently once its component is + // split. + test.fails( + 'means in the split route what it means in the untouched route (Vite: Oxc ignores it)', + () => expectSplitRendersLikeUntouched('vite', false), + timeout, + ) +}) + +// A framework JSX plugin registered before the router plugin is an order the +// docs do not support (SPEC G11): the build either works (the page renders, +// with the component split or left in the route with a warning the user can +// act on: naming the route file, or both plugins) or fails with an error +// naming both plugins (their package, factory or plugin name; the wording +// is free), so the user can act. Never a silent wrong result. +// Source: #6760 (`vueJsx()` before the router plugin). +describe('a framework JSX plugin registered before the router plugin', () => { + const route = ( + framework: Framework, + ) => `${routeHead(framework)}function Page() { + return

MARK_COMPONENT

+} +export const Route = createFileRoute('/')({ component: Page }) +` + /** + * Each framework's JSX plugin, and the names a user knows it by: its + * package, its factory, its Vite plugin names. + */ + const jsxPlugins: Record< + Framework, + { names: RegExp; create: () => Promise } + > = { + react: { + names: /@vitejs\/plugin-react|\bvite:react-[\w:-]+/, + create: async () => (await import('@vitejs/plugin-react')).default(), + }, + solid: { + names: /vite-plugin-solid|\bsolid\(\)|['"`]solid['"`]/, + create: async () => + (await import('vite-plugin-solid')).default({ ssr: true }), + }, + vue: { + names: /@vitejs\/plugin-vue-jsx|\bvueJsx\b|\bvite:vue-jsx\b/, + create: async () => (await import('@vitejs/plugin-vue-jsx')).default(), + }, + } + /** The names a user knows the router plugin by. */ + const routerPluginNames = + /@tanstack\/router-plugin|\btanstackRouter\b|\bTanStackRouterVite\b|\btanstack-router\b/ + + /** Whether a diagnostic's text names both plugins. */ + const namesBoth = (text: string, jsx: RegExp) => + jsx.test(text) && routerPluginNames.test(text) + + test.each(frameworks)( + 'splits the route of a %s app and renders it, or fails the build naming both plugins', + async (framework) => { + const { names, create } = jsxPlugins[framework] + const jsxPlugin = await create() + const { tanstackRouter } = await import('../../src/vite') + let app + try { + app = await build({ + bundler: 'vite', + env: 'ssr', + // The JSX plugin is given here, first; the harness adds no + // other plugin of the same name. + framework, + pluginOptions: { target: framework }, + routerPlugins: (config) => [jsxPlugin, tanstackRouter(config)], + files: routeApp(route(framework), { env: 'ssr', framework }), + }) + } catch (error) { + if (!(error instanceof BuildError)) { + throw error + } + expect( + diagnosticsOf(error, 'error').some(({ text }) => + namesBoth(text, names), + ), + String(error), + ).toBe(true) + return + } + const run = await app.run( + 'return await entry.render(entry.Route.options.component)', + ) + expect(run.result).toContain('MARK_COMPONENT') + if (app.where('MARK_COMPONENT') !== 'lazy') { + const reported = [...app.warnings, ...app.consoleMessages] + expect( + reported.some( + ({ text, severity }) => + severity === 'warning' && namesBoth(text, names), + ) || + findDiagnostics(reported, { + severity: 'warning', + file: 'routes/index.tsx', + root: app.root, + }).length > 0, + `the component stays in the route, reported: ${JSON.stringify(reported.map(({ text }) => text))}`, + ).toBe(true) + } + }, + timeout, + ) +}) + +// solid-refresh reads its `// @refresh reload` comments per module, so every +// module holding route code keeps them; the outcome is solid-refresh's own +// (it reloads what the comment governs, and whether that is a hot update or +// a page reload is its call: SPEC G10 never requires a reload). The oracle +// is the same app with the route left unsplit (`autoCodeSplitting: false`): +// after the same click and the same edit, the split app shows what the +// unsplit app shows (the new content, and the counter state the pragma +// leaves: the count the click set is reset). With Vite 8 and +// vite-plugin-solid the pragma's only other effect on the unsplit app is a +// page reload instead of a hot update, which G10 does not let a test +// require. (React's `/* @refresh reset */` has no +// observable effect under Vite 8's `@vitejs/plugin-react`, split or not: no +// outcome to assert.) +describe('refresh pragma comments of a route file, in a real page', () => { + const solidCounter = ( + header: string, + aboveComponent: string, + version: string, + ) => `${header}import { createFileRoute } from '@tanstack/solid-router' +import { createSignal } from 'solid-js' +${aboveComponent}function Page() { + const [count, setCount] = createSignal(0) + return ( + + ) +} +export const Route = createFileRoute('/')({ component: Page }) +` + + /** + * Opens the app, clicks the counter once, edits the route and returns + * what the counter shows once the page shows the new content. + */ + async function counterAfterEdit( + autoCodeSplitting: boolean, + header: string, + aboveComponent: string, + ) { + const app = await openRouteHmrPage({ + target: 'solid', + pluginOptions: { autoCodeSplitting }, + files: { + 'routes/index.tsx': solidCounter(header, aboveComponent, 'v1'), + }, + ready: 'Counter v1 count 0', + }) + await app.click('button') + await app.page.waitForText('Counter v1 count 1') + await app.edit( + { 'routes/index.tsx': solidCounter(header, aboveComponent, 'v2') }, + /Counter v2 count \d/, + ) + return /Counter v2 count \d/.exec(await app.page.text())?.[0] + } + + test.each([ + { + name: 'a // @refresh reload file header', + header: '// @refresh reload\n', + aboveComponent: '', + }, + { + name: 'a // @refresh reload comment above the split component', + header: '', + aboveComponent: '// @refresh reload\n', + }, + ])( + 'with $name, an edit of a Solid route shows what it shows unsplit', + async ({ header, aboveComponent }) => { + const [unsplit, split] = await Promise.all([ + counterAfterEdit(false, header, aboveComponent), + counterAfterEdit(true, header, aboveComponent), + ]) + expect(unsplit).toMatch(/Counter v2 count \d/) + expect(split).toBe(unsplit) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/code-splitter-robustness.test.ts b/packages/router-plugin/tests/integration/code-splitter-robustness.test.ts new file mode 100644 index 0000000000..131695c161 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-robustness.test.ts @@ -0,0 +1,146 @@ +/** + * Unusual but valid route files split like any other: route files with + * non-ASCII names and JavaScript route files, in real builds. + */ +import { expect, test } from 'vitest' +import { build, clientMountEntry, head, rootRoute } from '../build-harness' + +/** + * One app per bundler holds both unusual route files: a route + * file with a non-ASCII name (its route at `/café/日本語`, re-exported by + * the entry as `CafeRoute`) and a JavaScript route file (`routes/index.jsx`, + * the entry's `Route`). Built once and run once per route; each test reads + * its own route's markers. + */ +type BundlerName = 'vite' | 'rspack' | 'webpack' + +const results = new Map>() + +function appOf(bundler: BundlerName) { + let result = results.get(bundler) + if (!result) { + result = buildApp(bundler) + results.set(bundler, result) + } + return result +} + +async function buildApp(bundler: BundlerName) { + const app = await build({ + bundler, + env: 'client', + // No outcome here depends on webpack's minifier (terser), which takes + // most of a webpack build: generation, placement of live code and the + // rendering. + ...(bundler === 'webpack' && { minify: false }), + // Files outlive the test that built them; the result is all we keep + registerCleanup: undefined, + files: { + 'routes/__root.tsx': rootRoute, + 'routes/café.日本語.tsx': `${head}function Page() { + return

MARK_CAFE_COMPONENT

+} +export const Route = createFileRoute('/café/日本語')({ + staticData: { label: 'MARK_CAFE_ROUTE' }, + component: Page, +}) +`, + 'routes/index.jsx': `${head}const shared = { label: 'MARK_SHARED' } +function Page() { + return

MARK_COMPONENT {shared.label}

+} +export const Route = createFileRoute('/')({ + loader: () => shared, + component: Page, +}) +`, + 'entry.ts': `${clientMountEntry}export { Route as CafeRoute } from './routes/café.日本語' +`, + }, + }) + try { + const cafe = await app.run( + `await entry.mount(entry.CafeRoute.options.component)`, + ) + const jsx = await app.run( + `await entry.mount(entry.Route.options.component) +return entry.Route.options.loader().label`, + ) + return { + cafe: { + route: app.where('MARK_CAFE_ROUTE'), + component: app.where('MARK_CAFE_COMPONENT'), + html: cafe.html, + }, + jsx: { + component: app.where('MARK_COMPONENT'), + html: jsx.html, + loaded: jsx.result, + }, + } + } finally { + await app.dispose() + } +} + +test.each(['vite', 'rspack', 'webpack'] as const)( + 'a route file with a non-ASCII name is generated, split and rendered (%s)', + async (bundler) => { + expect((await appOf(bundler)).cafe).toEqual({ + route: 'eager', + component: 'lazy', + html: '

MARK_CAFE_COMPONENT

', + }) + }, + 120_000, +) + +// A JavaScript route file (`.jsx`) splits like a TypeScript one in each +// bundler's build. +test.each(['vite', 'rspack', 'webpack'] as const)( + 'a .jsx route file is generated, split and rendered (%s)', + async (bundler) => { + expect((await appOf(bundler)).jsx).toEqual({ + component: 'lazy', + html: '

MARK_COMPONENT MARK_SHARED

', + loaded: 'MARK_SHARED', + }) + }, + 120_000, +) + +// A watch build (webpack-dev-server, `--watch`) rebuilds from its cache after +// an edit: the split stays as in a fresh build. Source: the #8504 probe (a +// module marked side-effect free lost the mark on a cached rebuild). +test.each(['rspack', 'webpack'] as const)( + 'an exported component a split component renders still loads with its chunk after a cached rebuild (%s)', + async (bundler) => { + const route = (version: string) => `${head}export function Card() { + return {'MARK_CARD_END'} +} +function Page() { + return

{'${version}'}

+} +export const Route = createFileRoute('/')({ component: Page }) +` + const app = await build({ + bundler, + env: 'client', + files: { + 'routes/__root.tsx': rootRoute, + 'routes/index.tsx': route('v1'), + // Like the route tree, the entry imports only `Route`. + 'entry.ts': clientMountEntry, + }, + rebuildAfter: { 'routes/index.tsx': route('v2') }, + }) + const run = await app.run( + `await entry.mount(entry.Route.options.component)`, + ) + expect({ card: app.where('MARK_CARD_END'), html: run.html }).toEqual({ + card: 'lazy', + html: '

MARK_CARD_ENDv2

', + }) + }, + 120_000, +) diff --git a/packages/router-plugin/tests/integration/code-splitter-router.test.ts b/packages/router-plugin/tests/integration/code-splitter-router.test.ts new file mode 100644 index 0000000000..be37942967 --- /dev/null +++ b/packages/router-plugin/tests/integration/code-splitter-router.test.ts @@ -0,0 +1,231 @@ +/** + * Split route options rendered by a real router in a real build: the + * error, not-found and pending components load from their own chunks and + * render where the router needs them. + */ +import { describe, expect, test } from 'vitest' +import { build, head } from '../build-harness' +import type { BuildEnv } from '@tanstack/compiler-test-utils/build-harness' + +const rootRoute = `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ component: () => }) +` + +const routes = { + 'routes/__root.tsx': rootRoute, + 'routes/error.tsx': `${head}export const Route = createFileRoute('/error')({ + loader: () => { + throw new Error('failed') + }, + component: () =>

page

, + errorComponent: () =>

{'MARK_ERROR'}

, +}) +`, + 'routes/missing.tsx': `${head}import { notFound } from '@tanstack/react-router' +export const Route = createFileRoute('/missing')({ + loader: () => { + throw notFound() + }, + component: () =>

page

, + notFoundComponent: () =>

{'MARK_NOT_FOUND'}

, +}) +`, + 'routes/pending.tsx': `${head}export const Route = createFileRoute('/pending')({ + loader: () => new Promise(() => {}), + pendingMs: 0, + component: () =>

page

, + pendingComponent: () =>

{'MARK_PENDING'}

, +}) +`, +} + +/** + * `renderAt(path, text)` renders the app at `path` and returns its HTML: + * on the client once it shows `text` (or after 2 seconds), on the server + * once the router loaded. + */ +const entries: Record = { + client: `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export async function renderAt(path: string, text: string) { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [path] }), + }) + const container = document.createElement('div') + document.body.appendChild(container) + const root = createRoot(container) + flushSync(() => root.render(createElement(RouterProvider, { router }))) + for (let tries = 0; tries < 200 && !container.innerHTML.includes(text); tries++) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } + const html = container.innerHTML + root.unmount() + container.remove() + return html +} +`, + ssr: `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export async function renderAt(path: string) { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [path] }), + }) + await router.load() + return renderToString(createElement(RouterProvider, { router })) +} +`, +} + +const cases = { + client: [ + { path: '/error', marker: 'MARK_ERROR' }, + { path: '/missing', marker: 'MARK_NOT_FOUND' }, + { path: '/pending', marker: 'MARK_PENDING' }, + ], + // A server render waits for the loaders, so it never shows a pending + // component. + ssr: [ + { path: '/error', marker: 'MARK_ERROR' }, + { path: '/missing', marker: 'MARK_NOT_FOUND' }, + ], +} + +describe.each(['client', 'ssr'] as const)('a Vite %s build', (env) => { + test('renders split error, not-found and pending components through the router', async () => { + const app = await build({ + bundler: 'vite', + env, + files: { ...routes, 'entry.ts': entries[env] }, + pluginOptions: { + codeSplittingOptions: { + defaultBehavior: [ + ['component'], + ['errorComponent'], + ['notFoundComponent'], + ['pendingComponent'], + ], + }, + }, + }) + const { result } = await app.run(`const results = {} +for (const { path, marker } of ${JSON.stringify(cases[env])}) { + results[path] = (await entry.renderAt(path, marker)).includes(marker) +} +return results`) + expect({ + placement: Object.fromEntries( + cases[env].map(({ marker }) => [marker, app.where(marker)]), + ), + rendered: result, + }).toEqual({ + placement: Object.fromEntries( + cases[env].map(({ marker }) => [marker, 'lazy']), + ), + rendered: Object.fromEntries(cases[env].map(({ path }) => [path, true])), + }) + }, 120_000) +}) + +// An option value that is already lazy (`lazyRouteComponent(() => +// import(…))`, SPEC §6 OQ13): the code splitter may leave it in the route +// module or split it and chain its preload; either way, once the router has +// preloaded the route, rendering it requests no new module and shows no +// pending fallback (SPEC J2.6). One real Vite client build in Chromium: +// the requests are the page's resource entries. +describe('an already lazy route component', () => { + const files = { + 'routes/__root.tsx': `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ component: () => }) +`, + 'routes/index.tsx': `import { createFileRoute, lazyRouteComponent } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + component: lazyRouteComponent(() => import('../page')), + pendingComponent: () =>

MARK_PENDING

, + pendingMs: 0, +}) +`, + 'page.tsx': `export default function Page() { + return

MARK_PAGE

+} +`, + 'entry.ts': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +/** Preloads \`/\`, then renders it; what the first render shows and what loaded for it. */ +export async function renderPreloaded() { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: ['/'] }), + }) + await router.preloadRoute({ to: '/' }) + await router.load() + const before = performance.getEntriesByType('resource').length + const container = document.createElement('div') + document.body.appendChild(container) + const root = createRoot(container) + flushSync(() => root.render(createElement(RouterProvider, { router }))) + const first = container.innerHTML + for (let tries = 0; tries < 200 && !container.innerHTML.includes('MARK_PAGE'); tries++) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } + const requested = performance + .getEntriesByType('resource') + .slice(before) + .map((entry) => entry.name) + const html = container.innerHTML + root.unmount() + container.remove() + return { first, html, requested } +} +`, + } + + /** What a Vite client build of the app shows and requests (see the entry). */ + async function renderPreloaded(autoCodeSplitting: boolean) { + const app = await build({ + bundler: 'vite', + env: 'client', + files, + pluginOptions: { autoCodeSplitting }, + }) + return (await app.run(`return await entry.renderPreloaded()`)).result + } + const preloaded = { + first: '

MARK_PAGE

', + html: '

MARK_PAGE

', + requested: [], + } + + // Control for the pin below: without code splitting the router's own + // preload of the lazy component is enough. + test('renders without a new request or a pending fallback once the router preloaded it (splitting off)', async () => { + expect(await renderPreloaded(false)).toEqual(preloaded) + }, 120_000) + + // Bug: the code splitter moves the already lazy value into a chunk of its + // own, so the route's component is a lazy component whose module exports + // another lazy component: the router's preload loads the outer chunk only, + // and the first render suspends (pending fallback) and requests the page + // module. Leaving the value in the route module or chaining the inner + // preload both fix it (SPEC §6 OQ13). + // Impact: apps that already wrap a route component in + // lazyRouteComponent show their pending component, and wait for a + // request, on every navigation the router had preloaded (intent + // preloading no longer avoids the waterfall). + test.fails( + 'renders without a new request or a pending fallback once the router preloaded it', + async () => { + expect(await renderPreloaded(true)).toEqual(preloaded) + }, + 120_000, + ) +}) diff --git a/packages/router-plugin/tests/code-splitter-runtime.test.ts b/packages/router-plugin/tests/integration/code-splitter-runtime.test.ts similarity index 64% rename from packages/router-plugin/tests/code-splitter-runtime.test.ts rename to packages/router-plugin/tests/integration/code-splitter-runtime.test.ts index 0eb9b52ea5..1091358fc4 100644 --- a/packages/router-plugin/tests/code-splitter-runtime.test.ts +++ b/packages/router-plugin/tests/integration/code-splitter-runtime.test.ts @@ -1,18 +1,14 @@ -import { execFile } from 'node:child_process' -import { mkdir, mkdtemp, readFile, rm, writeFile } from 'node:fs/promises' +import { mkdir, readFile, rm, writeFile } from 'node:fs/promises' import path from 'node:path' -import { promisify } from 'node:util' import { pathToFileURL } from 'node:url' +import { createAppDirectory } from '@tanstack/compiler-test-utils/app-directory' +import { runNodeProgram } from '@tanstack/compiler-test-utils/run-node' import { build } from 'vite' import { expect, it } from 'vitest' -import { tanstackRouter } from '../src/vite' -import type { CodeSplitGroupings } from '../src/core/constants' +import { tanstackRouter } from '../../src/vite' +import type { CodeSplitGroupings } from '../build-harness' -const runNode = promisify(execFile) -const fixture = path.resolve( - __dirname, - 'code-splitter/test-files/react/shared-runtime.tsx', -) +const fixture = path.resolve(__dirname, '../test-files/shared-runtime.tsx') const groupings: Array<{ name: string; groupings: CodeSplitGroupings }> = [ { name: 'eager loader', groupings: [['component']] }, @@ -26,14 +22,15 @@ it.each(groupings)( 30_000, ) -// Shared extraction currently duplicates named default function declarations and -// drops TypeScript enum/namespace dependencies. Keep their intended contracts. -it.fails.each(['named-default', 'enum', 'namespace'] as const)( - 'preserves executable route contracts with shared %s declarations', - async (syntax) => { +// Known bug, remove .fails when fixed (more in known-bugs-code-splitter.test.ts). +// Bug: shared extraction duplicates a named default function declaration. +// Impact: the route fails to build (`Duplicate declaration`). +it.fails( + 'preserves executable route contracts with shared named-default declarations', + async () => { await assertRuntimeContracts({ groupings: [['component'], ['loader']], - syntax, + syntax: 'named-default', }) }, 30_000, @@ -44,10 +41,10 @@ async function assertRuntimeContracts({ syntax, }: { groupings: CodeSplitGroupings - syntax?: 'named-default' | 'enum' | 'namespace' + syntax?: 'named-default' }) { - // Keep the temporary app inside the package so real runtime imports resolve. - const root = await mkdtemp(path.join(__dirname, '.runtime-contract-')) + // A temporary app whose real runtime imports resolve as from this directory + const root = await createAppDirectory(__dirname, '.runtime-contract-') try { await mkdir(path.join(root, 'routes')) let source = await readFile(fixture, 'utf8') @@ -58,16 +55,6 @@ async function assertRuntimeContracts({ 'export default function createSeed()', ) .replace('export default createSeed', '') - } else if (syntax === 'enum') { - source = source.replace( - 'const Count = { Initial: 0 }', - 'enum Count { Initial = 0 }', - ) - } else if (syntax === 'namespace') { - source = source.replace( - "const Labels = { component: 'count' }", - "namespace Labels { export const component = 'count' }", - ) } await writeFile(path.join(root, 'routes/shared-runtime.tsx'), source) await writeFile( @@ -120,18 +107,18 @@ export function render() { source.split('\n').findIndex((line) => line.includes('throw new Error')) + 1 const entryUrl = pathToFileURL(path.join(root, 'dist/entry.mjs')).href - const combined = groupings.some( - (group) => group.includes('component') && group.includes('loader'), - ) - const { stdout } = await runNode(process.execPath, [ - '--enable-source-maps', - '--input-type=module', - '--eval', + // When each initialiser runs (with the route module, or with the first + // module that needs it) is free (SPEC G3); that every initialiser runs + // exactly once, and that the state the entry re-exports is ready when + // the entry has loaded, is not. + // In a child process that never outlives the test worker + const { stdout } = await runNodeProgram( `import assert from 'node:assert/strict' const messages = [] console.log = (message) => messages.push(message) const { Route, render, firstState, secondState, 'odd-name': oddState } = await import(${JSON.stringify(entryUrl)}) -assert.deepEqual(messages, ['shared-runtime:seed', 'shared-runtime:state', 'shared-runtime:reference']) +assert.deepEqual(messages, [...new Set(messages)]) +assert.ok(messages.includes('shared-runtime:reference')) const state = Route.options.beforeLoad({}) assert.strictEqual(firstState, state) assert.strictEqual(secondState, state) @@ -139,13 +126,12 @@ assert.strictEqual(oddState, state) assert.equal(state.count, 0) assert.strictEqual(await Route.options.loader({}), state) assert.equal(state.count, 1) -assert.deepEqual(messages, ${JSON.stringify(combined ? ['shared-runtime:seed', 'shared-runtime:state', 'shared-runtime:reference', 'shared-runtime:component'] : ['shared-runtime:seed', 'shared-runtime:state', 'shared-runtime:reference'])}) await Route.options.component.preload() assert.equal(render(), 'count:1') assert.strictEqual(await Route.options.loader({}), state) assert.equal(render(), 'count:2') await Route.options.component.preload() -assert.deepEqual(messages, ['shared-runtime:seed', 'shared-runtime:state', 'shared-runtime:reference', 'shared-runtime:component']) +assert.deepEqual([...messages].sort(), ['shared-runtime:component', 'shared-runtime:reference', 'shared-runtime:seed', 'shared-runtime:state']) await Route.options.loader({}) assert.throws(render, (error) => { assert.equal(error.message, 'route source-map contract') @@ -153,7 +139,8 @@ assert.throws(render, (error) => { return true }) process.stdout.write('route contracts passed')`, - ]) + { nodeArgs: ['--enable-source-maps'] }, + ) expect(stdout).toBe('route contracts passed') } finally { await rm(root, { recursive: true, force: true }) diff --git a/packages/router-plugin/tests/integration/dev-full-bundle.test.ts b/packages/router-plugin/tests/integration/dev-full-bundle.test.ts new file mode 100644 index 0000000000..21d292de86 --- /dev/null +++ b/packages/router-plugin/tests/integration/dev-full-bundle.test.ts @@ -0,0 +1,117 @@ +/** + * Code splitting in Vite's full-bundle dev mode (`experimental.bundledDev`, + * SPEC §2.1 "Modes", J2.13): Rolldown's dev engine bundles the client + * with the router plugin's emitted modules, a real browser page runs the + * bundle with Vite's HMR client, and the test edits the route file on disk. + * The page renders, the split component's code loads only when the router + * needs it, and an edit of the split component hot-updates the page. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import { expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { tanstackRouter } from '../../src/vite' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +const aboutRoute = ( + label: string, +) => `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/about')({ + component: About, +}) +function About() { + return

{'${label}'}

+} +` + +const files = { + 'index.html': ` + + +
+ + + +`, + 'main.tsx': `import { createRoot } from 'react-dom/client' +import { RouterProvider, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__router = router +createRoot(document.getElementById('app')!).render() +`, + 'routes/__root.tsx': `import { createRootRoute, Link, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: () => ( +
+ about + +
+ ), +}) +`, + 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + component: () =>

MARK_HOME

, +}) +`, + 'routes/about.tsx': aboutRoute('MARK_ABOUT_V1'), +} + +/** File names of the scripts the page loaded so far (resource entries). */ +const loadedScripts = (page: Awaited>) => + page.page.evaluate>( + `performance.getEntriesByType('resource').map((entry) => new URL(entry.name).pathname.slice(1))`, + ) + +test('a split route renders, loads its component on demand and hot-updates in full-bundle dev', async () => { + const server = await createDevServer({ + dir: harnessDir, + prefix: '.dev-full-bundle-', + registerCleanup: onTestFinished, + browser: true, + // The client bundle starts from the page, as \`vite dev\` bundles it. + bundledDev: { entry: 'index.html' }, + files, + plugins: ({ root }) => [ + tanstackRouter({ + target: 'react', + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + autoCodeSplitting: true, + }), + react(), + ], + }) + // The chunks of the client bundle the about page's code is in. + const bundle = await server.clientBundle() + const aboutChunks = Object.keys(bundle).filter((fileName) => + bundle[fileName]!.includes('MARK_ABOUT_V1'), + ) + expect(aboutChunks.length).toBeGreaterThan(0) + + const page = await openPage(server.url!, { registerCleanup: onTestFinished }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + const atHome = await loadedScripts(page) + await page.page.locator('a').first().click() + await page.waitForText('MARK_ABOUT_V1', { selector: '#app' }) + const afterNavigation = await loadedScripts(page) + expect({ + // Not loaded with the home page: its own chunk, loaded on navigation. + loadedAtHome: aboutChunks.filter((chunk) => atHome.includes(chunk)), + loadedForAbout: aboutChunks.every((chunk) => + afterNavigation.includes(chunk), + ), + }).toEqual({ loadedAtHome: [], loadedForAbout: true }) + + // An edit of the split component reaches the page as a hot update. + await server.edit({ 'routes/about.tsx': aboutRoute('MARK_ABOUT_V2') }) + await page.waitForText('MARK_ABOUT_V2', { selector: '#app' }) + expect({ loads: page.loads(), errors: page.errors }).toEqual({ + loads: 1, + errors: [], + }) +}, 60_000) diff --git a/packages/router-plugin/tests/integration/dev-server-generator-watching.test.ts b/packages/router-plugin/tests/integration/dev-server-generator-watching.test.ts new file mode 100644 index 0000000000..2dd74bb765 --- /dev/null +++ b/packages/router-plugin/tests/integration/dev-server-generator-watching.test.ts @@ -0,0 +1,56 @@ +/** + * The route generator's watching on a running Vite dev server, on a real + * page: edits of the virtual route config file and of a `__virtual.ts` file + * change the live routes (pinned below), and closing the dev server stops + * the generator (scenarios: `generator-dev-scenarios.ts`; the Rsbuild + * counterpart is rsbuild-dev-server-generator-watching.test.ts). + * + * Each pin waits for the outcome of a correct generator as long as the + * passing scenarios do (`waitForLiveRoute`'s default bound), so a correct + * but slower fix still turns it green, then fails. + */ +import { test } from 'vitest' +import { + describeGeneratorWatching, + expectVirtualRouteConfigEdit, + expectVirtualSubtreeEdit, +} from '../generator-dev-scenarios' + +describeGeneratorWatching('vite') + +// Bug: an edit of the file `virtualRouteConfig` names (path form, as the +// docs configure it: './routes.ts') never reaches the live routes: the +// generator drops the dev server's update event (it compares the absolute +// event path with the configured relative path) and would load the config +// module from jiti's cache anyway. +// Source: packages/router-generator/src/generator.ts +// (`isFileRelevantForRouteTreeGeneration`), src/filesystem/virtual/ +// loadConfigFile.ts (jiti import); the generator-level pin is +// router-generator tests/generator-dev.test.ts "editing the +// virtualRouteConfig file updates the route tree". +// Impact: in Vite dev, a route added to (or changed in) the virtual route +// config is missing from the app until the dev server restarts. +test.fails( + 'an edit of the virtual route config file changes the live routes', + async () => { + await expectVirtualRouteConfigEdit('vite') + }, + 45_000, +) + +// Bug: an edit of a `__virtual.ts` subtree config never reaches the live +// routes: the route tree keeps the subtree the dev server started with. +// Source (not probed in the product: a source probe was not permitted in +// this run): packages/router-generator/src/filesystem/virtual/ +// loadConfigFile.ts (each load imports the config through jiti, whose +// module cache keeps the first version), reached from +// src/filesystem/physical/getRouteNodes.ts for `__virtual.ts` files. +// Impact: in Vite dev, a route added to a `__virtual.ts` file is missing +// from the app until the dev server restarts. +test.fails( + 'an edit of a __virtual.ts file changes the live routes', + async () => { + await expectVirtualSubtreeEdit('vite') + }, + 45_000, +) diff --git a/packages/router-plugin/tests/integration/dev-server-generator.test.ts b/packages/router-plugin/tests/integration/dev-server-generator.test.ts new file mode 100644 index 0000000000..addb5bed55 --- /dev/null +++ b/packages/router-plugin/tests/integration/dev-server-generator.test.ts @@ -0,0 +1,10 @@ +/** + * The route generator on a running Vite dev server, on a real page: route + * files created, renamed, moved and deleted keep their `createFileRoute` + * path in line with their location, the live routes follow, and each route's + * component loads on navigation (scenarios: `generator-dev-scenarios.ts`; + * the Rsbuild counterpart is rsbuild-dev-server-generator.test.ts). + */ +import { describeRouteFileUpkeep } from '../generator-dev-scenarios' + +describeRouteFileUpkeep('vite') diff --git a/packages/router-plugin/tests/integration/dev-server-new-routes.test.ts b/packages/router-plugin/tests/integration/dev-server-new-routes.test.ts new file mode 100644 index 0000000000..850b498c09 --- /dev/null +++ b/packages/router-plugin/tests/integration/dev-server-new-routes.test.ts @@ -0,0 +1,10 @@ +/** + * Routes created while a Vite dev server runs, on a real page: a route file + * the generator cannot handle yet is reported and is added once fixed (the + * control of the Rsbuild pin in rsbuild-dev-server-new-routes.test.ts), and + * edits of created and renamed routes, and of the root route, are hot + * updates (scenarios: `generator-dev-scenarios.ts`). + */ +import { describeCreatedRoutes } from '../generator-dev-scenarios' + +describeCreatedRoutes('vite') diff --git a/packages/router-plugin/tests/integration/dev-source-maps.test.ts b/packages/router-plugin/tests/integration/dev-source-maps.test.ts new file mode 100644 index 0000000000..571fe21444 --- /dev/null +++ b/packages/router-plugin/tests/integration/dev-source-maps.test.ts @@ -0,0 +1,354 @@ +/** + * Source maps in development (SPEC G6, dev as in build): a thrown error in + * the route module, in what the loader and the split component share, and + * in the split component, executed in a real browser page served by Vite's + * dev server and by Rsbuild's, resolves through the maps the dev server + * serves to the user's file and line; on Vite, the module's map names the + * route file itself as its source. The modules are those the throws run + * in, named by the executed stack frames: their ids, how many there are and + * which of them holds which code are free (SPEC §5.3). Maps are the ones the + * page's modules point to (Vite's inline maps, Rsbuild's `sourceMappingURL`), + * read with a standard consumer (`@tanstack/compiler-test-utils/source-maps`). + * Source: #6667, #3828. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { pluginReact } from '@rsbuild/plugin-react' +import react from '@vitejs/plugin-react' +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { createPluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { + expectMapsTo, + inlineSourceMap, + positionAt, + tokenOffsets, + traceStack, +} from '@tanstack/compiler-test-utils/source-maps' +import { tanstackRouter } from '../../src/vite' +import { rootRoute, routeHead } from '../build-harness' +import type { AnySourceMap } from '@tanstack/compiler-test-utils/source-maps' + +const timeout = 60_000 + +/** The apps live next to the other harness apps, where imports resolve. */ +const appsDir = path.join(path.dirname(fileURLToPath(import.meta.url)), '..') + +/** + * A route that throws from its loader (route module), from a function the + * loader and the split component share, and from the split component, each + * with its own marker string on the line of the throw. + */ +const route = `${routeHead()}function fail(): never { + throw new Error('MARK_SHARED_THROW') +} +function Page(): never { + throw new Error('MARK_PAGE_THROW ' + typeof fail) +} +export const Route = createFileRoute('/')({ + loader: (input?: { which?: string }) => { + if (input?.which === 'loader') { + throw new Error('MARK_LOADER_THROW') + } + return fail() + }, + component: Page, +}) +` +const markers = ['MARK_SHARED_THROW', 'MARK_PAGE_THROW ', 'MARK_LOADER_THROW'] + +/** + * The page's code: runs each throw of the route (the loader's, the shared + * function's through the loader, the split component's through React) and + * returns each error's stack, by marker. + */ +const probe = `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { Route } from './routes/index' + +const stackOf = async (run: () => unknown) => { + try { + await run() + } catch (error) { + return (error as Error).stack + } + return undefined +} + +export async function throws() { + const options = Route.options as any + const loader = + typeof options.loader === 'function' ? options.loader : options.loader.handler + const stacks: Record = { + MARK_LOADER_THROW: await stackOf(() => loader({ which: 'loader' })), + MARK_SHARED_THROW: await stackOf(() => loader({})), + } + await options.component.preload?.() + let thrown: unknown + const root = createRoot(document.createElement('div'), { + onUncaughtError: (error) => { + thrown = error + }, + }) + flushSync(() => root.render(createElement(options.component))) + stacks['MARK_PAGE_THROW '] = (thrown as Error | undefined)?.stack + return stacks +} +` + +/** Where the string `marker` starts in the route file (1-based line). */ +function lineOf(marker: string) { + return positionAt(route, tokenOffsets(route, { string: marker })[0]!).line +} + +/** The files the frames of a stack name. */ +const frameLocations = (stack: string) => + stack + .split('\n') + .flatMap( + (line) => + /((?:[a-z][\w+.-]*:\/\/?)?[^\s()@]+?):(\d+):(\d+)\)?\s*$/.exec( + line, + )?.[1] ?? [], + ) + .filter((location) => /^https?:\/\//.test(location)) + +/** + * Asserts that the top frame of each throw's stack resolves, through the + * map of the module it names (`maps`), to the route file at the line of the + * throw. `mapUrl` gives what a relative source of a module's map resolves + * against. + */ +function expectThrowsMapToRouteFile( + stacks: Record, + maps: Map, + root: string, + mapUrl: (location: string) => string | undefined, + only: Array = markers, +) { + for (const marker of only) { + const stack = stacks[marker] + expect(stack, `the stack of ${marker}`).toBeDefined() + const [top] = traceStack(stack!, (location) => maps.get(location)) + expect(top, `the top frame of ${marker}: ${stack}`).toBeDefined() + const map = maps.get(top!.location) + expect(map, `${top!.location} (${marker}) has a source map`).toBeDefined() + expectMapsTo(map!, top!.generated, { + file: 'routes/index.tsx', + root, + mapUrl: mapUrl(top!.location), + line: lineOf(marker), + }) + } +} + +describe('vite dev server', () => { + const cleanups: Array<() => Promise> = [] + let throws: { + stacks: Record + maps: Map + root: string + origin: string + } + beforeAll(async () => { + const host = await createPluginHost({ + dir: appsDir, + prefix: '.dev-source-maps-', + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + files: { + 'routes/__root.tsx': rootRoute, + 'routes/index.tsx': route, + 'probe.ts': probe, + }, + client: true, + config: { + optimizeDeps: { + noDiscovery: true, + include: [ + 'react', + 'react/jsx-runtime', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + }, + }, + plugins: () => [ + tanstackRouter({ + target: 'react', + routesDirectory: './routes', + generatedRouteTree: './routeTree.gen.ts', + autoCodeSplitting: true, + }), + react(), + ], + }) + const { result: stacks } = await host.runClient< + Record + >('/probe.ts', 'return module.throws()') + // The map of every module a frame names, as the dev server serves it + // (Vite inlines it) + const maps = new Map() + const origin = new URL(host.dev.url!).origin + for (const location of new Set( + Object.values(stacks).flatMap((stack) => frameLocations(stack ?? '')), + )) { + const url = new URL(location) + if (url.origin !== origin) { + continue + } + const { body } = await host.dev.fetch(url.pathname + url.search) + maps.set(location, inlineSourceMap(body)) + } + throws = { stacks, maps, root: host.root, origin } + }, timeout) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + // The module each throw runs in maps it to its line in the route file, + // and names the route file as its source, as the browser resolves it + // against the module's URL: a debugger binds a breakpoint set in the + // route file by that URL. + // Bug: the module of the split component and the module of what the + // loader and the split component share name the route file with the code + // splitter's query (`index.tsx?tsr-split=component`, + // `index.tsx?tsr-shared=1`): the code splitter generates their maps with + // the module id as the source file name. + // Source: #6667; src/core/router-code-splitter-plugin.ts (`filename: id`). + // Impact: in Vite dev, a debugger sees the split component and the shared + // code as other files than the route file. + const rows = [ + { name: 'the loader', marker: 'MARK_LOADER_THROW', fails: false }, + { + name: 'a function the loader and the split component share', + marker: 'MARK_SHARED_THROW', + fails: true, + }, + { name: 'the split component', marker: 'MARK_PAGE_THROW ', fails: true }, + ] + for (const { name, marker, fails } of rows) { + ;(fails ? test.fails : test)( + `a throw in ${name} maps to its line in the route file, which its module names as its source`, + () => { + const { stacks, maps, root, origin } = throws + // (a module's URL path is relative to the app root) + expectThrowsMapToRouteFile( + stacks, + maps, + root, + (location) => path.join(root, new URL(location).pathname), + [marker], + ) + const [top] = traceStack(stacks[marker]!, (location) => + maps.get(location), + ) + expect(new URL(top!.original!.source, top!.location).href).toBe( + new URL('/routes/index.tsx', origin).href, + ) + }, + ) + } +}) + +describe('rsbuild dev server', () => { + // Bug: unplugin's Rspack transform loader drops the source map the + // router plugin's `transform` returns when no earlier loader passed one + // in, and the router plugin's loader is the first of a route file (same + // upstream cause as the Rspack and webpack pins of + // build-source-maps.test.ts). The modules compiled from the route file + // then map to the lines of the code splitter's output (here the throw of + // the shared function to line 2 instead of 3; re-verified 2026-10-21). + // Source: #6667, #3828; upstream (unplugin), not the router + // plugin. + // Impact: in Rsbuild dev, a thrown error in a split component, and a + // breakpoint in it, resolve to the generated split module's lines. + test.fails( + 'the route module and every module derived from it map a throw to its line in the route file', + async () => { + const { tanstackRouter: tanstackRouterRspack } = + await import('../../src/rspack') + const server = await createRsbuildDevServer({ + dir: appsDir, + prefix: '.dev-source-maps-rsbuild-', + registerCleanup: onTestFinished, + browser: true, + entry: 'main.tsx', + files: { + 'main.tsx': `import { throws } from './probe' +;(window as any).__throws = throws() +`, + 'probe.ts': probe, + 'routes/__root.tsx': rootRoute, + 'routes/index.tsx': route, + }, + config: { output: { sourceMap: { js: 'source-map' } } }, + plugins: ({ root }) => [ + pluginReact({ fastRefresh: false }), + { + name: 'dev-source-maps', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push( + tanstackRouterRspack({ + target: 'react', + autoCodeSplitting: true, + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + }), + ) + }) + }, + }, + ], + }) + await server.settle() + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.page.waitForFunction(() => (window as any).__throws, null, { + timeout: 15_000, + }) + const stacks = (await page.page.evaluate( + () => (window as any).__throws, + )) as Record + // The map each module a frame names points to (`sourceMappingURL`) + const maps = new Map() + for (const location of new Set( + Object.values(stacks).flatMap((stack) => frameLocations(stack ?? '')), + )) { + if (!location.startsWith(server.url!)) { + continue + } + const code = await (await fetch(location)).text() + const mapping = [ + ...code.matchAll(/[#@] sourceMappingURL=(\S+)\s*$/gm), + ].at(-1)?.[1] + maps.set( + location, + mapping === undefined + ? undefined + : mapping.startsWith('data:') + ? inlineSourceMap(code) + : await (await fetch(new URL(mapping, location))).json(), + ) + } + expectThrowsMapToRouteFile(stacks, maps, server.root, () => undefined) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/generator-watch-mode.test.ts b/packages/router-plugin/tests/integration/generator-watch-mode.test.ts new file mode 100644 index 0000000000..6e5526c952 --- /dev/null +++ b/packages/router-plugin/tests/integration/generator-watch-mode.test.ts @@ -0,0 +1,72 @@ +/** + * The generator entries of webpack and Rspack in the compiler's own watch + * mode (`compiler.watch`, as webpack-dev-server and `--watch` use it): a + * route file created while the compiler watches is scaffolded and joins the + * route tree the bundle runs (the real router, in Node), every compile + * succeeds, and closing the watch session stops the generator's watching + * (SPEC J1.10): a route file created afterwards is left as it is. Waits are + * on the compiler's own build events; nothing reacting after the close is + * observed for a bounded time. + */ +import { readFile, writeFile } from 'node:fs/promises' +import { expect, test } from 'vitest' +import { createFileRouteCall } from '../generator-dev-app' +import { startWatchSession, until } from '../generator-watch-session' + +/** + * How long nothing may react to a route file created after the close: a + * watching generator scaffolds one within a build (`aggregateTimeout` 50 ms) + * in these apps. + */ +const quietFor = 1500 + +test.each(['webpack', 'rspack'] as const)( + '%s: a created route file is scaffolded and joins the route tree the bundle runs, every compile succeeds, and closing the watch session stops the watching', + async (bundler) => { + const session = await startWatchSession(bundler) + const { builds, file, run, waitForBuild } = session + + await writeFile(file('routes/posts.js'), '') + let ran: Awaited> | undefined + await until( + async () => { + if (!builds.length || builds.at(-1)!.error) { + return false + } + try { + ran = await run('/posts') + } catch { + return false + } + return ran.routes.includes('/posts < __root__') + }, + () => + `no build ran /posts (builds: ${JSON.stringify(builds)}, last run: ${JSON.stringify(ran)})`, + waitForBuild, + ) + expect(ran!.routes).toEqual(['/posts < __root__', '__root__ < ']) + expect(ran!.html).toContain('MARK_SCAFFOLD') + expect( + createFileRouteCall(await readFile(file('routes/posts.js'), 'utf8')).path, + ).toBe('/posts') + expect( + builds.filter((build) => build.error || build.errors.length), + ).toEqual([]) + + // Closing the watch session stops the generator: a route file created + // afterwards is neither scaffolded nor added to the route tree. + const tree = await readFile(file('routeTree.gen.js'), 'utf8') + await session.close() + await writeFile(file('routes/later.js'), '') + await new Promise((resolve) => setTimeout(resolve, quietFor)) + expect( + await readFile(file('routes/later.js'), 'utf8'), + 'a route file created after the watch session closed', + ).toBe('') + expect( + await readFile(file('routeTree.gen.js'), 'utf8'), + 'the route tree after the watch session closed', + ).toBe(tree) + }, + 60_000, +) diff --git a/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-builds.test.ts b/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-builds.test.ts new file mode 100644 index 0000000000..017526aa8f --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-builds.test.ts @@ -0,0 +1,249 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/known-bugs-code-splitter.test.ts. +/** + * Known code-splitter bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ + +import { describe, expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { build, clientMountEntry, head, routeApp } from '../build-harness' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' + +/** + * Bundlers whose router plugin splits routes (the esbuild adapter does not; + * pinned in build-harness.test.ts). + */ +const clientBundlers: Array = ['vite', 'rspack', 'webpack'] + +describe('route options written in other shapes', () => { + // The unused `makeOptions` of the two rows above may name a `Page` its + // module no longer declares (SPEC G8: the bundlers + // delete it), as long as that dead code does not reach a production client + // bundle (which the build harness also checks for any dangling name). + test.each( + clientBundlers.flatMap((bundler) => + [ + `createFileRoute('/')({ ssr: false, component: Page } as any)`, + `(createFileRoute('/') as any)({ ssr: false, component: Page })`, + ].map((route) => ({ bundler, route })), + ), + )( + 'a route written as $route drops its unused options factory from a production client build ($bundler)', + async ({ bundler, route }) => { + const app = await build({ + bundler, + env: 'client', + files: routeApp( + `${head}function Page() { + return

page

+} +const makeOptions = () => ({ component: Page, title: 'MARK_MAKE_OPTIONS_END' }) +export const Route = ${route} +`, + { env: 'client' }, + ), + }) + const run = await app.run( + `await entry.mount(entry.Route.options.component)`, + ) + expect({ + makeOptions: app.where('MARK_MAKE_OPTIONS_END'), + html: run.html, + }).toEqual({ + makeOptions: 'nowhere', + html: '

page

', + }) + }, + 60_000, + ) +}) + +describe('what split chunks hold', () => { + // Bug: once the pin above is fixed, the split option must also end up + // split, or the build must say why (SPEC J2.8, G5). Splitting the result of + // a call would change when the call runs, so the user has to change the + // pattern: a warning naming the file and the option is acceptable. Today + // the build fails first (same root cause as the pin above). + // Impact: the component loads with the entry chunk. + test.fails( + 'a component declared by an array destructuring of a call shared with the errorComponent is split or reported', + async () => { + const app = await build({ + bundler: 'vite', + env: 'client', + files: routeApp( + `${head}const createPair = () => [() =>
{'MARK_PAGE'}
, () =>

error

] +const [Page, ErrorView] = createPair() +export const Route = createFileRoute('/')({ + component: Page, + errorComponent: ErrorView, +}) +`, + { env: 'client' }, + ), + }) + const reported = + findDiagnostics([...app.warnings, ...app.consoleMessages], { + severity: 'warning', + file: 'routes/index.tsx', + root: app.root, + }).length > 0 + expect({ + lazy: app.where('MARK_PAGE') === 'lazy', + reported, + }).not.toEqual({ lazy: false, reported: false }) + }, + 60_000, + ) +}) + +describe('exported bindings', () => { + // Bug: same as above, in a real client build whose entry imports the + // exported component (`export { PostErrorComponent } from './routes/index'`): the component is + // in both the entry chunk and the split chunk, and the route renders the + // copy. One instance is the goal: the function the route renders on its + // error path is the one the entry imports, its module-level state is + // created once (SPEC J2.4, G9); and the option is split, or unsplit with + // a warning naming the route file (SPEC J2.8), whichever chunk holds it. + // Impact: the component's code ships twice and runs as two components. + // Whether the option is lazy or reported is the router transform's + // decision, so one bundler shows it (the Rspack and webpack + // cells were decided by the same transform as this Vite cell). + test.fails( + 'an exported errorComponent written as `PostErrorComponent as any` is one instance in the client (vite build)', + async () => { + const app = await build({ + bundler: 'vite', + env: 'client', + files: routeApp( + `${head}import { label, see } from '../see' +const errorLabel = label('MARK_POST_ERROR_END') +export const Route = createFileRoute('/')({ + errorComponent: PostErrorComponent as any, + component: () => { + throw new Error('post failed') + }, +}) +export function PostErrorComponent() { + see(PostErrorComponent) + return

{errorLabel}

+} +`, + { + env: 'client', + files: { + 'see.ts': `export const seen: Array = [] +export let labels = 0 +export function see(component: unknown) { + seen.push(component) +} +export function label(text: string) { + labels++ + return text +} +`, + // The client entry (`mount`, the route and the exported + // component) and the app rendered at `/` through the real router. + 'entry.ts': `${clientMountEntry}export { PostErrorComponent } from './routes/index' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export { seen, labels } from './see' +export async function renderAt(path: string, text: string) { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [path] }), + }) + const container = document.createElement('div') + document.body.appendChild(container) + const root = createRoot(container) + flushSync(() => root.render(createElement(RouterProvider, { router }))) + for (let tries = 0; tries < 200 && !container.innerHTML.includes(text); tries++) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } + return container.innerHTML +} +`, + }, + }, + ), + }) + const { result } = await app.run( + `const html = await entry.renderAt('/', 'MARK_POST_ERROR_END') +return { + rendered: html.includes('MARK_POST_ERROR_END'), + oneInstance: + entry.seen.length > 0 && + entry.seen.every((component) => component === entry.PostErrorComponent), + labels: entry.labels, + lazy: typeof entry.Route.options.errorComponent.preload === 'function', +}`, + ) + const { lazy, ...instance } = result as Record + expect(instance).toEqual({ rendered: true, oneInstance: true, labels: 1 }) + // Placement: split, or kept in the route with a report. + const reported = + findDiagnostics([...app.warnings, ...app.consoleMessages], { + severity: 'warning', + file: 'routes/index.tsx', + root: app.root, + }).length > 0 + expect({ splitOrReported: lazy === true || reported }).toEqual({ + splitOrReported: true, + }) + }, + 60_000, + ) +}) + +describe('code that reads a split binding', () => { + /** + * Builds a route whose split component `Page` an unused module-level + * object also names, and mounts the component in the client bundle. + */ + async function mountUnusedReader(bundler: Bundler) { + const app = await build({ + bundler, + env: 'client', + files: routeApp( + `${head}function Page() { + return

MARK_PAGE

+} +const opts = { component: Page } +export const Route = createFileRoute('/')({ component: Page }) +`, + { env: 'client' }, + ), + }) + const run = await app.run( + `await entry.mount(entry.Route.options.component)`, + ) + return run.html + } + + // Control for the pin below: Rspack and webpack drop the unused object + // while minifying, together with its read of the deleted binding. + test.each(['rspack', 'webpack'] as const)( + 'a split component that an unused object names renders (%s)', + async (bundler) => { + expect(await mountUnusedReader(bundler)).toContain('

MARK_PAGE

') + }, + 60_000, + ) + + // Bug: same root cause as above, for an unused module-level object that + // names the split component: the route module keeps the object but loses + // `Page`. Rolldown keeps the object, as reading an undeclared binding can + // throw. (The build harness now rejects that output before it runs: its + // entry chunk reads the undeclared `Page`.) + // Source: Wave B (a Vite Start client bundle crashed on it). + // Impact: the client bundle throws when the route module loads ("Page is + // not defined"), so the app never renders. + test.fails( + 'a split component that an unused object names renders (vite)', + async () => { + expect(await mountUnusedReader('vite')).toContain('

MARK_PAGE

') + }, + 60_000, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-output.test.ts b/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-output.test.ts new file mode 100644 index 0000000000..15dd8645ae --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-code-splitter-client-output.test.ts @@ -0,0 +1,265 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/known-bugs-code-splitter.test.ts. +/** + * Known code-splitter bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ +import { BuildError } from '@tanstack/compiler-test-utils/build-harness' +import { describe, expect, test } from 'vitest' +import { + findDiagnostics, + mentionsFile, +} from '@tanstack/compiler-test-utils/diagnostics' +import { build, clientMountEntry, head, routeApp } from '../build-harness' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' + +/** + * Bundlers whose router plugin splits routes (the esbuild adapter does not; + * pinned in build-harness.test.ts). + */ +const clientBundlers: Array = ['vite', 'rspack', 'webpack'] + +describe('server-only route options on the client', () => { + /** Start's client configuration of the code splitter. */ + const deleteNodes = ['ssr', 'server', 'headers'] + + /** + * A client build with Start's `deleteNodes` of a route whose `option` + * reads a server secret (its options object followed by `cast`, e.g. + * `as any`). + */ + async function secretPlacement(bundler: Bundler, option: string, cast = '') { + const app = await build({ + bundler, + env: 'client', + pluginOptions: { codeSplittingOptions: { deleteNodes } }, + files: routeApp( + `${head}import { readSecret } from '../db.server' +export const Route = createFileRoute('/')({ + ${option}, + component: () =>

page

, +}${cast}) +`, + { + env: 'client', + files: { + 'db.server.ts': `export function readSecret() { + return (globalThis as any).MARK_SERVER_SECRET +} +`, + }, + }, + ), + }) + return app.where('MARK_SERVER_SECRET') + } + + // Whether a server-only option reaches the client bundle is the router + // transform's decision (an option it keeps stays referenced by the route + // options), so one bundler shows it (the Rspack and webpack + // cells of the two tests below were decided by the same transform as + // their Vite cells). + + // Control for the build-level canary below. + test('a client build has no server code of an `ssr` property (vite)', async () => { + expect(await secretPlacement('vite', 'ssr: () => !!readSecret()')).toBe( + 'nowhere', + ) + }, 60_000) + + // Bug: build-level canary of the method pin in + // pages/known-bugs-code-splitter.test.ts (same root cause). + // Impact: the server code of an `ssr()` method reaches the client bundle. + test.fails( + 'a client build has no server code of an `ssr()` method (vite)', + async () => { + expect( + await secretPlacement('vite', 'ssr() { return !!readSecret() }'), + ).toBe('nowhere') + }, + 60_000, + ) + + // Bug: build-level canary of the typed-wrapper pin in + // pages/known-bugs-code-splitter.test.ts (same root cause: options wrapped in + // a cast or `satisfies` are not read; one bundler, as above). + // Impact: the server handler and its server-only import reach the client + // bundle. + test.fails.each(['as never', 'as any', 'satisfies object'])( + 'a client build has no server code of options wrapped in `%s` (vite)', + async (cast) => { + expect( + await secretPlacement( + 'vite', + 'server: { handlers: { GET: () => readSecret() } }', + ` ${cast}`, + ), + ).toBe('nowhere') + }, + 60_000, + ) +}) + +describe('symlinked route files', () => { + /** + * A client build with `deleteNodes: ['server']` of a route file reached + * through `routes/index.tsx`, a symlink when `linked`; returns where the + * server handler's code is, or `refused` when the build fails naming the + * route file. + */ + async function serverCodePlacement(bundler: Bundler, linked: boolean) { + const route = `${head}import { readSecret } from '../db.server' +export const Route = createFileRoute('/')({ + server: { handlers: { GET: () => readSecret() } }, + component: () =>

page

, +}) +` + const files = routeApp(route, { + env: 'client', + files: { + 'db.server.ts': `export function readSecret() { + return (globalThis as any).MARK_SERVER_SECRET +} +`, + }, + }) + if (linked) { + delete files['routes/index.tsx'] + files['linked/index.tsx'] = route + } + try { + const app = await build({ + bundler, + env: 'client', + pluginOptions: { codeSplittingOptions: { deleteNodes: ['server'] } }, + files, + symlinks: linked ? { 'routes/index.tsx': 'linked/index.tsx' } : {}, + }) + return app.where('MARK_SERVER_SECRET') + } catch (error) { + // A refusal names the route file (the symlink or the file it links to) + if ( + error instanceof BuildError && + error.errors.some( + (text) => + mentionsFile(text, 'routes/index.tsx') || + mentionsFile(text, 'linked/index.tsx'), + ) + ) { + return 'refused' + } + throw error + } + } + + // Control for the pin below (same app, a regular route file). + test.each(clientBundlers)( + 'a client build has no server handler code (%s)', + async (bundler) => { + expect(await serverCodePlacement(bundler, false)).toBe('nowhere') + }, + 60_000, + ) + + // Bug: the code splitter looks route files up by the path the generator + // scanned (the symlink), but bundlers resolve modules to their real path, + // so a symlinked route file is never compiled: nothing is split or + // removed, silently. Failing the build is a valid fix too. Source: #8514. + // Impact: with symlinked sources (Bazel, Nix, linked checkouts), Start's + // client bundle ships `server.handlers` and their server-only imports. + test.fails.each(clientBundlers)( + 'a client build of a symlinked route file has no server handler code (%s)', + async (bundler) => { + expect(['nowhere', 'refused']).toContain( + await serverCodePlacement(bundler, true), + ) + }, + 60_000, + ) +}) + +// What split code's source maps name is checked where it matters, by +// executed throws mapped to the route file's line and column through each +// bundler's emitted maps (build-source-maps.test.ts: split, shared and +// route-module code; Vite, Rspack, webpack). Which source names the maps +// list (a virtual module's id among them) is free (SPEC §5.14). + +describe('production builds', () => { + /** + * A production client build, with `NODE_ENV` as given (`null`: unset), of + * a route whose exported component the app's entry imports eagerly + * (`export { Page } from './routes/index'`): a pattern the compiler may leave + * unsplit, telling the user at build time (J2.8). Mounts the route in the + * browser; returns whether the component was split, whether the build + * warned naming the route file, and whether the page logged anything (a + * production bundle of this app logs nothing: a development warning + * shipped in the bundle, whatever it names). + */ + async function productionWarnings(bundler: Bundler, nodeEnv?: null) { + const app = await build({ + bundler, + env: 'client', + nodeEnv, + files: routeApp( + `${head}export function Page() { + return

MARK_PAGE

+} +export const Route = createFileRoute('/')({ + component: Page, + errorComponent: () =>

error

, +}) +`, + { + env: 'client', + files: { + 'entry.ts': `${clientMountEntry}export { Page } from './routes/index'\n`, + }, + }, + ), + }) + const run = await app.run( + 'await entry.mount(entry.Route.options.component)', + ) + expect(run.html).toContain('MARK_PAGE') + const namingRoute = { file: 'routes/index.tsx', root: app.root } + return { + split: app.where('MARK_PAGE') === 'lazy', + // The option name is pinned in code-splitter-imports-exports.test.ts + warned: + findDiagnostics([...app.warnings, ...app.consoleMessages], { + ...namingRoute, + severity: 'warning', + }).length > 0, + loggedInPage: run.logs.length > 0, + } + } + + // Control for the pin below: with `NODE_ENV=production` exported, the + // build warns when it leaves the exported component eager (never when it + // splits it), and the page logs nothing. + test.each(['rspack', 'webpack'] as const)( + 'a production client bundle logs no development warning in the page; the build warns when the exported component stays eager (%s)', + async (bundler) => { + const { split, warned, loggedInPage } = await productionWarnings(bundler) + expect(split || warned).toBe(true) + expect(loggedInPage).toBe(false) + }, + 60_000, + ) + + // Bug: the code splitter's `console.warn` (today: "will not be + // code-split") is injected into the route module unless the build + // process's `NODE_ENV` is `production`, instead of following the + // bundler's mode as the rest of the code splitter does. webpack and Rspack + // set `NODE_ENV` only inside the bundle. + // Impact: webpack/Rspack production bundles built from a shell without + // `NODE_ENV` log a development warning in every user's console, with the + // developer's absolute file path. + test.fails.each(['rspack', 'webpack'] as const)( + 'a production client bundle logs no development warning in the page when NODE_ENV is unset (%s)', + async (bundler) => { + expect((await productionWarnings(bundler, null)).loggedInPage).toBe(false) + }, + 60_000, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-code-splitter-page-code.test.ts b/packages/router-plugin/tests/integration/known-bugs-code-splitter-page-code.test.ts new file mode 100644 index 0000000000..7c03d2c0dc --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-code-splitter-page-code.test.ts @@ -0,0 +1,534 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/known-bugs-code-splitter.test.ts. +/** + * Known code-splitter bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ + +import { afterAll, describe, expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { build, buildWithRsbuild, head } from '../build-harness' +import type { + BuildResult, + Bundler, +} from '@tanstack/compiler-test-utils/build-harness' + +/** + * Bundlers whose router plugin splits routes (the esbuild adapter does not; + * pinned in build-harness.test.ts). + */ +const clientBundlers: Array = ['vite', 'rspack', 'webpack'] + +/** + * Where a route's code ends up in a client build, which the bundler decides + * from what the code splitter emits, with or without side-effect hints. One + * app per bundler and hint holds a route file per case, each marking its + * page code with a marker; its entry imports the generated route tree, which + * imports only `Route` from each route file, like an app. + */ +describe('page code in client builds', () => { + type Case = { + name: string + /** Route file name in `routes/`; its path is `/`. */ + file: string + /** The route file after the `createFileRoute` import, with `$PATH`. */ + route: string + marker: string + } + + const page = (file: string, body: string): Case['route'] => + `${head}${body}`.replaceAll('$PATH', `/${file}`) + + const marker = (file: string) => `MARK_${file.replaceAll('-', '_')}_END` + + const routeCase = (name: string, file: string, body: string): Case => ({ + name, + file, + route: page(file, body.replaceAll('$MARK', marker(file))), + marker: marker(file), + }) + + const component = `export const Route = createFileRoute('$PATH')({ component: Page })` + + // Page code that loads with its chunk: code the route file does not + // export, and exported functions and classes (today the chunk declares its + // own copy, whose identity and state are pinned in "module state shared + // with split chunks" and "exported bindings", and the bundler drops the + // unused export of the route module). A fix must keep them out of the + // entry chunk. + const controls: Array = [ + routeCase( + 'a const only a split component renders', + 'local-const', + `const Card = () => {'$MARK'} +function Page() { + return +} +${component}`, + ), + routeCase( + 'an exported function component', + 'exported-function', + `export function Card() { + return {'$MARK'} +} +function Page() { + return +} +${component}`, + ), + routeCase( + 'a function component exported by specifier', + 'exported-specifier', + `function Card() { + return {'$MARK'} +} +export { Card } +function Page() { + return +} +${component}`, + ), + routeCase( + 'a default-exported function component', + 'exported-default', + `export default function Card() { + return {'$MARK'} +} +function Page() { + return +} +${component}`, + ), + routeCase( + 'an exported helper function', + 'exported-helper', + `export function format(value: number) { + return '$MARK' + value +} +function Page() { + return

{format(1)}

+} +${component}`, + ), + routeCase( + 'an exported class', + 'exported-class', + `export class Store { + value = '$MARK' +} +function Page() { + return

{new Store().value}

+} +${component}`, + ), + routeCase( + 'an exported function over module state', + 'exported-state', + `let count = 0 +export function next() { + count++ + return '$MARK' + count +} +function Page() { + return

{next()}

+} +${component}`, + ), + // A dependency with side effects next to the exported component: only + // the declaration is asserted, how the bundler groups the modules next + // to it is up to it. (A client build bundles `react/jsx-runtime`, a + // CommonJS module, whose interop call has side effects too.) + // Source: #8504 (code-splitter-exported-bindings-chunks.test.ts). + routeCase( + 'an exported function component with a dependency that has side effects', + 'exported-effect-dep', + `import { label } from '../label' +export function Card() { + return {'$MARK' + label} +} +function Page() { + return +} +${component}`, + ), + // What an exported function component imports loads with the chunk too. + // Source: #8504 (code-splitter-exported-bindings-chunks.test.ts). + { + ...routeCase( + "an exported function component's dependency", + 'exported-dep', + `import { heavy } from '../heavy' +export function Card() { + return {heavy()} +} +function Page() { + return +} +${component}`, + ), + marker: 'MARK_heavy_dependency_END', + }, + // Whether it renders is pinned at the compiler level ("top-level writes + // to the split component (property assignment) stay with the binding + // they write"); a fix must keep the component in its chunk. + // Source: review of #8504 (a candidate fix moved the component to the + // entry). + routeCase( + 'an exported function component next to a helper the loader and the component share', + 'shared-helper-export', + `const label = (value: string) => value + '!' +export function Card() { + return {'$MARK'} +} +export const Route = createFileRoute('$PATH')({ + loader: () => label('data'), + component: () =>

{label('page')}

, +})`, + ), + ] + + // Bug: page code the route file exports as a variable, and an exported + // split component, stay in the route module, which the entry chunk loads, + // with everything they import: a split chunk imports exported variables + // from the route module instead of owning them, and an exported component + // is not split (the code splitter warns). Bundlers can only move the code + // out with the export unused, which the generated route tree (importing + // `Route` only) allows; whether our compiler or the bundler's + // tree-shaking does it is free, with or without `"sideEffects": false` or + // a `/* @__PURE__ */` initialiser. + // Source: #8504's exported-bindings chunks tests. + // Impact: page code exported for tests or reuse loads with the entry chunk. + const exported: Array = [ + routeCase( + 'an exported const component only the split component renders', + 'exported-const', + `export const Card = () => {'$MARK'} +function Page() { + return +} +${component}`, + ), + routeCase( + 'an exported const with a pure initialiser', + 'exported-pure', + `function makeLabel(value: string) { + return { text: value } +} +export const label = /* @__PURE__ */ makeLabel('$MARK') +function Page() { + return

{label.text}

+} +${component}`, + ), + routeCase( + 'an exported function used as the component', + 'exported-component', + `export function Page() { + return

{'$MARK'}

+} +${component}`, + ), + routeCase( + 'a default-exported function used as the component', + 'exported-default-component', + `export default function Page() { + return

{'$MARK'}

+} +${component}`, + ), + // Source: review of #8504. + routeCase( + 'an exported const used as the component', + 'exported-const-component', + `export const Page = () =>

{'$MARK'}

+${component}`, + ), + routeCase( + "an exported component another route's split component renders", + 'exported-shared', + `export function Card() { + return {'$MARK'} +} +function Page() { + return +} +${component}`, + ), + ] + + // Bug: an exported component that two split options render goes to a + // module both chunks import, which the route module re-exports, so it + // loads with the entry chunk unless the app declares `"sideEffects": + // false` (then the bundler drops the unused re-export). + // Source: review of #8504. + const exportedSharedByOptions = routeCase( + 'an exported component two split options render', + 'exported-two-options', + `export function Card() { + return {'$MARK'} +} +export const Route = createFileRoute('$PATH')({ + component: () =>

, + errorComponent: () =>

, +})`, + ) + + // Goals for split options the code splitter leaves in the route module. + const unsplit: Array = [ + // Bug: a route option written as a method (`component() {}`) is not + // split (only property values are). SPEC J2.9: method shorthand + // options are splittable like any other. + // Impact: the component loads with the entry chunk. + routeCase( + 'a component written as a method', + 'method-component', + `export const Route = createFileRoute('$PATH')({ + component() { + return

{'$MARK'}

+ }, +})`, + ), + ] + + // Bug: the root route's options are never split + // (`computeSharedBindings` and the reference compiler skip + // `createRootRoute`), so its errorComponent and notFoundComponent, which + // only render on errors, load with the entry chunk. Its `component` + // renders on every page and may stay (SPEC J2.7). + const rootRoute = `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: () => , + errorComponent: () =>

{'MARK_root_error_END'}

, + notFoundComponent: () =>

{'MARK_root_not_found_END'}

, +}) +` + const rootMarkers = { + errorComponent: 'MARK_root_error_END', + notFoundComponent: 'MARK_root_not_found_END', + } + + // Bug: route options destructured from a call result + // (`const { component, loader } = createBits()`) are neither split nor + // reported: the destructuring moves to a module the route module imports + // statically, so the component's code loads with the entry, silently. + // Splitting them would change when the call runs, so the user has to + // change the pattern: a warning naming the file and the option is the + // expected outcome (SPEC J2.8, G5). + const destructured = routeCase( + 'route options destructured from a call result', + 'destructured-options', + `function DefaultComponent() { + return
Default
+} +const createBits = () => ({ component: ActualComponent, loader: () => 'data' }) +const { component: MyComponent = DefaultComponent, loader } = createBits() +function ActualComponent() { + return
{'$MARK'}
+} +export const Route = createFileRoute('$PATH')({ component: MyComponent, loader })`, + ) + + // Bug: a split chunk keeps the route file's exported declarations that + // its option does not read (SPEC J2.5; compiler-level pin in "what + // split chunks hold"), and bundlers keep them. + const unreadExport = routeCase( + 'an exported helper the split option does not read', + 'unread-export', + `export function helper() { + return '$MARK' +} +function Page() { + return

page

+} +${component}`, + ) + + const cases = [ + ...controls, + ...exported, + ...unsplit, + exportedSharedByOptions, + destructured, + unreadExport, + ] + /** + * `mount(path)` mounts the component of the route at `path` into #root; + * `renderEach(paths)` mounts each into its own element and returns what + * each renders (or the error it throws), by path. + */ + const mountEntry = `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export { routeTree } +// The routes as a router sees them (their public \`fullPath\`) +const router = createRouter({ routeTree, history: createMemoryHistory() }) +async function mountInto(path: string, element: HTMLElement) { + const route = (router.routesByPath as Record)[path] + await route.options.component.preload?.() + const root = createRoot(element) + flushSync(() => root.render(createElement(route.options.component))) +} +/** Mounts the component of the route at \`path\` into #root. */ +export async function mount(path: string) { + await mountInto(path, document.getElementById('root')!) +} +export async function renderEach(paths: Array) { + const rendered: Record = {} + for (const path of paths) { + const element = document.createElement('div') + document.body.append(element) + try { + await mountInto(path, element) + rendered[path] = element.innerHTML + } catch (error) { + rendered[path] = 'threw: ' + String(error) + } + } + return rendered +} +` + const files = { + 'label.ts': `;(globalThis as any).labelLoaded = true +export const label = 'label' +`, + 'heavy.ts': `export function heavy() { + return 'MARK_heavy_dependency_END' +} +`, + // Renders the exported component of `exported-shared` in its split + // component. + 'routes/imports-exported.tsx': `${head}import { Card } from './exported-shared' +function Page() { + return +} +export const Route = createFileRoute('/imports-exported')({ component: Page }) +`, + 'routes/__root.tsx': rootRoute, + ...Object.fromEntries( + cases.map((row) => [`routes/${row.file}.tsx`, row.route]), + ), + 'entry.ts': mountEntry, + } + + /** + * A production client build of `files` with `bundler`, or with Rsbuild + * and its production defaults (`rsbuild`). + */ + const clientBuild = ( + bundler: Bundler | 'rsbuild', + options: { + sideEffects: boolean | undefined + files: Record + registerCleanup?: () => void + }, + ) => + bundler === 'rsbuild' + ? buildWithRsbuild(options) + : build({ bundler, env: 'client', ...options }) + + describe.each([...clientBundlers, 'rsbuild'] as const)('%s', (bundler) => { + describe.each([ + { hint: 'without a sideEffects field', sideEffects: undefined }, + { hint: 'with "sideEffects": false', sideEffects: false }, + ])('$hint', ({ sideEffects }) => { + let built: Promise | undefined + const app = () => + (built ??= clientBuild(bundler, { + sideEffects, + files, + registerCleanup: () => {}, + })) + afterAll(async () => { + await (await built)?.dispose() + }) + const timeout = 120_000 + let renders: Promise> | undefined + /** What the route of each case renders when mounted, by file. */ + const rendered = async (file: string) => { + renders ??= app().then(async (result) => { + const paths = cases.map((row) => `/${row.file}`) + const run = await result.run( + `return await entry.renderEach(${JSON.stringify(paths)})`, + ) + return run.result as Record + }) + return (await renders)[`/${file}`] + } + /** + * Where the case's marked page code is in the build, and whether its + * route renders it: the page code must load with its chunk and still + * work. + */ + const outcome = async ({ file, marker: mark }: Case) => ({ + placement: (await app()).where(mark), + rendersPage: (await rendered(file))?.includes(mark), + }) + const lazyAndRendered = { placement: 'lazy', rendersPage: true } + + test.each(controls)( + '$name loads with its chunk', + async (row) => { + expect(await outcome(row)).toEqual(lazyAndRendered) + }, + timeout, + ) + + // A component the route file writes a property of, per bundler and + // hint: known-bugs-code-splitter-property-write.test.ts (its own apps). + + test.fails.each([...exported, ...unsplit])( + '$name loads with its chunk', + async (row) => { + expect(await outcome(row)).toEqual(lazyAndRendered) + }, + timeout, + ) + ;(sideEffects === false ? test : test.fails)( + `${exportedSharedByOptions.name} loads with its chunk`, + async () => { + expect(await outcome(exportedSharedByOptions)).toEqual( + lazyAndRendered, + ) + }, + timeout, + ) + + test.fails.each(['errorComponent', 'notFoundComponent'] as const)( + "a root route's %s loads lazily", + async (option) => { + expect((await app()).where(rootMarkers[option])).toBe('lazy') + }, + timeout, + ) + + test.fails( + `${destructured.name} load with their chunk or are reported`, + async () => { + const built = await app() + const reported = + findDiagnostics([...built.warnings, ...built.consoleMessages], { + severity: 'warning', + file: `routes/${destructured.file}.tsx`, + root: built.root, + }).length > 0 + expect({ + lazy: built.where(destructured.marker) === 'lazy', + reported, + }).not.toEqual({ lazy: false, reported: false }) + }, + timeout, + ) + + test.fails( + `${unreadExport.name} is not in its chunk`, + async () => { + expect((await app()).locate(unreadExport.marker).lazy).toEqual([]) + }, + timeout, + ) + }) + }) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-code-splitter-property-write.test.ts b/packages/router-plugin/tests/integration/known-bugs-code-splitter-property-write.test.ts new file mode 100644 index 0000000000..aa1a278175 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-code-splitter-property-write.test.ts @@ -0,0 +1,92 @@ +/** + * Known code-splitter bug, per bundler and side-effect hint (SPEC J2.5, G2, + * G8): a split component the route file writes a property of + * (`Page.displayName = ...`) must load with its chunk and render the + * property in every production client build. Whether a property-bearing + * component (or a support module or factory a compiler emits for it) is + * dropped from the entry is each bundler's tree-shaking decision, with and + * without `"sideEffects": false`: Vite/Rolldown, Rspack and webpack treat + * annotated factories differently, so every cell is its own outcome. Each + * cell is a small app of its own (the property write breaks today's entry + * chunk, which would take the other cases of a shared app down with it); + * the cells build concurrently. + */ +import { describe, it } from 'vitest' +import { build, buildWithRsbuild, head } from '../build-harness' +import type { TestContext } from 'vitest' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' + +const timeout = 120_000 + +const marker = 'MARK_display_name_END' + +const files = { + 'routes/__root.tsx': `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ component: () => }) +`, + 'routes/display-name.tsx': `${head}function Page() { + return
{'${marker}'}{Page.displayName}
+} +Page.displayName = 'PageDisplay' +export const Route = createFileRoute('/display-name')({ component: Page }) +`, + // Mounts the component of the route at `path` into #root (preloading it + // first when it is lazy), from the generated route tree. + 'entry.ts': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +// The routes as a router sees them (their public \`fullPath\`) +const router = createRouter({ routeTree, history: createMemoryHistory() }) +export async function mount(path: string) { + const route = (router.routesByPath as Record)[path] + await route.options.component.preload?.() + const root = createRoot(document.getElementById('root')!) + flushSync(() => root.render(createElement(route.options.component))) +} +`, +} + +// Bug: the code splitter moves a component into its chunk but leaves a +// top-level write to it (`Page.displayName = ...`) in the route module, +// where `Page` is no longer declared (in process: "top-level writes to the +// split component (property assignment) stay with the binding they write", +// pages/known-bugs-code-splitter.test.ts). The build harness rejects the +// production client output, whose entry chunk reads the undeclared `Page`. +// Keeping a copy of the component and its write in the route module as +// well is no fix: the page code then loads with the entry chunk. +// Source: #8504. +// Impact: the app's entry throws when it loads ("Page is not defined"). +describe.concurrent.each(['vite', 'rspack', 'webpack', 'rsbuild'] as const)( + '%s', + (bundler) => { + it.for([ + { hint: 'without a sideEffects field', sideEffects: undefined }, + { hint: 'with "sideEffects": false', sideEffects: false }, + ])( + 'a component the route file writes a property of loads with its chunk and renders the property ($hint)', + { timeout, fails: true }, + async ({ sideEffects }, { expect, onTestFinished }: TestContext) => { + const options = { + sideEffects, + files, + registerCleanup: onTestFinished, + } + const built = + bundler === 'rsbuild' + ? await buildWithRsbuild(options) + : await build({ + bundler: bundler satisfies Bundler, + env: 'client', + ...options, + }) + const { html } = await built.run(`await entry.mount('/display-name')`) + expect({ placement: built.where(marker), html }).toEqual({ + placement: 'lazy', + html: `
${marker}PageDisplay
`, + }) + }, + ) + }, +) diff --git a/packages/router-plugin/tests/integration/known-bugs-code-splitter-ssr-builds.test.ts b/packages/router-plugin/tests/integration/known-bugs-code-splitter-ssr-builds.test.ts new file mode 100644 index 0000000000..6ae174e424 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-code-splitter-ssr-builds.test.ts @@ -0,0 +1,416 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// page tests are in pages/known-bugs-code-splitter.test.ts. +/** + * Known code-splitter bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ +import { describe, expect, test } from 'vitest' +import { build, buildAndRun, head, routeApp } from '../build-harness' +import { loadRoute } from '../route-app' + +describe('module state shared with split chunks', () => { + // Bug: a `let` that code in another module than its declaration reassigns + // is imported there, read-only: a `let` the loader reassigns is shared, so + // the route module assigns to an import of the shared module; an exported + // `let` the split component reassigns stays in the route module, which the + // chunk imports it from ("Cannot assign to import"). + // Impact: the route cannot be built as soon as code splitting is on. + // A real build, as the user sees it: the bundler rejects the assignment. + // (Evaluated without a bundler, as in code-splitter-scope.test.ts, the + // first row throws "Assignment to constant variable" on load.) + test.fails.each([ + { + name: 'the loader reassigns', + route: `${head}let count = 0 +export const Route = createFileRoute('/')({ + loader: () => { count++; return count }, + component: () =>

{count}

, +})`, + script: `const loaded = [await entry.Route.options.loader({}), await entry.Route.options.loader({})] +return [...loaded, await entry.render(entry.Route.options.component)]`, + expected: [1, 2, '

2

'], + }, + { + name: 'the split component reassigns (exported)', + route: `${head}export let count = 0 +function Page() { + count++ + return

{count}

+} +export const Route = createFileRoute('/')({ component: Page })`, + script: `const component = entry.Route.options.component +return [await entry.render(component), await entry.render(component), entry.count]`, + expected: ['

1

', '

2

', 2], + }, + ])( + 'a let $name stays writable and the split component reads its value', + async ({ route, script, expected }) => { + expect(await buildAndRun(route, script)).toEqual(expected) + }, + 30_000, + ) +}) + +describe('split route options', () => { + /** Loads `/` with a real router and returns each match's loader data. */ + const routerEntry = `import { createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export async function load() { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: ['/'] }), + }) + await router.load() + return router.state.matches.map((match) => match.loaderData ?? null) +}` + + function loadWithSplitLoader(loader: string, declarations = '') { + return buildAndRun( + `${head}${declarations}export const Route = createFileRoute('/')({ + loader: ${loader}, + component: () =>

index

, +})`, + `return await entry.load()`, + { + files: { 'entry.ts': routerEntry }, + groupings: [['loader'], ['component']], + }, + ) + } + + // Control for the object-form loader pin below (same harness). + test('a split loader loads route data', async () => { + expect(await loadWithSplitLoader(`() => 'loaded'`)).toEqual([ + null, + 'loaded', + ]) + }, 30_000) + + // Bug: the object form `loader: { handler }` cannot be split: the virtual + // compiler throws "Unexpected splitNode type ☝️: ObjectExpression". + // Splitting only the handler, or keeping the object in the route module, + // are both valid fixes. + // Impact: a route with an object-form loader cannot be built once the + // loader is split. + test.fails.each([ + { name: 'an arrow handler', loader: `{ handler: () => 'loaded' }` }, + { name: 'a method handler', loader: `{ handler() { return 'loaded' } }` }, + { + name: 'a spread after the handler', + loader: `{ handler: () => 'loaded', ...defaults }`, + declarations: `const defaults = { staleReloadMode: 'blocking' as const }\n`, + }, + ])( + 'a split loader in object form with $name loads route data', + async ({ loader, declarations }) => { + expect(await loadWithSplitLoader(loader, declarations)).toEqual([ + null, + 'loaded', + ]) + }, + 30_000, + ) + + // Bug: an object-form loader passed by reference (`loader` holding + // `{ handler }`) is split as if it were the loader function, so the route + // calls the object ("... is not a function"). + // Impact: the route's data never loads once the loader is split. + test.fails( + 'a split loader in object form passed by reference loads route data', + async () => { + expect( + await loadWithSplitLoader( + 'loader', + `const loader = { handler: () => 'loaded' }\n`, + ), + ).toEqual([null, 'loaded']) + }, + 30_000, + ) +}) + +describe('exported bindings', () => { + /** + * An entry that imports `Route` and, like another module of the app, + * `imports` from the route file, then runs `setup` before any split chunk + * loads. + */ + const entryImporting = ( + imports: string, + setup: string, + ) => `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { Route, ${imports} } from './routes/index' +export { Route } +${setup} +export async function render(component: any) { + await component.preload?.() + return renderToString(createElement(component)) +} +` + + // Bug: a split chunk declares its own copy of the exported functions and + // classes of the route file it reads (and of the private state they read), + // so another module of the app that imports them gets other instances than + // the split component. Build-level form of "module state that the + // reference module keeps for a binding read by an exported function". + // Source: #8504 (code-splitter-exported-bindings-identity.test.ts), where + // they pass. + // Impact: `instanceof` checks, registries and counters see two copies + // once code splitting is on; module state is created twice. + test.fails.each([ + { + // An instance another module creates is an instance of the class the + // split component reads + name: 'class (instanceof)', + route: `export class Store {} +function Page() { + return

{String((globalThis as any).__store instanceof Store)}

+}`, + imports: 'Store', + setup: ';(globalThis as any).__store = new Store()', + expected: ['

true

'], + }, + { + // One state: the entry's call is the first, the split component's the + // second + name: 'function over module state', + route: `let count = 0 +export function next() { + return ++count +} +function Page() { + return

{next()}

+}`, + imports: 'next', + setup: 'next()', + expected: ['

2

'], + }, + { + // Created once and kept. The module that holds the state then has a + // top-level call, so the bundler has to keep it where it is imported + name: 'function over created state', + route: `import { init } from '../state' +const state = init({ count: 0 }) +export function increment() { + return ++state.count +} +function Page() { + return

{increment()}

+}`, + imports: 'increment', + setup: 'increment()', + expected: ['

2

', 1], + }, + { + name: 'function component', + route: `export function Card() { + return card +} +function Page() { + return

{String((globalThis as any).__Card === Card)}

+}`, + imports: 'Card', + setup: ';(globalThis as any).__Card = Card', + expected: ['

true

'], + }, + { + name: 'component and its private state', + route: `const registry = new Set() +function size() { + return registry.size +} +export function Card({ id }: { id: string }) { + registry.add(id) + return {size()} +} +function Page() { + return ( +

+ {String((globalThis as any).__Card === Card)} + +

+ ) +}`, + imports: 'Card', + setup: ";(globalThis as any).__Card = Card\nCard({ id: 'entry' })", + expected: ['

true2

'], + }, + ])( + 'the split component and other modules share an exported $name', + async ({ route, imports, setup, expected }) => { + const result = await buildAndRun( + `${head}${route} +export const Route = createFileRoute('/')({ component: Page }) +`, + `const html = await entry.render(entry.Route.options.component) +return globalThis.__inits === undefined ? [html] : [html, globalThis.__inits]`, + { + files: { + 'entry.ts': entryImporting(imports, setup), + 'state.ts': `export function init(value: T) { + ;(globalThis as any).__inits = ((globalThis as any).__inits ?? 0) + 1 + return value +} +`, + }, + }, + ) + expect(result).toEqual(expected) + }, + 30_000, + ) +}) + +/** + * The names a directory could share with the ids of the modules the + * compilers emit for a route's split component: the query keys of those + * modules' requests on a real dev server (`?tsr-split=component` gives + * `tsr-split`), else the file name of a request whose path is not the + * route file's. Read from the requests a page makes (`loadRoute`), so the + * probe follows the compiler's own id scheme (assumed to hold the same + * names in a build), each name cut into the parts a directory name can + * hold (`virtual:tsr-split` gives `virtual` and `tsr-split`). + */ +async function splitIdNames(route: string) { + const loaded = await loadRoute(route, { filename: 'routes/index.tsx' }) + const { ids } = await loaded.modules() + const names = new Set() + for (const [label, id] of Object.entries(ids)) { + if (label === 'reference') { + continue + } + const url = new URL(id, 'http://app.invalid') + const keys = [...url.searchParams.keys()] + if (keys.length > 0) { + keys.forEach((key) => names.add(key)) + } else if (url.pathname !== loaded.url) { + names.add( + url.pathname + .split('/') + .at(-1)! + .replace(/\.[^.]*$/, ''), + ) + } + } + return [ + ...new Set([...names].flatMap((name) => name.match(/[\w.-]+/g) ?? [])), + ] +} + +describe('app paths', () => { + const route = `${head}export const Route = createFileRoute('/')({ + component: () =>

index

, +})` + const script = `return await entry.render(entry.Route.options.component)` + + // Control for the `#` pin below (same app, without `#`). + test('an app builds and preloads a split component', async () => { + expect(await buildAndRun(route, script)).toBe('

index

') + }, 30_000) + + // Bug: the route module imports its chunks by absolute file path with the + // split query (`/routes/index.tsx?tsr-split=component`), and a `#` + // in the path is read as the start of a URL fragment. + // Impact: an app in a directory whose name contains `#` cannot be built + // with code splitting ([UNRESOLVED_IMPORT]). + test.fails( + 'an app in a directory with # in its name builds and preloads a split component', + async () => { + expect( + await buildAndRun(route, script, { prefix: '.regression-build-#' }), + ).toBe('

index

') + }, + 30_000, + ) + + // Bug: the code splitter compiles every module whose id contains the + // marker of its split ids (today `tsr-split`: path text, not its query) + // as a split chunk, and throws "The split value for the virtual route ... + // was not found" for the modules of an app in a directory named like + // `tsr-split-demo`. + // Source: mutation testing. + // Impact: an app in such a directory cannot be built. + // Fix-agnostic: the directory name holds what the compiler's own split + // ids hold, read from the modules a dev server serves for the route's + // split component (`splitIdNames`), whatever the compiler names them. + test.fails( + 'an app in a directory whose name contains what split module ids contain builds and preloads a split component', + async () => { + const names = await splitIdNames(route) + if (names.length === 0) { + // Nothing to probe: the pin passes, so vitest reports it (an + // expected failure must not come from the probe itself) + return + } + for (const name of names) { + expect( + await buildAndRun(route, script, { + prefix: `.regression-build-${name}-demo-`, + }), + `an app in a directory named after ${name}`, + ).toBe('

index

') + } + }, + 60_000, + ) + + // Bug: the route module's chunk importers are built by pasting the + // absolute file path into a single-quoted string + // (`import('${splitUrl}')`), so a `'` in the path ends the string early. + // Source: #7754. + // Impact: an app in a directory whose name contains `'` (e.g. a user + // folder) cannot be built or served once code splitting is on: every route + // fails with a syntax error. + test.fails( + "an app in a directory with ' in its name builds and preloads a split component", + async () => { + expect( + await buildAndRun(route, script, { prefix: ".regression-build-it's-" }), + ).toBe('

index

') + }, + 30_000, + ) +}) + +describe('code that reads a split binding', () => { + // Bug: same root cause as above, in a real build. + // Impact: the server render of the route throws "PostsPage is not defined" + // when it runs head(). + test.fails.each(['vite', 'rspack'] as const)( + 'an imported split component that head() reads renders, and head() reads it (%s build)', + async (bundler) => { + const app = await build({ + bundler, + env: 'ssr', + minify: false, + files: routeApp( + `${head}import { PostsPage } from '../posts-page' +export const Route = createFileRoute('/')({ + component: PostsPage, + head: () => ({ meta: [{ title: PostsPage.title }] }), +}) +`, + { + files: { + 'posts-page.tsx': `export function PostsPage() { + return

posts

+} +PostsPage.title = 'Posts' +`, + }, + }, + ), + }) + const { result } = await app.run( + `return [entry.Route.options.head().meta[0].title, await entry.render(entry.Route.options.component)]`, + ) + expect(result).toEqual(['Posts', '

posts

']) + }, + 60_000, + ) +}) + +// `this` in split callbacks (a split loader called as a method of its +// chunk's namespace by router-core's `lazyFn`): a runtime cause (#8688), +// not pinned in the compiler tests. diff --git a/packages/router-plugin/tests/integration/known-bugs-dev-server.test.ts b/packages/router-plugin/tests/integration/known-bugs-dev-server.test.ts new file mode 100644 index 0000000000..6f4c3cb99f --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-dev-server.test.ts @@ -0,0 +1,274 @@ +/** + * Known router plugin bugs that only show on a running dev server, after + * edits, in a real browser page. Each pin asserts correct behaviour for a + * bug on main and is marked .fails; remove .fails when the bug is fixed. + * Each pin has a control test that runs the same harness on a case that + * works. The in-process ones: ../known-bugs-dev-server.test.ts. + */ +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { routeHead } from '../build-harness' +import { routerDevServer } from '../dev-server' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +const timeout = 60_000 + +describe('a dev server compiling an edited route out of order', () => { + /** + * The page: it imports the route module from the dev server, like an app + * (the browser requests the route module and what it imports, getting + * what the dev server compiled last), then (`renderRoute()`, at once + * unless the page's URL has `?later`) loads its `component` and, when the + * route has one, its `errorComponent` (`preload()` of the real router's + * lazy route component), renders each with React into the page, and + * publishes their HTML. + */ + const page = { + 'index.html': ` + + + + + +`, + 'main.tsx': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { Route } from './routes/page' + +async function renderRoute() { +const rendered: Array = [] +const errors: Array = [] +const report = (error: unknown) => { + errors.push(error instanceof Error ? error.message : String(error)) +} +for (const option of ['component', 'errorComponent'] as const) { + const component = (Route.options as Record)[option] + if (!component) { + continue + } + await component.preload?.() + const container = document.createElement('div') + document.body.append(container) + const root = createRoot(container, { + onCaughtError: report, + onUncaughtError: report, + onRecoverableError: report, + }) + flushSync(() => root.render(createElement(component))) + rendered.push(container.innerHTML) +} +;(window as any).__rendered = { rendered, errors } +} +;(window as any).__renderRoute = renderRoute +;(window as any).__routeLoaded = true +if (!location.search.includes('later')) { + await renderRoute() +} +`, + } + + /** + * Opens the page and returns the HTML it rendered, or throws with what + * the page reported when it could not render (e.g. a module failing to + * link). + */ + async function renderInPage(server: DevServer) { + const opened = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + try { + return await renderedBy(opened) + } finally { + await opened.close() + } + } + + /** What the page rendered, once it did (see `renderInPage`). */ + async function renderedBy( + opened: BrowserPage, + ): Promise<{ rendered: Array }> { + const deadline = Date.now() + 15_000 + for (;;) { + // (A page opened after an edit loads twice: Vite's server keeps the + // edit's full reload for the next page that connects. Both loads get + // the modules as the server compiled them.) + const result = (await opened.page + .evaluate(() => (window as any).__rendered) + .catch(() => undefined)) as + | { rendered: Array; errors: Array } + | undefined + const errors = [...opened.errors, ...(result?.errors ?? [])] + if (result && errors.length === 0) { + return { rendered: result.rendered } + } + if (errors.length > 0 || Date.now() > deadline) { + throw new Error( + `the page did not render the route:\n${errors.join('\n') || '(no error)'}\nconsole:\n${opened.console.join('\n')}`, + ) + } + await new Promise((resolve) => setTimeout(resolve, 25)) + } + } + + /** + * Serves `before` as `routes/page.tsx` to a page whose dev server HMR + * client cannot connect (the WebSocket fails, as behind a proxy that + * drops it: the page gets no update of the edit), which imports the route + * module only. Edits the route to `after`. With `lazyFirst`, that page + * then loads the route's split options (`renderRoute()`: what a page + * does when it first renders the route, e.g. on navigation): the browser + * requests the split modules, and what they import, before anything + * requested the edited route module, and the dev server keeps each + * result until the next edit. Without it (the control), the page reloads + * first, which requests the route module before the rest. Then a fresh + * page loads the route from the dev server as it is now (the current + * route module and whatever it imports) and renders its components. + */ + async function editOutOfOrder( + lazyFirst: boolean, + before: string, + after: string, + ) { + const server = await routerDevServer({ + browser: true, + config: { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + }, + }, + files: { ...page, 'routes/page.tsx': before }, + }) + const stale = await openPage('about:blank', { + registerCleanup: onTestFinished, + }) + await stale.page.context().routeWebSocket(/./, (ws) => ws.close()) + await stale.page.goto(new URL('/?later', server.url).href) + await stale.page.waitForFunction(() => (window as any).__routeLoaded) + await server.edit({ 'routes/page.tsx': after }) + if (!lazyFirst) { + await stale.page.reload() + await stale.page.waitForFunction(() => (window as any).__routeLoaded) + } + // (What this page renders is the old route module's, and a stale + // module it asks for may fail as a stale request does: not judged) + await stale.page + .evaluate(() => (window as any).__renderRoute()) + .catch(() => undefined) + await stale.close() + return (await renderInPage(server)).rendered + } + + /** + * A route whose split `component` and `errorComponent` render the cards + * `CardA` and, with `cardB`, `CardB`, which counts its renders in module + * state: the two chunks share it. + */ + const cards = ( + cardB: boolean, + ) => `${routeHead()}function CardA() { return A } +${cardB ? 'let renders = 0\nfunction CardB() { renders++; return {"B" + renders} }\n' : ''}export const Route = createFileRoute('/page')({ + component: () =>

${cardB ? '' : ''}

, + errorComponent: () =>

${cardB ? '' : ''}

, +}) +` + + // Controls for the pins below (same harness): the route module requested + // first after the edit. + test.each([ + { + name: 'removing a component two split options render', + before: cards(true), + after: cards(false), + expected: ['

A

', '

A

'], + }, + { + name: 'adding a component two split options render', + before: cards(false), + after: cards(true), + expected: ['

AB1

', '

AB2

'], + }, + ])( + 'a page loading the route module first renders the edited route after $name', + async ({ before, after, expected }) => { + expect(await editOutOfOrder(false, before, after)).toEqual(expected) + }, + timeout, + ) + + // Bug: the route module's transform computes the bindings that go to the + // shared module (`?tsr-shared=1`) and stores them by file; the shared and + // split transforms read that stored set instead of deriving it from the + // code they compile (router-code-splitter-plugin.ts `sharedBindingsMap`). + // After an edit, a page can request the split modules before the route + // module: here a page whose HMR client cannot connect (so no update + // re-imports the route module) renders the route for the first time after + // the edit, which loads its split options; Vite keeps each result until + // the next edit, so every later page gets them. (With a connected HMR + // client, the update re-imports the route module first: a real page with + // route HMR and React Refresh did not reach the state in 12 tries.) + // Impact: a shared or split module requested before the route module + // compiles the new source with the previous set: a removed binding is still + // exported ("Export 'CardB' is not defined") and the page stays broken until + // the next edit or a restart; an added one is copied into each chunk instead + // of shared (two module states: each chunk's `CardB` counts its own + // renders). + // Source: #8504 code-splitter-plugin-pipeline + // .test.ts ("a dev server compiling an edited route out of order"). + // Any fix passes: the page renders the edited route, with one module + // state for what the split options share. + test.fails.each([ + { + name: 'removing a component two split options render', + before: cards(true), + after: cards(false), + expected: ['

A

', '

A

'], + }, + { + name: 'adding a component two split options render', + before: cards(false), + after: cards(true), + expected: ['

AB1

', '

AB2

'], + }, + ])( + 'a page loading the modules of the route file before the route module renders the edited route after $name', + async ({ before, after, expected }) => { + expect(await editOutOfOrder(true, before, after)).toEqual(expected) + }, + timeout, + ) + + // The same race for an exported component a split component renders, + // whose private helper the edit removes: main keeps the exported component + // and its helpers in the route module, so nothing is stored for them. + // An implementation that moves them to a module the chunk shares must not + // reach the race. Source: the #8504 probe (hybrid shared modules; #8504 + // code-splitter-plugin-pipeline.test.ts, first row). + test( + 'a page loading the modules of the route file before the route module renders the edited route after removing a helper of an exported component a split component renders', + async () => { + expect( + await editOutOfOrder( + true, + `${routeHead()}const prefix = 'a' +const suffix = 'b' +export function Card() { return {prefix}{suffix} } +export const Route = createFileRoute('/page')({ component: () => }) +`, + `${routeHead()}const prefix = 'a' +export function Card() { return {prefix} } +export const Route = createFileRoute('/page')({ component: () => }) +`, + ), + ).toEqual(['a']) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-route-hmr-components.test.ts b/packages/router-plugin/tests/integration/known-bugs-route-hmr-components.test.ts new file mode 100644 index 0000000000..ec44650bb4 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-route-hmr-components.test.ts @@ -0,0 +1,270 @@ +// Slow-tier pins of route HMR on a real page: component shapes React +// Refresh does not register. The other page pins are in +// known-bugs-route-hmr.test.ts (two files, to keep each within its time +// budget), the in-process pins in ../known-bugs-route-hmr.test.ts (fast +// tier). +/** + * Known route HMR and React Refresh bugs. Each test asserts correct behaviour + * for a bug on main and is marked .fails; remove .fails when the bug is fixed. + * + * Route HMR keeps the previous `component` (and the other component options) + * so that React Refresh can patch it in place; a component React Refresh does + * not register keeps rendering the old code until a full reload. Pins of what + * the page shows run a real dev server and a real browser page + * (`route-hmr-page.ts`): an edit must show its new code without a full + * reload and without errors in the page. A pin fails as soon as the page's + * HMR client reports the update applied without the new code showing. + * + * Concurrent: each pin has its own dev server and page, and mostly waits. + */ +import { describe, test } from 'vitest' +import { openRouteHmrPage } from '../route-hmr-page' +import { editRoute, inPlace } from '../route-hmr-edit' +import type { TestContext } from 'vitest' + +describe.concurrent('route HMR in a real page', { timeout: 60_000 }, () => { + /** A route at `/` with the `component` option `option`, after `imports`. */ + const inlineRoute = + (imports: string, option: (version: string) => string) => + (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +${imports} +export const Route = createFileRoute('/')({ + ${option(version)}, +}) +` + + // Controls for the inline component pins below (same harness): a + // component wrapped in `memo` or `forwardRef` at the option, declared + // under a name React Refresh registers, is patched in place with its + // state. + test.for(['memo', 'forwardRef'])( + 'vite: an edit of a component passed as %s(Page) shows in place with its state (autoCodeSplitting: false)', + async (wrapper: string, { expect, onTestFinished }: TestContext) => { + const route = inlineRoute('', () => `component: ${wrapper}(Page)`) + const file = 'routes/index.tsx' + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { + [file]: `import { ${wrapper}, useState } from 'react' +function Page() { + const [count, setCount] = useState(0) + return +} +${route('v1')}`, + }, + ready: 'page v1 count 0', + }) + await app.click('button') + await app.page.waitForText('page v1 count 1', { selector: '#app' }) + expect( + await app.edit( + { + [file]: `import { ${wrapper}, useState } from 'react' +function Page() { + const [count, setCount] = useState(0) + return +} +${route('v2')}`, + }, + 'page v2 count 1', + ), + ).toEqual(inPlace) + }, + ) + + // Bug: inline component options that are not plain functions (`memo(...)`, + // `forwardRef(...)`, method shorthand, a function wrapped in a TypeScript + // `as` / `satisfies`) are neither hoisted nor registered for React + // Refresh, nor is the function they wrap; route HMR keeps the previous + // component for React Refresh to patch, which it cannot. + // Impact: on unsplit routes (root routes, or file routes without automatic + // code splitting), and for a split method-shorthand component, edits to + // these components do not show until a reload. + // Source: ReactFreshBabelPlugin-test "registers likely HOCs with inline + // functions" and "registers top-level variable declarations with arrow + // functions"; #8504 react-refresh-route-components ("written inline and + // wrapped in ..."), where the wrapped rows pass; #8721 "keeps a + // method-shorthand component option" (split row). Formerly read React + // Refresh's registrations and modelled its runtime (now real tools only, + // SPEC §8). + // Any fix passes: the edit shows without a full reload. + test.fails.for([ + ...[ + ['as any', '', `(() =>

inline VERSION

) as any`], + [ + 'satisfies', + `import type { FC } from 'react'`, + `(() =>

inline VERSION

) satisfies FC`, + ], + [ + 'memo(() => ...)', + `import { memo } from 'react'`, + `memo(() =>

inline VERSION

)`, + ], + [ + 'forwardRef(function () { ... })', + `import { forwardRef } from 'react'`, + `forwardRef(function (props, ref) { + return

inline VERSION

+ })`, + ], + ].map(([name, imports, component]) => ({ + name: name!, + file: 'routes/index.tsx', + pluginOptions: { autoCodeSplitting: false }, + route: inlineRoute( + imports!, + (version) => `component: ${component!.replace('VERSION', version)}`, + ), + shows: (version: string) => `inline ${version}`, + })), + ...[false, true].map((autoCodeSplitting) => ({ + name: 'method shorthand', + file: 'routes/index.tsx', + pluginOptions: { autoCodeSplitting }, + route: inlineRoute( + '', + (version) => `component() { + return

inline ${version}

+ }`, + ), + shows: (version: string) => `inline ${version}`, + })), + { + name: 'React.memo(forwardRef(...)) on a root route', + file: 'routes/__root.tsx', + pluginOptions: { autoCodeSplitting: true }, + route: (version: string) => `import React, { forwardRef } from 'react' +import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: React.memo(forwardRef(function Root(props, ref) { + return

root ${version}

+ })), +}) +`, + shows: (version: string) => `root ${version}`, + }, + ])( + 'vite: an edit of an inline component written as $name shows in place (autoCodeSplitting: $pluginOptions.autoCodeSplitting)', + async (row, { expect, onTestFinished }: TestContext) => { + expect(await editRoute(row, onTestFinished)).toEqual(inPlace) + }, + ) + + /** + * A route at `/` whose component is `page`, declared by `declaration` + * (whose body names the version), with the other route `options`. + */ + const lowercaseRoute = + (declaration: (body: string) => string, options = '', exports = '') => + ( + version: string, + ) => `import { createFileRoute } from '@tanstack/react-router' +${declaration(`{ + return

page ${version}

+}`)} +${exports} +export const Route = createFileRoute('/')({ component: page${options} }) +` + + // Bug: a lowercase split component declared as a variable keeps its name + // in its split chunk, and React Refresh registers PascalCase names only (a + // lowercase `function` declaration is renamed, a variable is not); route + // HMR keeps the lazy component for React Refresh to patch, which it + // cannot. + // Impact: edits to the component do not show until a reload. + // Source: ReactFreshBabelPlugin-test "only registers pascal case + // functions"; the former in-process pin "registers a lowercase split + // component declared as %s" (React Refresh's registrations, read, are + // not what the page shows). Controls: the lowercase function + // declaration (split) and the unsplit variables of + // route-hmr-browser-names.test.ts. + // Any fix passes: the edit shows without a full reload or errors. + test.fails.for([ + { + name: 'an arrow function', + declaration: (body: string) => `const page = () => ${body}`, + }, + { + name: 'a function expression', + declaration: (body: string) => `const page = function page() ${body}`, + }, + ])( + 'vite: an edit of a split component declared lowercase as $name shows in place', + async ({ declaration }, { expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + file: 'routes/index.tsx', + route: lowercaseRoute(declaration), + shows: (version) => `page ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: React HMR renames a lowercase `function` component in its split + // chunk, also when the component is the unsplit `pendingComponent` too, + // so the chunk exports a binding nothing declares (the in-process pin + // "a lowercase function component that is also the unsplit + // pendingComponent renders as both", known-bugs-route-hmr.test.ts). + // Impact: in development, the route's component chunk fails to load + // (SyntaxError: Export 'SplitComponent' is not defined): the page never + // shows the route. + // Source: #8504 react-refresh-route-components ("that is also the unsplit + // pendingComponent"); the former in-process registration read. + // Any fix passes: the page shows the route, and an edit shows in place. + test.fails( + 'vite: a lowercase function component that is also the unsplit pendingComponent renders, and an edit shows in place', + async ({ expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + file: 'routes/index.tsx', + route: lowercaseRoute( + (body) => `function page() ${body}`, + ', pendingComponent: page', + ), + shows: (version) => `page ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: with React HMR, the code splitter moves a component exported by an + // export list (`export { page }`) into its chunk and leaves the export + // list in the route module (the in-process pin "a component exported by + // an export list renders for a module importing it and as the route + // component", known-bugs-route-hmr.test.ts). + // Impact: in development, the route module fails to load (SyntaxError: + // Export 'page' is not defined): the page never shows the route. + // Source: ReactFreshBabelPlugin-test "registers top-level exported function + // declarations" (`export { Baz }`). Unsplit: route-hmr-browser + // -names.test.ts. + // Any fix passes: the page shows the route, and an edit shows in place. + test.fails( + 'vite: a split component exported by an export list renders, and an edit shows in place', + async ({ expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + file: 'routes/index.tsx', + route: lowercaseRoute( + (body) => `const page = () => ${body}`, + '', + 'export { page }', + ), + shows: (version) => `page ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-route-hmr-production.test.ts b/packages/router-plugin/tests/integration/known-bugs-route-hmr-production.test.ts new file mode 100644 index 0000000000..f1fee2bf68 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-route-hmr-production.test.ts @@ -0,0 +1,71 @@ +// Production-build half of the known route HMR bugs: the page pins are in +// known-bugs-route-hmr.test.ts, the in-process pins in +// ../known-bugs-route-hmr.test.ts (fast tier). +/** + * Known route HMR bugs in production builds. Each test asserts correct + * behaviour for a bug on main and is marked .fails; remove .fails when the + * bug is fixed. + */ +import { describe, expect, test } from 'vitest' +import { build, head, routeApp } from '../build-harness' +import type { Bundler } from '@tanstack/compiler-test-utils/build-harness' + +describe('production builds', () => { + /** + * Builds a production client bundle with automatic code splitting on or + * off (off: the route HMR plugin's case), the plugin's own `addHmr` + * default and `NODE_ENV=production` (the harness's default for a + * production build), and returns where a bundler HMR API is used. + */ + async function hmrPlacement(bundler: Bundler, autoCodeSplitting: boolean) { + const app = await build({ + bundler, + env: 'client', + pluginOptions: { + autoCodeSplitting, + codeSplittingOptions: { addHmr: undefined }, + }, + files: routeApp( + `${head}function Page() { + return

page

+} +export const Route = createFileRoute('/')({ component: Page }) +`, + { env: 'client' }, + ), + }) + return app.where(/import\.meta\.(?:webpackHot|hot)\b|\bmodule\.hot\b/) + } + + // No Vite rows: Vite replaces `import.meta.hot` with `undefined` in a + // build and drops the code it guards, so they could not fail. + + // Control for the pin cited below: with `NODE_ENV=production` exported. + test.each(['rspack', 'webpack'] as const)( + 'a production client bundle has no route HMR code (%s)', + async (bundler) => { + expect(await hmrPlacement(bundler, false)).toBe('nowhere') + }, + 60_000, + ) + + // (No esbuild row: the esbuild plugin neither + // generates nor splits routes, pinned in build-harness.test.ts, so it + // could not fail.) + test.each(['rspack', 'webpack'] as const)( + 'a production client bundle with automatic code splitting has no route HMR code (%s)', + async (bundler) => { + expect(await hmrPlacement(bundler, true)).toBe('nowhere') + }, + 60_000, + ) + + // The pin of the control above (`NODE_ENV` unset: the route HMR plugin + // follows `NODE_ENV` at plugin creation, not the bundler's mode) is + // "rspack/webpack a production react client bundle without code splitting + // has no dev-only code" in + // build-production.test.ts and build-production-webpack.test.ts: the same + // build (React, automatic code splitting off, the plugin's `addHmr` + // default, `NODE_ENV` unset), whose check of the bundlers' hot APIs + // includes this one's. +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-route-hmr-removals.test.ts b/packages/router-plugin/tests/integration/known-bugs-route-hmr-removals.test.ts new file mode 100644 index 0000000000..1912b6e7a8 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-route-hmr-removals.test.ts @@ -0,0 +1,260 @@ +// Slow-tier pins of route HMR in a real page (continued from +// known-bugs-route-hmr.test.ts: two files, to keep each within the per-file +// time budget): edits that remove options, aliased route exports, and +// error boundaries. +/** + * Known route HMR and React Refresh bugs. Each test asserts correct behaviour + * for a bug on main and is marked .fails; remove .fails when the bug is fixed. + * See known-bugs-route-hmr.test.ts for how the pins observe the page. + */ +import { describe, test } from 'vitest' +import { isAppError, openRouteHmrPage } from '../route-hmr-page' +import { editRoute, inPlace } from '../route-hmr-edit' +import type { TestContext } from 'vitest' +import type { RouteHmrPageOptions } from '../route-hmr-page' + +describe.concurrent('route HMR in a real page', { timeout: 60_000 }, () => { + /** A React route at `/` whose component, `name`, keeps a click count. */ + const counterRoute = ( + version: string, + name = 'Page', + options = '', + ) => `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +function ${name}() { + const [count, setCount] = useState(0) + return +} +function Failed() { + return

failed ${version}

+} +export const Route = createFileRoute('/')({ + component: ${name}, + ${options} +}) +` + + /** + * The index route whose loader throws, with (`errorComponent: Failed`) or + * without its error component: without it, the router's default error + * component shows the error. + */ + const failingRoute = (version: string, errorComponent: boolean) => + counterRoute( + version, + 'Page', + `${errorComponent ? 'errorComponent: Failed,\n ' : ''}loader: () => { + throw new Error('loader failed') + },`, + ) + + /** + * Opens an app whose index route shows its error component, edits the + * route so that it has no error component anymore, and returns the result + * of the edit (without the deliberate loader error the app reports) once + * the page shows the router's default error component. + */ + async function removeErrorComponent( + options: Pick, + onTestFinished: TestContext['onTestFinished'], + ) { + const app = await openRouteHmrPage({ + ...options, + onTestFinished, + files: { 'routes/index.tsx': failingRoute('v1', true) }, + ready: 'failed v1', + }) + const result = await app.edit( + { 'routes/index.tsx': failingRoute('v2', false) }, + /^(?!.*failed v).*loader failed/, + ) + return { + reloaded: result.reloaded, + errors: result.errors.filter( + (error) => !isAppError(error, 'loader failed'), + ), + } + } + + // Bug: an edit that removes a split component option (here + // `errorComponent`, which the page had loaded) leaves its split module in + // Vite's module graph; Vite updates it with the rest of the route file, the + // code splitter serves it without any export or import, and + // `@vitejs/plugin-react` compiles that module's JSX as CommonJS + // (`require("react/jsx-dev-runtime")`). + // Impact: the page logs "[vite] ReferenceError: require is not defined" + // and "[vite] Failed to reload /routes/index.tsx?tsr-split=errorComponent"; + // some runs reload the page. + // Source: router-plugin src/core/code-splitter (the virtual split module + // of an option the route file no longer has); NEW (hmr-real). + // Goal (any fix): the edit applies in place, and the page logs no error. + test.fails( + 'vite: an edit that removes a split option the page loaded applies in place without errors', + async ({ expect, onTestFinished }: TestContext) => { + expect( + await removeErrorComponent( + { pluginOptions: { autoCodeSplitting: true } }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Controls for the pin above: the same removal applies in place where the + // option was not split (Vite), and on Rsbuild (its hot update replaces the + // route module and its chunks together). + test.for([ + { bundler: 'vite', autoCodeSplitting: false }, + { bundler: 'rsbuild', autoCodeSplitting: true }, + { bundler: 'rsbuild', autoCodeSplitting: false }, + ] as const)( + '$bundler: an edit that removes a component option the page loaded applies in place without errors (autoCodeSplitting: $autoCodeSplitting)', + async ( + { bundler, autoCodeSplitting }, + { expect, onTestFinished }: TestContext, + ) => { + expect( + await removeErrorComponent( + { bundler, pluginOptions: { autoCodeSplitting } }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: `handleRouteUpdate` keeps the previous component options for React + // Refresh to patch in place, also when no React Refresh runtime is + // installed (an Rsbuild React app with `pluginReact({ fastRefresh: false + // })`, or webpack / Rspack without a refresh plugin, like the webpack + // quickstart example with the default `addHmr`), so the new component + // never renders. With automatic code splitting, the kept component is the + // old chunk's. + // Impact: the bundler reports the route as hot-updated, but the page shows + // the old component until a reload; without the route HMR code the same + // edit reloads the page. + // Goal: a hot update rendering the new component (mounted anew, without a + // refresh runtime), without a full reload. + test.fails.for([true, false])( + 'rsbuild without React Refresh: an edit of the route component shows in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + expect( + await editRoute( + { + bundler: 'rsbuild', + reactRefresh: false, + pluginOptions: { autoCodeSplitting }, + file: 'routes/index.tsx', + route: (version) => counterRoute(version), + shows: (version) => `Page ${version} count`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + /** A route at `/` declared under another name and exported as `Route`. */ + const aliasedRoute = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +const MyRoute = createFileRoute('/')({ + loader: () => 'data ${version}', + component: () =>

page {MyRoute.useLoaderData()}

, +}) +export { MyRoute as Route } +` + + // Bug: the injected HMR code reads the module's route through the + // identifier `Route`, but a route may be declared under another name and + // exported as `Route` (`export { MyRoute as Route }`). + // Impact: Rsbuild (webpack-style HMR) apps throw "Route is not defined" + // when the route module loads in development, so the page never renders; + // Vite apps throw on the first hot update of the route, which never shows. + // Control: the ordinary `export const Route` of every other test here. + describe.each(['vite', 'rsbuild'] as const)('%s', (bundler) => { + test.fails( + 'a route exported under another local name is hot-updated in place', + async ({ expect, onTestFinished }: TestContext) => { + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + files: { 'routes/index.tsx': aliasedRoute('v1') }, + ready: 'page data v1', + }) + expect( + await app.edit( + { 'routes/index.tsx': aliasedRoute('v2') }, + 'page data v2', + ), + ).toEqual(inPlace) + }, + ) + }) + + /** + * The index route of an app without automatic code splitting (the route + * HMR plugin alone) whose `pendingComponent` renders an `ErrorBoundary` + * (`react-error-boundary`) around a child that throws, with the lowercase + * `errorFallback` component as its fallback; `errorComponent` reads the + * same component when `alsoErrorComponent`. The loader never settles, so + * the pending component shows. + */ + const errorBoundaryRoute = (alsoErrorComponent: boolean) => + `import { createFileRoute } from '@tanstack/react-router' +import { ErrorBoundary } from 'react-error-boundary' +const errorFallback = () =>

fallback shown

+function Thrower() { + throw new Error('child failed') +} +export const Route = createFileRoute('/')({ + loader: () => new Promise(() => {}), + pendingMs: 0, + pendingMinMs: 0, + pendingComponent: () => ( + + + + ),${alsoErrorComponent ? '\n errorComponent: errorFallback,' : ''} +}) +` + + // Control for the hoisted inline component pin below (same harness): an + // inline component reading a lowercase component renders it (the real + // `react-error-boundary` shows the fallback once its child throws). + test('vite: an inline pending component rendering an error boundary with a lowercase fallback shows the fallback', async ({ + expect, + onTestFinished, + }: TestContext) => { + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { 'routes/index.tsx': errorBoundaryRoute(false) }, + ready: 'fallback shown', + }) + expect( + app.page.errors.some((error) => error.includes('child failed')), + ).toBe(true) + }) + + // Bug: React HMR hoists inline component options into declarations it + // inserts after visiting every option, and renames a lowercase component + // passed to a later option. The rename only reaches nodes attached to the + // program, so a hoisted component still reads the old name. + // Impact: in development, the hoisted component throws when it renders + // (ReferenceError: errorFallback is not defined). + // Fix: rename before hoisting (or insert hoisted declarations immediately), + // or rename through the analyzer's binding references. + test.fails( + 'vite: an inline pending component hoisted before a renamed lowercase component renders it', + async ({ onTestFinished }: TestContext) => { + await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { 'routes/index.tsx': errorBoundaryRoute(true) }, + ready: 'fallback shown', + }) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-route-hmr.test.ts b/packages/router-plugin/tests/integration/known-bugs-route-hmr.test.ts new file mode 100644 index 0000000000..a2857bdba0 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-route-hmr.test.ts @@ -0,0 +1,406 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// in-process tests are in ../known-bugs-route-hmr.test.ts (fast tier); the +// production-build pins are in known-bugs-route-hmr-production.test.ts. +/** + * Known route HMR and React Refresh bugs. Each test asserts correct behaviour + * for a bug on main and is marked .fails; remove .fails when the bug is fixed. + * + * Route HMR keeps the previous `component` (and the other component options) + * so that React Refresh can patch it in place; a component React Refresh does + * not register keeps rendering the old code until a full reload. Pins of what + * the page shows run a real dev server and a real browser page + * (`route-hmr-page.ts`): an edit must show its new code without a full + * reload and without errors in the page. A pin fails as soon as the page's + * HMR client reports the update applied without the new code showing. + * + * Concurrent: each pin has its own dev server and page, and mostly waits. + * The pins of component shapes React Refresh does not register (inline + * wrapped components, lowercase split components) are in + * known-bugs-route-hmr-components.test.ts (two files, to keep each within + * its time budget). + */ +import { describe, test } from 'vitest' +import { + expectEditShownOrReportedFallback, + openRouteHmrPage, +} from '../route-hmr-page' +import { editRoute, inPlace } from '../route-hmr-edit' +import type { TestContext } from 'vitest' + +describe.concurrent('route HMR in a real page', { timeout: 60_000 }, () => { + /** A React route at `/` whose component, `name`, keeps a click count. */ + const counterRoute = ( + version: string, + name = 'Page', + options = '', + ) => `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +function ${name}() { + const [count, setCount] = useState(0) + return +} +function Failed() { + return

failed ${version}

+} +export const Route = createFileRoute('/')({ + component: ${name}, + ${options} +}) +` + + /** + * A route file of `target` at `/` whose loader and component name the + * version of the file; the component declares its own `Page`. + */ + const frameworkRoute = (target: 'solid' | 'vue') => (version: string) => + `import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return

page ${version} {${target === 'vue' ? 'data.value' : 'data()'}}

+} +` + + // Bug: route HMR keeps the previous split components only for React: for + // Solid and Vue, the route module creates a new lazy component on every + // update and `handleRouteUpdate` keeps no component option + // (`getFrameworkHmrCompilerPlugins` returns no plugin and the kept + // component keys are empty for other targets); in Vite, the route module + // is not an HMR boundary either (its accept call is on an alias), so the + // page reloads. + // Impact: every edit of a split Solid/Vue route remounts the route + // component: the router renders a new component, so the page loses the + // component's local state (signals, refs, form input) on both hosts, and + // on Vite the whole document reloads, losing all client state. Rsbuild's + // new text alone does not prove that the live component kept its identity. + // Goal (any fix): with either host and the framework's plugin, the + // edit shows without a full reload, and the live route keeps the component + // the page rendered. + // SPEC J3.2: Solid/Vue split components keep their identity across hot + // updates, as React's do. + test.fails.for( + (['vite', 'rsbuild'] as const).flatMap((bundler) => + (['solid', 'vue'] as const).map((target) => ({ bundler, target })), + ), + )( + '$bundler: an edit of a split $target route shows in place, keeping the split component', + async ({ bundler, target }, { expect, onTestFinished }: TestContext) => { + const route = frameworkRoute(target) + const app = await openRouteHmrPage({ + bundler, + target, + onTestFinished, + files: { 'routes/index.tsx': route('v1') }, + ready: 'page v1 data v1', + }) + const liveComponent = `window.__APP_ROUTER__.routesById['/'].options.component` + await app.evaluate(`window.shownComponent = ${liveComponent}`) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'page v2 data v2'), + ).toEqual(inPlace) + expect( + await app.evaluate(`window.shownComponent === ${liveComponent}`), + ).toBe(true) + }, + ) + + // Bug: the Vite route HMR code calls `accept` on a local alias + // (`const hot = import.meta.hot`), and Vite only marks a module + // self-accepting when its code contains a literal `import.meta.hot.accept(`. + // A route module is then never an HMR boundary of its own: the update + // propagates to the route tree and the app entry, and the page reloads. + // React apps are not affected because React Refresh makes route modules + // boundaries (route-hmr-browser.test.ts); Solid Refresh only does for + // modules that declare components (route-hmr-browser-frameworks.test.ts: + // an unsplit Solid route applies in place), and Vue JSX only for + // `defineComponent` components. + // Impact: every edit of a Vue route file reloads the page in Vite dev (and + // of a split Solid route: the pin above). + // Any boundary (the route module or an importer that accepts it) passes. + test.fails( + 'vite: an edit of an unsplit Vue route shows in place', + async ({ expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + target: 'vue', + pluginOptions: { autoCodeSplitting: false }, + file: 'routes/index.tsx', + route: frameworkRoute('vue'), + shows: (version) => `page ${version} data ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: on Rsbuild, an edit of an unsplit Solid route file (the route HMR + // plugin alone) shows its new loader data but keeps rendering the old + // component. The webpack-style route HMR code runs before Solid Refresh's + // `$$refresh(…, module.hot, registry)` in the route module and assigns + // `hot.data ??= {}` on the first run; Solid Refresh takes a truthy + // `hot.data` for the data of a previous run, so its dispose handler saves + // that object's (missing) registry instead of its own, and the next update + // has no registry to patch the live component with. Split Solid routes on + // Rsbuild (no route HMR code in the component's module), a plain Solid + // component module on Rsbuild, and unsplit Solid routes in Vite apply in + // place (route-hmr-browser-frameworks.test.ts). + // Impact: edits of a Solid route's component do not show until a reload + // in an Rsbuild app without automatic code splitting. + // Source: router-plugin src/core/hmr/webpack-adapter.ts:71 (`const hotData + // = hot.data ??= {}`); solid-refresh 0.6.3 `$$refreshStandard` (reads + // `hot.data` as the previous run). Found in review; cause located by a + // probe (reading `hot.data` without assigning it passes this pin; + // reverted). + test.fails( + 'rsbuild: an edit of an unsplit Solid route shows its new component in place', + async ({ expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + bundler: 'rsbuild', + target: 'solid', + pluginOptions: { autoCodeSplitting: false }, + file: 'routes/index.tsx', + route: frameworkRoute('solid'), + shows: (version) => `page ${version} data ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: the same on an edit of a Solid root route, whose module always + // holds its component and the route HMR code (root routes are never + // split): the page keeps showing the old root component, with or without + // automatic code splitting. Vite applies the same edit in place + // (route-hmr-browser-frameworks.test.ts). SPEC J3.5. + // Impact: edits of a Solid app's root component (its layout) do not show + // until a reload on Rsbuild. + test.fails.for([true, false])( + 'rsbuild: an edit of a Solid root route shows its new component in place (autoCodeSplitting: %s)', + async (autoCodeSplitting, { expect, onTestFinished }: TestContext) => { + expect( + await editRoute( + { + bundler: 'rsbuild', + target: 'solid', + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': frameworkRoute('solid')('v1') }, + file: 'routes/__root.tsx', + route: (version) => + `import { Outlet, createRootRoute } from '@tanstack/solid-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + return

root ${version}

+} +`, + shows: (version) => `root ${version}page v1 data v1`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: a route a helper function of the route file creates + // (`export const Route = makeRoute()`) edited without automatic code + // splitting (the route HMR plugin alone) shows its new loader data but + // keeps rendering the old inline component, and nothing warns: the route + // HMR code keeps the previous component for React Refresh to patch, but + // the component inside the helper is neither hoisted nor registered. With + // automatic code splitting, and for an IIFE, the edit shows + // (route-hmr-browser-plugin.test.ts). + // Impact: edits of such a route's component do not show until a reload, + // silently. + // Source: review (found by the real page; the former in-process model + // compared a component whose text did not change between versions). + // SPEC J2.10, J2.8: same-file route factories are + // unsupported but user-fixable. Any fix passes: the edit takes effect + // without errors, in place, or, when the compiler warns naming the route + // file through a real channel (the dev server's logger or console, or the + // page), possibly after a reload. A warning never excuses an edit that + // does not show (SPEC G10; `expectEditShownOrReportedFallback`). + // Silent wrong output fails. + test.fails.for(['vite', 'rsbuild'] as const)( + '%s: an edit of a route a helper function creates shows its new component, reloading only when the file is reported (autoCodeSplitting: false)', + async (bundler: 'vite' | 'rsbuild', { onTestFinished }: TestContext) => { + const route = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +function makeRoute() { + return createFileRoute('/')({ + loader: () => 'data ${version}', + component: () =>

helper ${version} {Route.useLoaderData()}

, + }) +} +export const Route = makeRoute() +` + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { 'routes/index.tsx': route('v1') }, + ready: 'helper v1 data v1', + }) + await expectEditShownOrReportedFallback( + app, + { 'routes/index.tsx': route('v2') }, + 'helper v2 data v2', + 'routes/index.tsx', + ) + }, + ) + + /** A root route rendering the loader data of the active matches. */ + const rootShowingLoaderData = `import { createRootRoute, Outlet, useRouterState } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: () => { + const data = useRouterState({ + select: (state) => state.matches.map((match) => match.loaderData ?? '').join(''), + }) + return

root {data}

+ }, +}) +` + + // Bug: same root cause as the pin above, for a React route file without + // JSX (`.ts`): React Refresh registers no component in it, so it is not a + // boundary either. + // Source: round-3 mutation testing (route HMR side finding). + // Impact: every edit of a React `.ts` route file reloads the page in Vite + // dev. + test.fails.for([true, false])( + 'vite: an edit of a React .ts route module shows its new loader data in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + expect( + await editRoute( + { + pluginOptions: { autoCodeSplitting }, + files: { 'routes/__root.tsx': rootShowingLoaderData }, + file: 'routes/index.ts', + route: (version) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ loader: () => 'data ${version}' }) +`, + shows: (version) => `root data ${version}`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: same root cause, for a React app without `@vitejs/plugin-react` + // (Vite compiles the JSX itself; nothing registers React Refresh + // boundaries): the route module's own accept call is on an alias, so the + // page reloads on every edit. (Without a refresh runtime, the new + // component may be mounted anew: a subtree replacement, not a document + // reload.) + // Impact: every edit of a route file reloads the page in a Vite React app + // without the React plugin. + test.fails.for([true, false])( + 'vite: an edit of a route component in an app without @vitejs/plugin-react shows in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + expect( + await editRoute( + { + frameworkPlugin: false, + pluginOptions: { autoCodeSplitting }, + file: 'routes/index.tsx', + route: (version) => counterRoute(version), + shows: (version) => `Page ${version} count`, + }, + onTestFinished, + ), + ).toEqual(inPlace) + }, + ) + + // Bug: `handleRouteUpdate` keeps the previous component options so that + // React Refresh patches them in place, also when the edit replaced the + // component with another one (renamed, so another component family for + // React Refresh), which React Refresh never patches. With automatic code + // splitting, the kept lazy component keeps the component its chunk loaded + // first. The same happens when an edit replaces inline route options of a + // split route with options a factory call builds. + // Impact: after renaming a route's component, the page keeps showing the + // old component until a reload (Vite and Rsbuild). + // Source: router-plugin src/core/hmr/handle-route-update.ts (component + // keys kept whenever both versions have them); NEW (hmr-real, found by the + // real-page harness; the former model treated it as expected). + // Goal: a hot update rendering the new component (React mounts it anew), + // without a full reload or errors. + describe.each(['vite', 'rsbuild'] as const)('%s', (bundler) => { + test.fails.for([true, false])( + 'renaming the route component shows the renamed component in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': counterRoute('v1') }, + ready: 'Page v1 count 0', + }) + expect( + await app.edit( + { 'routes/index.tsx': counterRoute('v2', 'Renamed') }, + 'Renamed v2 count', + ), + ).toEqual(inPlace) + }, + ) + }) + + // Bug: on Rsbuild (Rspack), an edit that only changes a loader split from + // the route module (`codeSplitGroupings` with `loader` in a chunk) never + // reaches the page: the route module's code is unchanged, so Rspack does + // not run it again and the route HMR code (`webpack-adapter.ts`, in the + // route module only) never refreshes the route; the split loader module + // accepts no update of its own. The next load gets the new loader, but + // nothing reloads the route. Vite updates the route in place + // (route-hmr-browser.test.ts). + // Impact: the page keeps the old loader's data until a reload or a + // navigation, with no sign that the edit was not applied. + // Source: router-plugin src/core/hmr/webpack-adapter.ts (HMR code only in + // the route module); NEW (hmr-real). + // Goal: a hot update showing the new loader's data, without a full reload. + test.fails.for([`[['loader'], ['component']]`, `[['component', 'loader']]`])( + 'rsbuild: an edit of a split loader (codeSplitGroupings: %s) shows its data in place', + async (groupings: string, { expect, onTestFinished }: TestContext) => { + const route = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +function Page() { + return

{Route.useLoaderData()}

+} +export const Route = createFileRoute('/')({ + loader: () => 'loader ${version}', + component: Page, + codeSplitGroupings: ${groupings}, +}) +` + const app = await openRouteHmrPage({ + bundler: 'rsbuild', + onTestFinished, + files: { 'routes/index.tsx': route('v1') }, + ready: 'loader v1', + }) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'loader v2'), + ).toEqual(inPlace) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator-physical.test.ts b/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator-physical.test.ts new file mode 100644 index 0000000000..94af85d476 --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator-physical.test.ts @@ -0,0 +1,42 @@ +/** + * Pins of the route generator on a running Rsbuild dev server (scenarios: + * `generator-dev-scenarios.ts`). Each pin's controls pass on Vite (the same + * scenario in dev-server-generator.test.ts and dev-server-new-routes.test.ts). + * + * The Rspack (and webpack) generator plugin watches the routes directory + * itself only for created files; the other route file events reach it + * through the bundler's watcher, which only watches the modules of the + * bundle. A route file outside both never runs the generator, so nothing + * happens at all: each pin waits for the outcome of a correct generator for + * a bounded time (`settleTimeout`, generous next to the second a correct one + * takes), then fails. + * + * The created broken route file pin is in known-bugs-rsbuild-generator.test.ts + * (one pin per file: each waits its full `settleTimeout`). + */ +import { test } from 'vitest' +import { expectPhysicalMountRouteFile } from '../generator-dev-scenarios' + +/** How long a pin waits for the outcome of a correct generator. */ +const settleTimeout = 6_000 + +// Control: "a route file created, edited and deleted under a physical() +// mount outside the routes directory reaches the live routes" +// (dev-server-generator.test.ts, Vite). +// Bug: a route file created under a `physical()` mount outside the routes +// directory never runs the generator: the generator's own watcher watches the +// routes directory only, and the new file is in no bundle yet. +// Source: packages/router-plugin/src/core/router-generator-plugin.ts:93-97 +// (webpack: :121-125); SPEC J1.10 makes route files under `physical()` +// mounts delivered edits like route-directory files. +// Impact: on Rsbuild, Rspack and webpack dev servers, a route created in a +// directory a virtual route config mounts with `physical()` is missing from +// the app until another route file is created in the routes directory or the +// dev server restarts. +test.fails( + 'a route file created under a physical() mount outside the routes directory reaches the live routes', + async () => { + await expectPhysicalMountRouteFile('rsbuild', settleTimeout) + }, + 30_000, +) diff --git a/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator.test.ts b/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator.test.ts new file mode 100644 index 0000000000..2c17d9294c --- /dev/null +++ b/packages/router-plugin/tests/integration/known-bugs-rsbuild-generator.test.ts @@ -0,0 +1,49 @@ +/** + * Pins of the route generator on a running Rsbuild dev server (scenarios: + * `generator-dev-scenarios.ts`). Each pin's controls pass on Vite (the same + * scenario in dev-server-generator.test.ts and dev-server-new-routes.test.ts). + * + * The Rspack (and webpack) generator plugin watches the routes directory + * itself only for created files; the other route file events reach it + * through the bundler's watcher, which only watches the modules of the + * bundle. A route file outside both never runs the generator, so nothing + * happens at all: each pin waits for the outcome of a correct generator for + * a bounded time (`settleTimeout`, generous next to the second a correct one + * takes), then fails. + * + * The `physical()` mount pin is in known-bugs-rsbuild-generator-physical + * .test.ts: each pin waits its full `settleTimeout`, so one pin per file + * keeps each file within its time budget. + */ +import { test } from 'vitest' +import { + createdBrokenRouteFiles, + expectCreatedBrokenRouteFileFixed, +} from '../generator-dev-scenarios' + +/** How long a pin waits for the outcome of a correct generator. */ +const settleTimeout = 6_000 + +// Control: "a created route file the generator cannot parse is reported, +// and fixing it adds the route" (dev-server-new-routes.test.ts, Vite). +// Bug: a created route file the generator leaves out of the route tree (it +// cannot parse it) is not in the bundle, so the edit that fixes it never runs +// the generator. +// Source: packages/router-plugin/src/core/router-generator-plugin.ts:93-97 +// (chokidar `add` only, on the routes directory; webpack: :121-125). +// Impact: on Rsbuild, Rspack and webpack dev servers, a new route file saved +// before it exports a valid `Route` (unparsable, or no `Route` export yet: +// the same path) stays out of the route tree, keeping the path it was +// written with, until another route file is created or the dev server +// restarts. +test.fails( + 'a created route file the generator cannot parse is reported, and fixing it adds the route', + async () => { + await expectCreatedBrokenRouteFileFixed( + 'rsbuild', + createdBrokenRouteFiles[0]!.initial, + settleTimeout, + ) + }, + 30_000, +) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-dead-code-shapes.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-dead-code-shapes.test.ts new file mode 100644 index 0000000000..060f73e001 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-dead-code-shapes.test.ts @@ -0,0 +1,108 @@ +/** + * What the route module drops with an option the router plugin removes from + * it: a split option (moved to its chunk, SPEC J2.5) and a `deleteNodes` + * option (J2.14, Start's client `server` handlers). The removal takes with + * it, in the route module, what only the removed option used, whatever the + * shape of the code in between (G16): nothing that loads with the route + * requests the module only that option imports. Kept code keeps what it + * reads, and code already dead before the transform keeps running (G3). + * Each route runs in a real browser page served by a real Vite dev server + * with the public router plugin (`route-app.ts`). The same shapes run + * through every removal of the Start compiler in start-plugin-core + * (`@tanstack/compiler-test-utils/dead-code-shapes`). + */ +import { describe, expect, it } from 'vitest' +import { + deadCodeShapes, + depSource, + recordFile, + shapeSetup, +} from '@tanstack/compiler-test-utils/dead-code-shapes' +import { expectValidModules, head, loadRoute } from '../../route-app' +import type { RouteAppOptions } from '../../route-app' + +interface Removal { + name: string + /** The route options around `root`, the expression the removed option returns. */ + options: (root: string) => string + routeOptions?: RouteAppOptions + /** The page script that gives what the removed option gives, and its value. */ + check: (expected: unknown) => { script: string; expected: unknown } +} + +const removals: Array = [ + { + name: 'a split component', + options: (root) => `component: () =>

{${root}}

,`, + check: (expected) => ({ + script: `return render('component')`, + expected: `

${expected}

`, + }), + }, + { + // Start's client configuration (SPEC §1.1); the server keeps the + // handlers (start-plugin-core integration/start-compose-server-only-routes.test.ts). + name: 'server handlers deleteNodes removes', + options: ( + root, + ) => `server: { handlers: { GET: () => new Response(String(${root})) } }, +component: () =>

page

,`, + routeOptions: { deleteNodes: ['server'] }, + check: () => ({ + script: `return ['server' in options, await render('component')]`, + expected: [false, '

page

'], + }), + }, +] + +/** + * Cells main gets wrong (KNOWN-BUGS S7): the route module keeps the class of + * a class and const cycle only the removed option used, and drops the const + * its static field reads (`ReferenceError` when the route module loads). + */ +const failsToday = new Set([ + 'a split component: a class and a const that read each other', + 'server handlers deleteNodes removes: a class and a const that read each other', +]) + +describe.each(removals)('$name', (removal) => { + for (const shape of deadCodeShapes) { + it( + `takes with it what only it uses through ${shape.name}`, + { fails: failsToday.has(`${removal.name}: ${shape.name}`) }, + async () => { + // A kept loader reads the shared declaration (loaders stay in the + // route module under the default groupings). + const loader = shape.kept + ? `loader: () => ${shape.kept.expression},\n` + : '' + const route = await loadRoute( + `${head}${shapeSetup(shape, './dep')} +export const Route = createFileRoute('/')({ +${loader}${removal.options(shape.root)} +}) +`, + { + ...removal.routeOptions, + files: { 'dep.ts': depSource, ...recordFile }, + }, + ) + await expectValidModules(route) + const { script, expected } = removal.check(shape.expected) + expect(await route.run(script)).toEqual(expected) + if (shape.kept) { + expect(await route.run(`return options.loader()`)).toEqual( + shape.kept.expected, + ) + } else { + expect(await route.requested()).not.toContain('/dep.ts') + } + if (shape.alreadyDead) { + expect( + await route.run(`return [...(await app('record.ts')).calls]`), + ).toContain('dead') + } + }, + ) + } +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-dead-code.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-dead-code.test.ts new file mode 100644 index 0000000000..052aef8deb --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-dead-code.test.ts @@ -0,0 +1,914 @@ +/** + * Dead code around split route options: what the route module keeps, what + * moves into a chunk, and that every surviving effect runs once (SPEC + * J2.5, J2.12, G1, G3). Each route runs in a real browser page served by a + * real Vite dev server with the public router plugin (`route-app.ts`); the + * route's other modules are files of the app, which record what runs. J2.5 + * absence checks read the modules the page loads: a user marker (a decoded + * string of the user's code), never declared names, import specifiers or + * printed text; what an unused import leaves is judged in a production + * build of the app, after tree-shaking (SPEC J2.5, §5.9). + */ +import { describe, expect, it } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, + uncaughtErrors, +} from '../../route-app' +import type { RouteAppOptions } from '../../route-app' + +/** + * The route compiled without and with React HMR: HMR rewrites the route + * options (hoisted components, refresh anchor) before dead code is removed, + * so the removal runs on a different program. + */ +const hmrModes = [{ hmr: false }, { hmr: true }] + +/** A package of the app (`node_modules/`), ES module `source`. */ +function appPackage(name: string, source: string) { + return { + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: source, + } +} + +/** A module recording what runs, in `calls` (read it with `app('calls.ts')`). */ +const callsModule = { 'calls.ts': 'export const calls: Array = []\n' } + +/** + * Renders the split component the way an app loads it: the route module (and + * what it imports) runs first, then the component loads lazily, every module + * linked to the others. A top-level statement may then reach the component + * by moving into its chunk or by staying in the route module and writing to + * a shared binding. + */ +async function renderSplitComponent( + code: string, + options: RouteAppOptions = {}, +) { + return (await loadRoute(code, options)).run( + `return render('component')`, + ) +} + +describe('the reference module only drops code that splitting left unused', () => { + // Each stub calls back what it is given, so a kept declaration that lost + // what it reads throws (an uncaught error of the page). + const callbackStubs = { + ...callsModule, + 'store.ts': `import { calls } from './calls' +export const store = { + state: { done: true }, + subscribe: (listener: () => void) => { + calls.push('subscribe') + queueMicrotask(listener) + return () => {} + }, +} +`, + 'persist.ts': `import { calls } from './calls' +export const createPersister = ({ onRestore }: { onRestore: () => void }) => { + calls.push('createPersister') + queueMicrotask(onRestore) + return { restore: () => calls.push('restore') } +} +`, + 'registry.ts': `import { calls } from './calls' +export const register = (read: () => unknown) => { + calls.push('register') + queueMicrotask(read) + return read +} +`, + } + + describe.each(hmrModes)('with hmr: $hmr', ({ hmr }) => { + it.each([ + { + name: 'a store subscription that unsubscribes itself', + setup: `import { store } from './store' +const unsubscribe = store.subscribe(() => { + if (store.state.done) unsubscribe() +})`, + calls: ['subscribe'], + }, + { + name: 'mutually-referencing declarations', + setup: `import { createPersister } from './persist' +const persister = createPersister({ onRestore: () => restore() }) +function restore() { + persister.restore() +}`, + calls: ['createPersister', 'restore'], + }, + { + // A reference cycle longer than two declarations: d closes it + name: 'a reference cycle of four declarations', + setup: `import { register } from './registry' +const a = register(() => b) +const b = register(() => c) +const c = register(() => d) +const d = register(() => a)`, + calls: ['register', 'register', 'register', 'register'], + }, + ])( + 'keeps $name that nothing used before splitting', + async ({ setup, calls: expected }) => { + const route = await loadRoute( + `${head}${setup} +export const Route = createFileRoute('/')({ component: () =>
}) +`, + { hmr, files: callbackStubs }, + ) + const run = + await route.runPage(`await new Promise((resolve) => setTimeout(resolve)) +return { calls: [...(await app('calls.ts')).calls], html: await render('component') }`) + expect(run.result).toEqual({ calls: expected, html: '
' }) + expect(uncaughtErrors(run)).toEqual([]) + await expectValidModules(route) + }, + ) + }) + + // A declaration that only an unused local inside it, or an uncalled + // function, reads is still live code: its initializer runs when the route + // module loads. Source: #8504 (regressions of the Yuku migration); inputs + // adapted from @babel/plugin-proposal-decorators + // 2023-11-misc/destructuring-transform-integration and TypeScript's + // conformance test classes/propertyMemberDeclarations/autoAccessor10.ts. + describe.each(hmrModes)('with hmr: $hmr', ({ hmr }) => { + it.each([ + { + name: 'declarations only an unused local inside them reads', + setup: `const plugin = { + id: register('plugin'), + describe() { + const self = plugin + return 'plugin' + }, +} +class Widget { + static { + register('widget') + } + render() { + const type = Widget + return 'widget' + } +}`, + registered: ['plugin', 'widget'], + }, + { + name: 'a declaration only an uncalled function reads, the function reading itself through a local', + setup: `const effect = register('effect') +function helper() { + const self = helper + return effect +}`, + registered: ['effect'], + }, + ])( + 'runs the initializers of $name when the route module loads', + async ({ setup, registered }) => { + const route = await loadRoute( + `${head}import { register } from './register' +${setup} +export const Route = createFileRoute('/')({ component: () =>
}) +`, + { + hmr, + files: { + ...callsModule, + 'register.ts': `import { calls } from './calls' +export const register = (name: string) => calls.push(name) +`, + }, + }, + ) + expect( + await route.run(`const loaded = [...(await app('calls.ts')).calls] +return [loaded, await render('component')]`), + ).toEqual([registered, '
']) + }, + ) + }) + + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "only + // eliminates newly unreferenced identifiers", "unexported circular references" + // and "SCC with external caller used -> all preserved". Whether unused user + // code is kept or dropped is free, and unused code may name a binding its + // module no longer declares (SPEC G8: the bundlers + // delete it; the validator checks what Rolldown's tree-shaking keeps); + // every module stays valid and the split component still reaches its + // helper. + const unusedFunctions = `${head}function helper() { return 'helper' } +function unused() { return 'MARK_UNUSED_END' + helper() } +function ping(): number { return pong() + 'MARK_PING_END'.length } +function pong(): number { return ping() } +export const Route = createFileRoute('/')({ component: () =>

{helper()}

}) +` + it('keeps the modules of unused functions, one calling a helper of the split component, valid', async () => { + await expectValidModules(await loadRoute(unusedFunctions)) + await expectValidModules(await loadRoute(unusedFunctions, { hmr: true })) + expect(await renderSplitComponent(unusedFunctions)).toBe('

helper

') + }) + + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "SCC dead + // code elimination" > "arrow functions in mutual recursion -> removed" + it.each(hmrModes)( + 'moves mutually recursive helpers only the component uses, and their imports, out of the route module (hmr: $hmr)', + async ({ hmr }) => { + // The helpers carry user markers (their results are unchanged), so + // that their code is recognised wherever it goes (SPEC J2.5). The + // markers join values of another module, so no compiler can fold + // them away. + const route = await loadRoute( + `${head}import { dep } from './dep' +const ping = (n: number): number => (n > 0 ? pong(n - 1) : ('MARK_PING' + dep).length) +const pong = function (n: number): number { return n > 0 ? ping(n - 1) : dep ?? 'MARK_PONG' } +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{ping(3)}

, +}) +`, + { hmr, files: { 'dep.ts': `export const dep = 'dep'\n` } }, + ) + // Nothing that loads with the route holds the helpers, or requests + // what only they read; what the component loads holds them. + const eager = await route.eagerModules() + expect( + eager.filter((code) => holdsMarker(code, 'MARK_PING')), + ).toHaveLength(0) + expect( + eager.filter((code) => holdsMarker(code, 'MARK_PONG')), + ).toHaveLength(0) + expect(await route.requested()).not.toContain('/dep.ts') + const component = await route.loadedBy('component') + expect( + ['MARK_PING', 'MARK_PONG'].filter((marker) => + component.some((code) => holdsMarker(code, marker)), + ), + ).toEqual(['MARK_PING', 'MARK_PONG']) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('

dep

') + }, + ) + + // Source: Next.js ssg/getStaticProps/should-remove-re-exported-function-declarations-dependents-variables-functions-imports + it('stops importing what only the split component reads from a module with an unused specifier', async () => { + const route = await loadRoute( + `${head}import { used, preUnused } from 'bar' +const b = function apples() { return 'MARK_APPLES ' + used } +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{b()}

, +}) +`, + { + // A package of the app is written with a host of its own (Vite's + // watcher does not report files in node_modules) + fresh: true, + files: appPackage( + 'bar', + `export const used = 'used'\nexport const preUnused = 'unused'\n`, + ), + }, + ) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe( + '

MARK_APPLES used

', + ) + // What loads with the route in a production build no longer holds the + // code that reads `used` (whether it keeps loading `bar`, or an import + // specifier tree-shaking drops, is free: SPEC §5.9). + expect((await route.production()).locate('MARK_APPLES').eager).toEqual([]) + }) + + // That `track` runs once too is pinned in known-bugs-code-splitter.test.ts + // ("an unreferenced top-level side effect (an unused subscription) runs + // once"): split chunks still copy it. + it('creates a store the split component shares once, next to a side effect nothing reads', async () => { + const route = await loadRoute( + `${head}import { createStore, track } from './store' +const store = createStore() +const stop = track(() => stop()) +export const Route = createFileRoute('/')({ + beforeLoad: () => store.get(), + component: () =>

{store.get()}

, +}) +`, + { + files: { + 'store.ts': `export const counts = { created: 0, tracked: 0 } +export const createStore = () => { + const id = ++counts.created + return { get: () => id } +} +export const track = (listener: () => void) => { + counts.tracked++ + return listener +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const { counts } = await app('store.ts') +// The side effect runs when the route module loads. +const tracked = counts.tracked +return [tracked, options.beforeLoad(), await render('component'), counts.created]`), + ).toEqual([1, 1, '

1

', 1]) + }) + + // Source: React Router route-chunks-test.ts "shared imports across chunks but + // not main chunk with shared side effect usage" + it('runs a top-level call once, with the route module, even when the chunks import its callee', async () => { + const route = await loadRoute( + `${head}import { shared } from './shared' +shared('top-level') +export const Route = createFileRoute('/')({ + component: () =>
{shared('component')}
, + errorComponent: () =>
{shared('error')}
, +}) +`, + { + files: { + ...callsModule, + 'shared.ts': `import { calls } from './calls' +export const shared = (label: string) => { + calls.push(label) + return label +} +`, + }, + }, + ) + expect( + await route.run(`const { calls } = await app('calls.ts') +const loaded = [...calls] +const rendered = [await render('component'), await render('errorComponent')] +return [loaded, rendered, [...calls]]`), + ).toEqual([ + ['top-level'], + ['
component
', '
error
'], + ['top-level', 'component', 'error'], + ]) + await expectValidModules(route) + }) + + // Source: #8504 (differential fuzzing). Other unused declarations with + // side effects run again in every chunk: pinned in + // known-bugs-code-splitter.test.ts ("an unreferenced top-level side + // effect"). + it('runs the initializer of a namespace no split option reads once, with the route module', async () => { + const route = await loadRoute( + `${head}import { track } from './track' +namespace Unused { export const value = track('namespace') } +export const Route = createFileRoute('/')({ + component: () =>
{track('component')}
, +}) +`, + { + files: { + ...callsModule, + 'track.ts': `import { calls } from './calls' +export const track = (label: string) => { + calls.push(label) + return label +} +`, + }, + }, + ) + expect( + await route.run(`const { calls } = await app('calls.ts') +const loaded = [...calls] +return [loaded, await render('component'), [...calls]]`), + ).toEqual([ + ['namespace'], + '
component
', + ['namespace', 'component'], + ]) + }) + + // TypeScript erases type positions, so a declaration whose binding only + // appears in a type is still live code that runs when the route loads. + it.each([ + { name: 'the reference module', options: {} }, + { + name: 'a route module compiled for HMR', + // The composed plugin without code splitting: its route HMR plugin + options: { + hmr: true, + pluginOptions: { autoCodeSplitting: false }, + } satisfies RouteAppOptions, + }, + ])( + 'runs a declaration only referenced from types in $name', + async ({ options }) => { + const route = await loadRoute( + `${head}import { registerAnalytics } from './analytics' +const analytics = registerAnalytics('/posts') +declare module './analytics' { + interface Registry { + posts: typeof analytics + } +} +export const Route = createFileRoute('/posts')({ + component: () =>

posts

, +}) +`, + { + ...options, + routeId: '/posts', + files: { + 'analytics.ts': `export interface Registry {} +export const registered: Array = [] +export const registerAnalytics = (path: string) => registered.push(path) +`, + }, + }, + ) + expect( + await route.run(`return [...(await app('analytics.ts')).registered]`), + ).toEqual(['/posts']) + await expectValidModules(route) + }, + ) +}) + +// Type arguments name types only: TypeScript erases them, so a type, its +// parameters and the values a `typeof` there names are no reads of module +// bindings. Source: #8504 (shared-bindings helper tests). +it.each([ + { name: 'a function type', type: '(value: Item) => void' }, + { name: 'a constructor type', type: 'new (value: Item) => object' }, + { name: 'a method signature', type: '{ read(value: Item): void }' }, + { name: 'a generic function type', type: '(value: T) => T' }, + { + name: 'a conditional type with infer', + type: 'Item extends Array ? U : typeof item', + }, +])( + 'keeps a context created with $name as type argument working in the split component', + async ({ type }) => { + // A user module stands for the context factory (React is never + // stubbed): it counts the contexts created. + const route = await loadRoute( + `${head}import { createContext } from './context' +type Item = { id: string } +const item: Item = { id: 'item' } +const Context = createContext<${type}>(null!) +export const Route = createFileRoute('/')({ + loader: () => item.id, + component: () =>

{String(Context.value)}

, +}) +`, + { + files: { + 'context.ts': `export const counts = { created: 0 } +export const createContext = (value: T) => { + counts.created++ + return { value } +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('context.ts')).counts.created, +]`), + ).toEqual(['item', '

null

', 1]) + }, +) + +describe('code a split option needs moves with it', () => { + // Source: Qwik optimizer test.rs should_not_move_over_side_effects, + // example_drop_side_effects; Turbopack tree-shaker analyzer/route-kind + it.each([ + { + name: 'a compound component member assignment', + setup: `function Card({ children }) { return
{children}
} +Card.Title = function Title() { return

t

}`, + render: '', + rendered: '

t

', + }, + { + name: 'a registry filled by a top-level call', + setup: `const registry = new Map() +registry.set('a', 'A')`, + render: `

{registry.get('a')}

`, + rendered: '

A

', + }, + { + name: 'a compiled enum initializing a var', + setup: `var Kind: any +;(function (Kind: any) { + Kind['A'] = 'a' +})(Kind || (Kind = {}))`, + render: '

{Kind.A}

', + rendered: '

a

', + }, + ])( + 'renders a split component that relies on $name', + async ({ setup, render, rendered }) => { + const code = `${head}${setup} +export const Route = createFileRoute('/')({ + component: () => ${render}, +}) +` + const route = await loadRoute(code) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe(rendered) + }, + ) + + // An unused function that renders the split component stays as written, or + // goes, without keeping the component's imports in the route module. + // Other shapes are pinned in known-bugs-code-splitter.test.ts ("page code + // left in the route module"). Source: #8504 (real apps: Jp-K/DmCompanionAi + // frontend_old/src/routes/_layout/chat.tsx). + it('moves the split component and its imports into its chunk when an unused function renders it', async () => { + const route = await loadRoute( + `${head}import { heavy } from './heavy' +export const Route = createFileRoute('/')({ + component: Page, +}) +function Page() { + return

{heavy()}

+} +function Unused() { + return +} +`, + { files: { 'heavy.ts': `export const heavy = () => 'heavy'\n` } }, + ) + expect(await route.requested()).not.toContain('/heavy.ts') + expect(await route.run(`return render('component')`)).toBe('

heavy

') + }) + + // A function annotated #__NO_SIDE_EFFECTS__ keeps its annotation where the + // code splitter moves it (a file with a pragma): its unused calls leave + // production builds, integration/code-splitter-dead-code.test.ts. + + // Source: React Compiler hook-ref-callback.js and + // dont-memoize-primitive-function-call-non-escaping.js: a function shared by + // the loader and the split component declares a local it never reads. + it.each([ + { name: 'a call', initializer: 'track(id)' }, + { name: 'an optional call', initializer: 'track?.(id)' }, + ])( + 'keeps an unused local initialized by $name in a shared function', + async ({ initializer }) => { + const route = await loadRoute( + `${head}import { track } from './track' +function useShared(id) { + const unused = ${initializer} + return id +} +export const Route = createFileRoute('/')({ + loader: () => useShared('loader'), + component: () =>

{useShared('component')}

, +}) +`, + { + files: { + ...callsModule, + 'track.ts': `import { calls } from './calls' +export const track = (label: string) => calls.push(label) +`, + }, + }, + ) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + [...(await app('calls.ts')).calls], +]`), + ).toEqual(['loader', '

component

', ['loader', 'component']]) + }, + ) + + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "object + // pattern" > "within function param" + it('keeps empty destructuring parameters of helpers moved into the chunk', async () => { + const route = + await loadRoute(`${head}function f(a: any, {}: any) { return a } +const g = (a: any, []: any) => a +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{f.length}{g.length}

, +}) +`) + expect(await route.run(`return render('component')`)).toBe('

22

') + }) + + // Source: React Router remove-exports-test.ts "iife with dependencies". + // The IIFE has no purity hint, so a compiler may also keep it eager, once, + // and warn once naming the file and the option (J2.8); splitting it with + // its dependencies is the better outcome. + it('moves a component created by an IIFE with its dependencies, next to a helper the loader uses too', async () => { + const route = await loadRoute( + `${head}import { removedLib } from 'removed-lib' +import { keptLib } from 'kept-lib' +import { sharedLib } from 'shared-lib' +const sharedUtil = (value?: unknown) => sharedLib(value) +const removedUtil = () => sharedUtil(removedLib()) +const keptUtil = () => sharedUtil(keptLib('MARK_KEPT_UTIL')) +const Page = (() => { + const message = removedUtil() + return () =>
{String(message)}
+})() +export const Route = createFileRoute('/')({ + loader: () => keptUtil(), + component: Page, +}) +`, + { + fresh: true, + files: { + ...appPackage( + 'removed-lib', + `export const removedLib = () => 'removed'\n`, + ), + ...appPackage('kept-lib', `export const keptLib = () => 'kept'\n`), + ...appPackage( + 'shared-lib', + `export const sharedLib = (value) => 'shared:' + value\n`, + ), + }, + }, + ) + await expectValidModules(route) + if (await route.isLazy('component')) { + // Nothing that loads with the route requests what only the component + // reads; in a production build, nothing the component loads holds the + // code only the loader runs (an import specifier tree-shaking drops + // is free: SPEC §5.9). + expect( + await route.run( + `return performance.getEntriesByType('resource').map((entry) => new URL(entry.name).pathname)`, + ), + ).not.toContainEqual( + expect.stringContaining('/node_modules/removed-lib/'), + ) + expect((await route.production()).locate('MARK_KEPT_UTIL').lazy).toEqual( + [], + ) + } else { + expectDiagnostic(await route.diagnostics(), { + severity: 'warning', + file: 'route.tsx', + root: route.host.root, + times: 1, + }) + } + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['shared:kept', '
shared:removed
']) + }) + + // Source: React Router route-chunks-test.ts "isolated exported variable + // declarations sharing an export statement"; Next.js + // ssg/getStaticProps/should-remove-re-exported-variable-declarations-safe + // The declarators carry user markers, so that each one's code is + // recognised wherever it goes (SPEC J2.5). The markers are part of what the + // route shows and returns, so no compiler can fold them away. + it.each([ + { + name: 'plain declarators', + declarations: `const Page = () =>
{chunkMessage}
, + main = 'MARK_MAIN ' + mainMessage`, + }, + { + name: 'destructured declarators', + declarations: `const { Page } = { Page: () =>
{chunkMessage}
}, + { main } = { main: 'MARK_MAIN ' + mainMessage }`, + }, + ])( + 'gives each of the $name of one statement to the module that reads it', + async ({ declarations }) => { + const route = await loadRoute( + `${head}import { chunkMessage, mainMessage } from './messages' +${declarations} +export const Route = createFileRoute('/')({ + loader: () => main, + component: Page, +}) +`, + { + files: { + 'messages.ts': `export const chunkMessage = 'chunk'\nexport const mainMessage = 'main'\n`, + }, + }, + ) + // What loads with the route holds nothing of the component, what the + // component loads nothing of the loader; each holds its own. + const eager = await route.eagerModules() + expect(eager.filter((code) => holdsMarker(code, 'MARK_PAGE'))).toEqual([]) + expect(eager.some((code) => holdsMarker(code, 'MARK_MAIN'))).toBe(true) + const component = await route.loadedBy('component') + expect( + component.filter((code) => holdsMarker(code, 'MARK_MAIN')), + ).toEqual([]) + expect(component.some((code) => holdsMarker(code, 'MARK_PAGE'))).toBe( + true, + ) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['MARK_MAIN main', '
chunk
']) + // In a production build too, after tree-shaking (what each module + // imports from './messages' is free: SPEC §5.9) + const built = await route.production() + expect({ + page: built.locate('MARK_PAGE').eager, + main: built.locate('MARK_MAIN').lazy, + }).toEqual({ page: [], main: [] }) + }, + ) + + // Source: React Router route-chunks-test.ts "exported variable declarations + // sharing an export statement" + // The component records the instance of `Page` it runs as: the one the + // loader returns. + it('keeps one component that a sibling declarator reads', async () => { + const route = await loadRoute( + `${head}import { sharedMessage, see } from './messages' +const Page = () =>
{see(Page)}{sharedMessage}
, + Preview = Page +export const Route = createFileRoute('/')({ + loader: () => Preview, + component: Page, +}) +`, + { + files: { + 'messages.ts': `export const sharedMessage = 'shared' +export const seen: Array = [] +export const see = (value: unknown) => { + seen.push(value) + return '' +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const html = await render('component') +const { seen } = await app('messages.ts') +return [html, seen.length, seen[0] === options.loader()]`), + ).toEqual(['
shared
', 1, true]) + }) +}) + +describe('var declarations nested in top-level statements', () => { + it.each([ + { + name: 'a for loop head', + setup: 'for (var value = 0; value < 3; value++) {}', + value: 3, + }, + { name: 'a for-of head', setup: "for (var value of ['a']) {}", value: 'a' }, + { + // The branch the page takes (the old server-only branch never runs + // in a browser): the value is the browser's + name: 'an if block', + setup: "if (typeof window !== 'undefined') { var value = 'browser' }", + value: 'browser', + }, + ])( + 'give the loader and the component the value of a binding $name declares', + async ({ setup, value }) => { + const route = await loadRoute(`${head}${setup} +export const Route = createFileRoute('/')({ + loader: () => value, + component: () =>
{value}
, +}) +`) + // That the statement runs once is pinned in + // known-bugs-code-splitter.test.ts ("a binding declared by a var in …"). + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([value, `
${value}
`]) + }, + ) + + it('stay exported when exported and read by the component', async () => { + const route = await loadRoute( + `${head}if (typeof window !== 'undefined') { var flag = 'browser' } +export { flag } +export const Route = createFileRoute('/')({ + component: () =>
{flag}
, +}) +`, + { files: { 'importer.ts': `export { flag } from './route'\n` } }, + ) + await expectValidModules(route) + expect( + await route.run( + `return [(await app('importer.ts')).flag, await render('component')]`, + ), + ).toEqual(['browser', '
browser
']) + }) + + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "variable" + // (var bindings declared inside nested statements) + it('run once and give each option its value', async () => { + const route = await loadRoute( + `${head}import { compute, connect } from './lib' +if (typeof globalThis !== 'undefined') { + var flag = compute() +} +for (var index = 0; index < 3; index++) {} +{ + var block = connect() +} +export const Route = createFileRoute('/')({ + loader: () => block, + component: () =>

{String(flag)}{index}

, +}) +`, + { + files: { + 'lib.ts': `export const calls = { compute: 0, connect: 0 } +export const compute = () => { + calls.compute++ + return 'flag' +} +export const connect = () => { + calls.connect++ + return 'block' +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + { ...(await app('lib.ts')).calls }, +]`), + ).toEqual(['block', '

flag3

', { compute: 1, connect: 1 }]) + }) +}) + +describe('robustness', () => { + it('compiles a route with a long method chain', async () => { + // Builder APIs (schemas, query builders) produce deep left-nested calls + const chain = Array.from({ length: 200 }, (_, i) => `.add(${i})`).join('') + const route = await loadRoute( + `${head}import { builder } from './builder' +const schema = builder()${chain} +export const Route = createFileRoute('/')({ + loader: () => schema, + component: () =>
{String(schema)}
, +}) +`, + { + files: { + 'builder.ts': `export const calls = { builder: 0, add: 0 } +export const schema = { + add: () => { + calls.add++ + return schema + }, + toString: () => 'schema', +} +export const builder = () => { + calls.builder++ + return schema +} +`, + }, + }, + ) + await expectValidModules(route) + // The chain runs once, whichever module holds it. + expect( + await route.run(`const lib = await app('builder.ts') +return [ + options.loader() === lib.schema, + await render('component'), + { ...lib.calls }, +]`), + ).toEqual([true, '
schema
', { builder: 1, add: 200 }]) + }) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-determinism.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-determinism.test.ts new file mode 100644 index 0000000000..29a893931a --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-determinism.test.ts @@ -0,0 +1,89 @@ +/** + * Code splitting does not depend on where the project lives: the same route + * splits the same way and runs the same under any project root (SPEC G4, + * relocation: emitted code may differ, `@tanstack/compiler-test-utils/ + * determinism`). Each root is a real app directory served by its own dev + * server (`./route-app`), observed in a real browser page. The slow tier + * builds the same app in two directories. Windows module ids are platform + * evidence for a Windows run. + */ +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { expectRelocatable } from '@tanstack/compiler-test-utils/determinism' +import { head, loadRoute } from '../../route-app' + +const route = `${head}import { format } from './format' +const prefix = 'MARK' +function Page() { + return

{format(prefix + ' page')}

+} +function Failure() { + return

{prefix} failure

+} +export const Route = createFileRoute('/')({ + loader: () => prefix + ' data', + errorComponent: Failure, + component: Page, +}) +` + +/** Directory of the other project roots of this file. */ +const rootsDir = path.join(import.meta.dirname, '.relocation-roots') + +/** + * Project roots the same route file is served from (directories the app + * stands in for: `@tanstack/compiler-test-utils/app-directory` creates it at + * the same path below a temporary directory). + */ +const roots: Record = { + reference: import.meta.dirname, + 'another root': path.join(rootsDir, 'srv/apps/project/src'), + 'a deeper root': path.join( + rootsDir, + 'home/user/work/some/deep/monorepo/apps/web/src', + ), +} + +/** + * What the route served from the root `name` does (SPEC G4: semantics, not + * bytes): the options that load lazily and how they group, the loader's + * data and the rendered components. Its emitted code and generated names + * are free to differ between roots. + */ +async function serveUnder(name: string) { + const dir = roots[name]! + const loaded = await loadRoute(route, { + dir, + fresh: true, + files: { + 'format.ts': `export const format = (text: string) => \`[\${text}]\`\n`, + }, + }) + return { + groups: await loaded.groups(), + rendered: await loaded.run(`return [ + await (await load('loader'))(), + await render('component'), + await render('errorComponent'), +]`), + } +} + +const reference = { + groups: [['component'], ['errorComponent']], + rendered: ['MARK data', '

[MARK page]

', '

MARK failure

'], +} + +describe('a route served under', () => { + test.each(['another root', 'a deeper root'])( + '%s splits and runs as under the reference root', + async (name) => { + await expectRelocatable(['reference', name], serveUnder, { + check: (observation) => expect(observation).toEqual(reference), + portable: (observation) => observation, + }) + }, + // Two dev servers of their own + 30_000, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-edits.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-edits.test.ts new file mode 100644 index 0000000000..db5cb31a25 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-edits.test.ts @@ -0,0 +1,91 @@ +/** + * A route file edited on a running dev server (one router plugin per dev + * server): the edited route's modules hold only the new version, and dev + * servers with different split settings in one process keep their own. + */ +import { describe, expect, it } from 'vitest' +import { holdsMarker, loadRoute } from '../../route-app' +import type { CodeSplittingOptions } from '../../../src/vite' +import type { RouteApp } from '../../route-app' + +type CodeSplitGroupings = NonNullable + +describe('a route file edited on a running dev server', () => { + it('refreshes chunk ownership after source changes and isolates split settings', async () => { + const source = (name: string, value: string) => ` +import { createFileRoute } from '@tanstack/react-router' +const ${name} = { value: ${JSON.stringify(value)} } +export const Route = createFileRoute('/changing')({ + loader: () => ${name}, + component: () => ( +

+ {${name}.value} {String(Route.useLoaderData() === ${name})} +

+ ), +})` + // One dev server per split setting, each compiling every version of + // the file as it is edited. + const load = (groupings: CodeSplitGroupings) => (code: string) => + loadRoute(code, { + routeId: '/changing', + pluginOptions: { + codeSplittingOptions: { defaultBehavior: groupings }, + }, + }) + const separate = load([['component'], ['loader']]) + const combined = load([['component', 'loader']]) + + /** + * The route rendered by the router: the value the component reads and + * whether the loader's data is that same object. Then checks which + * options load together: activating an option of a group makes the + * whole group available, another group stays unrequested. + */ + const read = async (route: RouteApp, groups: Array>) => { + const html = await route.run('return renderRoute()') + expect(await route.groups()).toEqual(groups) + return html + } + const separateGroups = [['component'], ['loader']] + + expect( + await read( + await separate(source('firstState', 'first version')), + separateGroups, + ), + ).toBe('

first version true

') + + const second = await separate(source('secondState', 'second version')) + // No module of the edited route holds code of the first version. + const secondModules = await second.modules() + for (const [name, output] of Object.entries(secondModules.modules)) { + expect(holdsMarker(output, 'first version'), name).toBe(false) + } + // ... and they hold the second version's (the same check finds the + // route's code where it is) + expect( + Object.values(secondModules.modules).some((output) => + holdsMarker(output, 'second version'), + ), + ).toBe(true) + expect(await read(second, separateGroups)).toBe( + '

second version true

', + ) + expect( + await read(await combined(source('secondState', 'second version')), [ + ['component', 'loader'], + ]), + ).toBe('

second version true

') + // The same version compiled again by the same dev server (the file + // written again, unchanged): the same modules, groups and behaviour + // (SPEC G4; the emitted text is free). + const again = await separate(source('secondState', 'second version')) + await again.host.edit({ 'route.tsx': again.code }) + expect((await again.modules()).ids).toEqual(secondModules.ids) + expect(await read(again, separateGroups)).toBe('

second version true

') + }, 30_000) + + // The first edit of a route file through the public plugin setup + // (`tanstackRouter({...})`) hot-updates the page: + // integration/route-hmr-browser.test.ts (every test's first edit). +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-imports-exports.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-imports-exports.test.ts new file mode 100644 index 0000000000..91533d7a50 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-imports-exports.test.ts @@ -0,0 +1,1164 @@ +/** + * Imports and exports of a split route file, loaded the way an app loads it + * (`route-app.ts`: the public router plugin in a real Vite dev server, the + * route run in a page of the test process's browser). What each module imports is + * judged by what loads and works (requests, rendered output, the instances + * other modules of the app import), and by J2.5 checks of user code absent + * from a module (decoded user markers), never by the spelling of import + * statements. The attribute of an import moved into a chunk is judged by a + * bundler that honours it: integration/code-splitter-import-attributes.test.ts. + */ +import { parse as parseWithBabel } from '@babel/core' +import { describe, expect, it } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import type { Plugin } from 'vite' +import type { RouteApp } from '../../route-app' + +/** A package of the app's `node_modules`, as files of the app. */ +const packageFiles = (name: string, source: string) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: source, +}) + +/** + * The code of every module of the route as the dev server serves it, + * following the dev server's own module graph from the route module (the + * modules it imports, statically or lazily, that are files of the app or + * derived from them, or virtual modules), without running them: for code + * the browser cannot run yet. + */ +async function servedGraph(route: RouteApp) { + const graph = route.host.dev.vite.environments.client.moduleGraph + const modules: Record = {} + const queue = [route.url] + while (queue.length > 0) { + const url = queue.shift()! + if (url in modules) { + continue + } + modules[url] = await route.transform(url) + const node = await graph.getModuleByUrl(url) + for (const imported of node?.importedModules ?? []) { + if ( + // A virtual module (a plugin's id: a compiler's support module) + imported.id?.startsWith('\0') || + (imported.file?.startsWith(route.host.root) && + !imported.file.includes('/node_modules/')) + ) { + queue.push(imported.url) + } + } + } + return modules +} + +describe('each module imports only the specifiers it reads', () => { + // Source: React Router route-chunks-test.ts "functions referencing their own + // identifiers"; babel-dead-code-elimination dead-code-elimination.test.ts + // "import" > "mixed default and named" and "namespace" + it('splits default, named and namespace specifiers between the modules', async () => { + const route = await loadRoute( + `${head}import defaultMessage, { targetMessage, otherMessage } from './messages' +import * as messages from './messages' +import other, * as ns from './other' +const getDefault = () => ({ marker: 'MARK_GET_DEFAULT', value: defaultMessage }).value +const getTarget = () => ({ marker: 'MARK_GET_TARGET', value: targetMessage }).value +const getOther = () => ['MARK_LOADER', otherMessage] +function getNamespaced() { + return { marker: 'MARK_GET_NAMESPACED', value: messages.namespaced }.value +} +export const Route = createFileRoute('/')({ + loader: () => [...getOther(), other], + component: () =>
{getDefault()}{ns.x}
, + errorComponent: () =>
{getNamespaced()}
, + notFoundComponent: () =>
{getTarget()}
, +}) +`, + { + files: { + 'messages.ts': `export default 'default' +export const targetMessage = 'target' +export const otherMessage = 'other' +export const namespaced = 'namespaced' +`, + 'other.ts': `export default 'otherDefault'\nexport const x = 'x'\n`, + }, + }, + ) + // Nothing that loads with the route module (the route module and the + // modules it imports statically) holds what only the split + // components read, and no split chunk holds what only the loader reads + // (SPEC J2.5: the user code, found by its markers). + const eager = await route.eagerModules() + for (const marker of [ + 'MARK_COMPONENT', + 'MARK_ERROR', + 'MARK_NOT_FOUND', + // The helpers only one split component reads (the default, named + // and namespace imports they read leave with them) + 'MARK_GET_DEFAULT', + 'MARK_GET_TARGET', + 'MARK_GET_NAMESPACED', + ]) { + expect( + eager.some((code) => holdsMarker(code, marker)), + marker, + ).toBe(false) + } + // Each component and helper loads with the component that reads it + for (const [option, marker] of [ + ['component', 'MARK_COMPONENT'], + ['errorComponent', 'MARK_ERROR'], + ['notFoundComponent', 'MARK_NOT_FOUND'], + ['component', 'MARK_GET_DEFAULT'], + ['errorComponent', 'MARK_GET_NAMESPACED'], + ['notFoundComponent', 'MARK_GET_TARGET'], + ] as const) { + expect( + (await route.loadedBy(option)).some((code) => + holdsMarker(code, marker), + ), + `${option} loads ${marker}`, + ).toBe(true) + } + for (const option of ['component', 'errorComponent', 'notFoundComponent']) { + const loaded = await route.loadedBy(option) + expect( + loaded.some((code) => holdsMarker(code, 'MARK_LOADER')), + option, + ).toBe(false) + } + // ... which loads with the route module + expect(eager.some((code) => holdsMarker(code, 'MARK_LOADER'))).toBe(true) + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + await render('errorComponent'), + await render('notFoundComponent'), +]`), + ).toEqual([ + ['MARK_LOADER', 'other', 'otherDefault'], + '
defaultx
', + '
namespaced
', + '
target
', + ]) + }) + + it('keeps the other specifiers of the import a split component comes from', async () => { + const route = await loadRoute( + `${head}import { Page, title } from './page' +export const Route = createFileRoute('/')({ + loader: () => title, + component: Page, +}) +`, + { + files: { + 'page.ts': `export const Page = () => 'page'\nexport const title = 'title'\n`, + }, + }, + ) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(true) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['title', 'page']) + }) + + it('moves a specifier with a string name into the chunk', async () => { + const route = await loadRoute( + `${head}import { "kebab-name" as Kebab } from './icons' +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => , +}) +`, + { + files: { + 'icons.ts': `const kebab = () => 'kebab'\nexport { kebab as 'kebab-name' }\n`, + }, + }, + ) + // Nothing the route module loads requests what only the component reads. + expect(await route.requested()).not.toContain('/icons.ts') + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('kebab') + }) + + // Source: babel-dead-code-elimination dead-code-elimination.test.ts "import" > + // "mixed default and named: none used" and "side-effect" + it.each([{ hmr: false }, { hmr: true }])( + 'removes an import whose specifiers all moved instead of leaving a side-effect import (hmr: $hmr)', + async ({ hmr }) => { + // React HMR rewrites the route module before unused code is removed. + // (Where a route's CSS import loads: start-plugin-core + // tests/integration/known-bugs-route-css.test.ts.) + const route = await loadRoute( + `${head}import a, { b } from 'pkg' +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{a}{b}

, +}) +`, + { + hmr, + files: packageFiles( + 'pkg', + `globalThis.pkgLoads = (globalThis.pkgLoads ?? 0) + 1 +export default 'a' +export const b = 'b' +`, + ), + }, + ) + // What only the component reads does not load with the route. + expect(await route.run(`return globalThis.pkgLoads ?? 0`)).toBe(0) + await expectValidModules(route) + expect( + await route.run( + `return [await render('component'), globalThis.pkgLoads]`, + ), + ).toEqual(['

ab

', 1]) + }, + ) + + // Import attributes change what a module is (`type: 'json'`, a bundler + // macro), so they move with the import. Vite gives an attribute no + // meaning: here the moved import keeps working; that the attribute + // still applies in the chunk is judged where a bundler honours it + // (integration/code-splitter-import-attributes.test.ts, webpack). + it('keeps an import with attributes working when it moves into the chunk', async () => { + const route = await loadRoute( + `${head}import { test } from './test' with { type: 'macro' } +export const Route = createFileRoute('/')({ + component: () => test, +}) +`, + { files: { 'test.ts': `export const test = 'macro value'\n` } }, + ) + // Nothing that loads with the route module (whichever modules a + // compiler emits) requests `./test`; the component gets it. + expect(await route.requested()).not.toContain('/test.ts') + expect(await route.run(`return render('component')`)).toBe('macro value') + await expectValidModules(route) + }) + + // Import assertions (`assert { type: 'json' }`) are the deprecated form of + // import attributes (SPEC J2.17). Here: the route keeps working + // and the JSON module moves with the component. That the attribute keeps + // its meaning in the chunk: integration/code-splitter-import-attributes.test.ts. + it('keeps an import assertion of a route file working', async () => { + const route = await loadRoute( + `${head}import data from './data.json' assert { type: 'json' } +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () =>

{data.title}

, +}) +`, + { files: { 'data.json': '{ "title": "from json" }' } }, + ) + expect(await route.requested()).not.toContain('/data.json') + expect(await route.run(`return render('component')`)).toBe( + '

from json

', + ) + await expectValidModules(route) + }) + + // With React's classic JSX runtime, JSX compiles to `React.createElement`, + // so a React import that the TypeScript code only uses in types must stay: + // the app's own classic transform runs on what the router plugin emits, + // and the page renders the component. + it.each([ + { name: 'split component modules', pluginOptions: undefined }, + { + name: 'route module compiled for HMR', + pluginOptions: { autoCodeSplitting: false }, + }, + ])( + 'keeps the React import of the $name for classic JSX', + async ({ pluginOptions }) => { + const route = await loadRoute( + `import * as React from 'react' +${head}function Page({ title = 'classic' }: { title?: React.ReactNode }) { + return

{title}

+} +export const Route = createFileRoute('/')({ component: Page }) +`, + { + frameworkPluginOptions: { jsxRuntime: 'classic' }, + pluginOptions, + hmr: pluginOptions !== undefined, + }, + ) + // `React.createElement` reads an imported `React`. + expect(await route.run(`return render('component')`)).toBe( + '

classic

', + ) + await expectValidModules(route) + }, + ) + + it('keeps the React import of the split component modules with inline JSX when only a top-level type reads React', async () => { + const route = await loadRoute( + `import * as React from 'react' +${head}type Title = React.ReactNode +export const Route = createFileRoute('/')({ component: () =>

classic

}) +`, + { frameworkPluginOptions: { jsxRuntime: 'classic' } }, + ) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe('

classic

') + await expectValidModules(route) + }) +}) + +describe('exports of the route file', () => { + it.each([ + { name: 'as-is', exports: 'export { Foo }', exported: 'Foo' }, + { name: 'renamed', exports: 'export { Foo as Bar }', exported: 'Bar' }, + ])( + 'are not redeclared when they re-export an import $name', + async ({ exports, exported }) => { + const route = await loadRoute( + `${head}import { Foo } from './foo' +${exports} +export const Route = createFileRoute('/')({ component: Page }) +function Page() { + return +} +`, + { + files: { + 'foo.ts': `export const Foo = () => 'foo'\n`, + // Another module of the app imports the re-export (SPEC G9, J2.4) + 'importer.ts': `export { ${exported} } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const importer = await app('importer.ts') +return [importer.${exported} === (await app('foo.ts')).Foo, await render('component')]`), + ).toEqual([true, 'foo']) + }, + ) + + // That `getStuff` runs once is pinned in known-bugs-code-splitter.test.ts + // ("module state that the reference module keeps for a destructuring with + // one exported binding is initialized once"): the chunk calls it again. + it('are not redeclared when destructured next to a non-exported binding', async () => { + const route = await loadRoute( + `${head}import { getStuff } from './stuff' +const { a, b } = getStuff() +export { a } +export const Route = createFileRoute('/')({ + component: () =>
{a}{b}
, +}) +`, + { + files: { + 'stuff.ts': `export const getStuff = () => ({ a: 'A', b: 'B' })\n`, + 'importer.ts': `export { a } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run( + `return [(await app('importer.ts')).a, await render('component')]`, + ), + ).toEqual(['A', '
AB
']) + }) + + it.each([ + { + name: 'function', + declaration: 'function () {\n return null\n}', + type: 'function', + }, + { name: 'class', declaration: 'class {\n x = 1\n}', type: 'class' }, + ])( + 'keep an anonymous default-exported $name valid in every module', + async ({ declaration, type }) => { + const route = await loadRoute( + `${head}const cache = new Map() +function Page() { + return
{cache.size}
+} +export const Route = createFileRoute('/')({ + loader: () => cache.get('x'), + component: Page, +}) +export default ${declaration} +`, + // As another module of the app imports it. + { files: { 'importer.ts': `export { default } from './route'\n` } }, + ) + await expectValidModules(route) + expect( + await route.run(`const { default: exported } = await app('importer.ts') +return [ + typeof exported, + ${type === 'class' ? 'new exported().x' : 'exported()'}, + await render('component'), +]`), + ).toEqual(['function', type === 'class' ? 1 : null, '
0
']) + }, + ) + + // Spec: what other modules import from the route file keeps working, as + // the instances the route uses (not the route module's export list). + it('stay importable through an export list next to bindings the route module shares', async () => { + const route = await loadRoute( + `${head}import { createStore } from './store' +const store = createStore() +const Route = createFileRoute('/')({ + loader: () => store.get(), + component: () =>

{store.get()}

, +}) +const title = 'title' +export { Route, title } +`, + { + files: { + 'store.ts': `export const createStore = () => ({ get: () => 'value' })\n`, + 'importer.ts': `export { Route, title } from './route'\n`, + }, + }, + ) + expect( + await route.run(`const other = await app('importer.ts') +return [other.title, other.Route === Route, options.loader(), await render('component')]`), + ).toEqual(['title', true, 'value', '

value

']) + await expectValidModules(route) + }) + + // Source: Next.js ssg/getStaticProps/issue-31855 and multi-declarator-export + it('keep one instance when declared in one statement and read by the chunk', async () => { + const route = await loadRoute( + `${head}export const a = { n: 0 }, + b = { n: 10 } +export const Route = createFileRoute('/')({ + component: () => { + a.n++ + return
{a.n + b.n}
+ }, +}) +`, + { + files: { + 'importer.ts': `import { a, b } from './route' +export const read = () => [a.n, b.n] +`, + }, + }, + ) + // The component updated the object other modules import. + expect( + await route.run(`const other = await app('importer.ts') +return [await render('component'), other.read()]`), + ).toEqual(['
11
', [1, 10]]) + await expectValidModules(route) + }) + + // Source: #8504. + it('keep working when the route module reassigns a binding declared with what the split component reads', async () => { + const route = await loadRoute( + `${head}let { title, visits } = { title: 'Home', visits: 0 } +export function reset() { + visits = 0 + return visits +} +export function Title() { + return

{title}

+} +export const Route = createFileRoute('/')({ + component: () => , +}) +`, + { files: { 'importer.ts': `export { reset } from './route'\n` } }, + ) + await expectValidModules(route) + expect( + await route.run(`const { reset } = await app('importer.ts') +return [reset(), await render('component')]`), + ).toEqual([0, '<h1>Home</h1>']) + }) + + it('keep module-level re-exports importable', async () => { + const route = await loadRoute( + `${head}export * from './lib' +export * as lib from './lib' +export {} +const cache = new Map() +export const Route = createFileRoute('/')({ + loader: () => cache.size, + component: () => <div>{cache.size}</div>, +}) +`, + { + files: { + 'lib.ts': `export const value = 'lib value'\n`, + 'importer.ts': `import { value, lib } from './route' +export const read = () => [value, lib.value] +`, + }, + }, + ) + expect( + await route.run(`const other = await app('importer.ts') +return [other.read(), options.loader(), await render('component')]`), + ).toEqual([['lib value', 'lib value'], 0, '<div>0</div>']) + await expectValidModules(route) + }) + + // An exported split option keeps working and keeps its identity (the + // component the route renders records itself with `see`: it is the one + // other modules import), and the other options are still split. + // Splitting it anyway is the goal, decided by the build (pinned in + // known-bugs-code-splitter.test.ts, "page code exported from the route + // file loads with its chunk"). + const exportedOptions = [ + { + name: 'an exported component, with the errorComponent split', + code: `${head}import { see } from './see' +export function Page() { + see(Page) + return <p>page</p> +} +export const Route = createFileRoute('/')({ + component: Page, + errorComponent: () => <p>error</p>, +}) +`, + routeId: '/', + split: 'errorComponent', + option: 'component', + binding: 'Page', + value: '<p>page</p>', + }, + { + name: 'a default-exported component, with the notFoundComponent split', + code: `${head}import { see } from './see' +export const Route = createFileRoute('/home')({ + component: Home, + notFoundComponent: NotFoundComponent, +}) +function NotFoundComponent() { + return <div>Not Found</div> +} +export default function Home() { + see(Home) + return <h1>home</h1> +} +`, + routeId: '/home', + split: 'notFoundComponent', + option: 'component', + binding: 'default', + value: '<h1>home</h1>', + }, + { + name: 'an exported loader, with the loader split', + code: `${head}import { see } from './see' +export function loaderFn() { + see(loaderFn) + return { foo: 'bar' } +} +function Layout() { + return <main>layout</main> +} +export const Route = createFileRoute('/_layout')({ + codeSplitGroupings: [['loader'], ['component']], + component: Layout, + loader: loaderFn, +}) +`, + routeId: '/_layout', + split: 'component', + option: 'loader', + binding: 'loaderFn', + value: { foo: 'bar' }, + }, + { + name: 'a component default-exported by name, with the errorComponent split', + code: `${head}import { see } from './see' +const Page = () => { + see(Page) + return <p>page</p> +} +export default Page +export const Route = createFileRoute('/')({ + component: Page, + errorComponent: () => <p>error</p>, +}) +`, + routeId: '/', + split: 'errorComponent', + option: 'component', + binding: 'default', + value: '<p>page</p>', + }, + ] + + const seeFile = `export const seen: Array<unknown> = [] +export const see = (value: unknown) => seen.push(value) +` + + it.each(exportedOptions)( + 'keep working: $name', + async ({ code, routeId, split, option, binding, value }) => { + const route = await loadRoute(code, { + routeId, + files: { + 'see.ts': seeFile, + 'importer.ts': `export { ${binding} as exported } from './route'\n`, + }, + }) + await expectValidModules(route) + // The function the route ran is the one another module of the app + // imports (SPEC J2.4, G9): one instance, not a copy. + expect( + await route.run(`const result = ${ + option === 'loader' + ? `await (await load('loader'))()` + : `await render(${JSON.stringify(option)})` + } +const { seen } = await app('see.ts') +const { exported } = await app('importer.ts') +return [result, seen.length, seen[0] === exported]`), + ).toEqual([value, 1, true]) + expect(await route.isLazy(split)).toBe(true) + // Left unsplit, the option is reported once, naming the route file + // (SPEC J2.8, J2.19) + if (!(await route.isLazy(option))) { + expectDiagnostic(await route.diagnostics(), { + severity: 'warning', + file: route.url.slice(1), + root: route.host.root, + times: 1, + }) + } + }, + ) + + // With route HMR, as a dev server has it: an exported component that + // another route imports is split, or the user is told once per file + // (SPEC J2.8, J2.19), however often the route module and its split + // modules are served and transformed. + it('an exported component another route imports is split, or reported once naming the file, with route HMR', async () => { + const route = await loadRoute( + `${head}export function Page() { + return <p>page</p> +} +export const Route = createFileRoute('/')({ component: Page }) +`, + { + hmr: true, + files: { + 'about.tsx': `${head}import { Page } from './route' +export const Route = createFileRoute('/about')({ component: () => <Page /> }) +`, + }, + }, + ) + expect( + await route.run(`await app('about.tsx') +return render('component')`), + ).toBe('<p>page</p>') + const split = await route.isLazy('component') + await route.transform() + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + if (!split) { + expectDiagnostic(await route.diagnostics(), { + severity: 'warning', + file: route.url.slice(1), + root: route.host.root, + times: 1, + }) + } + }) + + it.each([ + { + name: 'a default export of another binding', + exports: `const meta = { title: 'home' } +export default meta`, + }, + { + name: 'an exported object destructuring', + exports: `const config = { title: 't' } +export const { title } = config`, + }, + ])( + 'do not keep an unexported component from being split: $name', + async ({ exports }) => { + const route = await loadRoute(`${head}${exports} +function Page() { + return <p>page</p> +} +export const Route = createFileRoute('/')({ component: Page }) +`) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + }, + ) + + it.each([ + { + name: 'export function', + declaration: `export function helper() {\n return 'h'\n}`, + }, + { name: 'export const', declaration: `export const helper = () => 'h'` }, + ])( + 'stay readable by a split component next to an exported option component ($name)', + async ({ declaration }) => { + const route = await loadRoute( + `${head}${declaration} +export function NotFound() { + return <i>nf</i> +} +export const Route = createFileRoute('/')({ + component: () => <p>{helper()}</p>, + notFoundComponent: NotFound, +}) +`, + { files: { 'importer.ts': `export { helper } from './route'\n` } }, + ) + expect( + await route.run( + `return [await render('component'), (await app('importer.ts')).helper()]`, + ), + ).toEqual(['<p>h</p>', 'h']) + }, + ) + + // The chunk of a split option holds only what that option needs: an + // exported component of another option is not copied into it (J2.5: its + // code, found by its marker). + it.each([ + { + name: 'export default function', + declaration: `export default function NotFound() {\n return <i>MARK_NF</i>\n}`, + }, + { + name: 'export default by name', + declaration: `function NotFound() {\n return <i>MARK_NF</i>\n}\nexport default NotFound`, + }, + { + name: 'export function', + declaration: `export function NotFound() {\n return <i>MARK_NF</i>\n}`, + }, + { + name: 'export const', + declaration: `export const NotFound = () => <i>MARK_NF</i>`, + }, + ])( + "are not copied into another option's chunk ($name)", + async ({ declaration }) => { + const route = await loadRoute(`${head}${declaration} +export const Route = createFileRoute('/')({ + component: () => <p>page</p>, + notFoundComponent: NotFound, +}) +`) + expect( + await route.run( + `return [await render('component'), await render('notFoundComponent')]`, + ), + ).toEqual(['<p>page</p>', '<i>MARK_NF</i>']) + const loaded = await route.loadedBy('component') + expect(loaded.some((code) => holdsMarker(code, 'MARK_NF'))).toBe(false) + // ... but in what the notFoundComponent needs: its split code, or the + // modules that load with the route (left in the route module, J2.8, or + // an exported binding a split chunk imports back from it) + const notFound = [ + ...(await route.eagerModules()), + ...((await route.isLazy('notFoundComponent')) + ? await route.loadedBy('notFoundComponent') + : []), + ] + expect(notFound.some((code) => holdsMarker(code, 'MARK_NF'))).toBe(true) + }, + ) +}) + +describe('TypeScript-only syntax', () => { + it('erases type-only imports and exports from the split modules', async () => { + // `./types` is no file of the app: a module that still imported a value + // from it would fail to load in the page. + const route = await loadRoute( + `${head}import type { User } from './types' +import type * as Types from './types' +import { type Settings, defaults } from './settings' +export type * from './types' +export type * as types from './types' +export type { User } +const current: User | Types.Admin | Settings = defaults +export const Route = createFileRoute('/')({ + loader: () => current, + component: () => <div>{String(current)}</div>, +}) +`, + { files: { 'settings.ts': `export const defaults = 'defaults'\n` } }, + ) + await expectValidModules(route) + expect( + await route.run(`const result = [options.loader(), await render('component')] +return [...result, (await requested()).filter((request) => request.startsWith('/types'))]`), + ).toEqual(['defaults', '<div>defaults</div>', []]) + }) + + // Ambient declarations (`declare ...`) have no runtime binding: the + // environment provides the value (a <script> tag, a bundler define, a global). + it.each([ + { + name: 'a declare function', + declaration: 'declare function track(event: string): void', + use: 'track("x")', + global: 'globalThis.track = (event) => `tracked ${event}`', + expected: 'tracked x', + }, + { + name: 'an exported declare function', + declaration: 'export declare function track(event: string): void', + use: 'track("x")', + global: 'globalThis.track = (event) => `tracked ${event}`', + expected: 'tracked x', + }, + { + name: 'a declare enum', + declaration: 'declare enum Flags { On = 1 }', + use: 'Flags.On', + global: 'globalThis.Flags = { On: 1 }', + expected: 1, + }, + { + name: 'a declare namespace', + declaration: + 'declare namespace Analytics { function track(event: string): void }', + use: 'Analytics.track("x")', + global: 'globalThis.Analytics = { track: (event) => `tracked ${event}` }', + expected: 'tracked x', + }, + ])( + 'reads $name that the loader and the component use from the environment', + async ({ declaration, use, global, expected }) => { + const route = await loadRoute( + `${head}${declaration} +export const Route = createFileRoute('/ambient')({ + loader: () => ${use}, + component: () => <button onClick={() => ${use}}>{String(${use})}</button>, +}) +`, + { routeId: '/ambient', pageScript: global }, + ) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([expected, `<button>${expected}</button>`]) + }, + ) + + // An import the code only references from types (without `import type`) + // is not imported by the route module when only the split component's + // types reference it. (When only the loader's types do, the chunks import + // it: pinned in known-bugs-code-splitter.test.ts.) Source: #8504. + it('leaves an import only the split component references from types out of the route module', async () => { + const route = await loadRoute( + `${head}import { useState } from 'react' +import { Framework } from './projects' +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => { + const [framework] = useState<Framework>('react') + return <p>{framework}</p> + }, +}) +`, + { files: { 'projects.ts': `export const Framework = 'Framework'\n` } }, + ) + expect(await route.requested()).not.toContain('/projects.ts') + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('<p>react</p>') + }) + + // Source: @babel/plugin-transform-typescript class/private-method-override; + // #8504 (a guard against a parser bug, yuku-toolchain/yuku#257). + it('gives the split component a class with an overloaded private method', async () => { + const route = await loadRoute(`${head}class Parser { + #parse(value: string): number + #parse(value: number): string + #parse(value: string | number): string | number { + return typeof value === 'string' ? value.length : String(value) + } + run() { + return [this.#parse('abc'), this.#parse(7)].join('|') + } +} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{new Parser().run()}</p>, +}) +`) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('<p>3|7</p>') + }) + + // An ambient var merged with an interface has no runtime declaration: + // a declaration the loader and the split component share reads the + // global. Source: TypeScript conformance test + // expressions/functionCalls/overloadResolutionConstructors.ts; #8504. + async function readsAmbientVar(verbatimModuleSyntax: boolean) { + const route = await loadRoute( + `${head}interface readVersion { + (): string +} +declare var readVersion: readVersion +const version = readVersion() +export const Route = createFileRoute('/')({ + loader: () => version, + component: () => <p>{version}</p>, +}) +`, + { + tsconfig: { verbatimModuleSyntax }, + pageScript: `globalThis.readVersion = () => '1.0'`, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['1.0', '<p>1.0</p>']) + } + + it('reads an ambient var merged with an interface from the environment in a shared declaration', async () => { + await readsAmbientVar(false) + }) + + // Bug: the route module and the split chunk import the ambient var from + // the shared module (the interface of the same name stays in them and + // counts as a read of the shared binding), and the shared module has no + // runtime binding to export. TypeScript erasure without + // `verbatimModuleSyntax` drops the unused import by chance. + // Source: router-plugin src/core/code-splitter/compilers.ts:143-299 + // (shared bindings) and the shared imports it adds to every module. + // Impact: with `verbatimModuleSyntax` (Vite reads it from tsconfig) the + // client build fails ([MISSING_EXPORT] "readVersion" is not exported by + // "routes/index.tsx?tsr-shared=1"); in dev the route module fails to load. + it.fails( + 'reads an ambient var merged with an interface from the environment in a shared declaration, with verbatimModuleSyntax', + async () => { + await readsAmbientVar(true) + }, + ) + + it('keeps the namespace import that an import alias refers to', async () => { + const route = await loadRoute( + `${head}import * as lib from './lib' +import Helper = lib.Helper +export const Route = createFileRoute('/')({ + component: () => <div>{Helper.x}</div>, +}) +`, + { files: { 'lib.ts': `export const Helper = { x: 'helper' }\n` } }, + ) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe( + '<div>helper</div>', + ) + }) + + // Source: Qwik optimizer test.rs example_ts_enums, example_exports + it('gives the split component the enum and the overloaded function it uses', async () => { + const route = await loadRoute(`${head}enum Tone { Loud = 'LOUD' } +function label(value: string): string +function label(value: unknown) { return 'label:' + String(value) } +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{[Tone.Loud, label('x')].join('|')}</p>, +}) +`) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe( + '<p>LOUD|label:x</p>', + ) + }) + + it.each([ + { + // Source: @babel/plugin-transform-typescript enum/const + name: 'a const enum', + setup: `const enum Direction { Up = 1, Down }`, + render: '[Direction.Up, Direction.Down].join()', + expected: '1,2', + }, + { + // Sources: @babel/plugin-transform-typescript class/parameter-properties + // and @babel/generator typescript/class-abstract + name: 'an abstract class with parameter properties', + setup: `abstract class Base { + constructor(protected readonly label: string, public count = 2) {} + abstract render(): string +} +class Item extends Base { + declare extra: number + render() { return this.label + this.count } +}`, + render: "new Item('item').render()", + expected: 'item2', + }, + ])( + 'gives the split component $name it uses', + async ({ setup, render, expected }) => { + const route = await loadRoute(`${head}${setup} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{${render}}</p>, +}) +`) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe( + `<p>${expected}</p>`, + ) + }, + ) + + // TypeScript lets a type and a value share a name; exporting both is + // valid: another module of the app imports the value, from the split + // route module and from the route module the route HMR plugin compiles + // (automatic code splitting off). + it.each([ + { + name: 'a type alias and an export specifier', + exports: `export type Post = { id: string } +function Post(id: string): Post { + return { id } +} +export { Post }`, + }, + ])( + 'exports a type and a value with the same name: $name', + async ({ exports }) => { + const code = `${head}${exports} +export const Route = createFileRoute('/posts')({ + component: () => <p>posts</p>, +}) +` + const files = { 'importer.ts': `export { Post } from './route'\n` } + const read = `return (await app('importer.ts')).Post('1')` + const route = await loadRoute(code, { routeId: '/posts', files }) + await expectValidModules(route) + expect(await route.run(read)).toEqual({ id: '1' }) + const hmr = await loadRoute(code, { + routeId: '/posts', + files, + hmr: true, + pluginOptions: { autoCodeSplitting: false }, + }) + expect(await hmr.run(read)).toEqual({ id: '1' }) + }, + ) + + // Source: TanStack/router#6480 (an exported type that reads an imported + // value kept the import in the client module); replaces router-utils + // stripTypeExports "handles the issue #6480 scenario", which never checked + // the symptom. + it('drops an import that only an exported type and a split component read from the route module', async () => { + const route = await loadRoute( + `${head}import { secret } from './server-thing' +export type Secret = typeof secret +export const Route = createFileRoute('/')({ + component: () => <p>{secret}</p>, +}) +`, + { files: { 'server-thing.ts': `export const secret = 'server'\n` } }, + ) + await expectValidModules(route) + expect(await route.requested()).not.toContain('/server-thing.ts') + expect(await route.run(`return render('component')`)).toBe('<p>server</p>') + }) + + it('keeps decorators before `export` for legacy decorator transforms', async () => { + // TypeScript `experimentalDecorators` and Babel `decorators-legacy` only + // accept decorators before the `export` keyword: every module the + // router plugin emits must still parse with them. The app runs Babel's + // parser with `decorators-legacy` on every module of the app right + // after the router plugin (as a Babel step of an app's pipeline would), + // then Vite's legacy decorator transform (`experimentalDecorators`). + const legacyDecorators: Plugin = { + name: 'app:decorators-legacy', + enforce: 'pre', + transform(code, id) { + if ( + id.includes('/node_modules/') || + /\.(?:css|json)(?:\?|$)/.test(id) + ) { + return null + } + parseWithBabel(code, { + babelrc: false, + configFile: false, + filename: 'module.tsx', + parserOpts: { plugins: ['typescript', 'jsx', 'decorators-legacy'] }, + }) + return null + }, + } + const route = await loadRoute( + `${head}import { injectable } from 'tsyringe' +import { observable } from 'mobx' +@injectable() export class Store { @observable count = 0 } +export const Route = createFileRoute('/')({ + loader: () => new Store().count, + component: () => <div />, +}) +`, + { + tsconfig: { experimentalDecorators: true }, + plugins: { after: [legacyDecorators] }, + files: { + ...packageFiles( + 'tsyringe', + `export const injectable = () => (target) => target\n`, + ), + ...packageFiles('mobx', `export const observable = () => {}\n`), + }, + }, + ) + expect(await route.isLazy('component')).toBe(true) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([0, '<div></div>']) + }) + + // Auto-accessor fields (TypeScript 4.9+, ES decorators; MobX 6 and Lit use + // them). Compiled only: the browser does not run `accessor` yet, so the + // modules are read from the dev server's own module graph. + it('compiles a class with an auto-accessor field that the split component uses', async () => { + const route = await loadRoute(`${head}class Store { accessor count = 1 } +const store = new Store() +export const Route = createFileRoute('/')({ + loader: () => store, + component: () => <p>{store.count}</p>, +}) +`) + const modules = await servedGraph(route) + expect(Object.keys(modules).length).toBeGreaterThan(0) + await expectValidModules(modules) + }) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-module-state-bindings.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-module-state-bindings.test.ts new file mode 100644 index 0000000000..38d7f777d8 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-module-state-bindings.test.ts @@ -0,0 +1,344 @@ +/** + * Module-level bindings read by route options (SPEC G3, J2.4, J2.5, J2.12), + * across binding kinds, groupings and readers. Split from + * code-splitter-module-state.test.ts (same harness, `./route-app`): its own + * file so that the tier runs it in parallel with the rest. + */ +import { describe, expect, it } from 'vitest' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import type { CodeSplittingOptions } from '../../../src/vite' + +type CodeSplitGroupings = NonNullable<CodeSplittingOptions['defaultBehavior']> + +// Module-level bindings read by route options, across binding kinds, +// groupings and readers: every reader gets the value, the binding is created +// once with one identity, a function only the component reads is not in +// what loads with the route module but in what loading the component loads, +// and a binding only the loader reads is not in what loading the component +// loads (when the two are not grouped) but in what loads with the route +// module or the loader (SPEC J2.5: the user's own code, told by a string marker in +// its body or initializer, whatever the compiler names or prints). A route +// whose readers do not include the component gets one reading no binding, +// so that what loading it loads can be checked, except next to a class (a +// split chunk next to a class with a static initializer is the known bug of +// `isKnownBug`, pinned by its own row). (Where a const or class only the +// component reads is initialised, and so when, is free.) +describe('module-level bindings read by route options', () => { + type Kind = 'const' | 'function' | 'class' + type Reader = 'loader' | 'component' | 'beforeLoad' + + /** The user marker in the code declaring `name`. */ + const marker = (name: string) => `MARK_BINDING_${name}` + + /** Declares `name` as `kind`; consts and classes call `init` once. */ + const declare = (kind: Kind, name: string) => + ({ + const: `const ${name} = init({ name: '${marker(name)}' })`, + function: `function ${name}() { return '${marker(name)}' }`, + class: `class ${name} { static created = init('${marker(name)}') }`, + })[kind] + + const groupings: Array<{ name: string; groupings: CodeSplitGroupings }> = [ + { + name: 'default groupings', + groupings: [['component'], ['errorComponent'], ['notFoundComponent']], + }, + { + name: 'loader and component combined, errorComponent split', + groupings: [['loader', 'component'], ['errorComponent']], + }, + { + name: 'loader split, components combined', + groupings: [ + ['loader'], + [ + 'component', + 'pendingComponent', + 'errorComponent', + 'notFoundComponent', + ], + ], + }, + ] + + type Case = { + name: string + /** Declarations of the route file, after the imports. */ + declarations: string + /** Bindings each route option passes to `seen`. */ + readers: Partial<Record<Reader, Array<string>>> + /** How many times `init` runs: once per const or class binding. */ + inits: number + /** Identities that must be the same object, as expressions over `values`. */ + same?: Array<[string, string]> + /** + * The route also has a component that reads no binding (a split chunk + * next to the bindings), where the readers do not include it. + */ + nextToComponent?: true + } + + const kinds: Array<Kind> = ['const', 'function', 'class'] + const singleBinding = kinds.flatMap((kind): Array<Case> => { + const declarations = declare(kind, 'x') + const inits = kind === 'function' ? 0 : 1 + return [ + { name: `a ${kind} only the loader reads`, readers: { loader: ['x'] } }, + { + name: `a ${kind} only the component reads`, + readers: { component: ['x'] }, + }, + { + name: `a ${kind} the loader and the component read`, + readers: { loader: ['x'], component: ['x'] }, + }, + { + name: `a ${kind} the component and beforeLoad read`, + readers: { component: ['x'], beforeLoad: ['x'] }, + }, + ].map((row) => ({ ...row, declarations, inits })) + }) + + const cases: Array<Case> = [ + ...singleBinding, + { + name: 'a class only the loader reads, next to a component that reads no binding', + declarations: declare('class', 'x'), + readers: { loader: ['x'] }, + inits: 1, + nextToComponent: true, + }, + { + name: 'two consts the loader and the component read', + declarations: `${declare('const', 'a')}\n${declare('const', 'b')}`, + readers: { loader: ['a', 'b'], component: ['a', 'b'] }, + inits: 2, + }, + { + name: 'a const both read next to a const only the component reads', + declarations: `${declare('const', 'a')}\n${declare('const', 'b')}`, + readers: { loader: ['a'], component: ['a', 'b'] }, + inits: 2, + }, + { + name: 'a chain of consts (a reads b reads c)', + declarations: `${declare('const', 'c')} +const b = { c } +const a = { b }`, + readers: { loader: ['a'], component: ['a'] }, + inits: 1, + }, + { + name: 'a diamond of consts (a reads b and c, both read d)', + declarations: `${declare('const', 'd')} +const b = { d } +const c = { d } +const a = { b, c }`, + readers: { loader: ['a'], component: ['a'] }, + inits: 1, + same: [['a.b.d', 'a.c.d']], + }, + ] + + /** + * Known bug, remove from here when fixed: a class whose static initializer + * calls a function is kept in a module that does not read it (dead-code + * elimination keeps a class with a side-effectful static initializer), so + * the class is created twice: + * - read by the options of one split chunk only, it is declared in that + * chunk and also kept in the route module; + * - read by the unsplit loader only, it is kept in the route module and + * also declared in the chunk of a split component that does not read it + * (three times when the loader is split too; the const and function rows + * next to such a component are the controls). + * Impact: what the static initializer does (registrations, counters) runs + * again when the chunk loads, and a module holds a second class. + */ + const isKnownBug = (row: Case, codeSplitGroupings: CodeSplitGroupings) => { + const readers = Object.keys(row.readers) as Array<Reader> + const oneChunk = codeSplitGroupings.some((group) => + readers.every((reader) => group.includes(reader as never)), + ) + const chunkWithoutReader = + row.nextToComponent === true && + codeSplitGroupings.some( + (group) => + group.includes('component') && + !readers.some((reader) => group.includes(reader as never)), + ) + return row.name.startsWith('a class') && (oneChunk || chunkWithoutReader) + } + + const stateModule = `export let initCalls = 0 +export const entries: Array<{ reader: string; values: Record<string, unknown> }> = [] +export const init = <T,>(value: T): T => { + initCalls++ + return value +} +export const seen = (reader: string, values: Record<string, unknown>) => { + entries.push({ reader, values }) + return Object.keys(values).length +} +` + + describe.each(groupings)( + 'with $name', + ({ groupings: codeSplitGroupings }) => { + const assertReads = async ({ + declarations, + readers, + inits, + same, + nextToComponent, + }: Case) => { + const options = (['loader', 'component', 'beforeLoad'] as const) + .filter((reader) => readers[reader]) + .map((reader) => { + const values = `{ ${readers[reader]!.join(', ')} }` + return reader === 'component' + ? ` component: () => <p>{seen('component', ${values})}</p>,` + : ` ${reader}: () => seen('${reader}', ${values}),` + }) + const addedComponent = + !readers.component && + (nextToComponent === true || !declarations.includes('class ')) + if (addedComponent) { + options.push(` component: () => <p>no binding</p>,`) + } + const route = await loadRoute( + `${head}import { init, seen } from './state' +${declarations} +export const Route = createFileRoute('/')({ + codeSplitGroupings: ${JSON.stringify(codeSplitGroupings)}, +${options.join('\n')} +}) +`, + { files: { 'state.ts': stateModule } }, + ) + await expectValidModules(route) + + const names = [...new Set(Object.values(readers).flat())] + const observed = await route.run<{ + results: Array<unknown> + initCalls: number + distinct: Record<string, number> + same: Array<boolean> + eagerCode: Array<string> + componentCode: Array<string> + loaderCode: Array<string> + }>(`// What loads with the route module, what loading the component loads +// on top of it, and what loading the loader then loads +const eager = await compiled() +const before = new Set(eager) +await trigger('component') +const componentLoads = (await compiled()).filter((request) => !before.has(request)) +const beforeLoader = new Set(await compiled()) +await trigger('loader') +const loaderLoads = (await compiled()).filter((request) => !beforeLoader.has(request)) +const readers = ${JSON.stringify(readers)} +const results = [] +for (const reader of ['loader', 'beforeLoad']) { + if (readers[reader]) results.push(await (await load(reader))()) +} +if (readers.component) results.push(await render('component')) +const state = await app('state.ts') +// Every reader got the same value for each binding. +const distinct = {} +for (const name of ${JSON.stringify(names)}) { + distinct[name] = new Set( + state.entries.filter((entry) => name in entry.values).map((entry) => entry.values[name]), + ).size +} +const read = (values, path) => path.split('.').reduce((value, key) => value[key], values) +const same = [] +for (const [left, right] of ${JSON.stringify(same ?? [])}) { + for (const { values } of state.entries) same.push(read(values, left) === read(values, right)) +} +return { + results, + initCalls: state.initCalls, + distinct, + same, + eagerCode: await Promise.all(eager.map(served)), + componentCode: await Promise.all(componentLoads.map(served)), + loaderCode: await Promise.all(loaderLoads.map(served)), +}`) + expect(observed.results).toEqual( + (['loader', 'beforeLoad', 'component'] as const) + .filter((reader) => readers[reader]) + .map((reader) => + reader === 'component' + ? `<p>${readers.component!.length}</p>` + : readers[reader]!.length, + ), + ) + expect(observed.initCalls).toBe(inits) + expect(observed.distinct).toEqual( + Object.fromEntries(names.map((name) => [name, 1])), + ) + expect(observed.same.every(Boolean)).toBe(true) + + // A function only the component reads is not in what loads with the + // route module, but in what loading the component loads; a binding + // only the loader reads is not in what loading the component loads + // (unless the loader is grouped with the component), but in what + // loads with the route module or the loader. + const readBy = (name: string) => + (Object.keys(readers) as Array<Reader>).filter((reader) => + readers[reader]!.includes(name), + ) + const holding = (code: Array<string>, name: string) => + code.some((module) => holdsMarker(module, marker(name))) + const loaderWithComponent = codeSplitGroupings.some( + (group) => group.includes('loader') && group.includes('component'), + ) + for (const name of names) { + const readersOfName = readBy(name) + if ( + readersOfName.join() === 'component' && + declarations.includes(`function ${name}(`) + ) { + expect( + { + eager: holding(observed.eagerCode, name), + component: holding(observed.componentCode, name), + }, + name, + ).toEqual({ eager: false, component: true }) + } + if ( + readersOfName.join() === 'loader' && + addedComponent && + !loaderWithComponent + ) { + expect( + { + component: holding(observed.componentCode, name), + eagerOrLoader: holding( + [...observed.eagerCode, ...observed.loaderCode], + name, + ), + }, + name, + ).toEqual({ component: false, eagerOrLoader: true }) + } + } + } + + it.each(cases.filter((row) => !isKnownBug(row, codeSplitGroupings)))( + '$name', + assertReads, + ) + // See `isKnownBug`. + it.fails.each(cases.filter((row) => isKnownBug(row, codeSplitGroupings)))( + '$name', + assertReads, + ) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-module-state.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-module-state.test.ts new file mode 100644 index 0000000000..a7c84b9af7 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-module-state.test.ts @@ -0,0 +1,944 @@ +/** + * Split chunks keep the module state the route relies on (SPEC G3, J2.4, + * J2.12, G9): every value is created once, every reader gets that instance, + * and what the rest of the app imports from the route file is what the + * options read. Routes load in a real browser page from a real dev server + * (`./route-app`); the modules a route file imports are files of the app, + * which record what ran, and the page reads them. + */ +import { describe, expect, it } from 'vitest' +import { expectValidModules, head, loadRoute } from '../../route-app' + +/** + * An app module `init.ts` (or another name) whose `init` counts its calls + * (`calls`) and returns its argument. + */ +const countingInit = `export let calls = 0 +export const init = <T,>(value: T): T => { + calls++ + return value +} +` + +/** An app module whose `see` records what it is given (`seen`). */ +const recordingSee = `export const seen: Array<unknown> = [] +export const see = (value: unknown) => { + seen.push(value) + return value +} +` + +describe('split chunks keep the module state the route relies on', () => { + // Source: Qwik optimizer test.rs + // should_keep_non_migrated_binding_from_shared_destructuring_declarator_with_default (+ _with_rest) + it('evaluates a destructuring split between the loader and the component once', async () => { + const route = await loadRoute( + `${head}import { makeConfig } from './config' +const { a = 'A', ...b } = makeConfig() +export const Route = createFileRoute('/')({ + loader: () => a, + component: () => <div>{JSON.stringify(b)}</div>, +}) +`, + { + files: { + 'config.ts': `export let calls = 0 +export const makeConfig = () => { + calls++ + return { x: 1 } +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('config.ts')).calls, +]`), + ).toEqual(['A', '<div>{"x":1}</div>', 1]) + }) + + // Source: Qwik optimizer test.rs root_level_self_referential_qrl, + // example_self_referential_component_migration + it('declares mutually recursive components used by two lazy chunks once', async () => { + const route = await loadRoute( + `${head}import { see } from './see' +function A({ depth }: { depth: number }) { + see(A) + return depth ? <B depth={depth - 1} /> : <i>a</i> +} +function B({ depth }: { depth: number }) { + see(B) + return <b><A depth={depth} /></b> +} +export const Route = createFileRoute('/')({ + component: () => <A depth={1} />, + errorComponent: () => <B depth={0} />, +}) +`, + { files: { 'see.ts': recordingSee } }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + await render('component'), + await render('errorComponent'), + // Both chunks render the same A and the same B + new Set((await app('see.ts')).seen).size, +]`), + ).toEqual(['<b><i>a</i></b>', '<b><i>a</i></b>', 2]) + }) + + it('keeps one class with a static block and private members', async () => { + const route = await loadRoute(`${head}class Counter { + static created = 0 + static { Counter.created = 1 } + #n = 0 + increment() { return ++this.#n } + static owns(value: object) { return #n in value } +} +const counter = new Counter() +export const Route = createFileRoute('/')({ + loader: () => counter.increment(), + component: () => <div>{String(Counter.owns(counter))}</div>, +}) +`) + await expectValidModules(route) + // `#n in counter` only holds for the class that created `counter`. + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([1, '<div>true</div>']) + }) + + // Source: Turbopack tree-shaker analyzer/nanoid, analyzer/let-bug-1 + it('keeps one let that a helper the loader and the component call reassigns', async () => { + const route = + await loadRoute(`${head}let pool: Array<number> = [], offset = 0 +const fill = () => { pool = [offset++] } +export const Route = createFileRoute('/')({ + loader: () => { fill(); return pool }, + component: () => { fill(); return <p>{pool.join()}</p> }, +}) +`) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([[0], '<p>1</p>']) + }) + + // TypeScript erases type positions, so a declaration the split component + // only reads in a type is created once, by the route module. (Next to a + // type alias that reads it: pinned in known-bugs-code-splitter.test.ts.) + // Source: #8504 (real apps: forms that cast `as z.infer<typeof schema>` + // in the split component). + it('creates a declaration the split component only reads in a type once', async () => { + const route = await loadRoute( + `${head}import { init } from './state' +const value = init(1) +export const Route = createFileRoute('/')({ + component: () => <p>{typeof ({} as typeof value)}</p>, +})`, + { files: { 'state.ts': countingInit } }, + ) + await expectValidModules(route) + expect( + await route.run( + `return [await render('component'), (await app('state.ts')).calls]`, + ), + ).toEqual(['<p>object</p>', 1]) + }) +}) + +// Exported destructurings whose bindings split options read: each +// initializer runs once, and the route module exports the objects the +// options read. Shapes of the deleted code-splitter snapshot fixtures +// destructured-export-multiple, destructured-export-nested and +// shared-destructured-export. +it('keeps one instance of exported destructured bindings the loader and the component read', async () => { + const route = await loadRoute( + `${head}import { init, init2, see } from './state' +export const { + api: { base }, + ...rest +} = init({ api: { base: { url: '/api' } }, extra: { flag: true } }) +export const [x, y] = init2([{ id: 'x' }, { id: 'y' }]) +export const Route = createFileRoute('/')({ + loader: () => rest, + component: () => <p>{see({ base, x }) + base.url + x.id}</p>, +}) +`, + { + files: { + 'state.ts': `export const calls = { init: 0, init2: 0 } +export const seen: Record<string, unknown> = {} +export const init = <T,>(value: T): T => { + calls.init++ + return value +} +export const init2 = <T,>(value: T): T => { + calls.init2++ + return value +} +export const see = (values: Record<string, unknown>) => { + Object.assign(seen, values) + return '' +} +`, + // What the rest of the app imports from the route file + 'importer.ts': `export { rest, base, x, y } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const loaded = await (await load('loader'))() +const html = await render('component') +const state = await app('state.ts') +const imported = await app('importer.ts') +return { + loaded, + html, + calls: state.calls, + // What the rest of the app imports from the route file is what the + // options read. + rest: imported.rest === loaded, + base: imported.base === state.seen.base, + x: imported.x === state.seen.x, + y: imported.y, +}`), + ).toEqual({ + loaded: { extra: { flag: true } }, + html: '<p>/apix</p>', + calls: { init: 1, init2: 1 }, + rest: true, + base: true, + x: true, + y: { id: 'y' }, + }) +}) + +// Initializers whose side effects hide in their syntax, read by the loader +// and the split component: each runs once and both options read the one +// value (when it runs is free). Source: #8504 +// (shared-bindings-helpers.test.ts). +describe('a shared initializer with side effects', () => { + it.each([ + { + name: 'a template literal (toString)', + declaration: 'const value = { label: `${prefix}` }', + }, + { + name: 'a unary minus (valueOf)', + declaration: 'const value = { label: -prefix }', + }, + { + name: 'a constructor of an import', + declaration: `import { Map } from 'immutable' +const value = new Map()`, + }, + { + name: 'a static field calling an import', + declaration: `class Store { + static instance = register() +} +const value = Store`, + }, + // Creating the element does not call the component (no effect); the + // loader and the component still read one element. + { + name: 'JSX of a component that calls an import', + declaration: `function Tracked() { + register() + return 'tracked' +} +const value = { element: <Tracked /> }`, + effects: 0, + }, + { + name: 'a pure-annotated call (control)', + declaration: 'const value = /* @__PURE__ */ register()', + }, + ])('$name runs once', async ({ declaration, effects: expected = 1 }) => { + const route = await loadRoute( + `${head}import { prefix, register, see } from './state' +${declaration} +export const Route = createFileRoute('/')({ + loader: () => see(value), + component: () => <p>{String(see(value))}</p>, +}) +`, + { + files: { + 'state.ts': `export let effects = 0 +export const seen: Array<unknown> = [] +export const register = () => { + effects++ + return { id: effects } +} +export const prefix = { + toString: () => String(register().id), + valueOf: () => register().id, +} +export const see = (value: unknown) => { + seen.push(value) + return 1 +} +`, + 'node_modules/immutable/package.json': JSON.stringify({ + name: 'immutable', + type: 'module', + exports: './index.js', + }), + 'node_modules/immutable/index.js': `import { register } from '../../state.ts' +export class Map { + id = register().id +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`options.loader() +const html = await render('component') +const state = await app('state.ts') +return { + html, + effects: state.effects, + seen: state.seen.length, + same: state.seen[0] === state.seen[1], +}`), + ).toEqual({ html: '<p>1</p>', effects: expected, seen: 2, same: true }) + }) +}) + +describe('split chunks keep reassigned bindings next to their writers', () => { + // Source: React Router route-chunks-test.ts "reassignment"; babel-dead-code-elimination + // find-removable-bindings.test.ts "constant violations mark as external" + it('keeps a binding that only the split component reassigns writable, and its imports out of the route module', async () => { + const route = await loadRoute( + `${head}import { next } from './next' +let current = 'initial' +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => { + const previous = current + current = next + return <p>{previous}-{current}</p> + }, +}) +`, + { files: { 'next.ts': `export const next = 'next'\n` } }, + ) + // Nothing the route module loads requests what only the component reads. + expect(await route.requested()).not.toContain('/next.ts') + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + await render('component'), +]`), + ).toEqual(['data', '<p>initial-next</p>', '<p>next-next</p>']) + }) + + // A lazily initialised getter that replaces itself after the first call. + // Source: Next.js ssg/getStaticProps/should-support-babel-style-memoized-function + it.each([ + { name: 'the component', loader: `'data'`, loaded: 'data' }, + { + name: 'the loader and the component', + loader: 'see(getConfig()).title', + loaded: 'config', + }, + ])( + 'keeps a self-reassigning function used by $name working, with one result', + async ({ loader, loaded }) => { + const route = await loadRoute( + `${head}import { createConfig, see } from './config' +let getConfig = () => { + const config = createConfig() + getConfig = () => config + return config +} +export const Route = createFileRoute('/')({ + loader: () => ${loader}, + component: () => <div>{see(getConfig()).title}</div>, +}) +`, + { + files: { + 'config.ts': `export let created = 0 +export const seen = new Set<unknown>() +export const createConfig = () => { + created++ + return { title: 'config' } +} +export const see = <T,>(value: T): T => { + seen.add(value) + return value +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const results = [ + options.loader(), + await render('component'), + options.loader(), + await render('component'), +] +const config = await app('config.ts') +return [...results, config.created, config.seen.size]`), + ).toEqual([ + loaded, + '<div>config</div>', + loaded, + '<div>config</div>', + 1, + 1, + ]) + }, + ) + + // A const only the split component reads works with the module-level + // statements that write to it. Enums and namespaces do not: pinned in + // known-bugs-code-splitter.test.ts ("top-level writes to ... stay with the + // binding they write"). Source: #8504. + it('keeps the writes to a const the split component reads', async () => { + const route = await loadRoute(`${head}const State = { count: 0 } +Object.assign(State, { extra: 7 }) +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{(State as any).extra}</p>, +}) +`) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['data', '<p>7</p>']) + }) +}) + +// A binding the loader (route module) and the split component both read +// (directly or through what they call) is created once, and both get it. +describe('a binding the loader and the split component share', () => { + // `useQuery({ ... })` in a split component: only `createFileRoute(...)` + // gives the route options. + it('is created once when the component calls a hook with an options object', async () => { + const route = await loadRoute( + `${head}import { useThing } from './thing' +const state = { count: 0 } +export const Route = createFileRoute('/')({ + loader: () => ++state.count, + component: () => { + const value = useThing({ label: 'x' }) + return <p>{state.count}{value.label}</p> + }, +}) +`, + { + files: { + 'thing.ts': `export const useThing = <T,>(options: T): T => options\n`, + }, + }, + ) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([1, '<p>1x</p>']) + }) + + it('keeps exported classes next to it importable, with one identity', async () => { + const route = await loadRoute( + `${head}import { see } from './see' +export class AppError extends Error {} +export class Cache { + value = 'cached' +} +class Local { + value = 'local' +} +export const Route = createFileRoute('/')({ + loader: () => ({ AppError, cached: new Cache().value, local: new Local().value }), + component: () => { + see(AppError) + return <p>component</p> + }, +}) +`, + { + files: { + 'see.ts': recordingSee, + 'importer.ts': `export { AppError, Cache } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const imported = await app('importer.ts') +const loaded = options.loader() +const html = await render('component') +const { seen } = await app('see.ts') +return { + html, + sameInLoader: loaded.AppError === imported.AppError, + sameInComponent: seen.length === 1 && seen[0] === imported.AppError, + cached: loaded.cached, + local: loaded.local, + cache: new imported.Cache().value, +}`), + ).toEqual({ + html: '<p>component</p>', + sameInLoader: true, + sameInComponent: true, + cached: 'cached', + local: 'local', + cache: 'cached', + }) + }) + + /** + * Loads a route whose loader passes `loader` and whose split component + * passes `component` (expressions over `declarations`) to `see`, and + * checks that both ran with what the route file declares: `init` (called + * once by `declarations`) ran once, and the loader and the component got + * the same value when they read the same expression. + */ + async function expectSharedOnce({ + declarations, + loader = 'value', + component = 'value', + }: { + declarations: string + loader?: string + component?: string + }) { + const route = await loadRoute( + `${head}import { init, see, UI } from './state' +${declarations} +export const Route = createFileRoute('/')({ + loader: () => see(${loader}), + component: () => <p>{String(see(${component}))}</p>, +}) +`, + { + files: { + 'state.ts': `export let inits = 0 +export const seen: Array<any> = [] +export const init = <T,>(value: T): T => { + inits++ + return value +} +export const see = (value: any) => { + seen.push(value) + return typeof value?.read === 'function' ? value.read().name : 'ok' +} +export const UI = { Title: () => 'title' } +`, + }, + }, + ) + await expectValidModules(route) + const observed = await route.run<{ + loaded: string + html: string + seen: number + same: boolean + inits: number + }>(`const loaded = options.loader() +const html = await render('component') +const state = await app('state.ts') +return { + loaded, + html, + seen: state.seen.length, + same: state.seen[0] === state.seen[1], + inits: state.inits, +}`) + expect(observed.html).toBe(`<p>${observed.loaded}</p>`) + expect(observed.seen).toBe(2) + if (loader === component) { + expect(observed.same).toBe(true) + } + expect(observed.inits).toBe(1) + } + + it.each([ + { + name: 'a class that reads another binding', + declarations: `const config = init({ name: 'config' }) +class Store { settings = config } +const value = new Store()`, + }, + { + name: 'an array destructuring', + declarations: `const [a, b] = init([{ id: 'a' }, { id: 'b' }])`, + loader: 'a', + component: 'b', + }, + { + name: 'an array destructuring with a rest element', + declarations: `const [first, ...rest] = init([1, 2, 3])`, + loader: 'first', + component: 'rest', + }, + // Each call creates a new element: both read the tag it renders. + { + name: 'an object read as a JSX member tag', + declarations: `const Parts = init({ Title: () => 'title' }) +const Header = () => <Parts.Title />`, + loader: 'Header().type', + component: 'Header().type', + }, + { + name: 'a helper with a block-scoped local of the same name in one branch', + declarations: `const config = init({ name: 'config' }) +function read() { + if (Math.random() > 2) { const config = { name: 'local' }; return config } + return config +} +const value = { read }`, + }, + { + name: 'an object with a var of the same name in a sibling method', + declarations: `const config = init({ name: 'config' }) +const value = { + local() { var config = 'local'; return config }, + read() { return config }, +}`, + }, + // The private method is the only code reading `config` (found by + // mutation testing: a compiler ignoring private method bodies). + { + name: 'a private method, the only reader of the binding', + declarations: `const config = init({ name: 'config' }) +class Vault { + #read() { + return config + } + read() { + return this.#read() + } +}`, + loader: 'new Vault().read()', + component: 'new Vault().read()', + }, + ])('reaches the split component through $name', expectSharedOnce) + + // Each row declares a module-level `title` (or component) that reads + // `Route`, and a local of the same name inside the shared value: the local + // is not a read of the module-level binding. + it.each([ + ['an arrow function parameter', `init({ format: (title) => title })`], + [ + 'a function expression parameter', + `init({ format: function (title) { return title } })`, + ], + ['an object method parameter', `init({ format(title) { return title } })`], + [ + 'a class method parameter', + `init(new (class { format(title) { return title } })())`, + ], + [ + 'a private method parameter', + `init(new (class { #format(title) { return title } run() { return this.#format(1) } })())`, + ], + ['a destructured parameter', `init({ format: ({ title }) => title })`], + ['a rest parameter', `init({ f: (...title) => title })`], + [ + 'a catch parameter', + `init({ run: () => { try { return 1 } catch (title) { return title } } })`, + ], + ['a local const', `init({ run: () => { const title = 1; return title } })`], + [ + 'a const in a nested block', + `init({ run: () => { if (Math.random() < 2) { const title = 1; return title } return 0 } })`, + ], + [ + 'a var in a nested block', + `init({ run: () => { if (Math.random() < 2) { var title = 1 } return title } })`, + ], + [ + 'a function declared after its use', + `init({ run: () => { return title(); function title() { return 1 } } })`, + ], + [ + 'a const read by a closure before its declaration', + `init({ run: () => { const get = () => title; const title = 1; return get() } })`, + ], + [ + 'a class declared after its use', + `init({ run: () => { const make = () => new title(); class title {} return make() } })`, + ], + [ + 'a for-of binding', + `init({ run: () => { for (const title of [1]) { return title } } })`, + ], + [ + 'the name of a class expression', + `init(class title { static self = () => title })`, + ], + [ + 'a class declared in a function', + `init({ run: () => { class title {} return new title() } })`, + ], + [ + 'the name of a function expression', + `init({ run: function title() { return title } })`, + ], + [ + 'a function declared in a function', + `init({ run: () => { function title() { return 1 } return title() } })`, + ], + [ + 'a local type alias', + `init({ run: () => { type title = number; const x: title = 1; return x } })`, + ], + [ + 'a local enum', + `init({ run: () => { enum title { A } return title.A } })`, + ], + ])( + 'is not tied to a module-level helper reading Route by %s of the same name', + (_, value) => + expectSharedOnce({ + declarations: `const title = () => Route.id +const value = ${value}`, + }), + ) + + it.each([ + [ + 'a destructured prop rendered as JSX', + `const Icon = () => <i>{Route.id}</i> +const value = init({ render: ({ Icon }) => <Icon /> })`, + ], + [ + 'the property of a JSX member tag', + `const Title = () => <i>{Route.id}</i> +const value = init({ render: () => <UI.Title /> })`, + ], + [ + 'a JSX attribute name', + `const Title = () => Route.id +const value = init({ render: () => <div Title="x" /> })`, + ], + ])( + 'is not tied to a module-level component reading Route by %s of the same name', + (_, declarations) => expectSharedOnce({ declarations }), + ) +}) + +// The route module keeps what the rest of the app imports from the route +// file working when a split component comes from the same declaration. +describe('a split component declared next to other bindings', () => { + it.each([ + { name: 'plain', pattern: '{ Panel, usePanel }' }, + { + name: 'with defaults', + pattern: '{ Panel = Fallback, usePanel = useFallback }', + }, + ])( + 'keeps the sibling of a destructuring working ($name)', + async ({ pattern }) => { + const route = await loadRoute( + `${head}import { createPanel } from './panel' +const Fallback = () => <p>fallback</p> +const useFallback = () => 'fallback' +const ${pattern} = createPanel() +export function usePanelState() { + return usePanel() +} +export const Route = createFileRoute('/')({ component: Panel }) +`, + { + files: { + 'panel.ts': `export const createPanel = () => ({ + Panel: () => 'panel', + usePanel: () => 'state', +}) +`, + 'importer.ts': `export { usePanelState } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const { usePanelState } = await app('importer.ts') +return [usePanelState(), await render('component')]`), + ).toEqual(['state', 'panel']) + }, + ) + + it('reads an exported object destructuring created once', async () => { + const route = await loadRoute( + `${head}import { getConfig } from './config' +export const { title } = getConfig() +export const Route = createFileRoute('/')({ + component: () => <p>{title}</p>, +}) +`, + { + files: { + 'config.ts': `export let calls = 0 +export const getConfig = () => { + calls++ + return { title: 't' } +} +`, + 'importer.ts': `export { title } from './route'\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const html = await render('component') +const { title } = await app('importer.ts') +return [html, title, (await app('config.ts')).calls]`), + ).toEqual(['<p>t</p>', 't', 1]) + }) +}) + +// In a JavaScript route file, imports are not elided by a type-aware +// transform: state that split options share is still created once, every +// option reads the same instance, and what only one split option imports +// does not load with the route module. +describe('state only split options read, in a .jsx route file', () => { + const stateRoute = ( + options: string, + ) => `${head}import { init, see } from './init' +const store = init({ label: 'shared' }) +export const Route = createFileRoute('/')({ +${options} +}) +` + + it('is created once, and every option reads that instance', async () => { + const route = await loadRoute( + stateRoute(` component: () => <p>{see(store)}</p>, + errorComponent: () => <p>{see(store)}</p>,`), + { + filename: 'route.jsx', + files: { + 'init.js': `export let inits = 0 +export const seen = [] +export const init = (value) => { + inits++ + return { ...value } +} +export const see = (store) => { + seen.push(store) + return store.label +} +`, + }, + }, + ) + // When the store is created is free (initialiser timing is not pinned, + // nor whether its module loads with the route module): it is created + // once and both options read that one instance. + expect( + await route.run(`const html = [await render('component'), await render('errorComponent')] +const state = await app('init.js') +return [...html, state.inits, new Set(state.seen).size]`), + ).toEqual(['<p>shared</p>', '<p>shared</p>', 1, 1]) + }) + + it('is not created by loading a split option that does not read it', async () => { + const route = await loadRoute( + stateRoute(` component: () => <p>{see(store)}</p>, + errorComponent: () => <p>{see(store)}</p>, + notFoundComponent: () => <p>nf</p>,`), + { + filename: 'route.jsx', + files: { + 'init.js': `export let inits = 0 +export const init = (value) => { + inits++ + return value +} +export const see = (store) => store.label +`, + }, + }, + ) + // Whether the route module creates it is free; loading the + // notFoundComponent chunk does not (it holds only what it needs, SPEC J2.5). + expect( + await route.run(`// Until the page requests the module, nothing has created the store +const inits = async () => + (await requested()).includes('/init.js') ? (await app('init.js')).inits : 0 +const atLoad = await inits() +const notFound = await render('notFoundComponent') +const afterNotFound = await inits() +const component = await render('component') +return { notFound, unchanged: afterNotFound === atLoad, component, inits: await inits() }`), + ).toEqual({ + notFound: '<p>nf</p>', + unchanged: true, + component: '<p>shared</p>', + inits: 1, + }) + }) + + it('does not load what only the split component imports with the state the loader shares', async () => { + const route = await loadRoute( + `${head}import { createStore } from './store' +import { Chart } from './chart' +const store = createStore() +export const Route = createFileRoute('/')({ + loader: () => store.get(), + component: () => <Chart data={store.get()} />, +}) +`, + { + filename: 'route.jsx', + files: { + 'store.js': `export const createStore = () => ({ get: () => 'v' })\n`, + 'chart.js': `export const Chart = ({ data }) => data\n`, + }, + }, + ) + // Nothing the route module loads requests `./chart`. + expect(await route.requested()).not.toContain('/chart.js') + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['v', 'v']) + }) +}) + +// A split component wrapped in a call (`memo(Page)`, an HOC) of a `const` +// component: the call runs when the chunk loads, after `Page` is +// initialized (SPEC G3: ordering dependencies kept; J2.6: the chunk loads +// and renders). A `function Page() {}` declaration is hoisted and would hide +// a wrapper evaluated above it (found by mutation testing). +describe('a split component wrapped in a call of a const component', () => { + it.each([ + { + name: "React's memo", + code: `${head}import { memo } from 'react' +const Page = () => <h1>Posts</h1> +export const Route = createFileRoute('/')({ component: memo(Page) }) +`, + }, + { + name: 'an application HOC', + code: `${head}import { withAuth } from './auth' +const Page = () => <h1>Posts</h1> +export const Route = createFileRoute('/')({ component: withAuth(Page) }) +`, + }, + ])('renders when the chunk loads ($name)', async ({ code }) => { + const route = await loadRoute(code, { + files: { + 'auth.ts': `export const withAuth = <T,>(component: T): T => component\n`, + }, + }) + expect(await route.run(`return render('component')`)).toBe('<h1>Posts</h1>') + }) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline-routes.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline-routes.test.ts new file mode 100644 index 0000000000..c4bc46c05f --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline-routes.test.ts @@ -0,0 +1,685 @@ +/** + * The router plugin in a real Vite pipeline (SPEC J2.1, J2.13, G4, G5, + * G11), continued from code-splitter-plugin-pipeline.test.ts (two files, to + * keep each within the per-file time budget): modules the router plugin + * does not own, root routes without options, route HMR without code + * splitting, and routes created inside a function. The public composed + * `tanstackRouter` and the framework's Vite plugin run in a real dev server + * (`route-app.ts`), and the page imports what the dev server serves. + * Diagnostics are judged by content on every channel at once. + */ +import { describe, expect, it } from 'vitest' +import { expectNoProblems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { tanstackRouter } from '../../../src/vite' +import { createReactDevPage, renderProbe } from '../../dev-page' +import { expectValidModules, loadRoute, uncaughtErrors } from '../../route-app' +import type { Config } from '../../../src' +import type { RouteApp, RouteAppOptions } from '../../route-app' + +/** + * A virtual route config (the public `virtualRouteConfig` option) of an app + * whose root has the route files `files` (path → route id). + */ +const routesOf = (files: Record<string, string>) => + ({ + type: 'root', + file: '__root.tsx', + children: Object.entries(files).map(([file, path]) => ({ + type: 'route', + path, + file, + })), + }) as Config['virtualRouteConfig'] + +// Modules the router plugin does not own pass its transform untouched, and +// behave as written, in a real app (SPEC J2.1, G15): the composed +// `tanstackRouter` plugin (route generator and code splitter, or route HMR +// when splitting is off) in a real Vite dev server, which also loads a lazy +// route file the generator registers but which is never split further. +// Only route files the generator registers are the router plugin's; a +// module mentioning or calling a route factory is not one, whatever it +// imports. +describe('modules the router plugin does not own', () => { + const files = { + 'routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({}) +`, + 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => <p>home</p> }) +`, + // A lazy route file: registered, not split further (J2.1). + 'routes/posts.lazy.tsx': `import { createLazyFileRoute } from '@tanstack/react-router' +export const Route = createLazyFileRoute('/posts')({ + component: () => <p>posts</p>, + pendingComponent: () => <p>pending posts</p>, +}) +`, + // An API module of the app using router APIs, mentioning a route + // factory in a string. + 'src/api.ts': `import { redirect } from '@tanstack/react-router' +export const docs = "call createFileRoute('/path')({ component }) in a route file" +export function guard(user: string | undefined) { + if (!user) { + throw redirect({ to: '/login' }) + } + return user +} +`, + // Code-based routes (code-splitting.md:73-75: no automatic splitting). + 'src/code-routes.tsx': `import { createRootRoute, createRoute } from '@tanstack/react-router' +import { fetchItems } from './items' +const root = createRootRoute() +export const itemsRoute = createRoute({ + getParentRoute: () => root, + path: '/items', + loader: () => fetchItems(), + component: () => <p>items</p>, + errorComponent: () => <p>items failed</p>, +}) +export const routeTree = root.addChildren([itemsRoute]) +`, + 'src/items.ts': `export const fetchItems = () => ['item']\n`, + // A genuine route factory call in a module the generator does not + // register (a route built for a preview or a test, never in the route + // tree): not a route file, so not the router plugin's. + 'src/route-preview.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + loader: () => 'preview data', + component: () => <p>preview</p>, +}) +`, + // A registered route file whose other code uses a look-alike of the + // route factory: the same name from an unrelated package. Only the call + // bound to `Route` is the route's (SPEC J2.1, G15; a local factory + // shadowing the name in a route file: pinned in + // known-bugs-code-splitter.test.ts, "look-alike route factories"). + // An unregistered module calling the genuine factory: `route-preview`. + 'routes/widgets.tsx': `import { createFileRoute } from '@tanstack/react-router' +import * as other from 'other-router' +function ForeignWidget() { + return <p>foreign widget</p> +} +export const widgets = { + ForeignWidget, + foreign: other.createFileRoute('/foreign-widget')({ loader: () => 'foreign data', component: ForeignWidget }), +} +export const Route = createFileRoute('/widgets')({ + component: () => <p>widgets</p>, +}) +`, + // A factory of the same name from an unrelated package. + 'src/unrelated-factory.tsx': `import { createFileRoute } from 'other-router' +export const Route = createFileRoute('/unrelated')({ + loader: () => 'unrelated data', + component: () => <p>unrelated</p>, +}) +`, + 'node_modules/other-router/package.json': `{ "name": "other-router", "type": "module", "exports": "./index.js" }\n`, + 'node_modules/other-router/index.js': `export const createFileRoute = (path) => (options) => ({ path, options })\n`, + // A locally declared factory shadowing the router's name. + 'src/shadowed-factory.tsx': `function createFileRoute(path: string) { + return (options: Record<string, unknown>) => ({ path, options }) +} +export const Route = createFileRoute('/shadowed')({ + loader: () => 'shadowed data', + component: () => <p>shadowed</p>, +}) +`, + // Shapes of deleted snapshot fixtures (destructuring, function as + // parameter), in a module that is not a route. + 'src/destructuring.ts': `const thing = { foo: { bar: { destructured: 'destructured' } } } +export function test() { + const { + foo: { + bar: { destructured }, + }, + } = thing + return destructured +} +export const doubled = [1, 2].map(function double(value) { + return value * 2 +}) +`, + } + const unowned = Object.keys(files).filter( + (file) => + ![ + 'routes/__root.tsx', + 'routes/index.tsx', + 'routes/widgets.tsx', + 'routes/posts.lazy.tsx', + ].includes(file) && !file.startsWith('node_modules/'), + ) + + /** + * A served module without what differs between two dev servers of the + * same app: the app's root directory, the dependency optimizer's hash, + * the inline source map. + */ + const comparable = (code: string, root: string) => + code + .replaceAll(root, '<root>') + .replace(/([?&]v=)[0-9a-f]+/g, '$1<hash>') + .replace(/\n\/\/# sourceMappingURL=\S+\s*$/, '') + + it.each([ + { name: 'code splitting on', autoCodeSplitting: true }, + { name: 'code splitting off (route HMR)', autoCodeSplitting: false }, + ])( + 'pass through the router plugin and behave as written ($name)', + async ({ autoCodeSplitting }) => { + const app = await createReactDevPage({ + files, + plugins: () => [ + tanstackRouter({ + target: 'react', + routesDirectory: './routes', + generatedRouteTree: './routeTree.gen.ts', + autoCodeSplitting, + }), + ], + }) + // The same app without the router plugin (the control) + const control = await createReactDevPage({ files, plugins: () => [] }) + // The router plugin left each module as it was: the dev server + // serves it as the same app without the router plugin does. + for (const file of unowned) { + expect( + comparable(await app.transform(`/${file}`), app.root), + file, + ).toBe(comparable(await control.transform(`/${file}`), control.root)) + } + // The lazy route module is not split: loading it and its options + // requests no module but the app's own files and dependencies. + const lazy = await app.runClient( + '/routes/posts.lazy.tsx', + `const { render } = await import(${JSON.stringify(renderProbe)}) +const { component, pendingComponent } = module.Route.options +const rendered = [await render(component), await render(pendingComponent)] +const own = new Set(${JSON.stringify(Object.keys(files).map((file) => `/${file}`))}) +const tool = /^\\/(?:@vite\\/|@react-refresh|@fs\\/|node_modules\\/|__plugin-host__\\/)/ +const requests = performance.getEntriesByType('resource') + .map((entry) => new URL(entry.name)) + .filter((url) => url.origin === location.origin) + .map((url) => url.pathname + url.search) + .filter((request) => !tool.test(request) && !own.has(request) && request !== ${JSON.stringify(renderProbe)}) +return { lazy: 'preload' in component, rendered, requests }`, + ) + expect(lazy.result).toEqual({ + lazy: false, + rendered: ['<p>posts</p>', '<p>pending posts</p>'], + requests: [], + }) + const run = await app.runClient( + '/src/api.ts', + `const { render } = await import(${JSON.stringify(renderProbe)}) +const api = module +const code = await import('/src/code-routes.tsx') +const unrelated = await import('/src/unrelated-factory.tsx') +const shadowed = await import('/src/shadowed-factory.tsx') +const destructuring = await import('/src/destructuring.ts') +const preview = await import('/src/route-preview.tsx') +const { widgets, Route: widgetsRoute } = await import('/routes/widgets.tsx') +let redirected +try { + api.guard(undefined) +} catch (error) { + redirected = error +} +return { + values: { + docs: api.docs, + guard: api.guard('user'), + redirected: { to: redirected?.options?.to }, + test: destructuring.test(), + doubled: destructuring.doubled, + unrelated: [unrelated.Route.path, unrelated.Route.options.loader()], + shadowed: [shadowed.Route.path, shadowed.Route.options.loader()], + items: [ + await code.itemsRoute.options.loader(), + // Not lazy: the components are the functions the module wrote. + 'preload' in code.itemsRoute.options.component, + 'preload' in code.itemsRoute.options.errorComponent, + ], + preview: [preview.Route.options.loader(), 'preload' in preview.Route.options.component], + // The look-alike keeps its own semantics and the very function it + // was given. + widgets: [ + widgets.foreign.path, + widgets.foreign.options.loader(), + widgets.foreign.options.component === widgets.ForeignWidget, + ], + }, + rendered: [ + await render(code.itemsRoute.options.component), + await render(unrelated.Route.options.component), + await render(shadowed.Route.options.component), + await render(preview.Route.options.component), + await render(widgets.foreign.options.component), + await render(widgetsRoute.options.component), + ], + // The route the registered file creates is the one it splits (the + // genuine call bound to \`Route\`; SPEC J2.1). + widgetsSplit: 'preload' in widgetsRoute.options.component, +}`, + ) + expect(run.result).toEqual({ + values: { + docs: "call createFileRoute('/path')({ component }) in a route file", + guard: 'user', + redirected: { to: '/login' }, + test: 'destructured', + doubled: [2, 4], + unrelated: ['/unrelated', 'unrelated data'], + shadowed: ['/shadowed', 'shadowed data'], + items: [['item'], false, false], + preview: ['preview data', false], + widgets: ['/foreign-widget', 'foreign data', true], + }, + rendered: [ + '<p>items</p>', + '<p>unrelated</p>', + '<p>shadowed</p>', + '<p>preview</p>', + '<p>foreign widget</p>', + '<p>widgets</p>', + ], + widgetsSplit: autoCodeSplitting, + }) + expect(uncaughtErrors(run)).toEqual([]) + }, + 30_000, + ) +}) + +// The most common root route (1,891 files of real apps): `createRootRoute()` +// without options. Through the plugin it stays a valid module that +// evaluates, and the real router renders its child through the default +// `Outlet` (SPEC J2.1, J2.7). +describe('a root route created without options', () => { + it.each([false, true])( + 'renders its child through the default Outlet (hmr: %s)', + async (hmr) => { + const route = await loadRoute( + `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + { + filename: 'routes/__root.tsx', + hmr, + files: { + // Another module of the app builds the route tree on the root route. + 'app.tsx': `import { createMemoryHistory, createRoute, createRouter } from '@tanstack/react-router' +import { Route } from './routes/__root' +export { RouterProvider } from '@tanstack/react-router' +const child = createRoute({ + getParentRoute: () => Route, + path: '/', + component: () => <p>child</p>, +}) +export const router = createRouter({ + routeTree: Route.addChildren([child]), + history: createMemoryHistory({ initialEntries: ['/'] }), +}) +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`const { router, RouterProvider } = await app('app.tsx') +await router.load() +return renderComponent(RouterProvider, { router })`), + ).toBe('<p>child</p>') + }, + ) +}) + +describe('route HMR plugin without code splitting', () => { + /** The composed plugin without code splitting: its route HMR plugin. */ + const hmrRoute = (code: string, target: 'solid' | 'vue') => + loadRoute(code, { + targetFramework: target, + filename: 'hmr.tsx', + routeId: '/hmr', + hmr: true, + pluginOptions: { autoCodeSplitting: false }, + }) + + /** Rendered HTML without Vue's comment markers. */ + const html = (rendered: string) => rendered.replace(/<!--.*?-->/g, '') + + /** + * Asserts that the emitted module is valid and that the route it creates + * with the real router of `target` renders its component with the real + * framework, in the page (with the dev server's hot API). + */ + async function expectRenders(route: RouteApp) { + await expectValidModules(route) + expect(html(await route.run<string>(`return render('component')`))).toBe( + '<p>hmr</p>', + ) + } + + it.each(['solid', 'vue'] as const)( + 'keeps a %s route valid and rendering when compiled with HMR', + async (target) => { + const route = await hmrRoute( + ` +import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/hmr')({ + component: () => <p>hmr</p>, +}) +`, + target, + ) + await expectRenders(route) + // Without an HMR runtime (the dev server's SSR environment, its own + // module runner) the module evaluates and creates its route too + // (SPEC J3.8). Vue only: a Solid app's SSR environment needs Solid's + // server compile (`vite-plugin-solid` with `ssr`), which this client + // app does not configure. + if (target === 'vue') { + const { Route } = await route.host.importServer(route.url) + expect(typeof Route.options.component).toBe('function') + } + }, + ) + + // Source: real apps: tinloof/tanstack-wsr src/types.ts (an empty type + // import fixes TypeScript's "inferred type cannot be named" error); #8504 + // (a guard against a printer bug, yuku-toolchain/yuku#258). + it.each(['solid', 'vue'] as const)( + 'keeps a %s route with an empty type-only import valid', + async (target) => { + await expectRenders( + await hmrRoute( + `import type {} from 'zod' +import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/hmr')({ + component: () => <p>hmr</p>, +}) +`, + target, + ), + ) + }, + ) + + // A Solid or Vue route hot-updated through the bundler's hot API: + // integration/route-hmr-browser-frameworks.test.ts (a real page). +}) + +// A route the route file creates inside a function of the same file (a +// helper, an IIFE) is unsupported but user-fixable (SPEC J2.10, +// J2.8): it is either split like a module-scope route (and +// hot-updates in place), or left unsplit with a warning naming the file, in +// production as in development. Either way it renders correctly; silent +// wrong output, or unsplit without a warning, fails. +// Sources: #8504 (code-splitter-plugin-pipeline.test.ts); review of #8504. +describe('a route created inside a function', () => { + /** + * Whether a warning on any channel names the route file (absolute or + * project-relative: the spelling is free, SPEC §5.7), once the page + * loaded the route's modules. + */ + async function reported(route: RouteApp, file = 'route.tsx') { + return ( + findDiagnostics(await route.diagnostics(), { + severity: 'warning', + file, + root: route.host.root, + }).length > 0 + ) + } + + /** Route files whose `/made` route a function of the file creates. */ + const factoryRoutes = { + 'a helper function, with an inline component': (data: string) => + `import { createFileRoute } from '@tanstack/react-router' +function makeRoute() { + return createFileRoute('/made')({ + loader: () => '${data}', + component: () => <p>made</p>, + }) +} +export const Route = makeRoute() +`, + 'an IIFE, with an inline component': (data: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = (() => + createFileRoute('/made')({ + loader: () => '${data}', + component: () => <p>made</p>, + }))() +`, + 'a helper function, with a module-level component and loader': ( + data: string, + ) => `import { createFileRoute } from '@tanstack/react-router' +function Made() { + return <p>made</p> +} +const loader = () => '${data}' +function makeRoute() { + return createFileRoute('/made')({ loader, component: Made }) +} +export const Route = makeRoute() +`, + 'an arrow helper, with a module-level component': (data: string) => + `import { createFileRoute } from '@tanstack/react-router' +function Made() { + return <p>made</p> +} +const makeRoute = () => + createFileRoute('/made')({ loader: () => '${data}', component: Made }) +export const Route = makeRoute() +`, + 'an IIFE, with a module-level component': (data: string) => + `import { createFileRoute } from '@tanstack/react-router' +function Made() { + return <p>made</p> +} +export const Route = (() => + createFileRoute('/made')({ loader: () => '${data}', component: Made }))() +`, + } + + /** A route of its own dev server: a warning is due once per file. */ + const loadMade = (code: string, options: RouteAppOptions = {}) => + loadRoute(code, { routeId: '/made', fresh: true, ...options }) + + it.each(Object.entries(factoryRoutes))( + 'built in %s is split, or reported, and keeps working', + async (_, route) => { + const loaded = await loadMade(route('data')) + await expectValidModules(loaded) + const rendered = await loaded.run( + `return [options.loader(), await render('component')]`, + ) + const lazy = await loaded.isLazy('component') + expect({ + rendered, + splitOrReported: lazy || (await reported(loaded)), + }).toEqual({ rendered: ['data', '<p>made</p>'], splitOrReported: true }) + }, + ) + + // An edit of such a route in development shows its new code: + // integration/route-hmr-browser-plugin.test.ts (a real page). + + // Bug: route options that only exist inside the factory (its parameters, + // its locals) are split out of it as if they were module-level code: a + // split option that closes over a parameter throws a ReferenceError, a + // component declared in the factory leaves a chunk that exports an + // undeclared binding, and a parameter that shadows a module-level + // component makes the chunk render the module-level one. Leaving such + // options unsplit with a warning naming the file is a valid fix (the + // pattern is unsupported but user-fixable); unsplit and silent is not. + // Source: review of #8504. + // Impact: the route throws when it renders or loads, or silently renders + // the wrong component. + it.fails.each([ + { + name: 'a component the factory receives, shadowing a module-level component', + route: `function Comp() { + return <p>module</p> +} +function makeRoute(Comp: () => unknown) { + return createFileRoute('/made')({ loader: () => 'data', component: Comp }) +} +export const Route = makeRoute(() => <p>given</p>)`, + expected: ['data', '<p>given</p>'], + }, + { + name: 'a component the factory receives', + route: `function makeRoute(Given: () => unknown) { + return createFileRoute('/made')({ loader: () => 'data', component: Given }) +} +export const Route = makeRoute(() => <p>given</p>)`, + expected: ['data', '<p>given</p>'], + }, + { + name: 'a component declared inside the factory', + route: `function makeRoute() { + const Local = () => <p>given</p> + return createFileRoute('/made')({ loader: () => 'data', component: Local }) +} +export const Route = makeRoute()`, + expected: ['data', '<p>given</p>'], + }, + { + name: 'an inline component that reads a factory parameter', + route: `function makeRoute(label: string) { + return createFileRoute('/made')({ + loader: () => 'data', + component: () => <p>{label}</p>, + }) +} +export const Route = makeRoute('given')`, + expected: ['data', '<p>given</p>'], + }, + { + name: 'a split loader that reads a factory parameter', + route: `function makeRoute(label: string) { + return createFileRoute('/made')({ + codeSplitGroupings: [['loader'], ['component']], + loader: () => label, + component: () => <p>made</p>, + }) +} +export const Route = makeRoute('given')`, + expected: ['given', '<p>made</p>'], + split: ['loader', 'component'], + }, + ])( + 'a route built from $name renders what the factory was given, split or reported', + async ({ route, expected, split = ['component'] }) => { + const loaded = + await loadMade(`import { createFileRoute } from '@tanstack/react-router' +${route} +`) + const rendered = await loaded.run( + `return [await (await load('loader'))(), await render('component')]`, + ) + let splitOrReported = await reported(loaded) + if (!splitOrReported) { + const lazy = [] + for (const option of split) { + lazy.push(await loaded.isLazy(option)) + } + splitOrReported = lazy.every(Boolean) + } + expect({ rendered, splitOrReported }).toEqual({ + rendered: expected, + splitOrReported: true, + }) + }, + ) + + const moduleRoute = `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/made')({ component: () => <p>made</p> }) +` + + /** Each plugin path of the composed plugin. */ + const pluginPaths: Record<string, RouteAppOptions> = { + 'code splitter': {}, + 'route HMR plugin': { + hmr: true, + pluginOptions: { autoCodeSplitting: false }, + }, + } + + describe.each(Object.entries(pluginPaths))('through the %s', (_, options) => { + it('is not reported for a module-scope route', async () => { + const route = await loadMade(moduleRoute, { + ...options, + filename: 'made.tsx', + }) + // The page loads the route and every module of it + await route.modules() + expect(await route.run(`return render('component')`)).toBe('<p>made</p>') + expectNoProblems(await route.diagnostics()) + }) + }) + + // A route the splitter does not split is reported, once per file + // (SPEC J2.8: the user can change the pattern), across the edits of + // the files of one dev server. + it.each(Object.entries(factoryRoutes).slice(0, 2))( + 'built in %s is split, or reported once per file across repeated transforms', + async (_, route) => { + const version = (file: 'made' | 'other', edit: number) => + `${route('data').replace("'/made'", `'/${file}'`)}// edit ${edit}\n` + const loaded = await loadMade(version('made', 0), { + filename: 'made.tsx', + files: { 'other.tsx': version('other', 0) }, + pluginOptions: { + virtualRouteConfig: routesOf({ + 'made.tsx': '/made', + 'other.tsx': '/other', + }), + }, + }) + const mark = loaded.host.diagnostics.length + const split = new Set<string>() + for (let edit = 0; edit < 3; edit++) { + if (edit > 0) { + await loaded.host.edit({ + 'made.tsx': version('made', edit), + 'other.tsx': version('other', edit), + }) + } + // Both route files load with their split components + const lazy = await loaded.run< + Record<string, boolean> + >(`let before = new Set(await compiled()) +await trigger('component') +const made = (await compiled()).some((request) => !before.has(request)) +const other = await app('other.tsx') +before = new Set(await compiled()) +await other.Route.options.component?.preload?.() +return { made, other: (await compiled()).some((request) => !before.has(request)) }`) + for (const [file, isSplit] of Object.entries(lazy)) { + if (isSplit) { + split.add(`${file}.tsx`) + } + } + } + await loaded.host.dev.idle() + const reports = loaded.host.diagnostics.slice(mark) + for (const file of ['made.tsx', 'other.tsx']) { + const naming = findDiagnostics(reports, { + severity: 'warning', + file, + root: loaded.host.root, + }) + expect( + split.has(file) ? naming.length === 0 : naming.length === 1, + file, + ).toBe(true) + } + }, + 30_000, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline.test.ts new file mode 100644 index 0000000000..e3f16ce970 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-plugin-pipeline.test.ts @@ -0,0 +1,478 @@ +/** + * The router plugin in a real Vite pipeline (SPEC J2.1, J2.13, G4, G5, G11): + * the public composed `tanstackRouter` and the framework's Vite plugin in a + * real dev server (`route-app.ts`, or `dev-page.ts` for a whole app), Vite + * resolving the config, ordering the plugins, applying their hook filters, + * and the page importing what the dev server serves. Diagnostics are judged + * by content on every channel at once (the error a compile throws, the + * console, Vite's logger). + */ +import { createServerModuleRunner, parseSync } from 'vite' +import { describe, expect, it } from 'vitest' +import { + captureThrow, + diagnosticPosition, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import type { ESTree } from 'vite' +import type { Config } from '../../../src' +import type { RouteApp, RouteAppOptions } from '../../route-app' + +const routeSource = (name: string) => ` +import { createFileRoute } from '@tanstack/react-router' +const state = { name: ${JSON.stringify(name)} } +export const Route = createFileRoute('/${name}')({ + loader: () => state, + head: () => ({ meta: [{ title: state.name }] }), + component: () => <p>{state.name}</p>, + errorComponent: () => <p>error in ${name}</p>, +}) +` + +/** + * A virtual route config (the public `virtualRouteConfig` option) of an app + * whose root has the route files `files` (path → route id). + */ +const routesOf = (files: Record<string, string>) => + ({ + type: 'root', + file: '__root.tsx', + children: Object.entries(files).map(([file, path]) => ({ + type: 'route', + path, + file, + })), + }) as Config['virtualRouteConfig'] + +/** + * The directive prologue of a module as the page receives it: the leading + * string-literal expression statements, after the statements Vite's import + * analysis puts first (its hot context and the CommonJS interop of + * dependencies, which name Vite's own `__vite__` bindings: not the + * module's code). An independent parse of the served module. + */ +function servedPrologue(code: string) { + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + const body = program.body as Array<ESTree.Statement> + let index = 0 + while ( + index < body.length && + /\b__vite__\w+/.test(code.slice(body[index]!.start, body[index]!.end)) + ) { + index++ + } + const directives: Array<string> = [] + for (; index < body.length; index++) { + const statement = body[index]! + if ( + statement.type !== 'ExpressionStatement' || + statement.expression.type !== 'Literal' || + typeof statement.expression.value !== 'string' + ) { + break + } + directives.push(statement.expression.value) + } + return directives +} + +// The router plugin's public Vite adapter in a real Vite dev server: Vite +// resolves the config, orders the plugins, applies their hook filters and +// resolves and loads the emitted modules. +describe('code-splitter plugin pipeline', () => { + // A request with Vite's cache-busting parameter (`t=…`) reaches a split + // module the way real usage does: after an edit, Vite's import analysis + // adds it to the imports of the modules the edit changed + // (code-splitter-edits.test.ts renders the edited route in a new document; + // the route-hmr-browser*.test.ts pages hot-update it). Vite strips the + // parameter before any plugin hook sees a file's id, and a module whose + // id never changes is never requested with it, so no test imports an + // emitted module by its id (SPEC §8, §5.3). + + // One plugin instance compiles every route of an app: what it emits for a + // route does not depend on the routes it compiled before (SPEC G4). The + // same modules, the same groups and the same behaviour, and the same + // diagnostics; the emitted text is free. + it('compiles the modules of a route the same way after compiling another route', async () => { + const options: RouteAppOptions = { + filename: 'first.tsx', + routeId: '/first', + // A dev server of its own each: one compiles another route first + fresh: true, + files: { + 'other.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/other')({ component: () => <p /> }) +`, + }, + pluginOptions: { + virtualRouteConfig: routesOf({ + 'first.tsx': '/first', + 'other.tsx': '/other', + }), + }, + } + /** What the first route is and does, and what its compile reported. */ + const observe = async (route: RouteApp) => { + const mark = route.host.diagnostics.length + const observed = { + ids: (await route.modules()).ids, + groups: await route.groups(), + ...(await route.run<Record<string, unknown>>(`return { + loader: await options.loader(), + head: options.head(), + component: await render('component'), + errorComponent: await render('errorComponent'), +}`)), + } + await route.host.dev.idle() + const reported = route.host.diagnostics + .slice(mark) + .map(({ severity, text }) => ({ + severity, + text: text.replaceAll(route.host.root, '<root>'), + })) + return { observed, reported } + } + const fresh = await observe(await loadRoute(routeSource('first'), options)) + const reused = await loadRoute(routeSource('first'), options) + // The other route of the app, compiled first (its split component too) + await reused.host.runClient( + '/other.tsx', + 'await module.Route.options.component.preload?.()', + ) + const again = await observe(reused) + expect(fresh.observed.groups).not.toEqual([]) + expect(again).toEqual(fresh) + }) + + it('splits by the plugin-level splitBehavior for the route id', async () => { + const splitBehavior: NonNullable< + Config['codeSplittingOptions'] + >['splitBehavior'] = ({ routeId }) => + routeId === '/behavior' + ? [['loader', 'component', 'errorComponent']] + : undefined + const route = await loadRoute(routeSource('behavior'), { + routeId: '/behavior', + // A function option: a dev server of its own + fresh: true, + pluginOptions: { codeSplittingOptions: { splitBehavior } }, + }) + await expectValidModules(route) + expect( + await route.run(`return [ + await options.loader(), + await render('component'), + await render('errorComponent'), +]`), + ).toEqual([ + { name: 'behavior' }, + '<p>behavior</p>', + '<p>error in behavior</p>', + ]) + // The three options load lazily, together: loading one makes the + // others available. + expect(await route.groups()).toEqual([ + ['component', 'errorComponent', 'loader'], + ]) + }) + + it('rejects invalid splitBehavior groupings with an error naming the option and the route file', async () => { + const route = await loadRoute(routeSource('invalid'), { + filename: 'invalid.tsx', + routeId: '/invalid', + fresh: true, + pluginOptions: { + codeSplittingOptions: { + splitBehavior: () => [['component'], ['component']], + }, + }, + }) + // The error the compile throws, with what every channel reported (the + // wording and the channel are free, SPEC §5.7) + const thrown = await captureThrow(() => route.transform()) + expectDiagnostic([...thrown, ...(await route.diagnostics())], { + severity: 'error', + file: 'invalid.tsx', + root: route.host.root, + }) + }) + + // File names from real apps: optional segments, pathless groups and escaped dots. + it.each([ + 'src/routes/{-$locale}/changelog.tsx', + 'src/routes/(marketing)/about.tsx', + 'src/routes/api/[.]well-known/security[.]txt.tsx', + ])('loads the split modules of %s', async (filename) => { + const route = await loadRoute(routeSource('route'), { + filename, + routeId: '/route', + }) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(true) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([{ name: 'route' }, '<p>route</p>']) + }) + + // The documented order: the framework's JSX plugin after the router + // plugin (the order of every route app: `@vitejs/plugin-react` / + // `vite-plugin-solid` after `tanstackRouter`, as Vite resolves them). The + // other order (a correct split, or an actionable diagnostic naming the + // plugins, SPEC G11) goes through real builds: + // integration/code-splitter-pragmas.test.ts. + it.each([ + { + name: '@vitejs/plugin-react', + target: 'react' as const, + route: routeSource('order'), + routeId: '/order', + }, + { + name: 'vite-plugin-solid', + target: 'solid' as const, + route: `import { createFileRoute } from '@tanstack/solid-router' +export const Route = createFileRoute('/')({ component: () => <p>solid</p> }) +`, + routeId: '/', + }, + ])( + 'accepts $name after the router plugin', + async ({ target, route, routeId }) => { + const loaded = await loadRoute(route, { + targetFramework: target, + routeId, + }) + expect(await loaded.isLazy('component')).toBe(true) + }, + ) + + // A dev server compiles each edit of a route file with the same plugin + // instance. + it('compiles an edited route like a fresh one after a version whose loader and component shared a binding', async () => { + const files = { 'label.ts': `export const label = { text: 'imported' }\n` } + const before = await loadRoute( + `${head}const label = { text: 'before' } +export const Route = createFileRoute('/')({ + loader: () => label, + component: () => <p>{label.text}</p>, +}) +`, + { files }, + ) + expect(await before.run(`return render('component')`)).toBe('<p>before</p>') + const after = await loadRoute( + `${head}import { label } from './label' +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{label.text}</p>, +}) +`, + { files }, + ) + await expectValidModules(after) + expect( + await after.run(`return [options.loader(), await render('component')]`), + ).toEqual(['data', '<p>imported</p>']) + }) + + // A Solid directive (`use:tip`) names its function in a JSX attribute + // only; Solid's JSX transform turns it into a call of `tip` in the module + // the JSX ends up in. The split component keeps the module-level + // directive it uses (SPEC J2.3, G1). + it('a split Solid component runs the module-level directive it uses', async () => { + const route = await loadRoute( + `import { createFileRoute } from '@tanstack/solid-router' +function tip(el: HTMLElement) { + el.dataset.tip = 'on' +} +export const Route = createFileRoute('/')({ component: () => <p use:tip>tip</p> }) +`, + { targetFramework: 'solid' }, + ) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe( + '<p data-tip="on">tip</p>', + ) + }) + + // Each framework's route module imports the lazy route helpers from its + // own router package, and no module the page loads is another + // framework's router: the routes run with the real router of their + // framework in the page. + describe.each(['solid', 'vue'] as const)('a %s route', (framework) => { + const routerPackage = `@tanstack/${framework}-router` + const otherRouters = ['react', 'solid', 'vue'] + .filter((other) => other !== framework) + .map((other) => `${other}-router`) + // Route hooks return an accessor in Solid and a ref in Vue + const read = framework === 'solid' ? 'posts()' : 'posts.value' + + it.each([ + { groupings: undefined, loaderSplit: false }, + { groupings: `[['loader'], ['component']]`, loaderSplit: true }, + ])( + 'loads its split options with groupings $groupings', + async ({ groupings, loaderSplit }) => { + const code = `import { createFileRoute, Outlet } from '${routerPackage}' +import { fetchPosts } from './posts' +export const Route = createFileRoute('/posts')({ +${groupings ? ` codeSplitGroupings: ${groupings},\n` : ''} loader: fetchPosts, + component: PostsComponent, +}) +const PostsComponent = () => { + const posts = Route.useLoaderData() + return <ul>{${read}.length}<Outlet /></ul> +} +` + const route = await loadRoute(code, { + targetFramework: framework, + routeId: '/posts', + files: { 'posts.ts': `export const fetchPosts = () => ['post']\n` }, + }) + await expectValidModules(route) + const loaded = await route.run<{ + html: string + others: Array<string> + }>(`await trigger('component') +await trigger('loader') +const html = (await renderRoute()).replace(/<!--.*?-->/g, '') +const others = ${JSON.stringify(otherRouters)} +return { + html, + others: performance + .getEntriesByType('resource') + .map((entry) => entry.name) + .filter((name) => others.some((other) => name.includes(other))), +}`) + expect([ + loaded, + await route.isLazy('component'), + await route.isLazy('loader'), + ]).toEqual([{ html: '<ul>1</ul>', others: [] }, true, loaderSplit]) + }, + ) + }) +}) + +// A route compiled for route HMR also serves where no HMR runtime runs: +// the dev server's SSR environment through a module runner without HMR +// (Vite's public \`createServerModuleRunner(environment, { hmr: false })\`, +// as a custom SSR server or a non-Node runtime creates one: no +// \`import.meta.hot\`). SPEC J3.8: without an HMR runtime the module still +// evaluates and \`Route\` works. +it.each([ + { name: 'code splitter', options: {} }, + { + name: 'route HMR plugin (code splitting off)', + options: { pluginOptions: { autoCodeSplitting: false } }, + }, +])( + 'a route compiled for HMR by the $name evaluates and works in the SSR environment', + async ({ options }) => { + const route = await loadRoute(routeSource('ssr'), { + routeId: '/ssr', + hmr: true, + ...options, + }) + const runner = createServerModuleRunner( + route.host.dev.vite.environments.ssr, + { hmr: false }, + ) + const { Route } = await runner.import(route.url) + const { loader, component } = Route.options + await component.preload?.() + await runner.close() + expect([ + await (typeof loader === 'function' ? loader() : loader.handler()), + typeof component, + ]).toEqual([{ name: 'ssr' }, 'function']) + }, +) + +// Shape of the deleted code-splitter snapshot fixture directive-prologue. A +// directive only applies as the first statement of a module: the route +// module and every module carrying the route file's code keep it first +// (a pure support module the compiler adds may have none, §5.8). +it('keeps the directive prologue of a route file first in the route module and every module holding its code', async () => { + const route = await loadRoute( + `'use client' + +import { createFileRoute } from '@tanstack/react-router' + +const label = 'directive preserved' + +export const Route = createFileRoute('/directive')({ + loader: () => label, + component: () => <div>{label} MARK_PAGE</div>, + errorComponent: () => <div>MARK_ERROR</div>, +}) +`, + { routeId: '/directive' }, + ) + expect(await route.isLazy('component')).toBe(true) + const { modules } = await route.modules() + const carrying = Object.entries(modules).filter( + ([name, code]) => + name === 'reference' || + ['directive preserved', 'MARK_PAGE', 'MARK_ERROR'].some((marker) => + holdsMarker(code, marker), + ), + ) + // The route module, the component's and the error component's code + expect(carrying.length).toBeGreaterThan(2) + for (const [name, code] of carrying) { + expect(servedPrologue(code)[0], name).toBe('use client') + } +}) + +// Source: #8504 router-utils prepend-statements.test.ts ("inserts after the +// complete prologue"), at compiler level: the route HMR code and the +// splitter's imports go after the whole prologue. +it.each([false, true])( + 'keeps the whole directive prologue first (hmr: %s)', + async (hmr) => { + const route = await loadRoute( + `'use client' +'use strict' +import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/directive')({ + component: () => <div>page</div>, +}) +`, + { hmr, routeId: '/directive' }, + ) + // The order among the directives of one prologue is free (SPEC §5.5): + // both lead the module, each once. + expect(servedPrologue(await route.transform()).sort()).toEqual([ + 'use client', + 'use strict', + ]) + }, +) + +// Source: #8504 router-utils diagnostics.test.ts ("reports actionable syntax +// locations"), at plugin level. Bundlers name the file of a plugin error; +// the plugin reports where in it the error is. +it.each(['\n', '\r\n', '\r', '
', '
'])( + 'reports the line and column of a syntax error in a route file with %j line endings and Unicode source', + async (newline) => { + const code = `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({}) +// 😀é${newline}/* 😀é */ export const broken = ;` + const route = await loadRoute(code, { hmr: true }) + // The error points at the unexpected `;` (structured fields or a + // rendered code frame; the wording and the channel are free). + const thrown = await captureThrow(() => route.transform()) + expectDiagnostic([...thrown, ...(await route.diagnostics())], { + severity: 'error', + position: diagnosticPosition(code, code.lastIndexOf(';')), + }) + }, +) diff --git a/packages/router-plugin/tests/integration/pages/code-splitter-route-options-state.test.ts b/packages/router-plugin/tests/integration/pages/code-splitter-route-options-state.test.ts new file mode 100644 index 0000000000..f4251da199 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/code-splitter-route-options-state.test.ts @@ -0,0 +1,456 @@ +// Second half of code-splitter-route-options.test.ts (split for the fast +// tier's per-file time): code-split groupings, source text the split route +// keeps, options that read the Route singleton, root routes and code next +// to the route options. +import { describe, expect, it } from 'vitest' +import { + diagnosticsOf, + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import { directivesOfFunctionsHolding } from '../../served-code' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import type { RouteApp, RouteAppOptions } from '../../route-app' +import type { CodeSplittingOptions } from '../../../src/vite' + +type CodeSplitGroupings = NonNullable<CodeSplittingOptions['defaultBehavior']> + +describe('code-split groupings', () => { + const route = ( + groupings = '', + ) => `${head}export const Route = createFileRoute('/')({ +${groupings} loader: () => 'data', + component: () => <p>page</p>, + errorComponent: () => <p>error</p>, +}) +` + + /** The route works: its loader and both components. */ + const works = (loaded: RouteApp) => + loaded.run(`return [ + await options.loader(), + await render('component'), + await render('errorComponent'), +]`) + + /** + * Which options load lazily, grouped by what loads together (`groups`), + * once the route still works. + */ + async function lazyGroups(code: string, options: RouteAppOptions = {}) { + const loaded = await loadRoute(code, options) + expect(await works(loaded)).toEqual(['data', '<p>page</p>', '<p>error</p>']) + return loaded.groups() + } + + /** + * Compiles the route module: what compiling it threw (none: `undefined`), + * with everything the dev server reported, on every channel. + */ + async function compileOutcome(loaded: RouteApp) { + let thrown: Array<Diagnostic> | undefined + try { + await loaded.transform() + } catch (error) { + thrown = diagnosticsOf(error) + } + return { thrown, diagnostics: await loaded.diagnostics() } + } + + it('of the route split the options of a group into one module', async () => { + expect( + await lazyGroups( + route(` codeSplitGroupings: [['loader', 'component']],\n`), + ), + ).toEqual([['component', 'loader']]) + }) + + it('of the route split nothing when empty', async () => { + expect(await lazyGroups(route(` codeSplitGroupings: [],\n`))).toEqual([]) + }) + + // Type-invalid input (TS2322 against the real `codeSplitGroupings` type: + // an array of option names where groups are expected), so a + // never-fail-silently diagnostic control (SPEC §8, G5), not supported + // grouping coverage: an error naming the route file, or a working + // route that is either reported (naming the file) or split safely (unsplit, or the one group `[['loader']]` the input + // spells). Valid groupings: the tests around this one. The error is read + // with every channel of the dev server (§5.7: the thrown error may point + // at a report logged next to it). + it('of the route that are not arrays of arrays (type-invalid) are refused, reported or applied safely', async () => { + const loaded = await loadRoute(route(` codeSplitGroupings: ['loader'],\n`)) + const { thrown, diagnostics } = await compileOutcome(loaded) + if (thrown) { + expectDiagnostic([...thrown, ...diagnostics], { + severity: 'error', + file: 'route.tsx', + root: loaded.host.root, + }) + return + } + expect(await works(loaded)).toEqual(['data', '<p>page</p>', '<p>error</p>']) + const reported = await loaded.diagnostics() + // (a warning: the route works, so it was not refused) + const told = + findDiagnostics(reported, { + severity: 'warning', + file: 'route.tsx', + root: loaded.host.root, + }).length > 0 + if (!told) { + expect([[], [['loader']]]).toContainEqual(await loaded.groups()) + } + }) + + // Honouring groupings declared in a module-level constant is pinned in + // known-bugs-code-splitter.test.ts; until then the route is refused + // with an error naming the route file (on any channel), never split with + // other groupings. + it('of the route given through a variable are honoured or refused with an error naming the route file', async () => { + const loaded = + await loadRoute(`${head}const groupings: Array<Array<'loader' | 'component'>> = [['loader'], ['component']] +export const Route = createFileRoute('/')({ + codeSplitGroupings: groupings, + loader: () => 'data', + component: () => <p>page</p>, +}) +`) + const { thrown, diagnostics } = await compileOutcome(loaded) + if (thrown) { + expectDiagnostic([...thrown, ...diagnostics], { + severity: 'error', + file: 'route.tsx', + root: loaded.host.root, + }) + return + } + expect(await loaded.groups()).toEqual([['component'], ['loader']]) + }) + + const defaultBehavior: CodeSplitGroupings = [['loader', 'errorComponent']] + it.each([ + { + name: 'the route option over splitBehavior and defaultBehavior', + groupings: ` codeSplitGroupings: [['component', 'errorComponent']],\n`, + splitBehavior: () => [['loader']] as CodeSplitGroupings, + expected: [['component', 'errorComponent']], + }, + { + name: 'splitBehavior over defaultBehavior', + splitBehavior: () => [['loader', 'component']] as CodeSplitGroupings, + expected: [['component', 'loader']], + }, + { + name: 'defaultBehavior when splitBehavior returns undefined', + splitBehavior: () => undefined, + expected: [['errorComponent', 'loader']], + }, + ])('apply $name', async ({ groupings, splitBehavior, expected }) => { + expect( + await lazyGroups(route(groupings), { + pluginOptions: { + codeSplittingOptions: { defaultBehavior, splitBehavior }, + }, + }), + ).toEqual(expected) + }) +}) + +// Windows checkouts with `autocrlf` give route files CRLF line endings: the +// split route keeps the values the file has untouched (a template literal's +// line break is LF in its value, whatever the file's line ending; JSX text +// and attributes as the JSX transform reads them). The untouched file is the +// same source as another module of the app, which no route registers: the +// project's own transform, without the router's compilers. +it('keeps the runtime values of a route file with CRLF line endings', async () => { + const lines = (code: string) => code.replaceAll('\n', '\r\n') + const source = `${head}const banner = \`first +second\` +export const Route = createFileRoute('/')({ + loader: () => banner, + component: () => ( + <p title="a +b"> + text + more + </p> + ), +}) +` + for (const code of [source, lines(source)]) { + const route = await loadRoute(code, { + files: { 'untouched.tsx': code }, + }) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(true) + const [split, untouched, lazyUntouched] = await route.run< + [unknown, unknown, boolean] + >(`const untouched = (await app('untouched.tsx')).Route.options +return [ + [options.loader(), await render('component')], + [untouched.loader(), await renderComponent(untouched.component)], + 'preload' in untouched.component, +]`) + // The control is not compiled by the router (no lazy component). + expect(lazyUntouched).toBe(false) + expect(split).toEqual(untouched) + expect((split as Array<unknown>)[0]).toBe('first\nsecond') + } +}) + +// Source: TanStack/router#2361 and #3183, where non-ASCII text in a route +// file was printed as escape sequences, which JSX text and attributes do not +// interpret. +it('keeps non-ASCII characters of strings, JSX text and JSX attributes', async () => { + const route = await loadRoute(`${head}function Labelled({ title, children }) { + return <div>{title}: {children}</div> +} +export const Route = createFileRoute('/')({ + loader: () => ({ data: 'Usuário🤠' }), + component: () => <Labelled title="标题">Usuário 🤡</Labelled>, +}) +`) + expect(await route.isLazy('component')).toBe(true) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([{ data: 'Usuário🤠' }, '<div>标题: Usuário 🤡</div>']) +}) + +describe('split options that read the Route singleton', () => { + // `Route` stays in the reference module, so reading it from a split option + // must not attribute every dependency of the route options to that option. + it.each([ + { + name: 'an inline arrow component', + component: `() => <p>{format(Route.useLoaderData().length)}</p>`, + }, + { + name: 'an inline named function component', + component: `function Posts() { + const { page } = Route.useSearch() + return <p>{format(page)}</p> + }`, + }, + ])( + 'keep in the route module what only the loader reads, next to $name', + async ({ component }) => { + const route = await loadRoute( + `${head}const format = (value: unknown) => String(value) +const prefix = 'post:' +function fetchPosts() { + return [prefix + 1].filter((item) => item !== 'MARK_FETCH_POSTS') +} +export const Route = createFileRoute('/posts')({ + loader: () => [fetchPosts(), format(0)], + component: ${component}, +}) +`, + { routeId: '/posts' }, + ) + // SPEC J2.5: the split component's modules hold neither `fetchPosts` nor + // `prefix` (their user markers). + const chunk = await route.loadedBy('component') + expect( + chunk.some( + (code) => + holdsMarker(code, 'MARK_FETCH_POSTS') || holdsMarker(code, 'post:'), + ), + ).toBe(false) + // ... what loads with the route module (the loader's) holds both + const eager = await route.eagerModules() + expect( + ['MARK_FETCH_POSTS', 'post:'].filter((marker) => + eager.some((code) => holdsMarker(code, marker)), + ), + ).toEqual(['MARK_FETCH_POSTS', 'post:']) + await expectValidModules(route) + // The loader's data has two items; the search has `page=2`. + expect( + await route.run(`return [ + options.loader(), + await renderRoute({ at: '/posts?page=2' }), +]`), + ).toEqual([[['post:1'], '0'], '<p>2</p>']) + }, + ) + + // An imported binding is read-only: `label = ...` would throw at runtime. + it('keep a reassigned loader-only binding writable', async () => { + const route = await loadRoute( + `${head}let label = 'initial' +label = 'updated' +export const Route = createFileRoute('/label')({ + loader: () => label, + component: () => <p>{Route.useLoaderData()}</p>, +}) +`, + { routeId: '/label' }, + ) + await expectValidModules(route) + expect(await route.run('return renderRoute()')).toBe('<p>updated</p>') + }) + + // That the loader and the component share one `cache` is pinned in + // known-bugs-code-splitter.test.ts ("a destructuring whose sibling reads + // Route"). + it('keep a destructuring whose sibling reads Route working', async () => { + const route = await loadRoute(`${head}const getRoute = () => Route +const [cache, routeGetter] = [new Map(), getRoute] +export const Route = createFileRoute('/')({ + loader: () => cache.size, + component: () => <div>{cache.size}{typeof routeGetter}</div>, +}) +`) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([0, '<div>0function</div>']) + }) + + it.each([ + { + name: 'directly', + helpers: `const HEADER = 'Page' +function usePageTitle() { + return \`\${HEADER} - \${Route.fullPath}\` +}`, + }, + { + name: 'through a helper declared later', + helpers: `const usePageTitle = () => useTitle() +const useTitle = () => HEADER + ' - ' + Route.fullPath +const HEADER = 'Page'`, + }, + ])( + 'give the loader and the component a helper that reads Route $name, created once', + async ({ helpers }) => { + const route = await loadRoute( + `${head}${helpers} +export const Route = createFileRoute('/about')({ + loader: async () => ({ title: usePageTitle() }), + component: () => <div>{usePageTitle()}</div>, + errorComponent: () => <p>{usePageTitle()}</p>, +}) +`, + { routeId: '/about' }, + ) + await expectValidModules(route) + // The router gives the route it loads its path: every option reads it + // from that one route. + expect( + await route.run(`return [ + await renderRoute(), + await options.loader(), + await render('errorComponent'), +]`), + ).toEqual([ + '<div>Page - /about</div>', + { title: 'Page - /about' }, + '<p>Page - /about</p>', + ]) + }, + ) +}) + +// Whether a root route's error and not-found components are split is pinned +// in known-bugs-code-splitter.test.ts ("a root route's errorComponent and +// notFoundComponent load lazily"). +describe('root routes', () => { + it('keep module state the route options share, created once', async () => { + const route = await loadRoute( + `import { createRootRoute } from '@tanstack/react-router' +import { init } from './state' +const shared = init(42) +export const Route = createRootRoute({ + beforeLoad: () => shared, + component: () => <div>{shared}</div>, + errorComponent: () => <p>error {shared}</p>, + notFoundComponent: () => <p>not found</p>, +}) +`, + { + files: { + 'state.ts': `export let calls = 0 +export const init = (value: number) => { + calls++ + return value +} +`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + options.beforeLoad(), + await render('component'), + await render('errorComponent'), + await render('notFoundComponent'), + (await app('state.ts')).calls, +]`), + ).toEqual([42, '<div>42</div>', '<p>error 42</p>', '<p>not found</p>', 1]) + }) +}) + +describe('code next to the route options', () => { + // A top-level call on the route after its definition runs once, with the + // route module, also once a split option loads. Shape of the deleted + // code-splitter snapshot fixture inline (`Route.addChildren([])`), as an + // app registers a route with a helper of its own. + it('runs a top-level call that receives the route once', async () => { + const route = await loadRoute( + `${head}import { registerRoute } from './registry' +export const Route = createFileRoute('/')({ + component: () => <p>page</p>, +}) +registerRoute(Route) +`, + { + files: { + 'registry.ts': `export const registered: Array<unknown> = [] +export const registerRoute = (value: unknown) => registered.push(value) +`, + }, + }, + ) + expect( + await route.run(`const html = await render('component') +const { registered } = await app('registry.ts') +return [html, registered.length, registered[0] === Route]`), + ).toEqual(['<p>page</p>', 1, true]) + expect(await route.isLazy('component')).toBe(true) + }) + + // A directive in a function body applies to that function, wherever it + // moves: here React Compiler's opt-out of a component. Shape of the + // deleted code-splitter snapshot fixture random-number. Name- and + // form-independent: every function of the route's modules whose own body + // renders the chart starts with the directive (SPEC G12; names are free, + // §5.1: not one FunctionDeclaration named Chart). + it("keeps a 'use no memo' directive in the body of a component that moves into a chunk", async () => { + const route = await loadRoute(`${head}function Chart() { + 'use no memo' + return <p>chart</p> +} +export const Route = createFileRoute('/')({ + component: () => <Chart />, +}) +`) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe('<p>chart</p>') + + const { modules } = await route.modules() + const directives = Object.values(modules).flatMap((code) => + directivesOfFunctionsHolding(code, 'chart'), + ) + expect(directives.length).toBeGreaterThan(0) + expect(directives).toEqual(directives.map(() => 'use no memo')) + }) +}) diff --git a/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts new file mode 100644 index 0000000000..966e476b8f --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-bindings.test.ts @@ -0,0 +1,1073 @@ +/** + * Known code-splitter bugs (part 3 of known-bugs-code-splitter.test.ts): + * groupings, route options written as methods, bindings that read `Route`, + * options read from the environment, classic JSX pragmas, exported bindings + * and TypeScript-only syntax. Each test asserts correct behaviour for a bug + * on main and is marked .fails; remove .fails when the bug is fixed. + * + * Every route is loaded through the public router plugin in a real Vite dev + * server and run in a real browser page (`./route-app`); what the user is + * told is read from the dev server's merged diagnostic channel. + */ +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { expectValidModules, head, loadRoute } from '../../route-app' +import { servedImports } from '../../served-code' +import type { RouteApp, RouteAppOptions } from '../../route-app' + +/** + * Whether the dev server reported (a warning on any channel: the route + * loaded, so nothing was refused) something about the route file, naming + * it (J2.8: an option left unsplit is reported; the wording is free). Read + * once the page loaded the route. + */ +async function reportsNotSplit(route: RouteApp) { + return ( + findDiagnostics(await route.diagnostics(), { + severity: 'warning', + file: route.url.slice(1), + root: route.host.root, + }).length > 0 + ) +} + +describe('code-split groupings', () => { + // Bug: `codeSplitGroupings` must be written inline; a module-level + // constant holding the groupings is refused ("You must provide an array + // of arrays for the codeSplitGroupings"). + // Impact: groupings shared between route files through a constant cannot + // be used. + test.fails( + 'groupings declared in a module-level constant are honoured', + async () => { + const route = + await loadRoute(`${head}const groupings: Array<Array<'loader' | 'component'>> = [ + ['loader'], + ['component'], +] +export const Route = createFileRoute('/')({ + codeSplitGroupings: groupings, + loader: () => 'data', + component: () => <p>page</p>, +}) +`) + expect( + await route.run( + `return [await options.loader(), await render('component')]`, + ), + ).toEqual(['data', '<p>page</p>']) + // The loader and the component each load on their own. + expect(await route.groups()).toEqual([['component'], ['loader']]) + }, + ) +}) + +describe('module state read by route options written as methods', () => { + // Bug: shared bindings are computed from route options written as + // `key: value` only, so a binding that an option written as a method + // (kept in the route module) and a split option both read is not shared: + // the split chunk declares its own copy. + // Impact: the split component reads another instance of the module state + // than the route's other options. + test.fails( + 'module state a method option shares with a split option is created once', + async () => { + const route = await loadRoute(`${head}const state = { count: 0 } +export const Route = createFileRoute('/')({ + loader() { + return ++state.count + }, + component: () => <div>{state.count}</div>, +}) +`) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual([1, '<div>1</div>']) + }, + ) +}) + +describe('module state next to bindings that read Route', () => { + // Bug: bindings that depend on `Route` are never shared + // (`removeBindingsDependingOnRoute`), and a destructuring is never split + // across modules, so a `Map` declared next to a binding that reads `Route` + // is created by the route module and again by the chunk that reads it. + // Impact: the loader and the component use two different caches. + test.fails( + 'a destructuring whose sibling reads Route keeps one cache for the loader and the component', + async () => { + const route = await loadRoute( + `${head}import { createRouteHelpers } from './helpers' +const { cache, useTitle } = createRouteHelpers(() => Route) +export const Route = createFileRoute('/')({ + staticData: { title: 'title' }, + loader: () => { + cache.set('k', 1) + return cache.size + }, + component: () => <div>{cache.size}{useTitle()}</div>, +}) +`, + { + files: { + 'helpers.ts': `export let created = 0 +export const createRouteHelpers = (getRoute: () => any) => { + created++ + return { + cache: new Map(), + useTitle: () => getRoute().options.staticData.title, + } +} +`, + }, + }, + ) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('helpers.ts')).created, +]`), + ).toEqual([1, '<div>1title</div>', 1]) + }, + ) +}) + +describe('route options read from the environment', () => { + /** + * What the route's component renders, loaded first when it is lazy; + * `globals` runs in the page before the route module loads. + */ + async function renderRouteComponent( + code: string, + options: RouteAppOptions & { globals?: string } = {}, + ) { + const { globals, ...routeOptions } = options + return (await loadRoute(code, routeOptions)).run( + `return render('component')`, + { before: globals }, + ) + } + + // Control for the pins below (same harness). + test('a split component imported by the route file renders', async () => { + expect( + await renderRouteComponent( + `import { Page } from './page' +${head}export const Route = createFileRoute('/')({ component: Page }) +`, + { files: { 'page.tsx': `export const Page = () => 'page'\n` } }, + ), + ).toBe('page') + }) + + // Bug: a split option that is a global (no declaration in the module) or + // an ambient `declare const` is exported from the chunk under a name the + // chunk never declares ("Export '...' is not defined"), or the export is + // erased with the `declare`. + // Impact: the chunk fails to load, or the route renders no component. + test.fails.each([ + { name: 'an undeclared global', declaration: '' }, + { + name: 'an ambient declare const', + declaration: 'declare const TsrGlobalPage: () => string\n', + }, + ])('a component read from $name renders', async ({ declaration }) => { + expect( + await renderRouteComponent( + `${head}${declaration}export const Route = createFileRoute('/')({ + component: TsrGlobalPage, +}) +`, + { globals: `globalThis.TsrGlobalPage = () => 'global page'` }, + ), + ).toBe('global page') + }) +}) + +describe('classic JSX pragmas', () => { + const pragma = `/** @jsxRuntime classic */ +/** @jsx jsx */ +import { jsx } from '@emotion/react' +` + + /** + * Loads the route file, and the same file as another module of the app + * (`untouched.tsx`: no route file, so no compiler of the router plugin + * touches it; the project's real JSX transform and the real + * `@emotion/react` and React compile and run it). Returns what the split + * route's component and the untouched file's component render. + */ + async function renderBoth(code: string) { + const route = await loadRoute(code, { + files: { 'untouched.tsx': code }, + prebundle: ['@emotion/react'], + }) + return route.run<{ split: string; untouched: string }>(` +const untouched = (await app('untouched.tsx')).Route.options.component +return { + untouched: await renderComponent(untouched), + split: await render('component'), +}`) + } + + // Bug: dead-code elimination does not count a classic JSX pragma + // (`/** @jsx jsx */`) as a use of the factory it names, so a chunk whose + // only use of the factory is its JSX drops the factory import. Same root + // cause as the JSX pragma pins in + // start-plugin-core/tests/known-bugs-start-compiler.test.ts and + // known-bugs-hydrate.test.ts. + // Impact: the split component throws "jsx is not defined". + test.fails( + 'a split component renders through the factory of a classic JSX pragma', + async () => { + const { split, untouched } = + await renderBoth(`${pragma}${head}export const Route = createFileRoute('/')({ + component: () => <div css={{ color: 'red' }}>page</div>, + errorComponent: () => jsx('b', null, 'error'), +})`) + expect(split).toBe(untouched) + }, + ) + + // Bug: same root cause as above, for a chunk with only fragments (the + // @jsxFrag factory too) and a pragma written with two spaces. Source: #8504 + // (code-splitter-pragmas.test.ts; mutation testing of the dead code + // removal), where they pass. + // Impact: the split component throws "jsx is not defined". + test.fails.each([ + { + name: 'the fragments of a chunk, with @jsxFrag', + code: `/** @jsxRuntime classic */ +/** @jsx jsx */ +/** @jsxFrag Fragment */ +${head}import { jsx } from '@emotion/react' +import { Fragment } from 'react' +export const Route = createFileRoute('/')({ + component: () => <><b css={{ color: 'red' }}>page</b></>, + errorComponent: () => jsx(Fragment, null, 'error'), +})`, + }, + { + // Source: #8504 (mutation testing). + name: 'a pragma written with two spaces', + code: `/** @jsxRuntime classic */ +/** @jsx jsx */ +${head}import { jsx } from '@emotion/react' +export const Route = createFileRoute('/')({ + component: () => <div css={{ color: 'red' }}>page</div>, + errorComponent: () => jsx('b', null, 'error'), +})`, + }, + ])('a split component renders through $name', async ({ code }) => { + const { split, untouched } = await renderBoth(code) + expect(split).toBe(untouched) + }) + + /** + * The application's own classic JSX factory (module `./jsx`), rendering + * intrinsic elements as the text `tag(children)`, counting how many + * factories were created. + */ + const jsxModule = `export let creations = 0 +const textJsx = (type: string, _props: unknown, ...children: Array<string>) => + \`\${type}(\${children.join('')})\` +export const createJsx = () => { + creations++ + return textJsx +} +` + + // Bug: the shared-binding analysis does not count the JSX of a split option + // as a read of the classic JSX factory it compiles to, so a factory that + // the route module creates and the loader reads is not shared with the + // split component: the chunk drops it (same root cause as the pin above), + // and keeping it in the chunk without sharing it creates it again there. + // Impact: the split component throws "jsx is not defined", or the route + // module and the chunk each create their own factory. + // Source of the `@jsx` only row: #8504 (a project whose + // JSX runtime is classic: `@vitejs/plugin-react` with `jsxRuntime: + // 'classic'`). + test.fails.each([ + { + name: '@jsxRuntime classic and @jsx', + header: '/** @jsxRuntime classic */\n/** @jsx jsx */', + plugin: undefined, + }, + { + // A project whose default JSX runtime is classic (what `@jsx` alone + // requires: the automatic transform ignores a lone `@jsx`). + name: '@jsx only, in a classic-runtime project', + header: '/** @jsx jsx */', + plugin: { jsxRuntime: 'classic' }, + }, + ])( + 'a factory the route module creates and the loader reads is created once for the split component ($name)', + async ({ header, plugin }) => { + const route = await loadRoute( + `${header} +${head}import { createJsx } from './jsx' +const jsx = createJsx() +export const Route = createFileRoute('/')({ + loader: () => jsx('span', null), + component: () => <div>page</div>, +})`, + { files: { 'jsx.ts': jsxModule }, frameworkPluginOptions: plugin }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('jsx.ts')).creations, +]`), + ).toEqual(['span()', 'div(page)', 1]) + }, + ) +}) + +describe('exported bindings', () => { + // Bug: the "will not be code-split" warning is only reported when the code + // splitter changes the route module. In a production build, a route whose + // only split candidate is an exported component is left as is, so the + // warning is never shown (route HMR changes the module in dev, which shows + // it). + // Impact: no diagnostic in production builds for a page that stays in the + // entry chunk. + test.fails.each([ + { + name: 'an exported function', + declaration: `export function Page() { + return <p>page</p> +}`, + binding: 'Page', + }, + { + name: 'a default-exported function', + declaration: `export default function Page() { + return <p>page</p> +}`, + binding: 'Page', + }, + { + name: 'a function exported as default by name', + declaration: `function Page() { + return <p>page</p> +} +export default Page`, + binding: 'Page', + }, + { + // Source: #8504. + name: 'a function exported as default by specifier', + declaration: `function Page() { + return <p>page</p> +} +export { Page as default }`, + binding: 'Page', + }, + { + name: 'an exported destructuring of a call', + declaration: `const createBits = () => ({ + component: () => <p>page</p>, + loader: () => ({ message: 'hello' }), +}) +export const { component: Page, loader } = createBits()`, + binding: 'Page', + options: 'loader, ', + }, + ])( + 'an exported component ($name) that is the only split candidate is split or reported as not code-split', + async ({ declaration, binding, options = '' }) => { + const route = await loadRoute(`${head}${declaration} +export const Route = createFileRoute('/')({ ${options}component: ${binding} }) +`) + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + expect({ + split: await route.isLazy('component'), + warned: await reportsNotSplit(route), + }).not.toEqual({ split: false, warned: false }) + }, + ) + + // Bug: the entry's `useTitle` and the one the split component calls are + // two functions: a binding that reads `Route` is never shared + // (`removeBindingsDependingOnRoute`), so the chunk declares a copy of the + // exported function. Importers of the route module and the route must + // share one instance (SPEC G9, J2.4): a copy in the chunk is + // this bug even when the function holds no state. + // Impact: code that relies on the identity of an exported hook or helper + // (memoisation, registries, `===` checks) sees two of them. + // (The title lives in `staticData`, typed by the documented + // `StaticDataRouteOption` augmentation.) + test.fails( + 'an exported function that reads Route is the one the split component calls', + async () => { + const route = await loadRoute( + `${head}import { see } from './see' +declare module '@tanstack/react-router' { + interface StaticDataRouteOption { + title?: string + } +} +export function useTitle() { + return Route.options.staticData!.title +} +function Page() { + see(useTitle) + return <p>{useTitle()}</p> +} +export const Route = createFileRoute('/')({ + staticData: { title: 'title' }, + component: Page, +}) +`, + { + files: { + 'see.ts': `export const seen: Array<unknown> = [] +export const see = (value: unknown) => seen.push(value) +`, + // Another module of the app imports the hook. + 'importer.ts': `export { useTitle } from './route'\n`, + }, + }, + ) + expect( + await route.run(`const { useTitle } = await app('importer.ts') +const rendered = await render('component') +const { seen } = await app('see.ts') +return { + rendered, + imported: useTitle(), + sameInstance: seen.length === 1 && seen[0] === useTitle, +}`), + ).toEqual({ + rendered: '<p>title</p>', + imported: 'title', + sameInstance: true, + }) + }, + ) + + // Bug: a split component that reads a `Route` declared with `const` and + // exported later (`export { Route }`) gets a chunk that creates the route + // again instead of importing it from the route module. + // Source: real apps: route files that end with `export { Route }` + // (rahulroy0322/RacketHub, mchar7/nohiki-monorepo); #8504 + // (code-splitter-route-options.test.ts), where it passes. + // Impact: the split component reads a second route object, which the + // router does not know. + test.fails( + 'a split component reads the route the route module exports through export { Route }', + async () => { + const route = await loadRoute( + `${head}const Route = createFileRoute('/')({ + component: Page, +}) +function Page() { + return <p>{Route.id}</p> +} +export { Route } +`, + ) + // The router mounted the exported route (which sets its id): a second + // route object has none. + expect(await route.run(`return renderRoute()`)).toBe('<p>/</p>') + }, + ) + + // Bug: a route whose component is a default-exported function (which + // stays in the route module) that another split option renders cannot be + // compiled: the code splitter throws "Duplicate declaration \"Bar\"". + // Source: React Compiler gating/gating-test-export-default-function.js; + // #8504 (code-splitter-imports-exports.test.ts), where it passes. + // Impact: the route cannot be built once code splitting is on. + test.fails( + 'a split option renders the default-exported component other modules import', + async () => { + const route = await loadRoute( + `${head}import type { ReactNode } from 'react' +import { see } from './see' +export default function Bar(props: { children?: ReactNode }) { + return <div>{props.children}</div> +} +function NoForget(props: { noForget?: string }) { + see(Bar) + return <Bar>{props.noForget}</Bar> +} +export const Route = createFileRoute('/')({ component: Bar, errorComponent: NoForget }) +`, + { + files: { + 'see.ts': `export const seen: Array<unknown> = [] +export const see = (value: unknown) => seen.push(value) +`, + // The component other modules import. + 'importer.ts': `export { default } from './route'\n`, + }, + }, + ) + expect( + await route.run(`const rendered = await render('errorComponent', { noForget: 'x' }) +const { default: imported } = await app('importer.ts') +const { seen } = await app('see.ts') +return { rendered, seen: seen.length, sameInstance: seen[0] === imported }`), + ).toEqual({ rendered: '<div>x</div>', seen: 1, sameInstance: true }) + }, + ) + + // Bug: the code splitter deletes the exported declaration of an option's + // component from every chunk, so a split component that renders the + // exported component of another option, which reads `Route`, renders an + // undeclared binding ("NotFound is not defined"). + // Source: round-3 mutation testing (compilers-B, bug A). + // Impact: the route crashes when its component renders. + test.fails.each([ + { + name: 'export function', + declaration: `export function NotFound() { + return <i>{Route.options.staticData.label}</i> +}`, + }, + { + name: 'export const', + declaration: `export const NotFound = () => <i>{Route.options.staticData.label}</i>`, + }, + ])( + 'a split component renders the exported component of another option that reads Route ($name)', + async ({ declaration }) => { + const route = await loadRoute(`${head}${declaration} +export const Route = createFileRoute('/')({ + component: () => <p><NotFound /></p>, + staticData: { label: 'nf' }, + notFoundComponent: NotFound, +}) +`) + expect(await route.run(`return render('component')`)).toBe( + '<p><i>nf</i></p>', + ) + }, + ) + + // Bug: a default-exported function declaration that the loader and a split + // component both call cannot be compiled: Babel throws "Duplicate + // declaration" for it. + // Source: round-3 mutation testing (router-utils). + // Impact: the route cannot be built once code splitting is on. + test.fails( + 'a default-exported function the loader and the split component call works on one state', + async () => { + const route = await loadRoute( + `${head}import { init } from './state' +const store = init({ n: 0 }) +export default function bump() { + return ++store.n +} +export const Route = createFileRoute('/')({ + loader: () => bump(), + component: () => <p>{bump()}</p>, +}) +`, + { + files: { + 'state.ts': `export let inits = 0 +export const init = <T,>(value: T) => { + inits++ + return value +} +`, + 'importer.ts': `export { default } from './route'\n`, + }, + }, + ) + expect( + await route.run(`const { default: bump } = await app('importer.ts') +return [ + options.loader(), + await render('component'), + bump(), + (await app('state.ts')).inits, +]`), + ).toEqual([1, '<p>2</p>', 3, 1]) + }, + ) + + // Bug: a split loader that the route file also exports through an export + // list (`export { load }`) loses its declaration in the route module: + // "Export 'load' is not defined". + // Source: round-3 mutation testing (compilers-A). + // Impact: the route cannot be built once code splitting is on. + test.fails( + 'a split loader exported through an export list keeps working', + async () => { + const route = await loadRoute( + `${head}function load() { + return 'data' +} +export { load } +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: load, + component: () => <p>page</p>, +}) +`, + { files: { 'importer.ts': `export { load } from './route'\n` } }, + ) + expect( + await route.run(`const { load } = await app('importer.ts') +return [await options.loader(), load()]`), + ).toEqual(['data', 'data']) + }, + ) + + /** + * Loads a route whose errorComponent option is the exported + * `PostErrorComponent`, written as `value`, next to another module of the + * app that imports `PostErrorComponent` from the route file (SPEC G9, + * J2.4: through a real importer). `withAuth` (`./with-auth`) is an identity + * function. The component records the instance it runs as (`./see`). + * Returns what the route's errorComponent renders, whether it ran as the + * importer's instance, and whether the option is split or the user is told + * it is not (a warning naming the route file and the option). A host of + * its own: the control and the pin below load the same route, and each + * reads what compiling it reports. + */ + async function exportedErrorComponent(value: string) { + const route = await loadRoute( + `${head}import { withAuth } from './with-auth' +import { see } from './see' +import { memo } from 'react' +export const Route = createFileRoute('/posts/$postId')({ + errorComponent: ${value}, + component: () => <p>post</p>, +}) +export function PostErrorComponent() { + see(PostErrorComponent) + return <p>error</p> +} +`, + { + routeId: '/posts/$postId', + fresh: true, + files: { + 'with-auth.ts': `export const withAuth = <T,>(component: T) => component\n`, + 'see.ts': `export const seen: Array<unknown> = [] +export const see = (value: unknown) => seen.push(value) +`, + 'importer.ts': `import { PostErrorComponent } from './route' +export const imported = PostErrorComponent +`, + }, + }, + ) + const { rendered, sameInstance } = await route.run<{ + rendered: string + sameInstance: boolean + }>(`const { imported } = await app('importer.ts') +const rendered = await render('errorComponent') +const { seen } = await app('see.ts') +return { rendered, sameInstance: seen.length === 1 && seen[0] === imported }`) + return { + rendered, + sameInstance, + splitOrReported: + (await route.isLazy('errorComponent')) || + (await reportsNotSplit(route)), + } + } + + // The bare identifier. + test('an exported errorComponent named by the option is the instance its importers get', async () => { + expect(await exportedErrorComponent('PostErrorComponent')).toMatchObject({ + rendered: '<p>error</p>', + sameInstance: true, + }) + }) + + // Bug: an exported component named by a split option is only recognised + // as an export when the option is a bare identifier. Written in another + // shape (`as any`, `as typeof X`, an HOC call such as `withAuth(X)` or + // `memo(X)`), the option is split and its chunk declares its own copy of + // the exported component, so the route renders another instance than the + // one other modules import (and no "not code-split" warning is shown). + // Either outcome of the bare identifier (one instance, split or unsplit + // with a warning) is fine (SPEC G9, J2.4, J2.8). + // Reach: the repository's examples (react and solid + // basic-virtual-file-based posts-detail.tsx) and e2e apps (react, solid + // and vue basic-file-based-code-splitting, virtual and rspack-virtual + // routes, solid-start virtual-routes) write `errorComponent: + // PostErrorComponent as any`; no other module imports it there, so they + // show no symptom. + // Source: compilers.ts:945-960 (the export check only handles a bare + // Identifier), :572-591, the copy via :1170-1242; fuzzing. + // Impact: code that relies on the identity of the component (`===` + // checks, registries, memoised props) sees two of them, and the component + // code ships twice (see the build pin below). + test.fails.each([ + 'PostErrorComponent as any', + 'PostErrorComponent as typeof PostErrorComponent', + 'withAuth(PostErrorComponent)', + 'memo(PostErrorComponent)', + ])( + 'an exported errorComponent written as `%s` is the instance its importers get', + async (value) => { + expect(await exportedErrorComponent(value)).toEqual({ + rendered: '<p>error</p>', + sameInstance: true, + splitOrReported: true, + }) + }, + ) +}) + +describe('TypeScript-only syntax', () => { + // Bug: the code splitter rejects an ES decorator after `export` (`export + // @dec class`, valid since TypeScript 5.0): "Decorators must be placed + // before the export keyword". + // A real bug (SPEC §2.1, G1): the syntax is valid TypeScript. The pin reads + // the compiled module without running the page (whether a browser runs + // the decorator syntax is not the compiler's). + // Source: mutation testing. + // Impact: a route file with such a class cannot be built once code + // splitting is on. + test.fails('a decorator after `export` compiles', async () => { + const route = await loadRoute( + `${head}import { injectable } from 'tsyringe' +export @injectable() class Store {} +export const Route = createFileRoute('/')({ component: () => <div /> }) +`, + { + // The package is written with the app (Vite's watcher reports no + // edit under node_modules) + fresh: true, + files: { + 'node_modules/tsyringe/package.json': JSON.stringify({ + name: 'tsyringe', + type: 'module', + exports: './index.js', + }), + 'node_modules/tsyringe/index.js': `export const injectable = () => (value) => value\n`, + }, + }, + ) + // The route module the dev server serves is a valid module, and + // compiling it reported no error + await expectValidModules({ reference: await route.transform() }) + expect( + findDiagnostics(problems(await route.diagnostics()), { + severity: 'error', + file: 'route.tsx', + root: route.host.root, + }).map((diagnostic) => diagnostic.text), + ).toEqual([]) + }) + + // Bug: the code splitter cannot parse a constructor parameter decorator + // (TypeScript `experimentalDecorators`, as dependency injection libraries + // use them) and fails the build. Source: review of #8504, which compiles + // it. + // Impact: a route file with such a class cannot be built once code + // splitting is on. + test.fails( + 'a class with a parameter decorator that the split component uses compiles into parseable modules', + async () => { + const route = await loadRoute( + `${head}import { Inject } from './di' +class Service { + constructor(@Inject() readonly dep: unknown) {} +} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{String(new Service(1).dep)}</p>, +}) +`, + { + tsconfig: { experimentalDecorators: true }, + files: { + 'di.ts': `export const Inject = () => (_target: unknown, _key: unknown, _index: number) => {}\n`, + }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [options.loader(), await render('component')]`), + ).toEqual(['data', '<p>1</p>']) + // Compiled: nothing reported an error compiling the route, and the + // component is split, as configured (not left in the route module) + expect( + findDiagnostics(problems(await route.diagnostics()), { + severity: 'error', + file: 'route.tsx', + root: route.host.root, + }).map((diagnostic) => diagnostic.text), + ).toEqual([]) + expect(await route.isLazy('component')).toBe(true) + }, + ) + + // Bug: a type-only import re-exported without `type` (`export { Settings }`, + // which TypeScript accepts unless verbatimModuleSyntax is on) loses its + // import in the route module and the split chunks, which keep the export + // that the TypeScript transform can then no longer erase. The Start + // compiler has the same bug (pin in + // start-plugin-core/tests/known-bugs-start-compiler.test.ts). + // Impact: the route fails to load ("Export 'Settings' is not defined"). + test.fails.each([ + `import type { Settings } from './settings'`, + `import { type Settings } from './settings'`, + ])( + 'a type-only import re-exported as `export { Settings }` is erased (%s)', + async (importDeclaration) => { + const route = await loadRoute( + `${head}${importDeclaration} +export { Settings } +export const Route = createFileRoute('/')({ + component: () => <p>index</p>, +})`, + { + files: { + 'settings.ts': `export type Settings = { theme: string }\n`, + }, + }, + ) + await expectValidModules(route) + }, + ) + + // Bug: a value import that only types read (TypeScript erases it) is + // copied into every split chunk when the types that read it stay in the + // route module. Source: #8504 (code-splitter-imports-exports.test.ts, + // mutation testing of the dead code removal), where it passes. + // Impact: split chunks load modules none of their code reads, e.g. + // server-only code typed in the loader. + // Observed on what the page loads: every module that loading a split + // option requests, as the dev server serves it (TypeScript erased, so a + // runtime-neutral `import type` is gone, §5.5), must not import the module + // (a value the project exports next to the type, so the import is valid + // with `verbatimModuleSyntax`, which keeps it where it is written). + test.fails.each([ + { + name: 'the return type of the loader', + code: `import { Framework } from './projects' +export const Route = createFileRoute('/')({ + loader: (): Framework => 'react', + component: () => <p>index</p>, +})`, + file: 'projects.ts', + module: `export const Framework = { react: 'react', solid: 'solid' } as const +export type Framework = 'react' | 'solid' +`, + }, + { + name: 'a parameter type of a helper the loader calls', + code: `import { Database } from './server/db' +const load = (db: Database) => db.query() +export const Route = createFileRoute('/')({ + loader: ({ context }) => load(context.db), + component: () => <p>page</p>, +})`, + file: 'server/db.ts', + module: `export class Database { + query() { + return 'rows' + } +} +`, + }, + ])( + 'split chunks do not import what only $name reads', + async ({ code, file, module }) => { + const route = await loadRoute(`${head}${code}\n`, { + files: { [file]: module }, + }) + const loaded = await route.run< + Array<string> + >(`const before = new Set(await compiled()) +for (const option of Object.keys(options)) await trigger(option) +const loaded = (await compiled()).filter((request) => !before.has(request)) +return Promise.all(loaded.map(served))`) + expect(loaded.length).toBeGreaterThan(0) + expect( + loaded.filter((chunk) => servedImports(chunk).includes(`/${file}`)), + ).toEqual([]) + }, + ) + + // Bug: the split chunk declares a namespace the split component reads + // without its body. Source: #8504 (code-splitter-imports-exports.test.ts), + // where it passes. + // Impact: the split component throws ("Labels is not defined"). + test.fails( + 'a namespace the split component reads keeps its body', + async () => { + const route = + await loadRoute(`${head}namespace Labels { export const quiet = 'quiet' } +export const Route = createFileRoute('/')({ + component: () => <p>{Labels.quiet}</p>, +}) +`) + expect(await route.run(`return render('component')`)).toBe('<p>quiet</p>') + }, + ) + + // Bug: the split chunk prints a type assertion used as an update target + // without its parentheses (`count as number++`), which does not parse. + // Sources: @vitejs/plugin-rsc transform tests, typescript-eslint + // type-assertion/increment/as-increment.js; #8504 + // (code-splitter-imports-exports.test.ts), where it passes. + // Impact: the split component's chunk fails to compile. + test.fails( + 'an asserted update operand keeps its parentheses in a split component', + async () => { + const route = await loadRoute(`${head}let count = 0 +function Page() { + ;(count as number)++ + return count +} +export const Route = createFileRoute('/')({ component: Page }) +`) + expect(await route.run(`return render('component')`)).toBe('1') + }, + ) + + // Bug: the split chunk prints a type assertion that is the test of a + // conditional whose branch starts with a unary minus without its + // parentheses (`a as any ? -x : y`), which does not parse (`any ? -x` + // reads as the start of a conditional type). The root cause is upstream: + // @babel/generator 7.29.8 drops the parentheses (parse+generate of + // `f = ((a) as any) ? -x : y` gives `f = a as any ? -x : y;`; no + // workaround here; router-utils/src/ast.ts:72 `generateFromAst` prints + // with it). The Start compiler has the same bug (pin in + // start-plugin-core/tests/start-compiler-preserves-user-code.test.ts). + // Source: fuzzing. + // Impact: the split component's chunk fails to compile, so the build + // fails. + test.fails( + 'an asserted conditional test keeps its parentheses in a split component', + async () => { + const route = + await loadRoute(`${head}function pick(flag: unknown, x: number, y: number) { + return ((flag) as any) ? -x : y +} +function Page() { + return <p>{pick(true, 1, 2)}</p> +} +export const Route = createFileRoute('/')({ component: Page }) +`) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('<p>-1</p>') + }, + ) + + // Bug: the route module prints a JSX element whose member is read without + // its parentheses (`(<Tag />).props` becomes `<Tag />.props`), which + // Vite's transform does not parse. The root cause is upstream: + // @babel/generator 7.29.8 drops the parentheses (parse+generate of + // `f = (<X a="1" />).props.a` gives `f = <X a="1" />.props.a;`; no + // workaround here). + // Source: review. + // Impact: the route module fails to compile (the dev server answers 500). + test.fails( + 'a JSX element read as an object keeps its parentheses in the route module', + async () => { + const route = + await loadRoute(`${head}function Tag(props: { label: string }) { + return <p>{props.label}</p> +} +export const Route = createFileRoute('/')({ + loader: () => (<Tag label="kept" />).props.label, + component: () => <p>page</p>, +}) +`) + await expectValidModules(route) + expect(await route.run(`return options.loader()`)).toBe('kept') + }, + ) + + /** + * Loads a route whose split component returns `expression`, checks that + * every module the page loads for it is valid and returns what the + * component renders. + */ + async function renderReturned(expression: string) { + const route = await loadRoute(`${head}function Page() { + return ${expression} +} +export const Route = createFileRoute('/')({ component: Page }) +`) + await expectValidModules(route) + return route.run(`return render('component')`) + } + + test('parenthesized JSX keeps working in a split component', async () => { + expect(await renderReturned('(<p>page</p>)')).toBe('<p>page</p>') + }) + + /** A route whose `beforeLoad` and split loader both call `helper`. */ + const sharedHelperRoute = (helper: string) => `${head}${helper} +export { helper as helperAlias } +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['component'], ['loader']], + component: () => null, + beforeLoad: () => helper('before'), + loader: () => helper(42), +})` + + async function callSharedHelper(helper: string, verbatimModuleSyntax = true) { + const route = await loadRoute(sharedHelperRoute(helper), { + tsconfig: { verbatimModuleSyntax }, + // As another module of the app imports them. + files: { + 'importer.ts': `export { helper, helperAlias } from './route'\n`, + }, + }) + return route.run(`const imported = await app('importer.ts') +return [ + typeof imported.helper === 'function' && imported.helperAlias === imported.helper, + options.beforeLoad(), + await options.loader(), +]`) + } + + // Control for the overload pin below (same route, no overload signatures). + test('a function the route module and a split loader share keeps working', async () => { + expect( + await callSharedHelper( + `export function helper(value: string | number) { return value }`, + ), + ).toEqual([true, 'before', 42]) + }) + + const overloadedHelper = `export function helper(value: string): string +export function helper(value: number): number +export function helper(value: string | number) { return value }` + + // Control for the pin below: TypeScript erasure with + // `verbatimModuleSyntax` keeps the import of the shared function. + test('an overloaded function the route module and a split loader share keeps working, with verbatimModuleSyntax', async () => { + expect(await callSharedHelper(overloadedHelper)).toEqual([ + true, + 'before', + 42, + ]) + }) + + // Bug: the overload signatures of a function that the route module and a + // split chunk share stay in both modules, next to the import of the shared + // function, and the TypeScript transform then takes them for the binding's + // declaration and drops the import (dead-code elimination never removes + // overload signatures). Source: #8505. + // Impact: in a project without `verbatimModuleSyntax`, the route module + // fails to load ("Export 'helper' is not defined"). + test.fails( + 'an overloaded function the route module and a split loader share keeps working', + async () => { + expect(await callSharedHelper(overloadedHelper, false)).toEqual([ + true, + 'before', + 42, + ]) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-server.test.ts b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-server.test.ts new file mode 100644 index 0000000000..44aec0571a --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-server.test.ts @@ -0,0 +1,889 @@ +/** + * Known code-splitter bugs (part 4 of known-bugs-code-splitter.test.ts): + * code that reads a split binding, class components, side-effect imports, + * server-only route options on the client and look-alike route factories. + * Each test asserts correct behaviour for a bug on main and is marked + * .fails; remove .fails when the bug is fixed. + * + * Every route is loaded through the public router plugin in a real Vite dev + * server and run in a real browser page (`./route-app`); what the user is + * told is read from the dev server's merged diagnostic channel. + */ +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { + diagnosticsOf, + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import type { RouteApp, RouteAppOptions } from '../../route-app' + +/** + * Whether the dev server reported (a warning on any channel: the route + * loaded, so nothing was refused) something about the route file, naming + * it (J2.8: an option left unsplit is reported; the wording is free). Read + * once the page loaded the route. + */ +async function reportsNotSplit(route: RouteApp) { + return ( + findDiagnostics(await route.diagnostics(), { + severity: 'warning', + file: route.url.slice(1), + root: route.host.root, + }).length > 0 + ) +} + +describe('code that reads a split binding', () => { + /** + * Loads a route whose component is `Page`, declared next to `exports`, + * and returns what the route renders, what the component `read` (an + * expression of the imported `value`) gets from the route module's export + * `name` (as another module of the app imports it) renders, and whether + * `Page` is split or the user is told it is not (a warning naming the + * route file and `component`). + */ + async function renderPage(exports: string, name: string, read = 'value') { + const route = await loadRoute( + `${head}import { wrap } from './wrap' +function Page() { + return <p>page</p> +} +${exports} +export const Route = createFileRoute('/')({ component: Page }) +`, + { + files: { + 'wrap.ts': `export const wrap = <T,>(component: T) => component\n`, + 'importer.ts': `export { ${name} as value } from './route'\n`, + }, + }, + ) + const rendered = await route.run(`const rendered = await render('component') +const { value } = await app('importer.ts') +return [rendered, await renderComponent(${read})]`) + return { + rendered, + splitOrReported: + (await route.isLazy('component')) || (await reportsNotSplit(route)), + } + } + + // Control for the pin below (same harness, an export that does not read + // `Page`). + test('a split component renders next to another export', async () => { + expect( + await renderPage(`export const Label = wrap(() => 'label')`, 'Label'), + ).toEqual({ rendered: ['<p>page</p>', 'label'], splitOrReported: true }) + }) + + // Bug: when a route option names a binding that the code splitter moves + // into a chunk, the splitter deletes the binding's declaration from the + // route module (`removeIdentifierLiteral`), even when other code there + // still reads it. Only `export function`/`export const` declarations are + // checked, so export lists, aliases and exports that use the binding lose + // it. Source: #8505 (`export { component as View }`). + // A fix may also leave `Page` unsplit, but must then tell the user, in + // production builds too (SPEC J2.8, G5): unsplit and silent is still this + // bug. + // Impact: the route module throws when it loads ("Page is not defined", + // "Export 'Page' is not defined"), so the route never renders. + test.fails.each([ + { + name: 'an exported object', + exports: 'export const meta = { fn: Page }', + imported: 'meta', + read: 'value.fn', + }, + { + name: 'an exported function', + exports: 'export function Preview() { return <Page /> }', + imported: 'Preview', + }, + { + name: 'a default export', + exports: 'export default wrap(Page)', + imported: 'default', + }, + { + name: 'an export list', + exports: 'export { Page }', + imported: 'Page', + }, + { + name: 'an export alias', + exports: 'export { Page as View }', + imported: 'View', + }, + { + // Source: #8504. + name: 'a default export by specifier', + exports: 'export { Page as default }', + imported: 'default', + }, + ])( + 'a split component that $name reads renders from both', + async ({ exports, imported, read }) => { + expect(await renderPage(exports, imported, read)).toEqual({ + rendered: ['<p>page</p>', '<p>page</p>'], + splitOrReported: true, + }) + }, + ) + + // Bug: same root cause as above, for a function that module-level code + // keeps reachable: it renders the split component, whose declaration the + // route module lost. The registry is created, filled and subscribed to + // once, also after the chunk loads (a chunk that runs that code again + // makes a second registry). Source: #8504 (code-splitter-dead-code.test.ts). + // Impact: the route module throws when it loads ("Page is not defined"). + test.fails.each([ + { + name: 'module-level code registers', + setup: `registry.set('preview', Preview)`, + subscribes: 0, + }, + { + name: 'an unused subscription calls back', + setup: `const unsubscribe = subscribe((name) => registry.set(name, Preview))`, + subscribes: 1, + }, + ])( + 'a split component renders through a function $name', + async ({ setup, subscribes }) => { + const route = await loadRoute( + `${head}import { createRegistry, subscribe } from './subscribe' +const registry = createRegistry() +function Page() { + return <p>page</p> +} +function Preview() { + return <Page /> +} +${setup} +export const Route = createFileRoute('/')({ + component: Page, + loader: () => registry.get('preview')(), +}) +`, + { + files: { + 'subscribe.ts': `export const runs = { registries: 0, sets: 0, subscribes: 0 } +export const createRegistry = () => { + runs.registries++ + const map = new Map<string, any>() + return { + get: (name: string) => map.get(name), + set: (name: string, value: unknown) => { + runs.sets++ + map.set(name, value) + }, + } +} +export const subscribe = (callback: (name: string) => void) => { + runs.subscribes++ + callback('preview') +} +`, + }, + }, + ) + expect( + await route.run(`// The loader returns the element \`Preview\` renders +const element = options.loader() +const loaded = await renderComponent(() => element) +const rendered = await render('component') +return [loaded, rendered, { ...(await app('subscribe.ts')).runs }]`), + ).toEqual([ + '<p>page</p>', + '<p>page</p>', + { registries: 1, sets: 1, subscribes }, + ]) + }, + ) + + // Bug: same root cause as above, for an unsplit option that names the + // split component. Source: real apps: bex-co/bex + // src/routes/databases.$databaseId.tsx (`component: Page, + // pendingComponent: Page`); #8504 (code-splitter-route-options.test.ts), + // where it passes. + // Impact: the route module throws when it loads ("Page is not defined"). + test.fails( + 'a component read by a split and an unsplit option renders from both', + async () => { + const route = + await loadRoute(`${head}export const Route = createFileRoute('/')({ + component: Page, + pendingComponent: Page, +}) +function Page() { + return <p>{typeof Route}</p> +} +`) + expect( + await route.run( + `return [await render('pendingComponent'), await render('component')]`, + ), + ).toEqual(['<p>object</p>', '<p>object</p>']) + }, + ) + + // Bug: same root cause as above, for an unsplit option that reads the + // split component (which reads `Route`, so it moves to its chunk) with + // `typeof`. Reading an undeclared name with `typeof` does not throw, so + // the route module loads and the option silently sees `'undefined'`. + // Source: fuzzing (`beforeLoad` and `loaderDeps` readers of components of + // the repository's e2e routes). + // Impact: code that checks the component (`typeof Page === 'function'`) + // takes the wrong branch on every navigation, with no error. + test.fails( + 'an unsplit option that reads the split component with typeof sees a function', + async () => { + const route = + await loadRoute(`${head}export const Route = createFileRoute('/')({ + component: Page, + beforeLoad: () => typeof Page, +}) +function Page() { + return <p>{typeof Route}</p> +} +`) + expect( + await route.run( + `return [options.beforeLoad(), await render('component')]`, + ), + ).toEqual(['function', '<p>object</p>']) + }, + ) + + // Bug: same root cause as above, for a top-level call that reads the split + // component. The call runs once, also after the chunk loads (a chunk that + // calls `register` again registers a second component). Source: #8504 + // (differential fuzzing). + // Impact: the route module throws when it loads ("Page is not defined"). + test.fails( + 'a split component that a top-level call reads renders from both', + async () => { + const route = await loadRoute( + `${head}import { register } from './registry' +function Page() { + return <div>page</div> +} +export const Route = createFileRoute('/')({ component: Page }) +register(Page) +`, + { + files: { + 'registry.ts': `export const registered: Array<unknown> = [] +export const register = (component: unknown) => { + registered.push(component) +} +`, + }, + }, + ) + expect( + await route.run(`const rendered = await render('component') +const { registered } = await app('registry.ts') +const fromRegistry = [] +for (const component of registered) fromRegistry.push(await renderComponent(component)) +return [fromRegistry, rendered]`), + ).toEqual([['<div>page</div>'], '<div>page</div>']) + }, + ) + + // Control for the imported-component pins below (same harness): the split + // component is declared in the route file. + test('a split component declared in the route file renders, and head() reads it', async () => { + const route = await loadRoute( + `${head}function PostsPage() { + return <p>posts</p> +} +PostsPage.title = 'Posts' +export const Route = createFileRoute('/posts')({ + component: PostsPage, + head: () => ({ meta: [{ title: PostsPage.title }] }), +}) +`, + { routeId: '/posts' }, + ) + expect( + await route.run(`return [options.head(), await render('component')]`), + ).toEqual([{ meta: [{ title: 'Posts' }] }, '<p>posts</p>']) + }) + + // Bug: when a split option names an imported binding, the code splitter + // deletes its import specifier from the route module + // (`removeIdentifierLiteral` removes the binding without checking for other + // reads), then the emptied import, even when other code there still reads + // it: an unsplit option, an exported function or anything else. Sibling of + // the pins above, which cover bindings declared in the route file. + // Source: compilers.ts:571-593 (`removeIdentifierLiteral`), :1555-1593 + // (the binding is removed), :768-777 (the emptied import is dropped); + // fuzzing. + // Impact: the route throws "PostsPage is not defined" where the other code + // runs (head() on every navigation, an importer's render). + test.fails( + 'an imported split component that head() reads renders, and head() reads it', + async () => { + const route = await loadRoute( + `${head}import { PostsPage } from './posts-page' +export const Route = createFileRoute('/posts')({ + component: PostsPage, + head: () => ({ meta: [{ title: PostsPage.title }] }), +}) +`, + { + routeId: '/posts', + files: { + 'posts-page.ts': `export const PostsPage = Object.assign(() => 'posts', { + title: 'Posts', +}) +`, + }, + }, + ) + expect( + await route.run(`return [options.head(), await render('component')]`), + ).toEqual([{ meta: [{ title: 'Posts' }] }, 'posts']) + }, + ) + + // Bug: same root cause as above, for an exported component that renders + // the imported split one, used by another module of the app (SPEC G9, + // J2.4, J4.13: through a real importer, not the export list). Adapted from the + // repository's + // examples/solid/start-supabase-basic/src/routes/_authed/posts.$postId.tsx + // (written for React here; the code splitter handles the import the same + // way for every framework). + // Impact: rendering `PostErrorComponent` throws "ErrorComponent is not + // defined". + test.fails( + 'an imported split errorComponent that an exported component renders works for an importer', + async () => { + const route = await loadRoute( + `import { ErrorComponent, createFileRoute } from '@tanstack/react-router' +import type { ErrorComponentProps } from '@tanstack/react-router' +export const Route = createFileRoute('/posts/$postId')({ + loader: ({ params: { postId } }) => postId, + errorComponent: ErrorComponent, + component: PostComponent, +}) +export function PostErrorComponent({ error }: ErrorComponentProps) { + return <ErrorComponent error={error} /> +} +function PostComponent() { + return <h4>post</h4> +} +`, + { + routeId: '/posts/$postId', + files: { + 'importer.ts': `export { PostErrorComponent } from './route'\n`, + }, + }, + ) + const [routeError, imported, component] = await route.run< + Array<string> + >(`const error = new Error('boom') +const routeError = await render('errorComponent', { error }) +const { PostErrorComponent } = await app('importer.ts') +return [ + routeError, + await renderComponent(PostErrorComponent, { error }), + await render('component'), +]`) + expect(routeError).toContain('boom') + expect([imported, component]).toEqual([routeError, '<h4>post</h4>']) + }, + ) + + // Bug: same root cause as above, for a pendingComponent that custom + // groupings split and an unsplit errorComponent renders. + // Impact: rendering the errorComponent throws "Spinner is not defined". + test.fails( + 'an imported pendingComponent split by custom groupings renders, and an unsplit option renders it', + async () => { + const route = await loadRoute( + `${head}import { Spinner } from './spinner' +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['component'], ['pendingComponent']], + pendingComponent: Spinner, + errorComponent: () => <div><Spinner /></div>, + component: () => <p>page</p>, +}) +`, + { files: { 'spinner.ts': `export const Spinner = () => 'spin'\n` } }, + ) + expect( + await route.run( + `return [await render('errorComponent'), await render('pendingComponent')]`, + ), + ).toEqual(['<div>spin</div>', 'spin']) + }, + ) +}) + +describe('class components', () => { + const classPage = `class Page extends Component { + render() { + return <p>page</p> + } +}` + + // Control for the class pin below (same harness, a function component). + test('a function component declared in the route file renders', async () => { + const route = await loadRoute(`${head}function Page() { + return 'page' +} +export const Route = createFileRoute('/')({ component: Page }) +`) + expect(await route.run(`return render('component')`)).toBe('page') + }) + + // Bug: a route option that names a class cannot be split: the virtual + // compiler throws "Unexpected splitNode type ☝️: ClassDeclaration". + // A class only the route option reads must be split like a function + // component (our limitation otherwise, SPEC J2.8). A fix may leave an + // exported class unsplit, but must then tell the user, in production + // builds too. + // JavaScript route files: the route types of React accept function + // components only (TS2322 for a class). + // Source: #8505 (`export class component {}`). + // Impact: a route whose component is a class component cannot be built + // once code splitting is on. + test.fails.each([ + { declaration: classPage, exported: false }, + { declaration: `export ${classPage}`, exported: true }, + ])( + 'a class component declared in the route file renders (exported: $exported)', + async ({ declaration, exported }) => { + const route = await loadRoute( + `${head}import { Component } from 'react' +${declaration} +export const Route = createFileRoute('/')({ component: Page }) +`, + { filename: 'route.jsx' }, + ) + const rendered = await route.run(`return render('component')`) + const lazy = await route.isLazy('component') + expect({ + rendered, + split: exported ? lazy || (await reportsNotSplit(route)) : lazy, + }).toEqual({ rendered: '<p>page</p>', split: true }) + }, + ) + + // Bug: same root cause as above. Once split, the class's static fields + // and what they import belong to its chunk. + // Source: Next.js ssg/getStaticProps/should-support-class-exports; #8504 + // (code-splitter-dead-code.test.ts), where it passes. + test.fails( + 'a class component and the imports of its static fields leave the route module', + async () => { + const route = await loadRoute( + `${head}import { Component } from 'react' +import { format } from './format' +class Page extends Component { + static title = format('home') + render() { + return <p>{Page.title}</p> + } +} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: Page, +}) +`, + { + filename: 'route.jsx', + files: { + 'format.js': 'export const format = (value) => `[${value}]`\n', + }, + }, + ) + expect([ + // Nothing the route module loads requests what only the class reads + (await route.requested()).includes('/format.js'), + await route.run(`return render('component')`), + ]).toEqual([false, '<p>[home]</p>']) + }, + ) +}) + +describe('side-effect imports', () => { + /** + * `./setup` and `./Page`, which record when each module runs (in + * `./log`). + */ + const recordingModules = { + 'log.ts': `export const log: Array<string> = []\n`, + 'setup.ts': `import { log } from './log' +log.push('./setup') +export const ready = true +`, + 'Page.ts': `import { log } from './log' +log.push('./Page') +export const Page = () => 'page' +`, + } + + /** What ran when the route module loaded, then what the component renders. */ + const loadThenRender = `const ran = [...(await app('log.ts')).log] +return [ran, await render('component')]` + + // Control for the pin below: a side-effect import of another module runs + // when the route module loads. + test('a side-effect import runs when the route module loads', async () => { + const route = await loadRoute( + `${head}import './setup' +import { Page } from './Page' +export const Route = createFileRoute('/')({ component: Page }) +`, + { files: recordingModules }, + ) + expect(await route.run(loadThenRender)).toEqual([['./setup'], 'page']) + }) + + // Bug: when the split component is imported (`import { Page } from + // './Page'`), the code splitter also removes every bare import of that path + // from the route module (`removableImportPaths`), including the user's own + // `import './Page'`. + // Impact: what that module does when it loads (registrations, styles, + // polyfills) is deferred until the component chunk loads. + test.fails( + "a side-effect import of the split component's module runs when the route module loads", + async () => { + const route = await loadRoute( + `${head}import './Page' +import { Page } from './Page' +export const Route = createFileRoute('/')({ component: Page }) +`, + { files: recordingModules }, + ) + expect(await route.run(loadThenRender)).toEqual([['./Page'], 'page']) + }, + ) +}) + +describe('server-only route options on the client', () => { + /** Start's client configuration of the code splitter. */ + const deleteNodes: NonNullable<RouteAppOptions['deleteNodes']> = [ + 'ssr', + 'server', + 'headers', + ] + const clientFiles = { + 'secret-db.ts': `export const db = { + flag: () => true, + all: () => [], + headers: () => ({}), +} +`, + 'opts.ts': `export const makeOpts = <T,>(options: T) => options\n`, + } + + /** + * What the page loads for the route compiled for the client as Start + * compiles it: whether loading the route module and every option it has + * requests `./secret-db` (the server-only module), which server-only + * options the route still has, and what it renders. + */ + async function clientRoute(route: RouteApp) { + return route.run(`for (const option of Object.keys(options)) await trigger(option) +return { + serverRequested: (await requested()).includes('/secret-db.ts'), + serverOptions: ${JSON.stringify(deleteNodes)}.filter((key) => key in options), + rendered: await render('component'), +}`) + } + + const loadForClient = (code: string, options: RouteAppOptions = {}) => + loadRoute(code, { deleteNodes, files: clientFiles, ...options }) + + const stripped = { + serverRequested: false, + serverOptions: [], + rendered: '<p>x</p>', + } + + const serverOptions = ` ssr: () => db.flag(), + server: { handlers: { GET: () => db.all() } }, + headers: () => db.headers(), + component: () => <p>x</p>,` + + // Control for the pins below: options written as `key: value` are removed + // with their imports, on file routes and root routes, for every framework. + test.each([ + { + name: 'a file route', + code: `${head}import { db } from './secret-db' +export const Route = createFileRoute('/')({ +${serverOptions} +})`, + }, + { + name: 'a root route', + code: `import { createRootRoute } from '@tanstack/react-router' +import { db } from './secret-db' +export const Route = createRootRoute({ +${serverOptions} +})`, + }, + { + name: 'a root route with context', + code: `import { createRootRouteWithContext } from '@tanstack/react-router' +import { db } from './secret-db' +export const Route = createRootRouteWithContext<{ user: string }>()({ +${serverOptions} +})`, + }, + ])( + 'server-only options of $name written as properties are removed with their imports', + async ({ code }) => { + expect(await clientRoute(await loadForClient(code))).toEqual(stripped) + }, + ) + + // The same for a Solid route, run with the real Solid router in the + // page: every module the page loads is valid (no name the route file + // binds, such as `db`, is left without its binding), `./secret-db` is + // never requested, the route has none of the options, and no module the + // page loads for the route holds the server-only code (its marker). + test('server-only options of a Solid file route written as properties are removed with their imports', async () => { + const route = await loadForClient( + `import { createFileRoute } from '@tanstack/solid-router' +import { db } from './secret-db' +export const Route = createFileRoute('/')({ + ssr: () => db.flag('MARK_SSR_CODE'), + server: { handlers: { GET: () => db.all('MARK_SERVER_CODE') } }, + headers: () => db.headers('MARK_HEADERS_CODE'), + component: () => <p data-mark="MARK_COMPONENT_CODE">x</p>, +})`, + { + targetFramework: 'solid', + files: { + ...clientFiles, + 'secret-db.ts': `export const db = { + flag: (_marker: string) => true, + all: (_marker: string) => [], + headers: (_marker: string) => ({}), +} +`, + }, + }, + ) + await expectValidModules(route) + expect(await clientRoute(route)).toEqual({ + ...stripped, + rendered: '<p data-mark="MARK_COMPONENT_CODE">x</p>', + }) + const { modules } = await route.modules() + expect( + Object.entries(modules).flatMap(([label, code]) => + ['MARK_SSR_CODE', 'MARK_SERVER_CODE', 'MARK_HEADERS_CODE'] + .filter((marker) => holdsMarker(code, marker)) + .map((marker) => `${label}: ${marker}`), + ), + ).toEqual([]) + // ... while what the component loads holds the component's code + expect( + (await route.loadedBy('component')).some((code) => + holdsMarker(code, 'MARK_COMPONENT_CODE'), + ), + ).toBe(true) + }) + + // Without `deleteNodes` (a Router app without Start), the options are the + // route's own and stay. + test('server-only options stay without deleteNodes', async () => { + const route = await loadRoute( + `${head}import { db } from './secret-db' +export const Route = createFileRoute('/')({ +${serverOptions} +})`, + { files: clientFiles }, + ) + expect( + await route.run( + `return [${JSON.stringify(deleteNodes)}.filter((key) => key in options), options.ssr()]`, + ), + ).toEqual([deleteNodes, true]) + }) + + // Bug: `deleteNodes` only removes route options written as `key: value` + // (`ObjectProperty`); a method (`ssr() {}`, `async ssr() {}`, + // `headers() {}`) is kept, with the imports it uses. Source: docs + // (`selective-ssr.md` promise `ssr` is stripped). + // Impact: Start's client bundle ships the route's `ssr`/`headers` code and + // its server-only imports. + test.fails.each([ + 'ssr() { return db.flag() }', + 'async ssr() { return db.flag() }', + 'headers() { return db.headers() }', + ])( + 'a server-only option written as a method is removed with its imports (%s)', + async (option) => { + const route = await loadForClient(`${head}import { db } from './secret-db' +export const Route = createFileRoute('/')({ + ${option}, + component: () => <p>x</p>, +})`) + expect(await clientRoute(route)).toEqual(stripped) + }, + ) + + // Bug: server-only options whose key is not written literally in the + // route options (a spread, a computed key, options built by a call) are + // kept, with their imports, and nothing reports it. Removing them is best + // effort; refusing the route with an error naming the route file and the + // option is a valid fix too (SPEC J2.8). + // Impact: Start's client bundle silently ships server handlers and their + // server-only imports. + test.fails.each([ + { + name: 'a spread', + code: `const serverOptions = { server: { handlers: { GET: () => db.all() } } } +export const Route = createFileRoute('/')({ + ...serverOptions, + component: () => <p>x</p>, +})`, + }, + { + name: 'a computed key', + code: `export const Route = createFileRoute('/')({ + ['server']: { handlers: { GET: () => db.all() } }, + component: () => <p>x</p>, +})`, + }, + { + name: 'a call', + code: `import { makeOpts } from './opts' +export const Route = createFileRoute('/')( + makeOpts({ + server: { handlers: { GET: () => db.all() } }, + component: () => <p>x</p>, + }), +)`, + }, + ])( + 'a server-only option given through $name is removed, or the route is refused', + async ({ code }) => { + const route = await loadForClient( + `${head}import { db } from './secret-db'\n${code}`, + ) + let result + try { + result = await clientRoute(route) + } catch (error) { + // A refusal names the route file and the server-only option, on any + // channel (the compile error the dev server serves, what it logged) + const compiled = await route.transform().then( + () => [], + (compileError: unknown) => diagnosticsOf(compileError), + ) + expectDiagnostic( + [ + ...diagnosticsOf(error), + ...compiled, + ...problems(await route.diagnostics()), + ], + { + severity: 'error', + file: 'route.tsx', + root: route.host.root, + }, + ) + return + } + expect(result).toEqual(stripped) + }, + ) + + // Bug: a route whose options object is wrapped in a TypeScript cast or a + // `satisfies` (statically visible options, valid TypeScript) keeps its + // server-only options and their imports on the client. Unlike opaque + // options above, these must be removed: the options are written in the + // file, so refusing the route is not an option. + // Source: review of #8504 (4 files in 3 repositories of real apps cast their + // options, `as never` or `as any`, when the handlers' types do not fit). + // Impact: Start's client bundle ships server handlers and their + // server-only imports (build-level canary in + // integration/known-bugs-code-splitter-client-output.test.ts). + test.fails.each(['as never', 'as any', 'satisfies object'])( + 'a server-only option of options wrapped in `%s` is removed with its imports', + async (cast) => { + const route = await loadForClient(`${head}import { db } from './secret-db' +export const Route = createFileRoute('/')({ + server: { handlers: { GET: () => db.all() } }, + component: () => <p>x</p>, +} ${cast})`) + expect(await clientRoute(route)).toEqual(stripped) + }, + ) +}) + +describe('look-alike route factories', () => { + // Bug: in a registered route file, the code splitter treats every call of + // a function named `createFileRoute` as the route's factory, including a + // local function shadowing the router's: it splits the options of that + // call too, so the local factory gets a lazy route component instead of + // the function it was given (and in a dev server, where route HMR is on, + // the route module loses that function's declaration and throws + // "LocalWidget is not defined" when it loads). Only the call + // bound to `Route` is the route's (SPEC J2.1, G15). A look-alike from + // another package (a namespace member call) is left alone + // (code-splitter-plugin-pipeline.test.ts). + // Source: found while replacing the spelling-only look-alike controls of + // code-splitter-plugin-pipeline.test.ts. + // Impact: a route file whose own code uses a helper named + // `createFileRoute` (a widget registry, a test fixture builder) fails to + // load once code splitting is on. + test.fails( + 'a local factory shadowing createFileRoute in a route file keeps its own semantics', + async () => { + const route = await loadRoute(`${head}function LocalWidget() { + return <p>local widget</p> +} +function localWidget() { + const createFileRoute = + (path: string) => + (options: { loader: () => string; component: () => unknown }) => ({ + path, + options, + }) + return createFileRoute('/local-widget')({ + loader: () => 'local data', + component: LocalWidget, + }) +} +export const widget = localWidget() +export const Route = createFileRoute('/')({ + component: () => <p>page</p>, +}) +`) + const [path, loaded, preload, ...rendered] = await route.run< + Array<unknown> + >(`const { widget } = exports +return [ + widget.path, + widget.options.loader(), + 'preload' in widget.options.component, + await renderComponent(widget.options.component), + await render('component'), +]`) + expect([path, loaded, preload]).toEqual([ + '/local-widget', + 'local data', + false, + ]) + expect(rendered).toEqual(['<p>local widget</p>', '<p>page</p>']) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-shapes.test.ts b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-shapes.test.ts new file mode 100644 index 0000000000..46c0e59f25 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter-shapes.test.ts @@ -0,0 +1,904 @@ +/** + * Known code-splitter bugs (route options and factories written in other + * shapes, what split chunks hold, names the code splitter generates). Each + * test asserts correct behaviour for a bug on main and is marked .fails; + * remove .fails when the bug is fixed. Same harness as + * `known-bugs-code-splitter.test.ts`: every route is loaded the way an app + * loads it (`./route-app`), each check runs in a real browser page. + */ + +import { parseSync } from 'vite' +import { describe, expect, test } from 'vitest' +import { + diagnosticsOf, + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + expectValidModules, + head, + holdsMarker, + loadRoute, +} from '../../route-app' +import type { RouteApp, TargetFramework } from '../../route-app' +import type { Plugin } from 'vite' + +/** + * The modules of the app the served module `code` depends on (static + * imports, re-exports and dynamic imports), as the requests the dev server + * resolved them to (`/lib.ts`): an independent parse of what the page + * receives, for SPEC J2.5 checks that a split chunk does not depend on a module of + * the app that its option does not use (SPEC J2.5). + */ +function dependencies(code: string) { + const { module } = parseSync('module.js', code, { sourceType: 'module' }) + const requests = [ + ...module.staticImports.map((statement) => statement.moduleRequest.value), + ...module.staticExports.flatMap((statement) => + statement.entries.flatMap((entry) => + entry.moduleRequest ? [entry.moduleRequest.value] : [], + ), + ), + ...module.dynamicImports.map((dynamicImport) => + code + .slice( + dynamicImport.moduleRequest.start, + dynamicImport.moduleRequest.end, + ) + .replace(/^['"`]|['"`]$/g, ''), + ), + ] + return requests.map((request) => request.split('?')[0]!) +} + +/** + * Whether the dev server warned, on any channel, naming the route file + * (J2.8: an option the compiler leaves unsplit is reported; the wording is + * free). + */ +async function reportsNotSplit(route: RouteApp) { + return ( + findDiagnostics(await route.diagnostics(), { + severity: 'warning', + file: 'route.tsx', + root: route.host.root, + }).length > 0 + ) +} + +describe('route options written in other shapes', () => { + // Bug: a route whose options object or factory call is wrapped in a + // TypeScript cast is not split at all, and a component wrapped in + // `satisfies` cannot be split: the virtual compiler throws + // "Unexpected splitNode type ☝️: TSSatisfiesExpression". These are our + // limitations, so the goal is a split + // component (SPEC J2.8). + // Sources: real apps: openalgon-alt/agri-prep-path + // src/routes/admin/access.tsx (`createFileRoute('/admin/access')({ … } as + // any)`); differential fuzzing (casts around the route factory call); + // React Router route-chunks-test.ts "chunkable" detection of export + // values; #8504 (code-splitter-route-options.test.ts), where they pass. + // Impact: the component loads with the entry chunk, or the route cannot + // be built once code splitting is on. + test.fails.each([ + { + name: 'the options object wrapped in `as any`', + route: `createFileRoute('/')({ ssr: false, component: Page } as any)`, + }, + { + name: 'the options object wrapped in `satisfies object`', + route: `createFileRoute('/')({ ssr: false, component: Page } satisfies object)`, + }, + { + name: 'the route factory call wrapped in `as any`', + route: `(createFileRoute('/') as any)({ ssr: false, component: Page })`, + }, + { + name: 'the component wrapped in a satisfies expression', + route: `createFileRoute('/')({ component: Page satisfies (() => unknown) })`, + }, + ])('a component is split with $name', async ({ route }) => { + const loaded = await loadRoute(`${head}export const Route = ${route} +function Page() { + return <p>page</p> +} +`) + expect(await loaded.isLazy('component')).toBe(true) + expect(await loaded.run(`return render('component')`)).toBe('<p>page</p>') + }) + + // Controls for the pins above and in "route factories written in other + // shapes": these routes keep working (split or not), so the pins fail only + // because the component is not split. + test.each([ + `createFileRoute('/')({ ssr: false, component: Page } as any)`, + `(createFileRoute('/') as any)({ ssr: false, component: Page })`, + `createFileRoute('/')(makeOptions())`, + ])('a route written as %s renders its component', async (route) => { + const loaded = await loadRoute(`${head}function Page() { + return <p>page</p> +} +const makeOptions = () => ({ component: Page }) +export const Route = ${route} +`) + await expectValidModules(loaded) + expect(await loaded.run(`return render('component')`)).toBe('<p>page</p>') + }) + + // Bug: the virtual compiler accepts only a fixed list of expression types + // for the value of a split option; any other expression the route module + // splits makes the build throw "Unexpected splitNode type ☝️: + // MemberExpression" (LogicalExpression, TaggedTemplateExpression, + // ClassExpression). These are our limitations, so the goal is a split + // option (SPEC J2.8). + // Source: mutation testing. + // Impact: a route whose component is a namespace member (`Pages.Home`), a + // fallback (`A ?? B`), a styled-components tagged template or a class + // cannot be built once code splitting is on. + test.fails.each<{ + name: string + option?: string + value: string + declarations?: string + filename?: string + expected: unknown + }>([ + { + name: 'a member of a namespace import', + value: 'Pages.Home', + expected: 'home', + }, + { + name: 'a member of a local object (loader)', + option: 'loader', + value: 'api.load', + expected: 'data', + }, + { + name: 'a logical fallback', + declarations: `const overrides: { Home?: () => string } = {}\n`, + value: 'overrides.Home || Fallback', + expected: 'fallback', + }, + { + name: 'a nullish fallback', + declarations: `const overrides: { Home?: () => string } = {}\n`, + value: 'overrides.Home ?? Fallback', + expected: 'fallback', + }, + { + name: 'a tagged template', + value: 'styled`home`', + expected: 'styled home', + }, + { + // JavaScript: the route types of React accept function components + // only (TS2322 for a class). + name: 'a class expression', + filename: 'route.jsx', + declarations: `import { Component } from 'react'\n`, + value: `class extends Component { + render() { + return <p>class</p> + } + }`, + expected: '<p>class</p>', + }, + ])( + 'an option written as $name is split and works', + async ({ + option = 'component', + value, + declarations = '', + filename, + expected, + }) => { + const route = await loadRoute( + `${head}import * as Pages from './pages' +import { styled } from './styled' +${declarations}const Fallback = () => 'fallback' +const api = { load: () => 'data' } +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: ${option === 'loader' ? value : `() => 'data'`}, + component: ${option === 'component' ? value : `() => <p>page</p>`}, +}) +`, + { + filename, + files: { + 'pages.ts': `export const Home = () => 'home'\n`, + 'styled.ts': `export const styled = (strings: TemplateStringsArray) => () => + \`styled \${strings[0]}\` +`, + }, + }, + ) + expect(await route.isLazy(option)).toBe(true) + expect( + await route.run( + option === 'loader' + ? `return (await load('loader'))()` + : `return render(${JSON.stringify(option)})`, + ), + ).toBe(expected) + }, + ) + + // Bug: a component option written as a call cannot be split when its + // printed code does not parse on its own with Babel's default options: the + // virtual compiler prints the call and parses it again as a script + // statement, without JSX ("Support for the experimental syntax 'jsx' isn't + // currently enabled") and without TypeScript ("Unexpected token"). A type + // argument (`memo<Props>(Page)`) even parses, as comparisons, and the + // option silently becomes `false`. + // Source: compilers.ts:1081-1082 (`babel.parse(outputSplitNodeCode)`). + // Sources: differential fuzzing; dev servers of the e2e apps, where the + // `?tsr-split=component` module failed with HTTP 500; #8504 + // (code-splitter-jsx.test.ts), where the JSX rows pass; fuzzing for the + // TypeScript rows. + // Impact: the route cannot be built once code splitting is on, or renders + // a value that is not its component. + test.fails.each<{ + name: string + component: string + rendered?: string + imports?: string + targetFramework?: TargetFramework + }>([ + { + name: 'memo of an inline arrow', + component: `memo(() => <p>page</p>)`, + }, + { + name: 'memo of an inline named function', + component: `memo(function Page() {\n return <p>page</p>\n})`, + }, + { + name: 'a call with a JSX argument', + imports: `${head}import { withFallback } from './hoc'\nimport { Page } from './page'`, + component: `withFallback(Page, <p>loading</p>)`, + rendered: 'page', + }, + { + name: 'a Vue defineComponent with a render function', + targetFramework: 'vue', + imports: `import { createFileRoute } from '@tanstack/vue-router' +import { defineComponent } from 'vue'`, + component: `defineComponent({\n setup: () => () => <p>page</p>,\n})`, + }, + { + name: 'a call of a typed arrow function', + component: `memo((): string => 'page')`, + rendered: 'page', + }, + { + name: 'a call with a type assertion', + imports: `${head}import { memo } from 'react'\nimport { Page } from './page'`, + component: `memo(Page as any)`, + rendered: 'page', + }, + { + name: 'a call with a type argument', + imports: `${head}import { memo } from 'react'\nimport { Page } from './page'`, + component: `memo<typeof Page>(Page)`, + rendered: 'page', + }, + ])( + 'a component written as $name is split and renders', + async ({ + imports = `${head}import { memo } from 'react'`, + component, + rendered = '<p>page</p>', + targetFramework, + }) => { + const route = await loadRoute( + `${imports} +export const Route = createFileRoute('/')({ component: ${component} }) +`, + { + targetFramework, + files: { + 'hoc.ts': `export const withFallback = (component: unknown, _fallback: unknown) => component\n`, + 'page.ts': `export const Page = () => 'page'\n`, + }, + }, + ) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe(rendered) + }, + ) +}) + +describe('route factories written in other shapes', () => { + // Bug: the code splitter only recognises `createFileRoute` under its own + // name, so a route whose factory is imported under an alias is not split, + // and nothing says so. Our limitation, so the goal is a split component + // (SPEC J2.8). Source: review of #8504. + // Impact: the route's components load with the entry chunk, silently. + test.fails( + 'a component is split when createFileRoute is imported under an alias', + async () => { + const route = + await loadRoute(`import { createFileRoute as fileRoute } from '@tanstack/react-router' +export const Route = fileRoute('/')({ component: Page }) +function Page() { + return <p>page</p> +} +`) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + }, + ) + + // Bug: the code splitter only compiles files whose code matches + // `createFileRoute(`, so a route whose factory call has a type argument + // (`createFileRoute<'/'>('/')`) is left as is, and nothing says so. Our + // limitation, so the goal is a split component (SPEC J2.8). + // Source: mutation testing. + // Impact: the route's components load with the entry chunk, silently. + test.fails( + 'a component is split when createFileRoute has a type argument', + async () => { + const route = await loadRoute(`${head}function Page() { + return <p>page</p> +} +export const Route = createFileRoute<'/'>('/')({ component: Page }) +`) + expect(await route.isLazy('component')).toBe(true) + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + }, + ) + + // Bug: route options returned by a call (`createFileRoute('/')( + // makeOptions())`) are neither split nor reported. The user can write the + // options inline, so a warning naming the file is an acceptable outcome + // (SPEC J2.8). Source: review of #8504. + // Impact: the route's components load with the entry chunk, silently. + test.fails( + 'route options returned by a call are split or reported', + async () => { + const route = await loadRoute(`${head}function Page() { + return <p>page</p> +} +const makeOptions = () => ({ component: Page }) +export const Route = createFileRoute('/')(makeOptions()) +`) + expect(await route.run(`return render('component')`)).toBe('<p>page</p>') + expect({ + split: await route.isLazy('component'), + warned: await reportsNotSplit(route), + }).not.toEqual({ split: false, warned: false }) + }, + ) + + // Bug: a route file that creates two file routes compiles both routes' + // split options into the same chunk names, so one route renders the + // other's component, silently. Supporting it, or refusing it with an error + // or a warning naming the file, are both valid fixes. + // Source: review of #8504 (the pin of #8630 was + // dropped without a decision). + // Impact: a route renders another route's component. + test.fails( + 'each of two file routes of one module renders its own component, or the module is reported', + async () => { + const route = + await loadRoute(`${head}export const Legacy = createFileRoute('/old')({ + component: () => <p>legacy</p>, +}) +export const Route = createFileRoute('/')({ + component: () => <p>index</p>, +}) +`) + const root = route.host.root + let rendered: unknown + try { + await route.transform() + // Both options rendered, each loaded first when it is lazy + rendered = + await route.run(`const legacy = exports.Legacy.options.component +await legacy.preload?.() +return [await renderComponent(legacy), await render('component')]`) + } catch (error) { + // A refusal names the file (its wording is free), on any channel + expectDiagnostic( + [...diagnosticsOf(error), ...(await route.diagnostics())], + { severity: 'error', file: 'route.tsx', root }, + ) + return + } + if ( + findDiagnostics(await route.diagnostics(), { + severity: 'warning', + file: 'route.tsx', + root, + }).length > 0 + ) { + return + } + expect(rendered).toEqual(['<p>legacy</p>', '<p>index</p>']) + }, + ) +}) + +describe('what split chunks hold', () => { + // Bug: a split chunk keeps every exported `function`, `class` and + // `export default function` declaration of the route file, with the + // imports they use, whether its option reads them or not + // (`compilers.ts`, the virtual compiler keeps exported declarations). + // Bundlers cannot drop them: the chunk is imported with `import()` and read + // through a computed key (SPEC J2.5). + // Impact: every split chunk of the route downloads and evaluates the route + // file's exported helpers and their dependencies again. + test.fails( + 'a split chunk holds only what its option needs, not the other exports of the route file', + async () => { + // Each exported declaration carries a marker its code keeps under any + // name a compiler gives it (SPEC J2.5: identified independently of + // names) + const route = await loadRoute( + `${head}import { heavy } from './heavy' +export function helper() { return heavy() + 'MARK_helper' } +export class Api { call() { return heavy() + 'MARK_api' } } +export default function Def() { return heavy() + 'MARK_def' } +function Page() { return <div>page</div> } +export const Route = createFileRoute('/')({ component: Page }) +`, + { files: { 'heavy.ts': `export const heavy = () => 'heavy'\n` } }, + ) + expect(await route.run(`return render('component')`)).toBe( + '<div>page</div>', + ) + // What loading the component requests, and what loads with the route + // module (the route file's exports, which it keeps) + const loaded = await route.loadedBy('component') + const eager = await route.eagerModules() + expect({ + holds: ['MARK_helper', 'MARK_api', 'MARK_def'].filter((marker) => + loaded.some((code) => holdsMarker(code, marker)), + ), + dependsOnHeavy: loaded.some((code) => + dependencies(code).includes('/heavy.ts'), + ), + eagerHolds: ['MARK_helper', 'MARK_api', 'MARK_def'].filter((marker) => + eager.some((code) => holdsMarker(code, marker)), + ), + }).toEqual({ + holds: [], + dependsOnHeavy: false, + eagerHolds: ['MARK_helper', 'MARK_api', 'MARK_def'], + }) + }, + ) + + // Bug: same root cause as above, for re-exports and a default-exported + // class: every split chunk re-exports them or declares the class again. + // Source: Next.js ssg/getStaticProps/should-remove-extra-named-export-speicifers, + // should-support-full-re-export and should-support-class-exports; #8504 + // (code-splitter-imports-exports.test.ts), where it passes. + // Impact: every split chunk loads the re-exported modules and the class. + test.fails( + 'split chunks do not re-export or declare the re-exports and default class of the route file', + async () => { + // The class carries a marker its code keeps under any name a + // compiler gives the class (SPEC J2.5: identified independently + // of generated names). + const marker = 'default-class-marker-7f3a' + const route = await loadRoute( + `${head}export { getPaths, a as getProps } from './lib' +export { foo, bar as baz } from './lib' +export { helper } from './default-lib' +export default class Test { + render() { + return '${marker}' + } +} +export const Route = createFileRoute('/')({ + component: () => <div>home</div>, + errorComponent: () => <div>error</div>, +}) +`, + { + files: { + 'lib.ts': `export const getPaths = 1 +export const a = 2 +export const foo = 3 +export const bar = 4 +`, + 'default-lib.ts': `export const helper = 5\n`, + }, + }, + ) + expect( + await route.run( + `return [await render('component'), await render('errorComponent')]`, + ), + ).toEqual(['<div>home</div>', '<div>error</div>']) + // Every module loading a split option requests: what the lazy options + // reach beyond what loads with the route module. + const loaded = [ + ...(await route.loadedBy('component')), + ...(await route.loadedBy('errorComponent')), + ] + expect( + loaded.map((code) => ({ + requests: dependencies(code).filter((request) => + ['/lib.ts', '/default-lib.ts'].includes(request), + ), + holdsClass: holdsMarker(code, marker), + })), + ).toEqual(loaded.map(() => ({ requests: [], holdsClass: false }))) + // ... while what loads with the route module (which keeps the class) + // holds it + expect( + (await route.eagerModules()).some((code) => holdsMarker(code, marker)), + ).toBe(true) + }, + ) + + /** + * A route app whose dependency optimizer also pre-bundles `@emotion/react` + * (a CommonJS-dependent package the page imports), as a user's Vite config + * does with `optimizeDeps.include`. + */ + const emotionDeps: Plugin = { + name: 'test:app-optimize-emotion', + config: () => ({ + optimizeDeps: { + include: ['@emotion/react', '@emotion/react/jsx-runtime'], + }, + }), + } + + /** + * Renders the route file's component as the route renders it, and as the + * same file renders it untouched (an app module the router plugin does not + * compile, `untouched.tsx`); with whether `library` loads with the route + * module, read before anything else imports it. + */ + async function loadPragmaRoute(code: string, library: string) { + const route = await loadRoute(code, { + plugins: { before: [emotionDeps] }, + files: { 'untouched.tsx': code }, + }) + const observed = await route.run<{ + rendered: string + untouched: string + libraryLoadsEagerly: boolean + }>(`// The library's module as the dependency optimizer serves it +const library = ${JSON.stringify(library)} +const libraryLoaded = () => performance.getEntriesByType('resource').some((entry) => + new URL(entry.name).pathname.startsWith('/node_modules/.vite/deps/' + library.replace('/', '_') + '.js')) +const libraryLoadsEagerly = libraryLoaded() +const rendered = await render('component') +const untouched = await renderComponent((await app('untouched.tsx')).Route.options.component) +return { rendered, untouched, libraryLoadsEagerly }`) + return { route, ...observed } + } + + // Bug: the route module keeps importing the classic JSX factory its pragma + // names after the JSX that compiles to it moved to a split chunk (SPEC + // J2.5). Source: #8504 (code-splitter-pragmas.test.ts; mutation testing), + // where it passes. + // Impact: the entry chunk loads the JSX library for nothing. + // The factory is the real one (`@emotion/react`'s `jsx`), rendered by the + // real React: the split component renders as the untouched file renders + // it. + test.fails.each([ + { + name: '@jsx', + header: `/** @jsxRuntime classic */ +/** @jsx jsx */ +import { jsx } from '@emotion/react'`, + }, + { + name: '@jsx written with two spaces', + header: `/** @jsxRuntime classic */ +/** @jsx jsx */ +import { jsx } from '@emotion/react'`, + }, + ])( + 'a module without JSX does not import the classic factory ($name)', + async ({ header }) => { + const code = `${header} +${head}export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p css={{ color: 'red' }}>page</p>, +}) +` + // Without JSX left, the route module needs nothing of the library (nor + // does what loads with it). + const { rendered, untouched, libraryLoadsEagerly } = + await loadPragmaRoute(code, '@emotion/react') + expect({ rendered, libraryLoadsEagerly }).toEqual({ + rendered: untouched, + libraryLoadsEagerly: false, + }) + }, + ) + + // The `@jsxFrag` row of the pin above, without its import check: a chunk + // that keeps an unused `Fragment` specifier on the import of `react` it + // needs anyway pulls in no unrelated dependency (an unused specifier is + // free, SPEC §5.9), so what remains to check is that the split + // component renders as the untouched file renders it, with `@jsx` and + // `@jsxFrag` pragmas naming React's real factories. + test('a split component of a file with @jsx and @jsxFrag pragmas renders as the untouched file', async () => { + const code = `/** @jsxRuntime classic */ +/** @jsx createElement */ +/** @jsxFrag Fragment */ +import { createElement, Fragment } from 'react' +${head}export const Route = createFileRoute('/')({ + loader: () => <>{1}</>, + component: () => <p>page</p>, +}) +` + const { rendered, untouched } = await loadPragmaRoute(code, 'react') + expect(rendered).toBe(untouched) + expect(rendered).toBe('<p>page</p>') + }) + + // Control for the array destructuring pins below: a component declared by + // an object destructuring of a literal is split and renders. + test('a component declared by an object destructuring renders', async () => { + const route = + await loadRoute(`${head}const { Page } = { Page: () => <div>page</div> } +export const Route = createFileRoute('/')({ component: Page }) +`) + expect(await route.run(`return render('component')`)).toBe( + '<div>page</div>', + ) + }) + + // Bug: a split option that names a binding declared by an array + // destructuring cannot be split: the virtual compiler throws + // "Unexpected splitNode type ☝️: VariableDeclarator". + // Impact: a route whose component comes from an array destructuring + // cannot be built once code splitting is on. + test.fails( + 'a component declared by an array destructuring of a call shared with the errorComponent renders', + async () => { + const route = await loadRoute( + `${head}import { createPair } from './factory' +const [Page, ErrorView] = createPair() +export const Route = createFileRoute('/')({ + component: Page, + errorComponent: ErrorView, +}) +`, + { + files: { + 'factory.ts': `export const createPair = () => [() => 'page', () => 'error']\n`, + }, + }, + ) + expect(await route.run(`return render('component')`)).toBe('page') + }, + ) +}) + +describe('names the code splitter generates', () => { + /** A route file whose split options read `read` (`declaration` first). */ + const nameRoute = (read: string, declaration = '') => `${head}${declaration} +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component'], ['errorComponent']], + loader: () => String(${read}), + component: () => <p>{String(${read})}</p>, + errorComponent: () => <p>{String(${read})}</p>, +}) +` + + /** + * Loads a route file that declares `declaration` (or reads `name` as a + * global the page sets, `window` as the page's own) and whose split loader + * and components return `name`'s value, compiled for HMR; returns what the + * options return, and what they should return. + */ + async function readName(name: string, declaration?: string) { + const read = declaration?.startsWith('function') ? `${name}()` : name + const route = await loadRoute(nameRoute(read, declaration), { hmr: true }) + return route.run<{ actual: Array<unknown>; expected: Array<unknown> }>( + `const value = String(${declaration === undefined ? `globalThis[${JSON.stringify(name)}]` : `'value'`}) +return { + actual: [await options.loader(), await render('component'), await render('errorComponent')], + expected: [value, '<p>' + value + '</p>', '<p>' + value + '</p>'], +}`, + declaration === undefined && name !== 'window' + ? { before: `globalThis[${JSON.stringify(name)}] = 'value'` } + : {}, + ) + } + + async function expectNameKeepsValue(name: string, declaration?: string) { + const { actual, expected } = await readName(name, declaration) + expect(actual).toEqual(expected) + } + + // Control for the pins below. + test.each([ + { name: 'TSRComponent', declaration: `const TSRComponent = 'value'` }, + { name: 'window' }, + ])( + 'a route file binding or global named $name keeps its value', + async ({ name, declaration }) => { + await expectNameKeepsValue(name, declaration) + }, + ) + + // Bug: the code splitter declares fixed names in the modules it emits + // (`SplitComponent`, `SplitLoader`) without checking that the route file + // does not use them. + // Impact: a route file with such a binding cannot be built ("Duplicate + // declaration") or its options read the generated value instead of the + // user's. + // These two inputs only discriminate today's names; the adaptive pin + // below challenges whatever names a compiler introduces. + test.fails.each([ + { name: 'SplitComponent', declaration: `const SplitComponent = 'value'` }, + { name: 'SplitLoader', declaration: `const SplitLoader = 'value'` }, + ])( + 'a route file binding named $name keeps its value', + async ({ name, declaration }) => { + await expectNameKeepsValue(name, declaration) + }, + ) + + /** The top-level bindings a served module declares (an independent parse). */ + function topLevelNames(code: string) { + const names = new Set<string>() + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + const addPattern = (pattern: any): void => { + if (!pattern) { + return + } + switch (pattern.type) { + case 'Identifier': + names.add(pattern.name) + break + case 'ObjectPattern': + for (const property of pattern.properties) { + addPattern( + property.type === 'RestElement' + ? property.argument + : property.value, + ) + } + break + case 'ArrayPattern': + pattern.elements.forEach(addPattern) + break + case 'AssignmentPattern': + addPattern(pattern.left) + break + case 'RestElement': + addPattern(pattern.argument) + break + } + } + const addStatement = (statement: any): void => { + if (!statement) { + return + } + switch (statement.type) { + case 'ImportDeclaration': + for (const specifier of statement.specifiers) { + names.add(specifier.local.name) + } + break + case 'VariableDeclaration': + for (const declarator of statement.declarations) { + addPattern(declarator.id) + } + break + case 'FunctionDeclaration': + case 'ClassDeclaration': + if (statement.id) { + names.add(statement.id.name) + } + break + case 'ExportNamedDeclaration': + case 'ExportDefaultDeclaration': + addStatement(statement.declaration) + break + } + } + program.body.forEach(addStatement) + return names + } + + // Bug: as above, found adaptively, whatever names a compiler chooses: the + // top-level names the modules emitted for a route file declare that the + // same file, served untouched (an app module the router plugin does not + // compile, through the same framework transform), does not declare, given + // to bindings of the route file, keep their values in every split option. + // Names of Vite's own import rewriting (`__vite__`) are the tool's. + // Generated names: SPEC G9, §5.1. + // Impact: a route file whose binding has a name the compiler introduces + // cannot be built, or its options read the generated value. + test.fails( + 'route file bindings named like what the compiled modules introduce keep their values', + async () => { + const code = nameRoute('userValue', `const userValue = 'value'`) + const route = await loadRoute(code, { + hmr: true, + files: { + // The same file untouched; with a component the refresh runtime + // registers, as the compiled route module has one + 'control.tsx': `${code}export function RefreshProbe() {\n return null\n}\n`, + }, + }) + const { modules } = await route.modules() + const untouched = topLevelNames(await route.transform('/control.tsx')) + const introduced = new Set<string>() + for (const served of Object.values(modules)) { + for (const name of topLevelNames(served)) { + if (!untouched.has(name) && !name.startsWith('__vite__')) { + introduced.add(name) + } + } + } + // (A compiler that introduces no top-level name has nothing to lose.) + const lost: Array<string> = [] + for (const name of [...introduced].sort()) { + try { + const { actual, expected } = await readName( + name, + `const ${name} = 'value'`, + ) + if (JSON.stringify(actual) !== JSON.stringify(expected)) { + lost.push(name) + } + } catch { + lost.push(name) + } + } + expect(lost).toEqual([]) + }, + ) + + // The code splitter imports `lazyRouteComponent` and `lazyFn` from the + // router package; a route file that imports them itself, for an option + // the code splitter leaves alone, keeps working next to split options. + test.each([ + { + name: 'lazyRouteComponent', + option: `pendingComponent: lazyRouteComponent(() => import('./spinner'))`, + read: `await render('pendingComponent')`, + expected: 'spinner', + }, + { + name: 'lazyFn', + option: `loader: lazyFn(() => import('./load-data'), 'loadData')`, + read: `await options.loader()`, + expected: 'data', + }, + ])( + 'a route file that imports $name from the router package keeps working next to split options', + async ({ name, option, read, expected }) => { + const route = await loadRoute( + `import { createFileRoute, ${name} } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + ${option}, + component: () => <p>page</p>, + errorComponent: () => <p>error</p>, +}) +`, + { + files: { + 'spinner.tsx': `export default function Spinner() {\n return 'spinner'\n}\n`, + 'load-data.ts': `export const loadData = () => 'data'\n`, + }, + }, + ) + await expectValidModules(route) + expect([ + await route.isLazy('component'), + ...(await route.run<Array<unknown>>(`return [ + ${read}, + await render('component'), + await render('errorComponent'), +]`)), + ]).toEqual([true, expected, '<p>page</p>', '<p>error</p>']) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter.test.ts b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter.test.ts new file mode 100644 index 0000000000..62e9ebd4ae --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/known-bugs-code-splitter.test.ts @@ -0,0 +1,952 @@ +/** + * Known code-splitter bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + * + * Every route is loaded the way an app loads it (`./route-app`): the public + * router plugin in a real Vite dev server, and each check run in a real + * browser page. The modules the route file imports are files of the app; + * the page reads what they record. The other known code-splitter bugs are in + * `known-bugs-code-splitter-{shapes,bindings,server}.test.ts`. + */ + +import { parseSync } from 'vite' +import { describe, expect, test } from 'vitest' +import { head, holdsMarker, loadRoute } from '../../route-app' + +/** + * The modules of the app the served module `code` depends on (static + * imports, re-exports and dynamic imports), as the requests the dev server + * resolved them to (`/lib.ts`): an independent parse of what the page + * receives, for SPEC J2.5 checks that a split chunk does not depend on a module of + * the app that its option does not use (SPEC J2.5). + */ +function dependencies(code: string) { + const { module } = parseSync('module.js', code, { sourceType: 'module' }) + const requests = [ + ...module.staticImports.map((statement) => statement.moduleRequest.value), + ...module.staticExports.flatMap((statement) => + statement.entries.flatMap((entry) => + entry.moduleRequest ? [entry.moduleRequest.value] : [], + ), + ), + ...module.dynamicImports.map((dynamicImport) => + code + .slice( + dynamicImport.moduleRequest.start, + dynamicImport.moduleRequest.end, + ) + .replace(/^['"`]|['"`]$/g, ''), + ), + ] + return requests.map((request) => request.split('?')[0]!) +} + +/** + * `./state`: `init` returns its argument and `register` pushes an item; + * `calls` counts the calls of both. + */ +const stateFile = `export let calls = 0 +export const init = <T>(value: T) => { + calls++ + return value +} +export const register = (items: Array<string>) => { + calls++ + items.push('item') +} +` + +describe('module state shared with split chunks', () => { + // Control for loadRoute: a top-level const read by the loader and the split + // component moves to the shared module and is initialized once. + test('a const read by the loader and the split component is initialized once', async () => { + const route = await loadRoute( + `${head}import { init } from './state' +const value = init(1) +export const Route = createFileRoute('/')({ + loader: () => value, + component: () => <p>{value}</p>, + errorComponent: () => <p>error</p>, +})`, + { files: { 'state.ts': stateFile } }, + ) + // (When the shared initializer runs, with the route module or with the + // first chunk that needs it, is free: SPEC G3.) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + await render('errorComponent'), + (await app('state.ts')).calls, +]`), + ).toEqual([1, '<p>1</p>', '<p>error</p>', 1]) + }) + + // Bug: a binding that an option with a computed key and a split option + // both read is created twice: the computed-key option is not seen as a + // reader of the route module. + // Source: round-3 mutation testing (compilers-A). + // Impact: module state is created twice (two stores, registrations run + // twice). + test.fails( + 'a binding read by a computed-key option and a split option is created once', + async () => { + const route = await loadRoute( + `${head}import { init } from './state' +const store = init({ count: 1 }) +const key = 'staticData' +export const Route = createFileRoute('/')({ + [key]: { read: () => store }, + loader: () => 'data', + component: () => <p>{store.count}</p>, +}) +`, + { files: { 'state.ts': stateFile } }, + ) + expect( + await route.run( + `return [await render('component'), (await app('state.ts')).calls]`, + ), + ).toEqual(['<p>1</p>', 1]) + }, + ) + + // Bug: a `var` nested in a statement, an enum or a namespace is not shared. + // The `var` is missed because module bindings are collected from top-level + // declarations only (`collectLocalBindingsFromStatement`); same root cause + // as the nested-block `var` pin in + // start-plugin-core/tests/known-bugs-hydrate.test.ts. + // Impact: the route throws a ReferenceError or runs the declaration per module. + test.fails.each([ + { + name: 'a var in an if block', + declaration: `if (globalThis) { var value = init(1) } +const read = () => value`, + }, + { + name: 'a var in a try block', + declaration: `try { var value = init(1) } catch {} +const read = () => value`, + }, + { + name: 'an enum', + declaration: `enum Value { One = init(1) } +const read = () => Value.One`, + }, + { + name: 'a namespace', + declaration: `namespace Value { export const one = init(1) } +const read = () => Value.one`, + }, + // Source: mutation testing of #8504 (a direct read takes another path + // than a read through a helper). + { + name: 'an enum, read directly', + declaration: `enum Value { One = init(1) }`, + read: 'Value.One', + }, + { + name: 'a namespace, read directly', + declaration: `namespace Value { export const one = init(1) }`, + read: 'Value.one', + }, + { + // Source: #8504 (a namespace merged across two declarations). The + // second block reads `Value.one`: TypeScript transforms (Oxc, Babel) + // do not resolve a bare `one` across merged blocks. + name: 'a namespace declared in two blocks', + declaration: `namespace Value { export const one = init(1) } +namespace Value { export const two = Value.one }`, + read: 'Value.two', + }, + ])( + 'a binding declared by $name and read by the loader and the split component is initialized once', + async ({ declaration, read = 'read()' }) => { + const route = await loadRoute( + `${head}import { init } from './state' +${declaration} +export const Route = createFileRoute('/')({ + loader: () => ${read}, + component: () => <p>{${read}}</p>, +})`, + { files: { 'state.ts': stateFile } }, + ) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('state.ts')).calls, +]`), + ).toEqual([1, '<p>1</p>', 1]) + }, + ) + + // Bug: a top-level statement that writes a binding stays in the reference + // module when the binding moves to the shared module or a split chunk. + // Impact: the write throws (an import is read-only, or the moved binding is + // not declared there) or runs after the shared declarations that it should + // precede. + test.fails.each<{ + name: string + filename?: string + setup: string + loader: string + component: string + expected: Array<unknown> + inits?: number + }>([ + { + name: 'a function (reassignment)', + // Source: React Compiler fixture module-scoped-bindings.js + // JavaScript: TypeScript refuses an assignment to a function (TS2630). + filename: 'route.jsx', + setup: `function format() { + return 'original' +} +format = () => 'reassigned'`, + loader: 'format()', + component: '() => <p>{format()}</p>', + expected: ['reassigned', '<p>reassigned</p>'], + }, + { + name: 'a registry a shared store is created from (push)', + // Source: Turbopack tree-shaker analyzer/write-order, analyzer/shared-2 + // and analyzer/shared-regression + setup: `import { init } from './state' +const plugins: Array<string> = [] +plugins.push('auth') +const store = init({ plugins: [...plugins] }) +plugins.push('late')`, + loader: 'store.plugins', + component: '() => <p>{store.plugins.join()}</p>', + // One store, created once. + expected: [['auth'], '<p>auth</p>'], + inits: 1, + }, + { + name: 'the split component (property assignment)', + // Source: React Router remove-exports-test.ts "function statement with + // property assignment" and "arrow function with property assignment" + setup: `function Page() { + return <div>{Page.displayName}</div> +} +Page.displayName = 'PageDisplay'`, + loader: `'data'`, + component: 'Page', + // Whether `Page` is still split is a build-level goal ("page code + // the route file writes to at the top level loads with its chunk"). + expected: ['data', '<div>PageDisplay</div>'], + }, + { + // Source: React Router route-chunks-test.ts "reassignment with + // nullish coalescing" and "destructured reassignment" + name: 'lets only the split component reads (reassignments)', + setup: `let plain = 'initial' +plain = 'assigned' +let compound = 1 +compound += 1 +let logical = '' +logical ||= 'logical' +let handler: (() => string) | undefined +handler ??= () => 'handler' +let swapped = () => 'original' +;[swapped] = [() => 'swapped']`, + loader: `'data'`, + component: + "() => <p>{[plain, compound, logical, handler!(), swapped()].join(' ')}</p>", + expected: ['data', '<p>assigned 2 logical handler swapped</p>'], + }, + { + // Source: Turbopack tree-shaker analyzer/assign-before-decl-var + name: 'a var assigned before its declaration', + setup: `value = 'assigned' +var value: string`, + loader: `'data'`, + component: '() => <p>{value}</p>', + expected: ['data', '<p>assigned</p>'], + }, + { + // Source: Turbopack tree-shaker analyzer/assign-before-decl-fn + // JavaScript: TypeScript refuses an assignment to a function (TS2630). + name: 'a function declaration assigned before its declaration', + filename: 'route.jsx', + setup: `value = () => 'reassigned' +function value() { + return 'declared' +}`, + loader: `'data'`, + component: '() => <p>{value()}</p>', + expected: ['data', '<p>reassigned</p>'], + }, + ])( + 'top-level writes to $name stay with the binding they write', + async ({ filename, setup, loader, component, expected, inits = 0 }) => { + const route = await loadRoute( + `${head}${setup} +export const Route = createFileRoute('/')({ + loader: () => ${loader}, + component: ${component}, +})`, + { filename, files: { 'state.ts': stateFile } }, + ) + expect( + await route.run(`return [ + options.loader(), + await render('component'), + (await app('state.ts')).calls, +]`), + ).toEqual([...expected, inits]) + }, + ) + + // Bug: shared bindings are computed from the statically named route options + // only (`computeSharedBindings` skips computed keys), so a declaration that + // one split chunk reads and that the reference module keeps as well (for an + // export, a top-level call, another binding of the declaration, or a route + // option under a computed key, pinned above) is not shared: the chunk + // declares its own copy. + // Impact: module state is duplicated; the component reads another instance. + test.fails.each([ + { + name: 'a destructuring with one exported binding', + declaration: `const { a, b } = init({ a: 'a', b: 'b' }) +export { a }`, + render: '{a + b}', + html: '<p>ab</p>', + }, + { + name: 'a binding read by an exported function', + // Source: Qwik optimizer test.rs + // should_keep_module_level_var_used_in_both_main_and_qrl + declaration: `const state = init({ count: 0 }) +export function increment() { + return ++state.count +}`, + render: '{increment()}-{state.count}', + html: '<p>1-1</p>', + }, + { + name: 'an array destructuring with an unreferenced binding', + // Source: Next.js ssg/getStaticProps/destructuring-assignment-array + declaration: `const [unused, value] = init(['unused', 'value'])`, + render: '{value}', + html: '<p>value</p>', + }, + { + name: 'a binding filled by a top-level registration call', + // Source: React Router route-chunks-test.ts "top level await" and + // "object property mutation" + declaration: `const items: Array<string> = [] +register(items)`, + render: '{items.join()}', + html: '<p>item</p>', + }, + // Rows from #8504, where they pass (except the private call result row + // below). A type that reads a value is no read at runtime (TypeScript + // erases it), but the reference module keeps the declaration for it. + { + name: 'a type alias that reads it', + // Source: real apps: route files that derive a type with + // `type FormValues = z.infer<typeof schema>` + declaration: `const value = init(1) +type Value = typeof value`, + render: '{value satisfies Value}', + html: '<p>1</p>', + }, + { + // A second initialization in the chunk is another instance than the + // one other modules import. Importing `cache` from the route module is + // not enough: a chunk that declares the private `initial` again runs + // `init` twice. Source: #8504 (code-splitter-imports-exports.test.ts, + // which checks `cache` only). + name: 'an export built from a private call result the chunk reads too', + declaration: `const initial = init([['a', 1]]) +export const cache = new Map(initial)`, + render: "{cache.size === initial.length ? 'fresh' : 'changed'}", + html: '<p>fresh</p>', + }, + { + name: 'an export alias', + // Source: Next.js + // ssg/getStaticProps/should-support-export-named-as-default-with-other-specifiers + declaration: `const store = init({ count: 1 }) +export { store as appStore }`, + render: '{store.count}', + html: '<p>1</p>', + }, + { + name: 'a default export', + declaration: `const store = init({ count: 1 }) +export default store`, + render: '{store.count}', + html: '<p>1</p>', + }, + { + // The shared-binding analysis does not count a JSX member tag + // (`<ui.Box />`) as a read, so only the loader reads `ui` for it and + // the chunk declares its own copy. + name: 'the loader, when the component renders it as a JSX member tag', + // Source: Next.js ssg/getStaticProps/should-not-remove-import-used-in-render + declaration: `const ui = init({ Box: () => <b>box</b> })`, + options: ` loader: () => typeof ui.Box,\n`, + render: '<ui.Box />', + html: '<p><b>box</b></p>', + }, + ])( + 'module state that the reference module keeps for $name is initialized once', + async ({ declaration, options = '', render, html }) => { + const route = await loadRoute( + `${head}import { init, register } from './state' +${declaration} +export const Route = createFileRoute('/')({ +${options} component: () => <p>${render}</p>, +})`, + { files: { 'state.ts': stateFile } }, + ) + expect( + await route.run( + `return [await render('component'), (await app('state.ts')).calls]`, + ), + ).toEqual([html, 1]) + }, + ) + + /** + * Loads a route with a component and an errorComponent next to the + * top-level `effect`, which calls `track` or `subscribe` (`./effects`, + * which counts the calls), loads both chunks and asserts that the effect + * ran once, with the route module. + */ + async function expectEffectRunsOnce(effect: string) { + const route = await loadRoute( + `${head}import { subscribe, track } from './effects' +${effect} +export const Route = createFileRoute('/')({ + component: () => <p>index</p>, + errorComponent: () => <p>error</p>, +})`, + { + files: { + 'effects.ts': `export let calls = 0 +export const track = (..._args: Array<unknown>) => calls++ +export const subscribe = (listener: () => unknown) => { + calls++ + return listener +} +`, + }, + }, + ) + // Both chunks loaded, and the effect ran once, with the route module. + expect( + await route.run(`const effects = await app('effects.ts') +const callsBeforeChunks = effects.calls +const rendered = [await render('component'), await render('errorComponent')] +return [rendered, callsBeforeChunks, effects.calls]`), + ).toEqual([['<p>index</p>', '<p>error</p>'], 1, 1]) + } + + // Bug: split chunks keep the top-level statements that nothing references, + // except expression statements that read only imports: dead-code + // elimination only removes what the split made unreferenced, and + // `stripUnreferencedTopLevelExpressionStatements` only strips expression + // statements that name no module-level binding. So an `if` block, a + // declaration whose binding is never read, an `export * from`, or a call + // that reads a module-level binding (`register(...parts)`) is copied into + // every split chunk. + // A reference cycle that nothing else reads keeps its own references, so a + // fix that drops only declarations nothing references still copies it. + // Source: router-utils/src/compiler-helpers.ts:884-901 (called from + // compilers.ts:1278); the call rows: fuzzing, e.g. + // `const parts = [BarController, BarElement]; Chart.register(...parts)`. + // Impact: side effects run again for every chunk that loads, even a chunk + // holding only the errorComponent (duplicated subscriptions, logging, + // plugin registrations); every chunk depends on and re-exports all of the + // `export *` module through the opaque namespace of its dynamic import, + // which defeats tree-shaking of it. + test.fails.each([ + { + name: 'an if statement', + effect: `if (typeof globalThis === 'object') { + track() +}`, + }, + { + name: 'an unused subscription', + effect: `const unsubscribe = subscribe(() => {})`, + }, + { + name: 'an unused reference cycle', + effect: `const a = subscribe(() => b) +const b = () => a`, + }, + { + name: 'a static field of an unused class', + effect: `class Unused { + static value = track() +}`, + }, + { + name: 'a member initializer of an unused enum', + effect: `enum Unused { + Value = track(), +}`, + }, + // Types read no value at runtime. Source: review of #8504 (real apps). + { + name: 'an unused subscription only a type alias reads', + effect: `const unsubscribe = subscribe(() => {}) +type Unsubscribe = typeof unsubscribe`, + }, + { + name: 'an unused subscription only a module augmentation reads', + effect: `const unsubscribe = subscribe(() => {}) +declare module './effects' { + interface Registry { + unsubscribe: typeof unsubscribe + } +}`, + }, + { + name: 'an unused subscription only a props type reads', + effect: `const unsubscribe = subscribe(() => {}) +export function Card(props: { stop: typeof unsubscribe }) { + return null +}`, + }, + { + name: 'an unused reassigned let', + effect: `let label = track() +label = 'reassigned'`, + }, + { + name: 'a call spreading a module-level array', + effect: `const names = ['a', 'b'] +track(...names)`, + }, + { + name: 'a call reading a module-level function', + effect: `function widget() {} +track(widget)`, + }, + ])( + 'an unreferenced top-level side effect ($name) runs once, with the route module', + async ({ effect }) => { + await expectEffectRunsOnce(effect) + }, + ) + + // Control for the pin above (same harness): a top-level call that reads + // only imports and literals is stripped from the chunks. + test.each([ + { name: 'a call reading an import', effect: 'track(subscribe)' }, + { name: 'a call with literal arguments', effect: `track('a', 'b')` }, + ])( + 'an unreferenced top-level side effect ($name) runs once, with the route module', + async ({ effect }) => { + await expectEffectRunsOnce(effect) + }, + ) + + // Bug: same root cause as above: every split chunk keeps the route file's + // `export * from './lib'`. + // Impact: every split chunk depends on and re-exports all of `./lib`. + test.fails( + 'split chunks do not re-export a module-level export *, which importers of the route file still get', + async () => { + const route = await loadRoute( + `${head}export * from './lib' +export const Route = createFileRoute('/')({ + component: () => <p>index</p>, +})`, + { + files: { + 'lib.ts': `export const x = 1\n`, + // Another module of the app imports a name the route file + // re-exports (SPEC G9, J2.4: through a real importer) + 'importer.ts': `import { x } from './route'\nexport const v = x\n`, + }, + }, + ) + const { reExported, rendered } = await route.run<{ + reExported: number + rendered: string + }>(`return { + reExported: (await app('importer.ts')).v, + rendered: await render('component'), +}`) + expect({ + reExported, + rendered, + // What loading the component requests depends on `./lib` (SPEC J2.5: an + // unrelated module of the app, by the request it resolves to) + componentRequestsLib: (await route.loadedBy('component')).some((code) => + dependencies(code).includes('/lib.ts'), + ), + }).toEqual({ + reExported: 1, + rendered: '<p>index</p>', + componentRequestsLib: false, + }) + }, + ) + + // Bug: an ambient `declare const` is handled as a module binding. Read by + // the loader and the split component, it is shared: the shared module + // exports a name that TypeScript erases, and the reference module and the + // chunk import it. (Used as the split option itself: pinned in "route + // options read from the environment".) + // Impact: the build fails with a missing export, e.g. for a constant + // injected with Vite's `define`. + test.fails( + 'an ambient declare const read by the loader and the split component stays a global', + async () => { + const route = await loadRoute(`${head}declare const APP_VERSION: string +export const Route = createFileRoute('/')({ + loader: () => APP_VERSION, + component: () => <p>{APP_VERSION}</p>, +})`) + expect( + await route.run( + `return [options.loader(), await render('component')]`, + { before: `globalThis.APP_VERSION = '1.0'` }, + ), + ).toEqual(['1.0', '<p>1.0</p>']) + }, + ) +}) + +/** `./init`: `init` returns its argument and records it in `calls`. */ +const initFile = `export const calls: Array<unknown> = [] +export const init = (value: unknown) => { + calls.push(value) + return value +} +` + +describe('top-level code nothing reads at runtime', () => { + // Bug: the route module drops a declaration that only an exported type + // alias reads: it loses that reader when the code splitter removes the + // alias with the other exports, and the initializer then never runs. + // Source: #8504 (code-splitter-dead-code.test.ts), where it passes. + // Impact: what the initializer does when the route module loads + // (registrations, analytics, polyfills) silently stops once code splitting + // is on. + test.fails.each([ + { + name: 'a declaration only an exported type alias reads', + setup: `const analytics = init('analytics') +export type Analytics = typeof analytics`, + registered: ['analytics'], + }, + ])( + 'the initializers of $name run when the route module loads', + async ({ setup, registered }) => { + const route = await loadRoute( + `${head}import { init } from './init' +${setup} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>component</p>, +}) +`, + { files: { 'init.ts': initFile } }, + ) + expect( + await route.run( + `return [(await app('init.ts')).calls, await render('component')]`, + ), + ).toEqual([registered, '<p>component</p>']) + }, + ) + + // Bug: same as the type alias row above, in a route module compiled by the + // route HMR plugin (automatic code splitting off), which runs the same + // reference compiler. Source: review of #8504. + // Impact: as above, in development without automatic code splitting. + test.fails( + 'the initializer of a declaration only an exported type alias reads runs when a route module compiled for HMR loads', + async () => { + const route = await loadRoute( + `${head}import { init } from './init' +const analytics = init('analytics') +export type Analytics = typeof analytics +export const Route = createFileRoute('/')({ + component: () => <p>component</p>, +}) +`, + { + // The composed plugin's route HMR plugin compiles it in dev + pluginOptions: { autoCodeSplitting: false }, + files: { 'init.ts': initFile }, + }, + ) + expect(await route.run(`return (await app('init.ts')).calls`)).toEqual([ + 'analytics', + ]) + }, + ) +}) + +describe('page code left in the route module', () => { + /** + * Whether `./heavy` loads with the route module (requested by it or by a + * module it imports statically), and what the split component renders: a + * fix must render the same and leave `./heavy` to the chunk. + */ + async function splitComponent(code: string) { + const route = await loadRoute(code, { + files: { 'heavy.ts': `export const heavy = () => 'heavy'\n` }, + }) + return { + heavyLoadsEagerly: (await route.requested()).includes('/heavy.ts'), + rendered: await route.run(`return render('component')`), + } + } + + // Bug: page code that only the split component needs stays in the route + // module, with what it imports, when something there looks like a read of + // it: a type of the same name (TypeScript keeps types and values in + // separate namespaces), an overload signature or a second `var` + // declaration (dead-code elimination keeps them), or an unused function + // that renders it (one that renders the split component itself works: + // control in code-splitter-dead-code.test.ts). + // Sources: tanstack.com src/routes/index.tsx (`type PrincipleProof` next to + // `function PrincipleProof`); babel-dead-code-elimination + // dead-code-elimination.test.ts "function" > "declaration" and "variable" > + // "identifier"; real apps: Jp-K/DmCompanionAi + // frontend_old/src/routes/_layout/chat.tsx; #8504 + // (code-splitter-dead-code.test.ts), where they pass. + // Impact: the page's code and dependencies load with the entry chunk. + test.fails.each([ + { + name: 'a type of the same name', + code: `type Panel = 'a' | 'b' +export type Settings = { panel: Panel } +function Panel() { + return <div>{heavy()}</div> +} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <Panel />, +})`, + rendered: '<div>heavy</div>', + }, + { + name: 'overload signatures', + code: `function load(id: string): string +function load(id: number): string +function load(id: any) { return heavy() + id } +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{load(1)}</p>, +})`, + rendered: '<p>heavy1</p>', + }, + { + name: 'a redeclared var', + code: `var load = 'first' +var load = heavy() +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: () => <p>{load}</p>, +})`, + rendered: '<p>heavy</p>', + }, + { + name: 'an unused function that renders a component of the split component', + code: `export const Route = createFileRoute('/')({ + component: Page, +}) +function Card() { + return <p>{heavy()}</p> +} +function Page() { + return <Card /> +} +const Unused = () => <Card />`, + rendered: '<p>heavy</p>', + }, + { + name: 'an unused function that renders what an inline split component renders', + code: `export const Route = createFileRoute('/')({ + component: () => <Page />, +}) +function Page() { + return <p>{heavy()}</p> +} +function Unused() { + return <Page /> +}`, + rendered: '<p>heavy</p>', + }, + ])( + 'a split component and its imports leave the route module next to $name', + async ({ code, rendered }) => { + expect( + await splitComponent(`${head}import { heavy } from './heavy' +${code} +`), + ).toEqual({ heavyLoadsEagerly: false, rendered }) + }, + ) +}) + +describe('split route options', () => { + // Bug: once the object form compiles (pins above), its handler must also + // end up split: a loader configured to be split that stays in the route + // module is our limitation, not a pattern the user can change (SPEC + // J2.8). Only the handler can move; the router reads the other keys + // (`staleReloadMode`) from the route options. Today the compiler throws + // first (same root cause as above). A compiler that builds these routes + // but keeps a method handler, or a handler next to a spread, in the route + // module on purpose still has this bug. + // Impact: the loader's code loads with the entry chunk, or the route + // cannot be built. + test.fails.each([ + { name: 'an arrow handler', loader: `{ handler: () => 'MARK_handler' }` }, + { + name: 'a method handler', + loader: `{ handler() { return 'MARK_handler' } }`, + }, + { + name: 'a spread after the handler', + loader: `{ handler: () => 'MARK_handler', ...defaults }`, + }, + ])( + 'the handler of a split loader in object form with $name loads lazily', + async ({ loader }) => { + const route = + await loadRoute(`${head}const defaults = { staleReloadMode: 'blocking' as const } +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: ${loader}, + component: () => <p>index</p>, +}) +`) + // What loads with the route module loads with the entry: the + // handler's code (its user marker, decoded) is not in it, but in what + // loading the loader loads. + expect({ + eagerHandler: (await route.eagerModules()).some((code) => + holdsMarker(code, 'MARK_handler'), + ), + lazyHandler: + (await route.isLazy('loader')) && + (await route.loadedBy('loader')).some((code) => + holdsMarker(code, 'MARK_handler'), + ), + loaded: await route.run(`return options.loader.handler()`), + }).toEqual({ + eagerHandler: false, + lazyHandler: true, + loaded: 'MARK_handler', + }) + }, + ) + + // Bug: same root cause as the object-form pins above. The router reads the + // keys of a loader object other than `handler` (`staleReloadMode`) from the + // route options, so they must keep working next to a split handler, and + // module state the handler, those keys and the split component read must + // be created once. + // Impact: the route cannot be built once the loader is split. + test.fails.each([ + { + name: 'what the handler and the split component each read', + code: `import { createStore, createTheme } from './store' +const store = createStore() +const theme = createTheme() +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: { handler: () => store.get(), staleReloadMode: 'blocking' }, + component: () => <div>{theme.color}</div>, +})`, + expected: { + loaded: 'stored', + staleReloadMode: 'blocking', + rendered: '<div>red</div>', + created: { store: 1, theme: 1, config: 0 }, + }, + }, + { + name: 'what another key of the loader object and the split component read', + code: `import { createConfig } from './store' +const config = createConfig() +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: { handler: () => 1, staleReloadMode: config.mode }, + component: () => <div>{config.mode}</div>, +})`, + expected: { + loaded: 1, + staleReloadMode: 'background', + rendered: '<div>background</div>', + created: { store: 0, theme: 0, config: 1 }, + }, + }, + { + // Only the handler moves: its import leaves the route module, and the + // state it shares with `staleReloadMode` is created once. + // Source: #8504 (code-splitter-route-options.test.ts), where it passes. + name: 'an import only the handler reads, next to state the handler and another key read', + code: `import { fetchPosts } from './api' +import { createConfig } from './store' +const config = createConfig() +export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['component']], + loader: { + handler: () => [config.mode, fetchPosts()], + staleReloadMode: config.mode, + }, + component: () => <p>index</p>, +})`, + expected: { + loaded: ['background', 'posts'], + staleReloadMode: 'background', + rendered: '<p>index</p>', + created: { store: 0, theme: 0, config: 1 }, + apiLoadsEagerly: false, + }, + }, + ])( + 'a split loader in object form keeps $name working, created once', + async ({ code, expected }) => { + const route = await loadRoute(`${head}${code}\n`, { + files: { + 'api.ts': `export const fetchPosts = () => 'posts'\n`, + 'store.ts': `export const created = { store: 0, theme: 0, config: 0 } +export const createStore = () => { + created.store++ + return { get: () => 'stored' } +} +export const createTheme = () => { + created.theme++ + return { color: 'red' } +} +export const createConfig = () => { + created.config++ + return { mode: 'background' } +} +`, + }, + }) + const observed = await route.run<Record<string, unknown>>(` +// The handler of a loader, in object form or not, split or not +const loader = options.loader +const handler = typeof loader === 'function' ? loader : loader.handler +return { + loaded: await handler(), + staleReloadMode: options.loader.staleReloadMode, + rendered: await render('component'), + created: (await app('store.ts')).created, +}`) + expect({ + ...observed, + ...('apiLoadsEagerly' in expected && { + apiLoadsEagerly: (await route.requested()).includes('/api.ts'), + }), + }).toEqual(expected) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/pages/route-hmr.test.ts b/packages/router-plugin/tests/integration/pages/route-hmr.test.ts new file mode 100644 index 0000000000..3c237199a6 --- /dev/null +++ b/packages/router-plugin/tests/integration/pages/route-hmr.test.ts @@ -0,0 +1,436 @@ +/** + * Route HMR: the modules the compiler emits for development evaluate and + * render with or without a hot API, keep no React code for Solid and Vue. + * What the page shows after an edit is tested in a real dev server and a + * real browser page (integration/route-hmr-browser*.test.ts); that a dev + * server with `addHmr: false` applies no route HMR: + * integration/route-hmr-dev-addhmr-off.test.ts; production bundles: + * integration/build-production*.test.ts. Here: the route modules run where + * a dev server runs them, with the real tools: a real page served by the + * dev server (the real Vite client and its hot API, the framework's own + * plugin), and the dev server's SSR module runner (`route-app.ts`). + */ +import { SourceMap } from 'node:module' +import { parseSync } from 'vite' +import { describe, expect, it, test } from 'vitest' +import { renderRoutePath, routerDevServer } from '../../dev-server' +import { expectValidModules, head, loadRoute } from '../../route-app' +import type { + RouteApp, + RouteAppOptions, + TargetFramework, +} from '../../route-app' +import type { Plugin } from 'vite' + +/** A route file whose loader returns `data`, with its other options. */ +const fileRoute = ( + data: string, + options: string, + declarations = '', + framework: TargetFramework = 'react', +) => `import { createFileRoute } from '@tanstack/${framework}-router' +${declarations} +export const Route = createFileRoute('/')({ + loader: () => '${data}', + ${options} +})` + +/** Components whose text names the version of the route file. */ +const posts = (version: string) => `function PostsComponent() { + return <div>posts ${version}</div> +} +function PostsErrorComponent() { + return <div>Error loading posts ${version}</div> +}` + +/** + * Whether a request (a URL path a page fetched) loads a module of a React + * package: React, React DOM or the React router, pre-bundled by the dev + * server or served from its package directory. + */ +const reactPackage = + /\/node_modules\/(?:\.vite\/deps\/(?:react|react-dom|@tanstack_react-router)[._-]|react\/|react-dom\/)|\/packages\/react-router\// + +describe('the modules of a Solid or Vue route compiled with HMR', () => { + // What the page shows after an edit, with the framework's own refresh: + // integration/route-hmr-browser-frameworks.test.ts. Here: loading the + // route and every option it splits in a page requests nothing of React + // (resolved request provenance), and the route works with the + // framework's router (source: add-hmr snapshot fixture + // solid/arrow-function). + test.each([ + { framework: 'solid', style: 'vite' }, + { framework: 'solid', style: 'webpack' }, + { framework: 'vue', style: 'vite' }, + { framework: 'vue', style: 'webpack' }, + ] as const)( + '$framework ($style style): import the router package of the framework and no React code', + async ({ framework, style }) => { + const route = await loadRoute( + fileRoute( + 'data', + 'component: PostsComponent,', + `function PostsComponent() { + return <div>posts</div> +}`, + framework, + ), + { + targetFramework: framework, + hmr: true, + pluginOptions: { plugin: { hmr: { style } } }, + }, + ) + const { html, requests } = await route.run<{ + html: string + requests: Array<string> + }>(`for (const option of ['component', 'errorComponent', 'pendingComponent', 'notFoundComponent', 'loader']) { + await trigger(option) +} +const html = await renderRoute() +return { + html, + requests: performance.getEntriesByType('resource').map((entry) => new URL(entry.name).pathname), +}`) + expect(html).toContain('posts') + expect(requests.filter((request) => reactPackage.test(request))).toEqual( + [], + ) + }, + ) +}) + +/** + * A route app's tools: whether its modules see a hot API (Vite's + * `import.meta.hot`, webpack's `import.meta.webpackHot`) and a `window`. + */ +const environmentProbe = { + 'environment.ts': `export const environment = { + hot: typeof import.meta.hot, + webpackHot: typeof (import.meta as any).webpackHot, + window: typeof window, +} +`, + // React's server renderer as an app's SSR code imports it + 'ssr-render.ts': `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +export const render = (component: any) => renderToString(createElement(component)) +`, +} + +/** A user plugin of the app turning Vite's HMR off (`server.hmr: false`). */ +const withoutHmr: Plugin = { + name: 'app:no-hmr', + config: () => ({ server: { hmr: false } }), +} + +interface Host { + name: string + /** Where the route module runs: a page, or the SSR module runner. */ + side: 'page' | 'ssr' + /** The dev server runs without HMR (no hot API in its modules). */ + noHmr?: boolean + /** What the modules see there (checked: the row's precondition). */ + environment: { hot: string; webpackHot: string; window: string } +} + +/** + * Loads the route module where `host` runs it and returns the loader's + * value, the component's HTML (after the router's `preload()` of a split + * component), and what the modules see there. + */ +async function runWhere(route: RouteApp, host: Host) { + if (host.side === 'page') { + return route.run(`return { + data: await options.loader(), + html: await render('component'), + environment: (await app('environment.ts')).environment, +}`) + } + // The dev server's SSR module runner: the route module, and React DOM's + // server renderer as the app's SSR code imports it + const { Route } = await route.host.importServer(route.url) + const { render } = await route.host.importServer('/ssr-render.ts') + const { environment } = await route.host.importServer('/environment.ts') + const component = Route.options.component + await component.preload?.() + return { + data: await Route.options.loader(), + html: render(component), + environment, + } +} + +describe('route modules compiled for the dev server', () => { + // Source: #7074 / J3.8. Initial evaluation where the dev server runs the + // route module: with the host's hot API or without one (a dev server + // without HMR), in a page or in the SSR module runner (no `window`), and + // no router on the page yet. Every emitted module is linked by the real + // tools: a missing lazy target must not pass as a property. A page of a + // Vite dev server always has Vite's hot API (also with `server.hmr: + // false`); a page without a hot API, and webpack's hot API + // (`import.meta.webpackHot`) present: Rsbuild's dev server, + // integration/route-hmr-rsbuild-hosts.test.ts; webpack's hot API without a + // `window`: a webpack or Rspack server build with hot module replacement, + // integration/route-hmr-webpack-server-hosts.test.ts. + const vite: Array<Host> = [ + { + name: 'a page (hot API present, window)', + side: 'page', + environment: { hot: 'object', webpackHot: 'undefined', window: 'object' }, + }, + { + name: 'the SSR module runner (hot API present, no window)', + side: 'ssr', + environment: { + hot: 'object', + webpackHot: 'undefined', + window: 'undefined', + }, + }, + { + name: 'the SSR module runner of a dev server without HMR (no hot API, no window)', + side: 'ssr', + noHmr: true, + environment: { + hot: 'undefined', + webpackHot: 'undefined', + window: 'undefined', + }, + }, + ] + // The webpack style in Vite: Vite gives no `import.meta.webpackHot` + const webpackInVite: Array<Host> = [ + { ...vite[0]!, name: 'a page (no webpack hot API, window)' }, + { + ...vite[1]!, + name: 'the SSR module runner (no webpack hot API, no window)', + }, + ] + + describe.each([ + { style: 'vite', hosts: vite }, + { style: 'webpack', hosts: webpackInVite }, + ] as const)('$style style', ({ style, hosts }) => { + describe.each([ + { + name: 'a split route', + route: fileRoute('data', 'component: PostsComponent,', posts('data')), + html: '<div>posts data</div>', + }, + { + name: 'a root route', + route: `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ + loader: () => 'data', + component: () => <div>root</div>, +})`, + html: '<div>root</div>', + }, + ])('$name', ({ route, html }) => { + it.each(hosts)('renders and loads in $name', async (host) => { + const options: RouteAppOptions = { + hmr: true, + pluginOptions: { plugin: { hmr: { style } } }, + files: environmentProbe, + ...(host.noHmr && { plugins: { before: [withoutHmr] } }), + } + const loaded = await loadRoute(route, options) + expect(await runWhere(loaded, host)).toEqual({ + data: 'data', + html, + environment: host.environment, + }) + }) + }) + }) + + it.each([false, true])( + 'renders a dev-SSR route and its loader through Vite (autoCodeSplitting: %s)', + async (autoCodeSplitting) => { + const server = await routerDevServer({ + pluginOptions: { autoCodeSplitting }, + files: { + 'routes/index.tsx': `${head}function Page() { + return <p>SSR {Route.useLoaderData()}</p> +} +export const Route = createFileRoute('/')({ loader: () => 'data', component: Page })`, + }, + }) + expect(await renderRoutePath(server, '/')).toContain( + '<p>SSR <!-- -->data</p>', + ) + }, + 30_000, + ) + + // Source: add-hmr snapshot fixture string-literal-keys. + it('split options under quoted keys like the others', async () => { + const route = await loadRoute( + `${head}function Page() { + return <p>page</p> +} +function Err() { + return <p>error</p> +} +export const Route = createFileRoute('/')({ 'component': Page, 'errorComponent': Err })`, + { hmr: true }, + ) + await expectValidModules(route) + expect(await route.groups()).toEqual([['component'], ['errorComponent']]) + expect( + await route.run( + `return [await render('component'), await render('errorComponent')]`, + ), + ).toEqual(['<p>page</p>', '<p>error</p>']) + }) + + // Source: add-hmr snapshot fixture explicit-undefined-component. + it('keep an explicitly undefined component undefined', async () => { + const route = await loadRoute( + `${head}export const Route = createFileRoute('/')({ + component: undefined, +})`, + { hmr: true }, + ) + await expectValidModules(route) + expect(await route.isLazy('component')).toBe(false) + expect( + await route.run( + `return ['component' in options, options.component === undefined]`, + ), + ).toEqual([true, true]) + }) +}) + +// Route modules compiled without HMR (the add-hmr `@false` snapshots): +// a dev server with `addHmr: false` applies no route HMR: +// integration/route-hmr-dev-addhmr-off.test.ts; production bundles carry no +// dev-only code: integration/build-production.test.ts and +// build-production-webpack.test.ts (decided on the bundle, SPEC G7). + +/** Where the string literal `value` starts in `code` (an independent parse). */ +function markerOffset(code: string, value: string) { + let found: number | undefined + const visit = (node: unknown) => { + if (found !== undefined || !node || typeof node !== 'object') { + return + } + if (Array.isArray(node)) { + node.forEach(visit) + return + } + const current = node as Record<string, any> + if (current.type === 'Literal' && current.value === value) { + found = current.start + return + } + Object.values(current).forEach(visit) + } + visit(parseSync('module.js', code, { sourceType: 'module' }).program) + expect( + found, + `the served module holds ${JSON.stringify(value)}`, + ).toBeDefined() + return found! +} + +// The route HMR plugin that `tanstackRouter` adds in development when +// automatic code splitting is off, in a Vite dev server. +describe('route HMR in a Vite dev server without automatic code splitting', () => { + const timeout = 30_000 + // Vite's SSR transform serves `import.meta` as `__vite_ssr_import_meta__`; + // the hot API read as a member, whatever its spelling + const hasRouteHmr = (code: string) => + /(?:import\.meta|__vite_ssr_import_meta__)\s*(?:\.\s*hot\b|\[\s*(['"`])hot\1\s*\])/.test( + code, + ) + const loaderRoute = (target: TargetFramework = 'react') => + `import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/')({ loader: () => 'x' })` + + // An edit of a `.ts` route file, the environment name, `plugin.hmr.style` + // alone, plugin options given as a function and a `tsr.config.json` + // target, on a real page: integration/route-hmr-browser-plugin.test.ts + // (the environment the option names gets working route HMR) and + // known-bugs-route-hmr.test.ts. Here: the environment + // `plugin.vite.environmentName` excludes gets no route HMR code in any + // module the environment serves from its route module: the router's + // packages and any support module the compiler imports included. Left + // out: Vite's own client, and packages the environment externalizes + // (bare ids: Node loads the installed package itself). + test( + 'serves no route HMR code to an environment plugin.vite.environmentName does not name', + async () => { + const server = await routerDevServer({ + pluginOptions: { + autoCodeSplitting: false, + plugin: { vite: { environmentName: 'client' } }, + }, + files: { 'routes/index.tsx': loaderRoute() }, + }) + // Positive delivery control: integration/route-hmr-browser-plugin.test.ts + // edits an environment-selected loader on a real page. The compiler + // may delegate HMR to an imported helper instead of inlining an API. + const served = await server.load('/routes/index.tsx', { + environment: 'ssr', + skip: /^\/@(?:vite|react-refresh)\b|^[^./]/, + }) + for (const [url, code] of Object.entries(served)) { + expect(hasRouteHmr(code), url).toBe(false) + } + // The environment the option names gets route HMR code the check + // above recognises (otherwise that check would prove nothing) + const client = await server.load('/routes/index.tsx', { + environment: 'client', + skip: /^\/@(?:vite|react-refresh)\b|^[^./]/, + }) + expect(Object.values(client).some(hasRouteHmr)).toBe(true) + }, + timeout, + ) + + // Stack traces and breakpoints of route files in development. + test.each(['react', 'solid', 'vue'] as const)( + 'maps the served %s route module to the lines of the route file', + async (target) => { + const route = `import { createFileRoute } from '@tanstack/${target}-router' + + +// comment + +export const Route = createFileRoute('/')({ + loader: () => { + const value = [1, 2, 3].map((n) => n * 2).filter((n) => n > 2) + + + throw new Error('MARK_THROW ' + value.length) + }, +}) +` + const server = await routerDevServer({ + pluginOptions: { target, autoCodeSplitting: false }, + files: { 'routes/index.tsx': route }, + }) + const result = + await server.vite.environments.client.transformRequest( + '/routes/index.tsx', + ) + const code = result!.code + // Where the served module holds the user's marker (its own string + // literal: the code around it, a helper the compiler adds before it + // included, is free) + const before = code.slice(0, markerOffset(code, 'MARK_THROW ')) + const line = before.split('\n').length - 1 + const column = before.length - before.lastIndexOf('\n') - 1 + const entry = new SourceMap(result!.map as any).findEntry( + line, + column, + ) as { originalLine: number } + expect(entry.originalLine + 1).toBe( + route.slice(0, route.indexOf("'MARK_THROW '")).split('\n').length, + ) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/plugin-options.test.ts b/packages/router-plugin/tests/integration/plugin-options.test.ts new file mode 100644 index 0000000000..38e8d34167 --- /dev/null +++ b/packages/router-plugin/tests/integration/plugin-options.test.ts @@ -0,0 +1,141 @@ +// Slow-tier half of this suite: the tests that need a real tool. Its +// in-process tests are in ../plugin-options.test.ts (fast tier). +/** + * Router plugin options and entry points, through real builds: what each + * option changes in the output or on disk. + */ +import { readFile } from 'node:fs/promises' +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { build, clientMountEntry, routeApp, routeHead } from '../build-harness' +import type { + BuildResult, + Bundler, +} from '@tanstack/compiler-test-utils/build-harness' +import type { RouterPluginOptions } from '../build-harness' + +const timeout = 120_000 + +const bundlers = ['vite', 'rspack', 'webpack'] as const + +/** A route whose component is split by default. */ +const route = (routePath = '/') => `${routeHead()}function Page() { + return <p>MARK_COMPONENT</p> +} +export const Route = createFileRoute('${routePath}')({ + staticData: { label: 'MARK_ROUTE' }, + component: Page, +}) +` + +/** + * Client entry re-exporting the index route module next to `mount` (see + * `clientMountEntry`) and `renderTree()`, which renders the app at `/` + * through the real router over the generated route tree and returns the + * HTML once it shows the page (or after 2 seconds). + */ +const treeEntry = `${clientMountEntry}import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export async function renderTree() { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: ['/'] }), + }) + const container = document.createElement('div') + document.body.appendChild(container) + const root = createRoot(container) + flushSync(() => root.render(createElement(RouterProvider, { router }))) + for (let tries = 0; tries < 200 && !container.innerHTML.includes('MARK_COMPONENT'); tries++) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } + const html = container.innerHTML + root.unmount() + container.remove() + return html +} +` + +/** + * Builds the route for the client and renders its component; `script` + * (run after mounting it) gives `result`. + */ +async function buildRoute( + bundler: Bundler, + pluginOptions: RouterPluginOptions, + options: { + files?: Record<string, string> + routes?: (config: RouterPluginOptions) => Array<unknown> + script?: string + } = {}, +) { + const app = await build({ + bundler, + env: 'client', + // No outcome here depends on webpack's minifier (terser): placement of + // live code, the rendering and the generated route tree. + ...(bundler === 'webpack' && { minify: false }), + pluginOptions, + routerPlugins: options.routes, + files: routeApp(options.files?.['routes/index.tsx'] ?? route(), { + env: 'client', + files: options.files, + }), + }) + const run = await app.run( + `await entry.mount(entry.Route.options.component)\n${options.script ?? ''}`, + ) + return { app, html: run.html, result: run.result } +} + +const read = (app: BuildResult, file: string) => + readFile(path.join(app.root, file), 'utf8').catch(() => null) + +// Every cell per bundler entry, `undefined` included: each entry (Vite, +// Rspack, webpack) takes the user's options through its own code before the +// default applies, so an entry could resolve an absent option differently; +// the harness itself turns splitting on, so these are the only checks of +// the default per entry. +describe.each([false, undefined])( + 'autoCodeSplitting: %s', + (autoCodeSplitting) => { + test.each(bundlers)( + 'splits nothing and still generates the route tree (%s)', + async (bundler) => { + const { app, html, result } = await buildRoute( + bundler, + { autoCodeSplitting }, + { + files: { 'entry.ts': treeEntry }, + script: 'return await entry.renderTree()', + }, + ) + // The route's component loads with the app (whatever other chunks + // a correct compiler or the bundler emits) + expect(app.where('MARK_COMPONENT')).toBe('eager') + expect(html).toContain('MARK_COMPONENT') + // The generated tree exists, and the real router over it renders + // the index route at `/` (however the tree spells its imports). + expect(await read(app, 'routeTree.gen.ts')).not.toBeNull() + expect(result).toContain('MARK_COMPONENT') + }, + timeout, + ) + }, +) + +describe('plugin.vite.environmentName', () => { + test.each([ + ['client', 'lazy'], + ['ssr', 'eager'], + ] as const)( + 'with %s code-splits only that environment (client build: %s)', + async (environmentName, placement) => { + const { app, html } = await buildRoute('vite', { + plugin: { vite: { environmentName } }, + }) + expect(app.where('MARK_COMPONENT')).toBe(placement) + expect(html).toContain('MARK_COMPONENT') + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-frameworks.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-frameworks.test.ts new file mode 100644 index 0000000000..ba86a258f8 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-frameworks.test.ts @@ -0,0 +1,157 @@ +/** + * Route HMR in Solid and Vue apps, as the developer sees it: a real dev + * server (Vite with `vite-plugin-solid` / `@vitejs/plugin-vue-jsx`, or + * Rsbuild with `@rsbuild/plugin-solid` / `@rsbuild/plugin-vue` + + * `@rsbuild/plugin-vue-jsx`) serves a file-based app with the framework's + * router package to a real browser page, and the test edits its route files + * on disk (`route-hmr-page.ts`). An edit of a route file shows its new + * code: the new loader's data and the new component body. Whether without a + * full reload, keeping the split component (SPEC J3.2): where it does, + * required here; where it does not, pinned in known-bugs-route-hmr.test.ts. + * + * React apps: route-hmr-browser.test.ts. + */ +import { describe, it } from 'vitest' +import { runPins } from '@tanstack/compiler-test-utils/pins' +import { openRouteHmrPage } from '../route-hmr-page' +import type { TestContext } from 'vitest' + +const timeout = 90_000 + +/** + * A route file of `target` at `/` whose loader and component name the + * version of the file; the component declares its own `Page`, which Solid + * Refresh and Vue's HMR runtime can patch. + */ +const route = (target: 'solid' | 'vue', version: string) => + `import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return <p>page ${version} {${target === 'vue' ? 'data.value' : 'data()'}}</p> +} +` + +/** A cell of the bundler × framework × code-splitting matrix. */ +interface Cell { + bundler: 'vite' | 'rsbuild' + target: 'solid' | 'vue' + autoCodeSplitting: boolean +} + +const same = (a: Cell, b: Cell) => + a.bundler === b.bundler && + a.target === b.target && + a.autoCodeSplitting === b.autoCodeSplitting + +/** + * Where an edit of a route file applies in place today: Solid in Vite + * without automatic code splitting (Solid Refresh makes a module that + * declares its component a boundary), split Solid and Vue on Rsbuild (the + * route module runs again). The other cells reload the page (Vite: the + * route module's accept call is on an alias) and are pinned in + * known-bugs-route-hmr.test.ts ("an edit of a split Solid/Vue route", "an + * edit of an unsplit Vue route"). With `COMPILER_TESTS_PINS=run`, every + * cell is required to apply in place. + */ +const hotToday = (cell: Cell) => + runPins || + [ + { bundler: 'vite', target: 'solid', autoCodeSplitting: false }, + { bundler: 'rsbuild', target: 'solid', autoCodeSplitting: true }, + { bundler: 'rsbuild', target: 'vue', autoCodeSplitting: true }, + { bundler: 'rsbuild', target: 'vue', autoCodeSplitting: false }, + ].some((hot) => same(hot as Cell, cell)) + +/** + * Where the edit does not show at all today: an unsplit Solid route on + * Rsbuild keeps its old component (pinned in known-bugs-route-hmr.test.ts + * "rsbuild: an edit of an unsplit Solid route"). With + * `COMPILER_TESTS_PINS=run`, no cell is left out. + */ +const brokenToday = (cell: Cell) => + !runPins && + same(cell, { bundler: 'rsbuild', target: 'solid', autoCodeSplitting: false }) + +describe.concurrent.each([ + { bundler: 'vite', target: 'solid' }, + { bundler: 'vite', target: 'vue' }, + { bundler: 'rsbuild', target: 'solid' }, + { bundler: 'rsbuild', target: 'vue' }, +] as const)('$bundler: a $target app', ({ bundler, target }) => { + it.for( + [true, false].filter( + (autoCodeSplitting) => + !brokenToday({ bundler, target, autoCodeSplitting }), + ), + )( + 'shows the new code of an edited route file (autoCodeSplitting: %s)', + { timeout }, + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + bundler, + target, + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route(target, 'v1') }, + ready: 'page v1 data v1', + }) + const result = await app.edit( + { 'routes/index.tsx': route(target, 'v2') }, + 'page v2 data v2', + ) + if (hotToday({ bundler, target, autoCodeSplitting })) { + expect(result).toEqual({ reloaded: false, errors: [] }) + } + }, + ) +}) + +/** + * A Solid root route whose component names the version of the file and + * renders the child route. + */ +const solidRoot = (version: string) => + `import { Outlet, createRootRoute } from '@tanstack/solid-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + return <div><p>root ${version}</p><Outlet /></div> +} +` + +// SPEC J3.5: an edit of the root route (never split) hot-updates. On +// Rsbuild the edit does not show today: pinned in +// known-bugs-route-hmr.test.ts ("rsbuild: an edit of a Solid root route"). +// React apps: route-hmr-browser.test.ts. +describe.concurrent('vite: a solid app', () => { + it.for([true, false])( + 'shows the new code of an edited root route in place (autoCodeSplitting: %s)', + { timeout }, + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + target: 'solid', + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { + 'routes/__root.tsx': solidRoot('v1'), + 'routes/index.tsx': route('solid', 'v1'), + }, + ready: /root v1[\s\S]*page v1 data v1/, + }) + const result = await app.edit( + { 'routes/__root.tsx': solidRoot('v2') }, + /root v2[\s\S]*page v1 data v1/, + ) + expect(result).toEqual({ reloaded: false, errors: [] }) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-metadata.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-metadata.test.ts new file mode 100644 index 0000000000..7955972003 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-metadata.test.ts @@ -0,0 +1,157 @@ +/** Host-delivery outcomes: real route edits reach matching, context, + * search parsing and the document head through the public router APIs. + */ +import { describe, test } from 'vitest' +import { openRouteHmrPage } from '../route-hmr-page' +import type { TestContext } from 'vitest' + +const inPlace = { reloaded: false, errors: [] } + +const root = `import { createRootRoute, HeadContent, Outlet, Scripts } from '@tanstack/react-router' +import { createPortal } from 'react-dom' +export const Route = createRootRoute({ component: Root }) +function Root() { + return <>{createPortal(<HeadContent />, document.head)}<Outlet /><Scripts /></> +}` + +const item = ( + version: string, + removed = false, +) => `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/items/$itemId')({ + ${ + removed + ? '' + : `params: { parse: ({ itemId }) => ({ itemId: itemId.${version === 'v1' ? 'toUpperCase' : 'toLowerCase'}() }) }, + validateSearch: (search) => ({ term: String(search.term ?? '').${version === 'v1' ? 'toUpperCase' : 'toLowerCase'}() }), + beforeLoad: () => ({ label: 'context ${version}' }), + head: () => ({ meta: [{ title: 'title ${version}' }], scripts: [{ 'data-hmr-head': '${version}', children: 'void "head ${version}"' }] }), + scripts: () => [{ 'data-hmr-body': '${version}', children: 'void "body ${version}"' }],` + } + component: Page, +}) +function Page() { + const params = Route.useParams() + const search: { term?: string } = Route.useSearch() + const context: { label?: string } = Route.useRouteContext() + return <p>item ${version} {params.itemId} {search.term} {context.label ?? 'no context'}</p> +}` + +describe.concurrent.each(['vite', 'rsbuild'] as const)( + '%s: route metadata delivered by the real host', + (bundler) => { + test.for([false, true])( + 'delivers matching, search, context, head and scripts edits (removal: %s)', + { timeout: 60_000 }, + async (removed: boolean, { expect, onTestFinished }: TestContext) => { + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { + 'routes/__root.tsx': root, + 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => <p>home</p> })`, + 'routes/items/$itemId.tsx': item('v1'), + }, + ready: 'home', + }) + const fallbackTitle = await app.evaluate<string>('document.title') + const visit = async (to: string, term?: string) => { + await app.evaluate( + `window.__APP_ROUTER__.navigate(${JSON.stringify({ to, search: term === undefined ? {} : { term } })})`, + ) + } + const documentOptions = () => + app.evaluate(`({ + title: document.title, + head: [...document.head.querySelectorAll('[data-hmr-head]')].map((node) => node.getAttribute('data-hmr-head')), + body: [...document.querySelectorAll('[data-hmr-body]')].map((node) => node.getAttribute('data-hmr-body')), + })`) + await visit('/items/One', 'First') + await app.page.waitForText('item v1 ONE FIRST context v1') + await expect.poll(documentOptions).toEqual({ + title: 'title v1', + head: ['v1'], + body: ['v1'], + }) + const activeTerm = await app.evaluate<string>( + `new URLSearchParams(location.search).get('term') ?? ''`, + ) + // A fresh app per replacement/removal keeps this to one edit per + // file (Rspack loses a removal during a compile: oracle/KNOWN-BUGS.md, + // "Upstream issues"). + expect( + await app.edit( + { 'routes/items/$itemId.tsx': item('v2', removed) }, + removed + ? `item v2 One ${activeTerm} no context` + : 'item v2 one first context v2', + ), + ).toEqual(inPlace) + await visit('/') + await visit('/items/Two', 'Second') + await app.page.waitForText( + removed + ? 'item v2 Two Second no context' + : 'item v2 two second context v2', + ) + await expect + .poll(documentOptions) + .toEqual( + removed + ? { title: fallbackTitle, head: [], body: [] } + : { title: 'title v2', head: ['v2'], body: ['v2'] }, + ) + expect(app.loads()).toBe(1) + expect(app.page.errors).toEqual([]) + }, + ) + + // Bug: a replacement index export must keep the generated navigation + // target, which differs from its fullPath's trailing slash. + // Source: mutation testing (SPEC J3.1, G1, G9). + // Impact: user code importing Route builds a different link after HMR. + test( + 'an edited index export keeps its public navigation target', + { timeout: 60_000 }, + async ({ expect, onTestFinished }: TestContext) => { + const posts = ( + version: string, + ) => `import { createFileRoute, Link } from '@tanstack/react-router' +export const Route = createFileRoute('/posts/')({ + loader: (): { version: string; to: string } => ({ version: '${version}', to: Route.to }), + component: Posts, +}) +function Posts() { + const data = Route.useLoaderData() + return <p>posts {data.version} <span data-testid="target">{data.to}</span> <Link to={data.to}>index target</Link></p> +}` + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + files: { + 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => <p>home</p> })`, + 'routes/posts/index.tsx': posts('v1'), + }, + ready: 'home', + }) + await app.evaluate(`window.__APP_ROUTER__.navigate({ to: '/posts' })`) + await app.page.waitForText('posts v1') + expect(await app.page.page.locator('a').getAttribute('href')).toBe( + '/posts', + ) + expect( + await app.edit({ 'routes/posts/index.tsx': posts('v2') }, 'posts v2'), + ).toEqual(inPlace) + expect(await app.page.page.locator('a').getAttribute('href')).toBe( + '/posts', + ) + expect( + await app.page.page.locator('[data-testid=target]').textContent(), + ).toBe('/posts') + }, + ) + }, +) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-names.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-names.test.ts new file mode 100644 index 0000000000..4aee698cf1 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-names.test.ts @@ -0,0 +1,274 @@ +/** + * Route HMR of React route components under the names users give them, on + * a real page (`route-hmr-page.ts`): lowercase components (React Refresh's + * own transform registers PascalCase names only), components the route file + * exports, reassigns or overloads, split or not. An edit of a component's + * body shows its new code in place, without a full reload, without errors, + * and without mounting the component anew (React Refresh keeps its state). + * How the compiler gets there (renaming, hoisting, registration) is free. + * + * Replaces the in-process registration checks of + * react-refresh-route-components.test.ts and known-bugs-route-hmr.test.ts: + * those read which names React Refresh's transform registered, + * which neither shows new code nor kept state. Pins: known-bugs-route-hmr + * -components.test.ts (integration). What modules importing the exports get: + * react-refresh-route-components.test.ts. + * + * Concurrent: each test has its own dev server and page, and mostly waits. + */ +import { describe, test } from 'vitest' +import { + countMounts, + isAppError, + mountsOf, + openRouteHmrPage, +} from '../route-hmr-page' +import type { TestContext } from 'vitest' + +const inPlace = { reloaded: false, errors: [] } + +/** Errors the page logged that the app causes on purpose. */ +const withoutLoaderErrors = (errors: Array<string>) => + errors.filter((error) => !isAppError(error, 'loader failed')) + +describe.concurrent('vite: React route components', { timeout: 60_000 }, () => { + /** + * A route at `/` whose `mode` search parameter picks what the page shows: + * its component (no mode), its error component (`error`: the loader + * throws) or its pending component (`pending`: the loader never settles). + * The three options are lowercase function declarations that count their + * mounts and name the version of the file. `options` passes them (and + * the code split groupings). + */ + const lowercaseOptionsRoute = + (options: string) => + ( + version: string, + ) => `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +export const Route = createFileRoute('/')({ + validateSearch: (search: Record<string, unknown>) => ({ + mode: search.mode as string | undefined, + }), + loaderDeps: ({ search }) => ({ mode: search.mode }), + loader: ({ deps }) => + deps.mode === 'error' + ? Promise.reject(new Error('loader failed')) + : deps.mode === 'pending' + ? new Promise<never>(() => {}) + : null, + pendingMs: 0, + pendingMinMs: 0, + ${options} +}) +function pendingComponent() { + ${countMounts('pendingComponent')} + return <p>pendingComponent ${version}</p> +} +function errorComponent() { + ${countMounts('errorComponent')} + return <p>errorComponent ${version}</p> +} +function component() { + ${countMounts('component')} + return <p>component ${version}</p> +} +` + + // Source: add-hmr snapshot fixture createFileRoute-lowercase-components + // (with the default groupings, `component` and `errorComponent` are split + // and `pendingComponent` stays in the route module), and the former + // known-bugs-route-hmr "registers a split %s declared as a lowercase + // function" (each option in its own group). + test.for([ + { + name: 'the default groupings', + options: `pendingComponent: pendingComponent, + errorComponent: errorComponent, + component: component,`, + }, + { + name: 'each option in its own group', + options: `codeSplitGroupings: [['component'], ['pendingComponent'], ['errorComponent']], + pendingComponent, + errorComponent, + component,`, + }, + ])( + 'declared as lowercase functions, with $name: an edit of the component, the error component and the pending component shows each in place', + async ({ options }, { expect, onTestFinished }: TestContext) => { + const route = lowercaseOptionsRoute(options) + const file = 'routes/index.tsx' + const app = await openRouteHmrPage({ + onTestFinished, + files: { [file]: route('v1') }, + ready: 'component v1', + }) + let version = 1 + for (const [option, mode] of [ + ['component', undefined], + ['errorComponent', 'error'], + ['pendingComponent', 'pending'], + ] as const) { + if (mode) { + await app.evaluate( + `void window.__APP_ROUTER__.navigate({ to: '/', search: { mode: '${mode}' } })`, + ) + await app.page.waitForText(`${option} v${version}`, { + selector: '#app', + }) + } + const mounts = await mountsOf(app) + expect(mounts[option], option).toBeGreaterThan(0) + version++ + const { reloaded, errors } = await app.edit( + { [file]: route(`v${version}`) }, + `${option} v${version}`, + ) + expect( + { reloaded, errors: withoutLoaderErrors(errors) }, + option, + ).toEqual(inPlace) + // The router runs the edited route's loader again, so the error and + // pending states it shows start anew: only the component's state + // is the framework's to keep. + if (option === 'component') { + expect((await mountsOf(app))[option], option).toBe(mounts[option]) + } + } + }, + ) + + /** + * A route at `/` whose component is `page`, declared by `declaration` + * (with `version`), counting its mounts; `options` are the other route + * options. + */ + const pageRoute = + (declaration: (body: string) => string, imports = '', exports = '') => + ( + version: string, + ) => `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +${imports} +${declaration(`{ + ${countMounts('page')} + return <p>page ${version}</p> +}`)} +${exports} +export const Route = createFileRoute('/')({ component: page }) +` + + // Source: ReactFreshBabelPlugin-test "only registers pascal case + // functions", "uses original function declaration if it get reassigned" + // and "registers top-level exported function declarations" / "... + // exported named arrow functions"; the former react-refresh-route + // -components "declared lowercase as %s, by renaming it" and "renamed + // lowercase and exported (%s)". The split rows of the lowercase + // variables, and `export { page }` split: pinned in + // known-bugs-route-hmr-components.test.ts. + test.for([ + ...[false, true].flatMap((autoCodeSplitting) => [ + { + name: 'a function declaration', + autoCodeSplitting, + route: pageRoute((body) => `function page() ${body}`), + }, + { + name: 'an overloaded function declaration', + autoCodeSplitting, + route: pageRoute( + (body) => `function page(props: { title?: string }): ReactNode +function page(props: any) ${body}`, + `import type { ReactNode } from 'react'`, + ), + }, + { + name: 'an exported function declaration', + autoCodeSplitting, + route: pageRoute((body) => `export function page() ${body}`), + }, + { + name: 'a function declaration exported as default', + autoCodeSplitting, + route: pageRoute( + (body) => `function page() ${body}`, + '', + 'export default page', + ), + }, + ]), + { + name: 'a const arrow function', + autoCodeSplitting: false, + route: pageRoute((body) => `const page = () => ${body}`), + }, + { + name: 'a function expression that names itself', + autoCodeSplitting: false, + route: pageRoute((body) => `const page = function page() ${body}`), + }, + { + name: 'an arrow function exported by an export list', + autoCodeSplitting: false, + route: pageRoute( + (body) => `const page = () => ${body}`, + '', + 'export { page }', + ), + }, + ])( + 'declared lowercase as $name: an edit shows in place without mounting it again (autoCodeSplitting: $autoCodeSplitting)', + async ( + { route, autoCodeSplitting }, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route('v1') }, + ready: 'page v1', + }) + const mounts = await mountsOf(app) + expect(mounts.page).toBeGreaterThan(0) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'page v2'), + ).toEqual(inPlace) + expect(await mountsOf(app)).toEqual(mounts) + }, + ) + + // A lowercase function declaration the route file reassigns to what a + // higher-order component returns (`page = connect(page)`; JavaScript + // only: TypeScript rejects assigning to a function declaration, TS2630). + // Source: ReactFreshBabelPlugin-test "uses original function declaration + // if it get reassigned"; the former react-refresh-route-components row. + test('declared lowercase as a reassigned function declaration: an edit shows in place (autoCodeSplitting: false)', async ({ + expect, + onTestFinished, + }: TestContext) => { + const route = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { connect } from '../connect' +function page() { + ${countMounts('page')} + return <p>page ${version}</p> +} +page = connect(page) +export const Route = createFileRoute('/')({ component: page }) +` + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting: false }, + files: { + 'connect.js': `export const connect = (component) => component\n`, + 'routes/index.jsx': route('v1'), + }, + ready: 'page v1', + }) + expect( + await app.edit({ 'routes/index.jsx': route('v2') }, 'page v2'), + ).toEqual(inPlace) + }) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-options.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-options.test.ts new file mode 100644 index 0000000000..993fe9d435 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-options.test.ts @@ -0,0 +1,333 @@ +/** + * Route HMR of React route components written inline, of root route + * components, of edits that add route options beside a component, and of + * components using custom hooks, on a real page (`route-hmr-page.ts`). An + * edit shows its new code in place, without a full reload and without + * errors; a component React Refresh can patch in place (a body edit that + * keeps its hooks) is not mounted anew, and one whose hooks changed may be + * (React Refresh remounts it). How the compiler gets there (hoisting, + * naming, registration, hook signatures) is free. + * + * Replaces the in-process registration and signature checks of + * react-refresh-route-components.test.ts, which read the names + * and hook signatures React Refresh's transform computed. + * + * Concurrent: each test has its own dev server and page, and mostly waits. + */ +import { describe, test } from 'vitest' +import { countMounts, mountsOf, openRouteHmrPage } from '../route-hmr-page' +import type { TestContext } from 'vitest' + +const inPlace = { reloaded: false, errors: [] } + +describe.concurrent('vite: React route components', { timeout: 60_000 }, () => { + /** + * Opens an app whose route file `file` holds `route('v1')`, waits until it + * shows `shows('v1')` (after navigating to `path`, when given), edits it + * to `route('v2')`, and asserts that the page shows `shows('v2')` in place + * and that no component `countMounts` counts was mounted anew. + */ + async function expectEditInPlace( + { + file, + files, + route, + shows, + path, + autoCodeSplitting, + }: { + file: string + files?: Record<string, string> + route: (version: string) => string + shows: (version: string) => string + path?: string + autoCodeSplitting: boolean + }, + { expect, onTestFinished }: TestContext, + ) { + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { ...files, [file]: route('v1') }, + ready: path ? /./ : shows('v1'), + }) + if (path) { + await app.evaluate( + `void window.__APP_ROUTER__.navigate({ to: '${path}' })`, + ) + await app.page.waitForText(shows('v1'), { selector: '#app' }) + } + const mounts = await mountsOf(app) + expect(Object.keys(mounts)).not.toEqual([]) + expect(await app.edit({ [file]: route('v2') }, shows('v2'))).toEqual( + inPlace, + ) + expect(await mountsOf(app)).toEqual(mounts) + } + + /** A route at `/` whose component is `component`, after `imports`. */ + const inlineRoute = + (component: (body: string) => string) => (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +export const Route = createFileRoute('/')({ + component: ${component(`{ + ${countMounts('page')} + return <p>inline ${version}</p> + }`)}, +}) +` + + // Source: ReactFreshBabelPlugin-test "registers top-level variable + // declarations with function expressions" and "... with arrow + // functions"; the former react-refresh-route-components "written inline + // as %s". An inline arrow function: route-hmr-browser.test.ts. + test.for( + [false, true].flatMap((autoCodeSplitting) => [ + { + name: 'an anonymous function expression', + autoCodeSplitting, + component: (body: string) => `function () ${body}`, + }, + { + name: 'a parenthesized arrow function', + autoCodeSplitting, + component: (body: string) => `(() => ${body})`, + }, + ]), + )( + 'written inline as $name: an edit shows in place without mounting it again (autoCodeSplitting: $autoCodeSplitting)', + async ({ autoCodeSplitting, component }, context: TestContext) => { + await expectEditInPlace( + { + file: 'routes/index.tsx', + route: inlineRoute(component), + shows: (version) => `inline ${version}`, + autoCodeSplitting, + }, + context, + ) + }, + ) + + // Every component option of a root route at once, each its own + // component: the edit shows each one's new code, and the root component + // keeps its state. The page is at a path no route matches, so the root's + // not-found component shows. Source: the former react-refresh-route + // -components "for every inline component option of a root route, under + // distinct names", "for every lowercase function component of a root + // route, under distinct names" (add-hmr snapshot fixture + // createRootRoute-lowercase-components) and "of a root route created with + // context type arguments" (createRootRouteWithContext-type-args). + test.for( + [false, true].flatMap((autoCodeSplitting) => [ + { + name: 'written inline', + autoCodeSplitting, + route: (version: string) => + `import { Outlet, createRootRoute } from '@tanstack/react-router' +import { useState } from 'react' +export const Route = createRootRoute({ + component: () => { + ${countMounts('root')} + return <div>root ${version} <Outlet /></div> + }, + pendingComponent: () => <p>pending ${version}</p>, + errorComponent: ({ error }) => <p>error ${version} {String(error)}</p>, + notFoundComponent: () => <p>not found ${version}</p>, + shellComponent: ({ children }) => <div>shell ${version} {children}</div>, +}) +`, + }, + { + name: 'declared as lowercase functions', + autoCodeSplitting, + route: (version: string) => + `import { Outlet, createRootRoute } from '@tanstack/react-router' +import type { ReactNode } from 'react' +import { useState } from 'react' +export const Route = createRootRoute({ + shellComponent: shellComponent, + pendingComponent: pendingComponent, + errorComponent: errorComponent, + notFoundComponent: notFoundComponent, + component: component, +}) +function shellComponent({ children }: { children: ReactNode }) { + return <div>shell ${version} {children}</div> +} +function pendingComponent() { + return <p>pending ${version}</p> +} +function errorComponent() { + return <p>error ${version}</p> +} +function notFoundComponent() { + return <p>not found ${version}</p> +} +function component() { + ${countMounts('root')} + return <div>root ${version} <Outlet /></div> +} +`, + }, + { + name: 'of a root route created with context type arguments', + autoCodeSplitting, + route: (version: string) => + `import { Outlet, createRootRouteWithContext } from '@tanstack/react-router' +import { useState } from 'react' +interface MyRouterContext { + auth?: boolean +} +export const Route = createRootRouteWithContext<MyRouterContext>()({ + component: () => { + ${countMounts('root')} + return <div>root ${version} <Outlet /></div> + }, + notFoundComponent: () => <p>not found ${version}</p>, + shellComponent: ({ children }) => <div>shell ${version} {children}</div>, +}) +`, + }, + ]), + )( + 'root route components $name: an edit shows each in place, and the root component keeps its state (autoCodeSplitting: $autoCodeSplitting)', + async ({ autoCodeSplitting, route }, context: TestContext) => { + await expectEditInPlace( + { + file: 'routes/__root.tsx', + files: { + 'routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => <p>index</p> }) +`, + }, + route, + path: '/missing', + shows: (version) => + `shell ${version} root ${version} not found ${version}`, + autoCodeSplitting, + }, + context, + ) + }, + ) + + // An edit that adds component options before an inline component shows + // in place. Whether the component keeps its state is free: adding sibling + // options next to an inline component may remount it (SPEC J3.2). Source: + // the former react-refresh-route-components "names hoisted components + // after their option, so adding options keeps the family" + // (ReactFreshIntegration-test "preserves state ..."). + test.for([false, true])( + 'an edit that adds component options before an inline component shows in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const route = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({${ + version === 'v1' + ? '' + : ` + pendingComponent: () => <p>pending</p>, + errorComponent: () => <p>error</p>,` + } + component: () => <p>page ${version}</p>, +}) +` + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route('v1') }, + ready: 'page v1', + }) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'page v2'), + ).toEqual(inPlace) + }, + ) + + /** + * A route at `/` whose inline component calls the custom hook + * `useCounter`, declared by `hook` (with `version`); the loader shares + * `format` with the hook. The component counts its mounts. + */ + const hookRoute = (hook: (version: string) => string) => (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { useMemo, useState } from 'react' +const format = (n: number) => 'n' + n +${hook(version)} +export const Route = createFileRoute('/')({ + loader: () => format(1), + component: () => { + ${countMounts('page')} + const count = useCounter() + return <p>page {count} {Route.useLoaderData()}</p> + }, +}) +` + + // A body edit of a custom hook that keeps its hook calls: React Refresh + // keeps the component that calls it. Source: the former + // react-refresh-route-components "with the hook signature of the + // component the user wrote, also in the split chunk" + // (ReactFreshBabelPlugin-test "includes custom hooks into the + // signatures"). + test.for([false, true])( + 'an edit of the body of a custom hook a component calls shows in place and keeps its state (autoCodeSplitting: %s)', + async (autoCodeSplitting: boolean, context: TestContext) => { + await expectEditInPlace( + { + file: 'routes/index.tsx', + route: hookRoute( + (version) => `function useCounter() { + const [count] = useState(0) + return format(count) + ' ${version}' +}`, + ), + shows: (version) => `page n0 ${version} n1`, + autoCodeSplitting, + }, + context, + ) + }, + ) + + // An edit that changes the hooks a custom hook calls: React Refresh must + // mount the component calling it anew (its state no longer matches its + // hooks); the edit shows without a reload and without errors (a component + // kept with mismatched hooks throws). Source: as above + // (ReactFreshIntegration-test "remounts on changed hook order" for custom + // hooks). + test.for([false, true])( + 'an edit that changes the hooks of a custom hook a component calls shows in place (autoCodeSplitting: %s)', + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const route = hookRoute((version) => + version === 'v1' + ? `function useCounter() { + const [count] = useState(0) + return format(count) + ' v1' +}` + : `function useCounter() { + const [count] = useState(0) + const doubled = useMemo(() => count * 2, [count]) + return format(doubled) + ' ${version}' +}`, + ) + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route('v1') }, + ready: 'page n0 v1 n1', + }) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'page n0 v2 n1'), + ).toEqual(inPlace) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-plugin.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-plugin.test.ts new file mode 100644 index 0000000000..066d6c5143 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-plugin.test.ts @@ -0,0 +1,317 @@ +/** + * Route HMR with the router plugin configured in its supported ways, and + * for the route files it recognises, as the developer sees it: a real dev + * server serves a file-based app to a real browser page, and the test edits + * its route files on disk (`route-hmr-page.ts`). What matters is what the + * page shows after the edit, not which code the plugin serves. + * + * Sources: the former route-hmr.test.ts "route HMR in a Vite dev server + * without automatic code splitting" (which looked for the hot API in the + * served code), code-splitter-route-options.test.ts "hot-update a root + * route created with ..." and code-splitter-plugin-pipeline.test.ts "a route + * created inside a function ... is hot-updated" (which ran the route HMR + * code against a modelled hot API), plugin-options.test.ts "makes routes + * accept hot updates through the bundler even when plugin.hmr.style is vite" + * (which scanned a build for the hot API). + */ +import { describe, it } from 'vitest' +import { + expectEditShownOrReportedFallback, + openRouteHmrPage, +} from '../route-hmr-page' +import type { TestContext } from 'vitest' +import type { RouteHmrPageOptions } from '../route-hmr-page' + +const timeout = 90_000 +const inPlace = { reloaded: false, errors: [] } + +/** + * A route file of `target` at `/` whose loader and component name the + * version of the file. + */ +const indexRoute = (target: 'react' | 'solid', version: string) => + `import { createFileRoute } from '@tanstack/${target}-router' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return <p>page ${version} {${target === 'solid' ? 'data()' : 'data'}}</p> +} +` + +/** `tsr.config.json` of an app of `target`, as the plugin reads it. */ +const tsrConfig = (target: 'react' | 'solid') => + JSON.stringify({ + target, + routesDirectory: './routes', + generatedRouteTree: './routeTree.gen.ts', + autoCodeSplitting: false, + }) + +// The router plugin, configured as the plugin's public API allows: each +// configuration serves route HMR, so an edit shows in place. +describe.concurrent('the router plugin configured with', () => { + const rows: Array<{ + name: string + target?: 'react' | 'solid' + options: Partial<RouteHmrPageOptions> + }> = [ + { + // Source: route-hmr.test.ts "works with plugin.hmr.style alone". + name: 'plugin.hmr.style alone (vite)', + options: { + pluginOptions: { + autoCodeSplitting: false, + plugin: { hmr: { style: 'vite' } }, + }, + }, + }, + { + // Source: route-hmr.test.ts "is limited to the environment + // plugin.vite.environmentName names" (the excluded environment: the + // pages/route-hmr.test.ts). + name: 'plugin.vite.environmentName naming the client (vite)', + options: { + pluginOptions: { + autoCodeSplitting: false, + plugin: { vite: { environmentName: 'client' } }, + }, + }, + }, + { + // Source: route-hmr.test.ts "takes plugin options given as a + // function". + name: 'its options given as a function (vite, solid)', + target: 'solid', + options: { + pluginOptions: { autoCodeSplitting: false }, + pluginOptionsAsFunction: true, + }, + }, + // Source: route-hmr.test.ts "compiles for the target of a + // tsr.config.json in the Vite root". + ...(['react', 'solid'] as const).map((target) => ({ + name: `no options, reading tsr.config.json (vite, ${target})`, + target, + options: { + pluginOptions: null, + files: { 'tsr.config.json': tsrConfig(target) }, + }, + })), + { + // The Rspack entry uses Rspack's hot API whatever `plugin.hmr.style` + // says (src/rspack.ts). Source: plugin-options.test.ts. + name: 'plugin.hmr.style: vite (rsbuild)', + options: { + bundler: 'rsbuild', + pluginOptions: { plugin: { hmr: { style: 'vite' } } }, + }, + }, + ] + + it.for(rows)( + '$name applies an edit of a route file in place', + { timeout }, + async ({ target = 'react', options }, { expect, onTestFinished }) => { + const app = await openRouteHmrPage({ + ...options, + target, + onTestFinished, + files: { + ...options.files, + 'routes/index.tsx': indexRoute(target, 'v1'), + }, + ready: 'page v1 data v1', + }) + expect( + await app.edit( + { 'routes/index.tsx': indexRoute(target, 'v2') }, + 'page v2 data v2', + ), + ).toEqual(inPlace) + }, + ) +}) + +// Source: utils.test.ts routeFactoryCallCodeFilter (type arguments and +// whitespace before the call); the former code-splitter-route-options +// "hot-update a root route created with ...". +describe.concurrent('vite: an edited root route created with', () => { + it.for([ + 'createRootRoute({', + 'createRootRoute ({', + 'createRootRouteWithContext()({', + 'createRootRouteWithContext<{ user: string }>()({', + 'createRootRouteWithContext <{ user: string }>()({', + ])( + '`%s` shows in place', + { timeout }, + async (call: string, { expect, onTestFinished }: TestContext) => { + const root = (version: string) => + `import { createRootRoute, createRootRouteWithContext } from '@tanstack/react-router' +export const Route = ${call} + loader: () => 'data ${version}', + component: () => <p>root ${version} {Route.useLoaderData()}</p>, +}) +` + const app = await openRouteHmrPage({ + onTestFinished, + files: { 'routes/__root.tsx': root('v1') }, + ready: 'root v1 data v1', + }) + expect( + await app.edit({ 'routes/__root.tsx': root('v2') }, 'root v2 data v2'), + ).toEqual(inPlace) + }, + ) +}) + +// A route the route file creates inside a function of the same file (a +// helper, an IIFE) is unsupported but user-fixable (SPEC J2.10, +// J2.8): it is either split like a module-scope route and +// hot-updated in place, or left unsplit with a warning naming the file +// (code-splitter-plugin-pipeline.test.ts). Either way, an edit shows its +// new loader data and component without errors: in place, or, when the +// compiler warns naming the route file through a real channel (the dev +// server's logger or console, or the page), possibly after a reload. A +// warning never excuses an edit that does not show (SPEC G10; +// `expectEditShownOrReportedFallback`). (A helper function +// without automatic code splitting keeps its old component silently: +// pinned in known-bugs-route-hmr.test.ts.) +describe.concurrent.each(['vite', 'rsbuild'] as const)( + '%s: an edit of a route created inside', + (bundler) => { + const factoryRoutes = { + helper: (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +function makeRoute() { + return createFileRoute('/')({ + loader: () => 'data ${version}', + component: () => <p>helper ${version} {Route.useLoaderData()}</p>, + }) +} +export const Route = makeRoute() +`, + iife: (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = (() => + createFileRoute('/')({ + loader: () => 'data ${version}', + component: () => <p>iife ${version} {Route.useLoaderData()}</p>, + }))() +`, + 'iife-module': (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +function Made() { + return <p>iife-module ${version} {Route.useLoaderData()}</p> +} +export const Route = (() => + createFileRoute('/')({ loader: () => 'data ${version}', component: Made }))() +`, + } + + it.for( + Object.keys(factoryRoutes) + .flatMap((shape) => + [true, false].map((autoCodeSplitting) => ({ + shape, + autoCodeSplitting, + })), + ) + .filter( + ({ shape, autoCodeSplitting }) => + shape !== 'helper' || autoCodeSplitting, + ), + )( + '$shape shows (autoCodeSplitting: $autoCodeSplitting)', + { timeout }, + async ({ shape, autoCodeSplitting }, { onTestFinished }: TestContext) => { + const route = factoryRoutes[shape as keyof typeof factoryRoutes] + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route('v1') }, + ready: `${shape} v1 data v1`, + }) + await expectEditShownOrReportedFallback( + app, + { 'routes/index.tsx': route('v2') }, + `${shape} v2 data v2`, + 'routes/index.tsx', + ) + }, + ) + }, +) + +// Route files the framework plugin gives no refresh boundary: a React route +// file without JSX (`.ts`), and a React app without `@vitejs/plugin-react` +// (Vite compiles the JSX itself). An edit shows its new code, after a hot +// update or a reload; whether in place: pinned in +// known-bugs-route-hmr.test.ts. +describe.concurrent('vite: an edit of', () => { + /** A root route rendering the loader data of the active matches. */ + const root = `import { createRootRoute, Outlet, useRouterState } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: () => { + const data = useRouterState({ + select: (state) => state.matches.map((match) => match.loaderData ?? '').join(''), + }) + return <p>root {data}<Outlet /></p> + }, +}) +` + const loaderRoute = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ loader: () => 'data ${version}' }) +` + + it.for([true, false])( + 'a route file without JSX (.ts) shows its new loader data (autoCodeSplitting: %s)', + { timeout }, + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { + 'routes/__root.tsx': root, + 'routes/index.ts': loaderRoute('v1'), + }, + ready: 'root data v1', + }) + const { errors } = await app.edit( + { 'routes/index.ts': loaderRoute('v2') }, + 'root data v2', + ) + expect(errors).toEqual([]) + }, + ) + + it.for([true, false])( + 'a route component in an app without @vitejs/plugin-react shows (autoCodeSplitting: %s)', + { timeout }, + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + onTestFinished, + frameworkPlugin: false, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': indexRoute('react', 'v1') }, + ready: 'page v1 data v1', + }) + const { errors } = await app.edit( + { 'routes/index.tsx': indexRoute('react', 'v2') }, + 'page v2 data v2', + ) + expect(errors).toEqual([]) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser-updates.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser-updates.test.ts new file mode 100644 index 0000000000..94597e559f --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser-updates.test.ts @@ -0,0 +1,566 @@ +/** + * What a route file edit does to the live router of a running app (SPEC + * J3.1, J3.3, G10), through real tools only (SPEC §8): a real + * dev server with the public router plugin and the framework's plugin, a + * real page running the dev server's own HMR client, and edits of route + * files on disk (`openRouteHmrPage`). The app keeps its own reference to the + * router it creates (`window.__app.router`, assigned in its `main.tsx`); + * the tests read the page and that router through public router APIs. + * + * These rows decide the concepts main's updater-entry controls + * (handle-route-update.test.ts, deleted) checked with explicit inputs: + * matching and resolving next to an edited parent or pathless + * layout, params parsing, the generated route state of the hot `Route` + * export, the lazy options the route tree gave a route, + * removed loaders and callbacks, loader races with an older refresh or an + * inactive preload, route context, and descendants of an edited parent; + * and an edit of a route the router the HMR code finds on the page does not + * have (a second router created after the app's; SPEC J3.11). + */ +import { describe, test } from 'vitest' +import { openRouteHmrPage } from '../route-hmr-page' +import type { RouteHmrPage } from '../route-hmr-page' +import type { TestContext } from 'vitest' + +const timeout = 60_000 +const inPlace = { reloaded: false, errors: [] } + +/** The app's entry: mounts the router and keeps the app's own reference. */ +const main = `import { createRoot } from 'react-dom/client' +import { RouterProvider, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__app = { router } +createRoot(document.getElementById('app')!).render(<RouterProvider router={router} />) +` + +const fileRoute = (id: string, body: string, extra = '') => + `import { createFileRoute, Outlet } from '@tanstack/react-router' +${extra} +export const Route = createFileRoute('${id}')({ +${body} +}) +` + +/** A route option adding `key` to the search of a location it resolves to. */ +const markSearch = (key: string) => + `search: { middlewares: [({ search, next }: any) => ({ ...next(search), ${key}: 1 })] },` + +const home = fileRoute('/', `component: () => <p>home</p>,`) + +/** + * Navigates the app's router (to a path, or a route template with + * `params`) and returns the route of the deepest match and the search keys + * of the location, once the page shows `shows`. + */ +async function visit( + app: RouteHmrPage, + to: string, + shows: string, + params?: Record<string, string>, +) { + const result = await app.evaluate<{ leaf: string; dest: Array<string> }>( + `(async () => { + const router = window.__app.router + await router.navigate(${JSON.stringify({ to, params })}) + return { + leaf: router.state.matches.at(-1)?.routeId, + dest: Object.keys(router.state.location.search).sort(), + } +})()`, + ) + await app.page.waitForText(shows, { selector: '#app' }) + return result +} + +/** Counters the app's routes keep on `window.__calls`. */ +const calls = (app: RouteHmrPage) => + app.evaluate<Record<string, number>>('window.__calls ?? {}') +const count = (name: string) => + `{ const calls = ((window as any).__calls ??= {}); calls.${name} = (calls.${name} ?? 0) + 1 }` + +describe.concurrent( + 'vite: an edit of a route the live router matches, refreshes or preloads', + () => { + test( + 'keeps matching and resolving routes next to an edited pathless layout or parent; a params.parse edit refreshes matching; the hot Route export keeps its generated route state', + { timeout }, + async ({ expect, onTestFinished }: TestContext) => { + const form = (version: string) => + fileRoute( + '/livestock/$farmId/medicine/_form', + `staticData: { version: '${version}' }, + component: () => <section>form ${version} <Outlet /></section>,`, + ) + const path = (version: string) => + fileRoute( + '/path', + `component: () => <div>path ${version} <Outlet /></div>,`, + ) + const item = (version: string, parse: string) => + fileRoute( + '/items/$itemId', + `params: { parse: ({ itemId }: { itemId: string }) => ${parse} }, + component: () => <p>item {Route.useParams().itemId} ${version}</p>,`, + ) + const thing = (version: string) => + fileRoute( + '/things/$thingId', + `loader: () => ({ + version: '${version}', + id: Route.id, + path: Route.path, + fullPath: Route.fullPath, + to: Route.to, + parent: (Route as any).parentRoute?.id, + }), + component: () => <p>thing {JSON.stringify(Route.useLoaderData())}</p>,`, + ) + const app = await openRouteHmrPage({ + onTestFinished, + files: { + 'main.tsx': main, + 'routes/index.tsx': home, + 'routes/livestock/$farmId/medicine.tsx': fileRoute( + '/livestock/$farmId/medicine', + `component: () => <div>medicine <Outlet /></div>,`, + ), + 'routes/livestock/$farmId/medicine/index.tsx': fileRoute( + '/livestock/$farmId/medicine/', + `${markSearch('index')} + component: () => <p>medicine index</p>,`, + ), + 'routes/livestock/$farmId/medicine/_form.tsx': form('v1'), + 'routes/livestock/$farmId/medicine/_form/new.tsx': fileRoute( + '/livestock/$farmId/medicine/_form/new', + `${markSearch('new')} + component: () => <p>medicine new</p>,`, + ), + 'routes/path.tsx': path('v1'), + 'routes/path/index.tsx': fileRoute( + '/path/', + `${markSearch('index')} + component: () => <p>path index</p>,`, + ), + 'routes/items/$itemId.tsx': item( + 'v1', + `/^\\d+$/.test(itemId) ? { itemId } : false`, + ), + 'routes/things/$thingId.tsx': thing('v1'), + }, + ready: 'home', + }) + + // An index route and the route under a pathless layout, by path and + // by route template, before and after the layout's edit + const index = { + leaf: '/livestock/$farmId/medicine/', + dest: ['index'], + } + const added = { + leaf: '/livestock/$farmId/medicine/_form/new', + dest: ['new'], + } + const medicine = async () => [ + await visit(app, '/livestock/1/medicine', 'medicine index'), + await visit(app, '/livestock/$farmId/medicine', 'medicine index', { + farmId: '1', + }), + await visit(app, '/livestock/$farmId/medicine/new', 'medicine new', { + farmId: '1', + }), + await visit(app, '/livestock/1/medicine/new', 'form v1 medicine new'), + ] + expect(await medicine()).toEqual([index, index, added, added]) + expect( + await app.edit( + { 'routes/livestock/$farmId/medicine/_form.tsx': form('v2') }, + 'form v2 medicine new', + ), + ).toEqual(inPlace) + expect( + await app.evaluate( + `window.__app.router.state.matches.find((match) => match.routeId === '/livestock/$farmId/medicine/_form')?.staticData`, + ), + ).toEqual({ version: 'v2' }) + const again = [ + await visit(app, '/livestock/1/medicine', 'medicine index'), + await visit(app, '/livestock/$farmId/medicine', 'medicine index', { + farmId: '1', + }), + await visit(app, '/livestock/$farmId/medicine/new', 'form v2', { + farmId: '1', + }), + await visit(app, '/livestock/1/medicine/new', 'form v2 medicine new'), + ] + expect(again).toEqual([index, index, added, added]) + + // An index route under its edited parent + const pathIndex = { leaf: '/path/', dest: ['index'] } + expect(await visit(app, '/path', 'path v1 path index')).toEqual( + pathIndex, + ) + expect( + await app.edit( + { 'routes/path.tsx': path('v2') }, + 'path v2 path index', + ), + ).toEqual(inPlace) + expect(await visit(app, '/', 'home')).toMatchObject({ leaf: '/' }) + expect(await visit(app, '/path', 'path v2 path index')).toEqual( + pathIndex, + ) + expect(await visit(app, '/path/', 'path v2 path index')).toEqual( + pathIndex, + ) + + // A params.parse edit: what the route matches follows the new parser + expect((await visit(app, '/items/1', 'item 1 v1')).leaf).toBe( + '/items/$itemId', + ) + expect((await visit(app, '/items/abc', 'Not Found')).leaf).not.toBe( + '/items/$itemId', + ) + await visit(app, '/items/1', 'item 1 v1') + expect( + await app.edit( + { 'routes/items/$itemId.tsx': item('v2', '({ itemId })') }, + 'item 1 v2', + ), + ).toEqual(inPlace) + expect((await visit(app, '/items/abc', 'item abc v2')).leaf).toBe( + '/items/$itemId', + ) + + // Code reading the hot module's Route export sees the route's + // generated place in the tree + const generated = { + id: '/things/$thingId', + path: 'things/$thingId', + fullPath: '/things/$thingId', + to: '/things/$thingId', + parent: '__root__', + } + await visit(app, '/things/7', 'thing') + expect( + JSON.parse((await app.page.text('#app')).replace(/^thing /, '')), + ).toEqual({ version: 'v1', ...generated }) + expect( + await app.edit( + { 'routes/things/$thingId.tsx': thing('v2') }, + '"version":"v2"', + ), + ).toEqual(inPlace) + expect( + JSON.parse((await app.page.text('#app')).replace(/^thing /, '')), + ).toEqual({ version: 'v2', ...generated }) + expect(app.loads()).toBe(1) + expect(app.page.errors).toEqual([]) + }, + ) + + test( + 'keeps the hot loader data when an older refresh settles later', + { timeout }, + async ({ expect, onTestFinished }: TestContext) => { + const root = (loader: string) => + `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ + loader: ${loader}, + component: () => <div>root {String(Route.useLoaderData())} <Outlet /></div>, +}) +` + const app = await openRouteHmrPage({ + onTestFinished, + files: { + 'main.tsx': main, + 'routes/__root.tsx': root(`() => { + ${count('old')} + const gate = (window as any).__gate + return gate ? gate.promise : 'initial' + }`), + 'routes/index.tsx': home, + }, + ready: 'root initial home', + }) + // An older refresh, still loading when the edit lands + await app.evaluate(`(() => { + let resolve + const promise = new Promise((done) => { resolve = done }) + window.__gate = { promise, resolve } + window.__refresh = window.__app.router.invalidate() +})()`) + await expect.poll(async () => (await calls(app)).old).toBe(2) + expect( + await app.edit( + { + 'routes/__root.tsx': root(`() => { + ${count('hot')} + return 'hot' + }`), + }, + 'root hot home', + ), + ).toEqual(inPlace) + await app.evaluate(`(async () => { + window.__gate.resolve('stale') + await window.__refresh +})()`) + expect(await app.page.text('#app')).toBe('root hot home') + // The old loader does not run again; the hot one runs at least once + // (how often an edit runs a changed loader is the router's business, + // SPEC J3.1) + const { old, hot } = await calls(app) + expect({ old, hot: hot! >= 1 }).toEqual({ old: 2, hot: true }) + expect( + await app.evaluate( + `window.__app.router.state.matches.map((match) => [match.routeId, match.loaderData ?? null])`, + ), + ).toEqual([ + ['__root__', 'hot'], + ['/', null], + ]) + expect(app.loads()).toBe(1) + }, + ) + + test( + 'does not cache an obsolete inactive preload, nor run removed loader or beforeLoad callbacks on a later visit', + { timeout }, + async ({ expect, onTestFinished }: TestContext) => { + const pre = (loader: string) => + fileRoute( + '/pre', + `loader: ${loader}, + preloadStaleTime: Infinity, + component: () => <p>pre {String(Route.useLoaderData())}</p>,`, + ) + const gone = (callbacks: boolean) => + fileRoute( + '/gone', + `${ + callbacks + ? `beforeLoad: () => { ${count('beforeLoad')}; return { hotBeforeLoad: true } }, + loader: () => { ${count('loader')}; return 'hot loader data' },` + : '' + } + staleTime: Infinity, + gcTime: Infinity, + component: () => <p>gone {String(Route.useLoaderData())} {String((Route.useRouteContext() as any).hotBeforeLoad)}</p>,`, + ) + const app = await openRouteHmrPage({ + onTestFinished, + files: { + 'main.tsx': main, + 'routes/index.tsx': home, + 'routes/other.tsx': fileRoute( + '/other', + `component: () => <p>other</p>,`, + ), + 'routes/pre.tsx': pre(`() => { + ${count('preOld')} + return (window as any).__preGate.promise + }`), + 'routes/gone.tsx': gone(true), + }, + ready: 'home', + }) + + // An inactive preload still loading when the edit lands + await app.evaluate(`(() => { + let resolve + const promise = new Promise((done) => { resolve = done }) + window.__preGate = { promise, resolve } + window.__preload = window.__app.router.preloadRoute({ to: '/pre' }) +})()`) + await expect.poll(async () => (await calls(app)).preOld).toBe(1) + expect( + await app.edit( + { + 'routes/pre.tsx': pre(`() => { + ${count('preNew')} + return 'hot' + }`), + }, + 'home', + ), + ).toEqual(inPlace) + await app.evaluate(`(async () => { + window.__preGate.resolve('obsolete') + await window.__preload +})()`) + await visit(app, '/pre', 'pre hot') + // The obsolete loader does not run again; the new one runs at least + // once (SPEC J3.1: not exactly once) + const { preOld, preNew } = await calls(app) + expect({ preOld, preNew: preNew! >= 1 }).toEqual({ + preOld: 1, + preNew: true, + }) + + // Callbacks an edit removes from a route the router cached + await visit(app, '/gone', 'gone hot loader data true') + await visit(app, '/other', 'other') + expect(await calls(app)).toMatchObject({ beforeLoad: 1, loader: 1 }) + expect( + await app.edit({ 'routes/gone.tsx': gone(false) }, 'other'), + ).toEqual(inPlace) + await visit(app, '/gone', 'gone undefined undefined') + expect(await calls(app)).toMatchObject({ beforeLoad: 1, loader: 1 }) + expect( + await app.evaluate(`(() => { + const match = window.__app.router.state.matches.find((match) => match.routeId === '/gone') + return { loaderData: match?.loaderData ?? null, hotBeforeLoad: 'hotBeforeLoad' in (match?.context ?? {}) } +})()`), + ).toEqual({ loaderData: null, hotBeforeLoad: false }) + expect(app.loads()).toBe(1) + expect(app.page.errors).toEqual([]) + }, + ) + }, +) + +describe.concurrent.each(['vite', 'rsbuild'] as const)( + '%s: an edit applied to the live router', + (bundler) => { + test( + 'keeps the lazy options the route tree gave the route, removes a removed loader, and applies parser, context and parent edits to the active matches', + { timeout }, + async ({ expect, onTestFinished }: TestContext) => { + const items = (version: string) => + fileRoute('/items/$id', `loader: () => 'data ${version}',`) + const hot = (loader: boolean) => + fileRoute( + '/hot', + `${loader ? `loader: () => 'stale loader data',` : ''} + component: () => <p>hot {String(Route.useLoaderData() ?? 'no data')}</p>,`, + ) + const ctx = (version: string) => + fileRoute( + '/ctx/$itemId', + `params: { parse: ({ itemId }: { itemId: string }) => ({ itemId, parser: '${version}' }) }, + context: () => ({ source: '${version}' }), + component: () => { + const params: any = Route.useParams() + const context: any = Route.useRouteContext() + return <p>ctx {params.itemId} {params.parser} {context.source}</p> + },`, + ) + const parent = (version: string) => + fileRoute( + '/parent', + `context: () => ({ source: '${version}' }), + component: () => <div>parent <Outlet /></div>,`, + ) + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + files: { + 'main.tsx': main, + 'routes/index.tsx': home, + 'routes/items.$id.tsx': items('v1'), + 'routes/items.$id.lazy.tsx': `import { createLazyFileRoute } from '@tanstack/react-router' + export const Route = createLazyFileRoute('/items/$id')({ + component: () => <p>lazy {String(Route.useLoaderData())}</p>, + }) + `, + 'routes/hot.tsx': hot(true), + 'routes/ctx/$itemId.tsx': ctx('old'), + 'routes/parent.tsx': parent('old'), + 'routes/parent/child.tsx': fileRoute( + '/parent/child', + `context: ({ context }: any) => ({ inheritedSource: context.source }), + component: () => <p>child {String((Route.useRouteContext() as any).inheritedSource)}</p>,`, + ), + }, + ready: 'home', + }) + + // The edited route file has no lazy options; the route keeps the ones + // the route tree gave it (its `.lazy.tsx` component) + await visit(app, '/items/1', 'lazy data v1') + expect( + await app.edit( + { 'routes/items.$id.tsx': items('v2') }, + 'lazy data v2', + ), + ).toEqual(inPlace) + await visit(app, '/items/2', 'lazy data v2') + expect(await app.page.text('#app')).toBe('lazy data v2') + + // A loader the edit removes: its stale data goes + await visit(app, '/hot', 'hot stale loader data') + expect( + await app.edit({ 'routes/hot.tsx': hot(false) }, 'hot no data'), + ).toEqual(inPlace) + expect( + await app.evaluate( + `window.__app.router.state.matches.map((match) => [match.routeId, match.loaderData ?? null])`, + ), + ).toEqual([ + ['__root__', null], + ['/hot', null], + ]) + + // Parser and route-context edits on the active route + await visit(app, '/ctx/abc', 'ctx abc old old') + expect( + await app.edit( + { 'routes/ctx/$itemId.tsx': ctx('new') }, + 'ctx abc new new', + ), + ).toEqual(inPlace) + + // A parent's edit reaches the context its active child derives + await visit(app, '/parent/child', 'parent child old') + expect( + await app.edit( + { 'routes/parent.tsx': parent('new') }, + 'parent child new', + ), + ).toEqual(inPlace) + expect(app.loads()).toBe(1) + expect(app.page.errors).toEqual([]) + }, + ) + + // The route HMR code updates the router it finds on the page: with a + // second router created after the app's, the hot update is for a route + // that router does not have. The app keeps working. + test( + "an edit while the page has a second router created after the app's keeps the app working", + { timeout }, + async ({ expect, onTestFinished }: TestContext) => { + const page = (version: string) => + fileRoute('/', `component: () => <p>home ${version}</p>,`) + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + files: { + 'main.tsx': `import { createRoot } from 'react-dom/client' +import { RouterProvider, createRootRoute, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__app = { router } +createRoot(document.getElementById('app')!).render(<RouterProvider router={router} />) +// A second router of the page (e.g. an embedded widget's, code-based) +createRouter({ routeTree: createRootRoute() }) +`, + 'routes/index.tsx': page('v1'), + 'routes/other.tsx': fileRoute( + '/other', + `component: () => <p>other</p>,`, + ), + }, + ready: 'home v1', + }) + expect( + await app.edit({ 'routes/index.tsx': page('v2') }, 'home v2'), + ).toEqual(inPlace) + await visit(app, '/other', 'other') + expect(app.loads()).toBe(1) + expect(app.page.errors).toEqual([]) + }, + ) + }, +) diff --git a/packages/router-plugin/tests/integration/route-hmr-browser.test.ts b/packages/router-plugin/tests/integration/route-hmr-browser.test.ts new file mode 100644 index 0000000000..e0aed61598 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-browser.test.ts @@ -0,0 +1,645 @@ +/** + * Route HMR as the developer sees it: a real dev server (Vite with the + * framework's Vite plugin, or Rsbuild with `@rsbuild/plugin-react`) serves a + * file-based app with the real router package to a real browser page, and + * the test edits its route files on disk (`route-hmr-page.ts`). An edit must + * show its new code; where a hot update is feasible, without a full reload, + * keeping the state of the components React Refresh patches in place, and + * without errors in the page. + * + * Solid and Vue apps: route-hmr-browser-frameworks.test.ts. The router + * plugin's configurations and the route shapes it recognises: + * route-hmr-browser-plugin.test.ts. Known bugs: known-bugs-route-hmr.test.ts. + * + * Several edits share one dev server and page. The tests run concurrently + * (each has its own dev server and page; most of their time is waiting). + */ +import { describe, it } from 'vitest' +import { isAppError, openRouteHmrPage } from '../route-hmr-page' +import type { TestContext } from 'vitest' +import type { EditResult, RouteHmrPage } from '../route-hmr-page' + +const timeout = 90_000 + +/** + * A React route file creating the route at `path` with `options`, after + * `declarations` (it imports `createFileRoute` and `notFound` of the router + * package, and React's `useState`). + */ +const fileRoute = ( + path: string, + declarations: string, + options: string, +) => `import { createFileRoute, notFound } from '@tanstack/react-router' +import { useState } from 'react' +${declarations} +export const Route = createFileRoute('${path}')({ + ${options} +}) +` + +/** + * A component named `name` whose button counts its clicks and names the + * version of the route file: `<name> <version> count <clicks>`. + */ +const counter = (name: string, version: string) => `function ${name}() { + const [count, setCount] = useState(0) + return <button onClick={() => setCount(count + 1)}>${name} ${version} count {count}</button> +}` + +/** + * Route files at `/<path>` whose component keeps a click count: each is a + * function of the version its component and loader show. Sources: add-hmr + * snapshot fixtures arrow-function, function-declaration, multi-component + * and string-literal-keys; the split loader rows replace + * react-refresh-route-components "does not keep a split loader in the HMR + * data"; "user bindings" is the former react-refresh-route-components + * "route HMR code next to user bindings with common names" (the route HMR + * code declares `hotData` and `handleRouteUpdate` of its own). + */ +const statefulRoutes: Array<{ + name: string + path: string + route: (version: string) => string + shows: (version: string) => string + /** The route's loader is split from the route module. */ + splitLoader?: boolean +}> = [ + { + name: 'an arrow function component', + path: 'arrow', + route: (v) => + fileRoute( + '/arrow', + `const Page = () => { + const [count, setCount] = useState(0) + return <button onClick={() => setCount(count + 1)}>arrow ${v} count {count}</button> +}`, + 'component: Page,', + ), + shows: (v) => `arrow ${v} count`, + }, + { + name: 'two components', + path: 'two', + route: (v) => + fileRoute( + '/two', + `${counter('Two', v)} +function Failed() { + return <p>failed ${v}</p> +}`, + 'component: Two,\n errorComponent: Failed,', + ), + shows: (v) => `Two ${v} count`, + }, + { + name: 'components under quoted keys', + path: 'quoted', + route: (v) => + fileRoute( + '/quoted', + `${counter('Quoted', v)} +function Failed() { + return <p>failed ${v}</p> +}`, + `'component': Quoted,\n 'errorComponent': Failed,`, + ), + shows: (v) => `Quoted ${v} count`, + }, + { + name: 'a loader in its own chunk', + path: 'loader-chunk', + route: (v) => + fileRoute( + '/loader-chunk', + `function LoaderChunk() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>{data} count {count}</button> +}`, + `loader: () => 'own chunk ${v}', + component: LoaderChunk, + codeSplitGroupings: [['loader'], ['component']],`, + ), + shows: (v) => `own chunk ${v} count`, + splitLoader: true, + }, + { + name: 'a loader in the component chunk', + path: 'shared-chunk', + route: (v) => + fileRoute( + '/shared-chunk', + `function SharedChunk() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>{data} count {count}</button> +}`, + `loader: () => 'component chunk ${v}', + component: SharedChunk, + codeSplitGroupings: [['component', 'loader']],`, + ), + shows: (v) => `component chunk ${v} count`, + splitLoader: true, + }, + { + name: 'a value the loader and the component share', + path: 'shared-value', + route: (v) => + fileRoute( + '/shared-value', + `const label = 'label ${v}' +function SharedValue() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>{label} {data} count {count}</button> +}`, + `loader: () => label, + component: SharedValue,`, + ), + shows: (v) => `label ${v} label ${v} count`, + }, + { + name: 'user bindings named like the route HMR code', + path: 'names', + route: (v) => + fileRoute( + '/names', + `const hotData = 'data ${v}' +function handleRouteUpdate() { + return 'update ${v}' +} +function Names() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>{data} {handleRouteUpdate()} count {count}</button> +}`, + `loader: () => hotData, + component: Names,`, + ), + shows: (v) => `data ${v} update ${v} count`, + }, +] + +/** The index route: a component reading the live route, and its loader. */ +const indexRoute = (version: string, hooks = '') => + fileRoute( + '/', + `function Page() { + const [count, setCount] = useState(0) + ${hooks} + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>page ${version} {data} {Route.fullPath} count {count}</button> +}`, + `loader: () => 'data ${version}', + component: Page,`, + ) + +/** The index route with other component options and a loader. */ +const indexRouteWith = (version: string, options: string, loader: string) => + fileRoute( + '/', + `${counter('Page', version)} +function Failed() { + return <p>failed ${version}</p> +} +function Pending() { + return <p>pending ${version}</p> +} +function Missing() { + return <p>missing ${version}</p> +}`, + `loader: ${loader}, + component: Page, + ${options}`, + ) + +/** Navigates the app's router (client side: the page does not reload). */ +async function navigate(app: RouteHmrPage, to: string) { + await app.evaluate(`window.__APP_ROUTER__.navigate({ to: '${to}' })`) +} + +/** Clicks the counter until the page shows `count <n>`. */ +async function click(app: RouteHmrPage, shows: string, count: number) { + await app.click('button') + await app.page.waitForText(`${shows} ${count}`, { selector: '#app' }) +} + +/** + * A hot update with no error the app did not cause itself: the errors of + * an edit without the ones mentioning `expected` (what the app's own code + * threw on purpose, which React and the router report). + */ +function hot(result: EditResult, ...expected: Array<string>) { + return { + reloaded: result.reloaded, + errors: result.errors.filter( + (error) => !expected.some((message) => isAppError(error, message)), + ), + } +} + +const inPlace = { reloaded: false, errors: [] } + +describe.concurrent.each(['vite', 'rsbuild'] as const)( + '%s: a React app', + (bundler) => { + // Sources: the former route-hmr.test.ts hot updates of split and unsplit + // routes (add-hmr snapshot fixtures), the former regression-helpers.test.ts + // React Refresh controls (body edit keeps state, added hook remounts). + describe.each([true, false])( + 'with autoCodeSplitting: %s', + (autoCodeSplitting) => { + it( + 'shows an edited route component in place with its state, the options the edit adds, changes or removes, and remounts a component whose hooks changed', + async ({ expect, onTestFinished }) => { + const files: Record<string, string> = { + 'routes/index.tsx': indexRoute('v1'), + } + for (const { path, route } of statefulRoutes) { + files[`routes/${path}.tsx`] = route('v1') + } + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files, + ready: 'page v1 data v1 / count 0', + }) + await click(app, 'page v1 data v1 / count', 1) + // The loader of some versions throws on purpose; React and the + // router report it. + const edit = async ( + files: Record<string, string>, + expected: string | RegExp, + ) => hot(await app.edit(files, expected), 'loader failed') + // The new body, the new loader's data and the live route (`Route`) + // show; the component keeps its state. + expect( + await edit( + { 'routes/index.tsx': indexRoute('v2') }, + 'page v2 data v2 / count 1', + ), + ).toEqual(inPlace) + // A component whose hooks changed loses its state (React remounts + // it), as in any React app. + expect( + await edit( + { + 'routes/index.tsx': indexRoute( + 'v3', + `const [other] = useState('other')`, + ), + }, + 'page v3 data v3 / count 0', + ), + ).toEqual(inPlace) + + // Component options the edit adds or changes (removing one the + // page loaded: last). + const failing = `() => { + throw new Error('loader failed') + }` + const withError = 'errorComponent: Failed,' + for (const version of ['v4', 'v5']) { + expect( + await edit( + { + 'routes/index.tsx': indexRouteWith( + version, + withError, + failing, + ), + }, + `failed ${version}`, + ), + ).toEqual(inPlace) + } + const withPending = `${withError} + pendingComponent: Pending, + pendingMs: 0, + pendingMinMs: 0,` + for (const version of ['v6', 'v7']) { + expect( + await edit( + { + 'routes/index.tsx': indexRouteWith( + version, + withPending, + `() => new Promise(() => {})`, + ), + }, + `pending ${version}`, + ), + ).toEqual(inPlace) + } + const withNotFound = `${withPending} + notFoundComponent: Missing,` + for (const version of ['v8', 'v9']) { + expect( + await edit( + { + 'routes/index.tsx': indexRouteWith( + version, + withNotFound, + `() => { + throw notFound() + }`, + ), + }, + `missing ${version}`, + ), + ).toEqual(inPlace) + } + + // Other shapes of route files. (A loader split from the route + // module on Rsbuild: pinned in known-bugs-route-hmr.test.ts.) + for (const { + name, + path, + route, + shows, + splitLoader, + } of statefulRoutes) { + if (bundler === 'rsbuild' && autoCodeSplitting && splitLoader) { + continue + } + await navigate(app, `/${path}`) + await app.page.waitForText(`${shows('v1')} 0`, { + selector: '#app', + }) + await click(app, shows('v1'), 1) + expect( + await edit( + { [`routes/${path}.tsx`]: route('v2') }, + `${shows('v2')} 1`, + ), + name, + ).toEqual(inPlace) + } + + // An edit that removes the component options the page loaded: the + // route shows the router's default error component. Whether in + // place and without errors: pinned in known-bugs-route-hmr.test.ts + // ("removes a split option the page loaded"), per bundler and + // split setting. Last, as the pinned failure may reload the page + // later. + await navigate(app, '/') + await app.page.waitForText('missing v9', { selector: '#app' }) + await edit( + { 'routes/index.tsx': indexRouteWith('v10', '', failing) }, + /^(?!.*failed v).*loader failed/, + ) + }, + timeout, + ) + }, + ) + + // Source: SPEC J3.5 (shellComponent and HMR), the add-hmr snapshot + // fixture createRootRoute, and SPEC J3.3, G10 for routes whose options a + // factory call builds (a reload is fine, the edit must show). + it( + 'shows an edited root route in place, and the shell component the edit adds, changes or removes; an edit of a route whose options a factory call builds shows', + async ({ expect, onTestFinished }) => { + const root = (version: string, shell = '') => + `import { createRootRoute, Outlet } from '@tanstack/react-router' +import { useState } from 'react' +function Root() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return ( + <div> + <button onClick={() => setCount(count + 1)}>root ${version} {data} count {count}</button> + <Outlet /> + </div> + ) +} +export const Route = createRootRoute({ + loader: () => 'data ${version}', + component: Root,${ + shell && + ` + shellComponent: ({ children }) => ( + <div> + <p>shell ${shell}</p> + {children} + </div> + ),` + } +}) +` + const factoryRoute = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { makeOptions } from './-options' +export const Route = createFileRoute('/')(makeOptions('${version}')) +` + const app = await openRouteHmrPage({ + bundler, + onTestFinished, + files: { + 'routes/__root.tsx': root('v1'), + 'routes/-options.tsx': `export const makeOptions = (version: string) => ({ + component: () => <p>made {version}</p>, +}) +`, + 'routes/index.tsx': factoryRoute('v1'), + }, + ready: 'root v1 data v1 count 0made v1', + }) + await click(app, 'root v1 data v1 count', 1) + expect( + await app.edit( + { 'routes/__root.tsx': root('v2') }, + 'root v2 data v2 count 1', + ), + ).toEqual(inPlace) + // A shell changes the tree the route renders in: adding or removing it + // may remount the route's component; editing it patches both in place. + expect( + await app.edit( + { 'routes/__root.tsx': root('v3', 'v3') }, + /shell v3root v3 data v3 count \d+made v1/, + ), + ).toEqual(inPlace) + await click(app, 'root v3 data v3 count', 1) + expect( + await app.edit( + { 'routes/__root.tsx': root('v4', 'v4') }, + 'shell v4root v4 data v4 count 1made v1', + ), + ).toEqual(inPlace) + expect( + await app.edit( + { 'routes/__root.tsx': root('v5') }, + /^root v5 data v5 count \d+made v1$/, + ), + ).toEqual(inPlace) + // Route options a factory call builds: the edit shows, after a hot + // update or a reload (SPEC J3.3, G10). + await app.edit({ 'routes/index.tsx': factoryRoute('v2') }, 'made v2') + }, + timeout, + ) + }, +) + +// A React route module stays an HMR boundary of React Refresh in Vite +// (`@vitejs/plugin-react` reloads the page when a module it compiled +// exports anything but components, beyond the exports the route HMR code +// has it ignore), also without a component of its own or as the root route. +// Sources: react-refresh-route-components "a React route module compiled +// for Vite stays a Fast Refresh boundary" (it called the refresh runtime's +// boundary check by hand; now real tools only, SPEC §8). +describe.concurrent( + 'vite: a React route module without a component, and a root route with an inline component', + () => { + it.for([true, false])( + 'apply their edits in place (autoCodeSplitting: %s)', + { timeout }, + async ( + autoCodeSplitting: boolean, + { expect, onTestFinished }: TestContext, + ) => { + const root = (version: string) => + `import { createRootRoute, Outlet, useRouterState } from '@tanstack/react-router' +import { useState } from 'react' +export const Route = createRootRoute({ + component: () => { + const [count, setCount] = useState(0) + const data = useRouterState({ + select: (state) => state.matches.map((match) => match.loaderData ?? '').join(''), + }) + return ( + <div> + <button onClick={() => setCount(count + 1)}>root ${version} {data} count {count}</button> + <Outlet /> + </div> + ) + }, +}) +` + const index = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + loader: () => 'index ${version}', + component: undefined, +}) +` + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { + 'routes/__root.tsx': root('v1'), + 'routes/index.tsx': index('v1'), + }, + ready: 'root v1 index v1 count 0', + }) + await click(app, 'root v1 index v1 count', 1) + expect( + await app.edit( + { 'routes/index.tsx': index('v2') }, + 'root v1 index v2 count 1', + ), + ).toEqual(inPlace) + expect( + await app.edit( + { 'routes/__root.tsx': root('v2') }, + 'root v2 index v2 count 1', + ), + ).toEqual(inPlace) + }, + ) + }, +) + +// React Refresh patches route components that are not plain declarations +// in place, without mounting them again. Sources: +// react-refresh-route-components "React Refresh registers split route +// components" (ReactFreshBabelPlugin-test "registers likely HOCs with +// inline functions"; #8504 "written inline in a memo / forwardRef call"), +// which read React Refresh's registrations and modelled how its runtime +// resolves memo / forwardRef (now real tools only, SPEC §8); the former +// known-bugs-route-hmr "an edit of a React route with only inline components +// is a hot update" (the route HMR plugin runs before React +// Refresh, so a route whose components are all inline still becomes a +// boundary). The split bodies have no JSX: with JSX, the code splitter +// cannot split the call (pinned in known-bugs-code-splitter.test.ts "a +// component written as memo of an inline arrow is split and renders"). +// Each component counts its mounts in a state initializer (React runs it on +// mount only; React Refresh keeps the state and re-runs effects): a body +// edit React Refresh patches in place mounts nothing anew. Unsplit inline memo / forwardRef +// components: pinned in known-bugs-route-hmr-components.test.ts. +describe.concurrent('vite: an edited React route component written', () => { + const mounted = `useState(() => (window.mounts = (window.mounts ?? 0) + 1))` + const rows = [ + { + name: 'inline in a memo call, split', + autoCodeSplitting: true, + route: (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { memo, useState } from 'react' +export const Route = createFileRoute('/')({ + component: memo(() => { + ${mounted} + return 'inline ${version}' + }), +}) +`, + shows: (version: string) => `inline ${version}`, + }, + { + name: 'inline in a forwardRef call, split', + autoCodeSplitting: true, + route: (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { forwardRef, useState } from 'react' +export const Route = createFileRoute('/')({ + component: forwardRef(function (props, ref) { + ${mounted} + return 'inline ${version}' + }), +}) +`, + shows: (version: string) => `inline ${version}`, + }, + { + name: 'as an inline arrow function, unsplit', + autoCodeSplitting: false, + route: (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: () => { + ${mounted} + return <p>inline ${version} {Route.useLoaderData()}</p> + }, +}) +`, + shows: (version: string) => `inline ${version} data ${version}`, + }, + ] + it.for(rows)( + '$name shows in place without mounting again', + { timeout }, + async ( + { autoCodeSplitting, route, shows }, + { expect, onTestFinished }: TestContext, + ) => { + const app = await openRouteHmrPage({ + onTestFinished, + pluginOptions: { autoCodeSplitting }, + files: { 'routes/index.tsx': route('v1') }, + ready: shows('v1'), + }) + const mounts = await app.evaluate<number>('window.mounts') + expect(mounts).toBeGreaterThan(0) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, shows('v2')), + ).toEqual(inPlace) + expect(await app.evaluate<number>('window.mounts')).toBe(mounts) + }, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-dev-addhmr-off.test.ts b/packages/router-plugin/tests/integration/route-hmr-dev-addhmr-off.test.ts new file mode 100644 index 0000000000..48cbb433f6 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-dev-addhmr-off.test.ts @@ -0,0 +1,237 @@ +/** + * A dev server compiling with `addHmr: false` applies no route HMR (SPEC + * J3.7: with `addHmr: false` no HMR code in any output): an edit of the + * route file, while a page has the route module and its split modules + * loaded, is not applied in place by route HMR code: nothing in the route's + * modules accepts the update, so the dev server's HMR client reloads the + * page. Whatever the compiler emits, and however it names it. + * The control: with `addHmr: true` the same edit applies in place. + * + * The route app of `../route-app.ts` (the public router plugin and the + * framework's plugin in a real Vite dev server), with a page of its own + * that stays open across the edit (`openPage`), with the real Vite client. + * Source: the add-hmr `@false` snapshots (every fixture compiled with + * `addHmr: false`). Production bundles of these routes: + * build-production*.test.ts. + * + * The router plugin's Rspack entry on an Rsbuild dev server (webpack's hot + * API, `route-hmr-page.ts`): the same outcome, decided the same way (the + * page reloads instead of applying the edit in place); its control is the + * Rsbuild row of route-hmr-browser-plugin.test.ts (with route HMR the edit + * applies in place). + */ +import { describe, expect, it, onTestFinished } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { + hmrSyncInitScript, + hmrSyncModule, + settlePage, + trackRequests, +} from '@tanstack/compiler-test-utils/hmr-sync' +import { entryFile, loadRoute, probeFile } from '../route-app' +import { routeShapes } from '../production-bundle' +import { openRouteHmrPage } from '../route-hmr-page' +import { openWebpackHmrPage } from '../webpack-hmr-page' +import type { TargetFramework } from '../route-app' + +const timeout = 60_000 + +const routes = routeShapes + +/** + * Loads the route app with `addHmr`, opens a page of its dev server with a + * live router over the generated route tree (every route option's module + * loaded), edits the route file to add an option (`staticData`), and + * returns, once the page took in and handled everything the dev server sent + * for the edit (`settlePage`: the update applied, or the reload done), + * whether the page reloaded and whether the live router's route got the new + * option in place. No time bound decides the outcome: a slow update is + * waited for. + */ +async function editWhileLoaded( + route: string, + options: { targetFramework?: TargetFramework; hmr: boolean }, +) { + const app = await loadRoute(route, { + targetFramework: options.targetFramework, + hmr: options.hmr, + fresh: true, + files: { 'hmr-sync.ts': hmrSyncModule }, + }) + const page = await openPage( + new URL('/__plugin-host__/page.html', app.host.dev.url).href, + { + registerCleanup: onTestFinished, + initScript: hmrSyncInitScript('/hmr-sync.ts'), + }, + ) + const inFlight = trackRequests(page) + await page.page.evaluate(`(async () => { + const probe = await import('/${probeFile}') + const entry = await import('/${entryFile}') + const { Route } = entry.route + for (const option of ['component', 'errorComponent', 'pendingComponent', 'notFoundComponent', 'loader']) { + await probe.trigger(Route, option) + } + const { routeTree } = await import('/routeTree.gen.ts') + window.__router = probe.createRouter({ + routeTree, + history: probe.createMemoryHistory({ initialEntries: ['/'] }), + }) + await window.__router.load() +})()`) + const edited = route.replace('({', '({ staticData: { edited: true },') + expect(edited).not.toBe(route) + // The page imported the sync module (it holds a first token) + await settlePage(app.host.dev, page, inFlight) + const consoleBefore = page.console.length + await app.host.edit({ 'route.tsx': edited }) + await settlePage(app.host.dev, page, inFlight) + const editedInPlace = () => + page.page.evaluate<boolean>( + `Object.values(window.__router?.routesById ?? {}).some((route) => route.options.staticData?.edited === true)`, + ) + const reloaded = page.loads() > 1 + const inPlace = !reloaded && (await editedInPlace()) + // Shown: a reload, the edit in the live route, or Vite's client reporting + // the update applied (e.g. by the framework's own refresh of the split + // component) + const shown = + reloaded || + inPlace || + page.console + .slice(consoleBefore) + .some((line) => line.includes('[vite] hot updated')) + return { shown, reloaded, inPlace, page, app } +} + +describe('a dev server with addHmr: false', () => { + it.each(routes)( + 'applies no route HMR to an edit ($name)', + async ({ route, targetFramework }) => { + const { shown, inPlace, page, app } = await editWhileLoaded(route, { + targetFramework, + hmr: false, + }) + // Reloaded, or updated by the framework's own refresh: the live route + // never gets the edited options in place + expect(shown, 'the edit showed (a reload or a refresh)').toBe(true) + expect( + inPlace, + [ + ...page.console, + JSON.stringify( + app.host.dev.hmr.map((message) => [message.type, message.paths]), + ), + ].join('\n'), + ).toBe(false) + }, + timeout, + ) +}) + +// Control of the observation: the same edit, compiled with route HMR, +// applies in place (the live route gets the new option, no reload). +it( + 'a dev server with addHmr: true applies the same edit in place (a split route)', + async () => { + const { shown, reloaded, inPlace } = await editWhileLoaded( + routes[0]!.route, + { hmr: true }, + ) + expect({ shown, reloaded, inPlace }).toEqual({ + shown: true, + reloaded: false, + inPlace: true, + }) + }, + timeout, +) + +// The Rspack entry with `addHmr: false` (an Rsbuild dev server with the +// framework's React Refresh): no route module accepts the edit, so the page +// reloads to show it; with route HMR it applies in place (control: +// route-hmr-browser-plugin.test.ts "plugin.hmr.style: vite (rsbuild)"). +// Source: plugin-options.test.ts "with addHmr: false, a development build +// with the HMR plugin has no route HMR code" (which looked for the hot API's +// accept call by a local name in the build). +it( + 'an Rsbuild dev server with addHmr: false applies no route HMR to an edit', + async () => { + const route = (version: string) => + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return <p>page ${version} {data}</p> +} +` + const app = await openRouteHmrPage({ + bundler: 'rsbuild', + pluginOptions: { codeSplittingOptions: { addHmr: false } }, + files: { 'routes/index.tsx': route('v1') }, + ready: 'page v1 data v1', + }) + expect( + await app.edit({ 'routes/index.tsx': route('v2') }, 'page v2 data v2'), + ).toEqual({ reloaded: true, errors: [] }) + }, + timeout, +) + +// The webpack entry with `addHmr: false` (webpack-dev-server with `hot: true`, +// as the webpack quickstart example runs it; no React Refresh): no route +// module accepts the edit, so webpack's HMR client reloads the page to show +// it. The control below: with route HMR the same edit applies in place. The +// edit changes the loader only: without a refresh runtime, route HMR keeps +// the old component (pinned in known-bugs-route-hmr-removals.test.ts "rsbuild +// without React Refresh"), so a component edit would not tell the two apart. +// Source: plugin-options.test.ts "with addHmr: false, a development build +// with the HMR plugin has no route HMR code" (which looked for the hot API's +// accept call by a local name in a webpack development build). +describe('a webpack dev server', () => { + const route = (version: string) => + `import { createElement } from 'react' +import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + loader: () => 'data ${version}', + component: Page, +}) +function Page() { + const data = Route.useLoaderData() + return createElement('p', null, 'page ', data) +} +` + + it( + 'with addHmr: false applies no route HMR to an edit', + async () => { + const app = await openWebpackHmrPage({ + pluginOptions: { codeSplittingOptions: { addHmr: false } }, + files: { 'routes/index.ts': route('v1') }, + ready: 'page data v1', + }) + expect( + await app.edit({ 'routes/index.ts': route('v2') }, 'page data v2'), + ).toEqual({ reloaded: true, errors: [] }) + }, + timeout, + ) + + it( + 'with route HMR applies the same edit in place', + async () => { + const app = await openWebpackHmrPage({ + files: { 'routes/index.ts': route('v1') }, + ready: 'page data v1', + }) + expect( + await app.edit({ 'routes/index.ts': route('v2') }, 'page data v2'), + ).toEqual({ reloaded: false, errors: [] }) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-rsbuild-hosts.test.ts b/packages/router-plugin/tests/integration/route-hmr-rsbuild-hosts.test.ts new file mode 100644 index 0000000000..71fed5ae4a --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-rsbuild-hosts.test.ts @@ -0,0 +1,214 @@ +/** + * Route modules compiled for the dev server evaluate and render where an + * Rsbuild dev server runs them (SPEC J3.8): a page with webpack's hot API + * (`import.meta.webpackHot`), a page of a dev server without HMR (no hot + * API, a `window`), and Rsbuild's server environment (no `window`). The + * Vite hosts of the same rows: route-hmr.test.ts "route modules compiled + * for the dev server"; webpack's hot API without a `window` (Rsbuild's + * server environment has no hot API): route-hmr-webpack-server-hosts.test.ts. + * + * The public Rsbuild plugin of React and the router plugin's Rspack entry, + * added as an Rsbuild app adds it, through Rsbuild's JavaScript API + * (`@tanstack/compiler-test-utils/rsbuild-plugin-host`); the router + * plugin's own generator registers the route (a virtual route config). The + * page runs in a run page of the test process; the server environment loads + * through Rsbuild's own `loadBundle`. + */ +import path from 'node:path' +import { pluginReact } from '@rsbuild/plugin-react' +import { describe, expect, it, onTestFinished } from 'vitest' +import { createRsbuildPluginHost } from '@tanstack/compiler-test-utils/rsbuild-plugin-host' +import { tanstackRouter } from '../../src/rspack' +import type { RsbuildConfig, RsbuildPlugin } from '@rsbuild/core' + +const timeout = 60_000 + +const posts = `function PostsComponent() { + return <div>posts data</div> +}` + +const routes = [ + { + name: 'a split route', + root: false, + route: `import { createFileRoute } from '@tanstack/react-router' +${posts} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: PostsComponent, +})`, + html: '<div>posts data</div>', + }, + { + name: 'a root route', + root: true, + route: `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ + loader: () => 'data', + component: () => <div>root</div>, +})`, + html: '<div>root</div>', + }, +] + +/** What the modules see: the hot APIs and `window`. */ +const environment = `export const environment = { + hot: typeof import.meta.hot, + webpackHot: typeof import.meta.webpackHot, + window: typeof window, +} +` + +/** + * The client entry: loads the route's component (the router's `preload()` + * of a split component), renders it with React's client renderer, and + * reports it with the loader's value and what the modules see. + */ +const clientEntry = `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { Route } from '../route' +import { environment } from '../environment' +;(window as any).check = async () => { + const component = (Route.options as any).component + await component.preload?.() + const el = document.createElement('div') + document.body.append(el) + const root = createRoot(el) + flushSync(() => root.render(createElement(component))) + return { data: await (Route.options as any).loader(), html: el.innerHTML, environment } +} +` + +/** The server entry: the same, with React's server renderer. */ +const serverEntry = `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { Route } from '../route' +import { environment } from '../environment' +export async function check() { + const component = (Route.options as any).component + await component.preload?.() + return { + data: await (Route.options as any).loader(), + html: renderToString(createElement(component)), + environment, + } +} +` + +async function host(options: { + route: string + root: boolean + style: 'webpack' | 'vite' + hmr: boolean +}) { + const routerPlugin = (root: string): RsbuildPlugin => ({ + name: 'app:tanstack-router', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push( + tanstackRouter({ + target: 'react', + routesDirectory: root, + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + tmpDir: path.join(root, '.tanstack/tmp'), + disableLogging: true, + virtualRouteConfig: options.root + ? { type: 'root', file: 'route.tsx', children: [] } + : { + type: 'root', + file: '__root.tsx', + children: [{ type: 'index', file: 'route.tsx' }], + }, + autoCodeSplitting: true, + codeSplittingOptions: { addHmr: true }, + plugin: { hmr: { style: options.style } }, + }), + ) + }) + }, + }) + const config: RsbuildConfig = { + dev: { hmr: options.hmr, liveReload: options.hmr }, + environments: { + web: { source: { entry: { index: './src/entry.tsx' } } }, + node: { + source: { entry: { index: './src/server.tsx' } }, + // CommonJS: Rsbuild's `loadBundle` runs an ES module bundle only + // with Node's `--experimental-vm-modules` + output: { target: 'node', module: false }, + }, + }, + } + return createRsbuildPluginHost({ + dir: path.dirname(import.meta.dirname), + prefix: '.route-hmr-rsbuild-', + registerCleanup: onTestFinished, + entry: 'src/entry.tsx', + files: { + ...(options.root + ? {} + : { + '__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({}) +`, + }), + 'route.tsx': options.route, + 'environment.ts': environment, + 'src/entry.tsx': clientEntry, + 'src/server.tsx': serverEntry, + }, + plugins: ({ root }) => [pluginReact(), routerPlugin(root)], + config, + client: true, + }) +} + +const hosts = [ + { + name: 'a page with webpack hot API (webpack style)', + side: 'page', + style: 'webpack', + hmr: true, + environment: { hot: 'undefined', webpackHot: 'object', window: 'object' }, + }, + { + name: 'the server environment (no window; webpack style)', + side: 'server', + style: 'webpack', + hmr: true, + environment: { + hot: 'undefined', + webpackHot: 'undefined', + window: 'undefined', + }, + }, + { + name: 'a page of a dev server without HMR (no hot API, window; vite style)', + side: 'page', + style: 'vite', + hmr: false, + environment: { + hot: 'undefined', + webpackHot: 'undefined', + window: 'object', + }, + }, +] as const + +describe.each(routes)('$name', ({ route, root, html }) => { + it.each(hosts)( + 'renders and loads in $name', + async ({ side, style, hmr, environment: seen }) => { + const app = await host({ route, root, style, hmr }) + const result = + side === 'page' + ? (await app.runClient('return window.check()')).result + : await ( + await app.loadServer<{ check: () => Promise<unknown> }>('node') + ).check() + expect(result).toEqual({ data: 'data', html, environment: seen }) + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/route-hmr-webpack-server-hosts.test.ts b/packages/router-plugin/tests/integration/route-hmr-webpack-server-hosts.test.ts new file mode 100644 index 0000000000..576c55d696 --- /dev/null +++ b/packages/router-plugin/tests/integration/route-hmr-webpack-server-hosts.test.ts @@ -0,0 +1,135 @@ +/** + * Route modules compiled for the dev server evaluate and render where a + * webpack or Rspack server build with hot module replacement runs them + * (SPEC J3.8): webpack's hot API (`import.meta.webpackHot`) present and no + * `window`, the webpack-style cell no other host reaches. The page hosts, + * Rsbuild's server environment (no hot API there) and the Vite hosts of the + * same rows: integration/route-hmr-rsbuild-hosts.test.ts and + * route-hmr.test.ts "route modules compiled for the dev server". + * + * The host is a server bundle built the way an app's own webpack or Rspack + * configuration builds one for development with hot updates (the server-HMR + * setup of webpack's guides: `target: 'node'`, development mode, the + * bundler's `HotModuleReplacementPlugin`), with the router plugin's public + * entry of that bundler; the bundle runs in Node (`run()` of the build + * harness). Initial evaluation only, no router on the page yet: what an + * edit does is tested in a real dev server and page + * (integration/route-hmr-browser*.test.ts). + */ +import { describe, expect, it } from 'vitest' +import { build, routeApp } from '../build-harness' + +const timeout = 60_000 + +const posts = `function PostsComponent() { + return <div>posts data</div> +}` + +/** What the modules see: the hot APIs and `window`. */ +const environment = `export const environment = { + hot: typeof (import.meta as any).hot, + webpackHot: typeof import.meta.webpackHot, + window: typeof window, +} +` + +/** + * The server entry: loads the route's component (the router's `preload()` + * of a split component), renders it with React's server renderer, and + * reports it with the loader's value and what the modules see. + */ +const serverEntry = (route: string) => `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { Route } from './routes/${route}' +import { environment } from './environment' +export async function check() { + const component = (Route.options as any).component + await component.preload?.() + return { + data: await (Route.options as any).loader(), + html: renderToString(createElement(component)), + environment, + } +} +` + +const routes = [ + { + name: 'a split route', + files: routeApp( + `import { createFileRoute } from '@tanstack/react-router' +${posts} +export const Route = createFileRoute('/')({ + loader: () => 'data', + component: PostsComponent, +})`, + { files: { 'entry.ts': serverEntry('index') } }, + ), + html: '<div>posts data</div>', + }, + { + name: 'a root route', + files: routeApp( + `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({}) +`, + { + files: { + 'routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ + loader: () => 'data', + component: () => <div>root</div>, +})`, + 'entry.ts': serverEntry('__root'), + }, + }, + ), + html: '<div>root</div>', + }, +] + +/** Adds the bundler's own `HotModuleReplacementPlugin`, as the app's configuration does. */ +async function withHotModuleReplacement(bundler: 'webpack' | 'rspack') { + const { HotModuleReplacementPlugin } = + bundler === 'webpack' + ? (await import('webpack')).default + : // (Rspack as Rsbuild ships it) + (await import('@rsbuild/core')).rspack + return (options: Record<string, unknown>) => { + ;(options.plugins as Array<unknown>).push(new HotModuleReplacementPlugin()) + } +} + +describe.each(routes)('$name', ({ files, html }) => { + it.each(['webpack', 'rspack'] as const)( + 'renders and loads in a %s server build with hot module replacement (webpack hot API, no window)', + async (bundler) => { + const app = await build({ + bundler, + env: 'ssr', + mode: 'development', + minify: false, + files: { ...files, 'environment.ts': environment }, + pluginOptions: { + codeSplittingOptions: { addHmr: true }, + plugin: { hmr: { style: 'webpack' } }, + }, + configure: await withHotModuleReplacement(bundler), + }) + try { + expect((await app.run('return await entry.check()')).result).toEqual({ + data: 'data', + html, + environment: { + hot: 'undefined', + webpackHot: 'object', + window: 'undefined', + }, + }) + } finally { + await app.dispose() + } + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/integration/rsbuild-dev-server-generator-watching.test.ts b/packages/router-plugin/tests/integration/rsbuild-dev-server-generator-watching.test.ts new file mode 100644 index 0000000000..cf4a7b950f --- /dev/null +++ b/packages/router-plugin/tests/integration/rsbuild-dev-server-generator-watching.test.ts @@ -0,0 +1,58 @@ +/** + * The route generator's watching on a running Rsbuild dev server (the + * router plugin's Rspack entry), on a real page: edits of the virtual route + * config file and of a `__virtual.ts` file change the live routes (pinned + * below), and closing the dev server stops the generator (scenarios: + * `generator-dev-scenarios.ts`; the Vite counterpart is + * dev-server-generator-watching.test.ts, with the same pins). + * + * Each pin waits for the outcome of a correct generator as long as the + * passing scenarios do (`waitForLiveRoute`'s default bound), so a correct + * but slower fix still turns it green, then fails. + */ +import { test } from 'vitest' +import { + describeGeneratorWatching, + expectVirtualRouteConfigEdit, + expectVirtualSubtreeEdit, +} from '../generator-dev-scenarios' + +describeGeneratorWatching('rsbuild') + +// Bug: an edit of the file `virtualRouteConfig` names never reaches the +// live routes. On Rspack the file is not a module of the bundle, so the +// bundler's watcher does not report it, and the generator's own watcher +// reports only files created in the routes directory; the generator would +// also drop the event (relative/absolute path comparison) and load the +// config from jiti's cache (see the Vite pin). +// Source: packages/router-plugin/src/core/router-generator-plugin.ts +// (`rspack`: chokidar on the routes directory, 'add' only); +// packages/router-generator/src/generator.ts +// (`isFileRelevantForRouteTreeGeneration`), src/filesystem/virtual/ +// loadConfigFile.ts. +// Impact: in Rsbuild/Rspack dev, a route added to the virtual route config +// is missing from the app until the dev server restarts. +test.fails( + 'an edit of the virtual route config file changes the live routes', + async () => { + await expectVirtualRouteConfigEdit('rsbuild') + }, + 45_000, +) + +// Bug: an edit of a `__virtual.ts` subtree config never reaches the live +// routes: the file is in no bundle and the generator's own watcher reports +// only created files; the config would also come from jiti's cache (see the +// Vite pin). +// Source: packages/router-plugin/src/core/router-generator-plugin.ts +// (`rspack`); packages/router-generator/src/filesystem/virtual/ +// loadConfigFile.ts (not probed in the product). +// Impact: in Rsbuild/Rspack dev, a route added to a `__virtual.ts` file is +// missing from the app until the dev server restarts. +test.fails( + 'an edit of a __virtual.ts file changes the live routes', + async () => { + await expectVirtualSubtreeEdit('rsbuild') + }, + 45_000, +) diff --git a/packages/router-plugin/tests/integration/rsbuild-dev-server-generator.test.ts b/packages/router-plugin/tests/integration/rsbuild-dev-server-generator.test.ts new file mode 100644 index 0000000000..f91585f654 --- /dev/null +++ b/packages/router-plugin/tests/integration/rsbuild-dev-server-generator.test.ts @@ -0,0 +1,13 @@ +/** + * The route generator on a running Rsbuild dev server (the router plugin's + * Rspack entry, the real router bundled and run on a real page): route files + * created, renamed, moved and deleted keep their `createFileRoute` path in + * line with their location, the live routes follow, and each route's + * component loads on navigation (scenarios: `generator-dev-scenarios.ts`; + * the Vite counterpart is dev-server-generator.test.ts). A route file + * created under a `physical()` mount is pinned in + * known-bugs-rsbuild-generator-physical.test.ts. + */ +import { describeRouteFileUpkeep } from '../generator-dev-scenarios' + +describeRouteFileUpkeep('rsbuild', { pinPhysicalMountCreation: true }) diff --git a/packages/router-plugin/tests/integration/rsbuild-dev-server-new-routes.test.ts b/packages/router-plugin/tests/integration/rsbuild-dev-server-new-routes.test.ts new file mode 100644 index 0000000000..c8abcf237c --- /dev/null +++ b/packages/router-plugin/tests/integration/rsbuild-dev-server-new-routes.test.ts @@ -0,0 +1,11 @@ +/** + * Routes created while an Rsbuild dev server runs, on a real page: a route + * file broken by an edit is reported and comes back once fixed, and edits of + * created and renamed routes, and of the root route, are hot updates + * (scenarios: `generator-dev-scenarios.ts`; the Vite counterpart is + * dev-server-new-routes.test.ts). A route file created before it exports a + * valid `Route` is pinned in known-bugs-rsbuild-generator.test.ts. + */ +import { describeCreatedRoutes } from '../generator-dev-scenarios' + +describeCreatedRoutes('rsbuild', { pinCreatedBrokenRouteFiles: true }) diff --git a/packages/router-plugin/tests/integration/split-mode-parity.test.ts b/packages/router-plugin/tests/integration/split-mode-parity.test.ts new file mode 100644 index 0000000000..ae20701d3f --- /dev/null +++ b/packages/router-plugin/tests/integration/split-mode-parity.test.ts @@ -0,0 +1,456 @@ +/** + * Dev/build parity of the split decision (SPEC G13, J2.13, + * J2.2, J2.3): for one app and one configuration, which route options are + * lazy, which load together and which `deleteNodes` removed are the same in + * a dev server and in a production build, on Vite and on Rsbuild, and are + * what the configuration asks for; the loaders return and the routes render + * what they did unsplit. The app's routes cover the precedence of the + * groupings (a route's own `codeSplitGroupings` over the plugin's + * `splitBehavior` over its `defaultBehavior`), the five splittable options + * (`component`, `errorComponent`, `pendingComponent`, `notFoundComponent`, + * `loader`) and the options Start deletes from the client (`ssr`, `server`, + * `headers`). Each option imports a module recording when it loads + * (`loadMarker`), and the same script observes every environment through + * the real router's public contract (`preload()` of a component, a loader + * call, then the route rendered by the real router) in a real browser page. + * + * Which options load together is observed from each group's first option: + * the routes come in pairs with the same options and groupings, one + * observed in the order of `options`, the other (`-reverse`) in the reverse + * order, so a group that loads from one of its options but not from another + * (or that pulls in another group) shows. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { pluginReact } from '@rsbuild/plugin-react' +import react from '@vitejs/plugin-react' +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { + loadMarker, + loadedModulesExpression, +} from '@tanstack/compiler-test-utils/importers' +import { tanstackRouter as tanstackRouterRspack } from '../../src/rspack' +import { build, buildWithRsbuild, routeHead } from '../build-harness' +import { routerDevServer } from '../dev-server' +import type { CodeSplitGroupings, RouterPluginOptions } from '../build-harness' +import type { RsbuildPlugin } from '@rsbuild/core' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) +const timeout = 90_000 + +/** The splittable options, in the order the forward routes observe them. */ +const options = [ + 'component', + 'errorComponent', + 'pendingComponent', + 'notFoundComponent', + 'loader', +] as const + +/** The plugin's groupings for routes that set none of their own. */ +const defaultBehavior: CodeSplitGroupings = [ + ['component', 'errorComponent'], + ['loader'], +] +/** The plugin's groupings for `/behavior` (over `defaultBehavior`). */ +const behaviorGroupings: CodeSplitGroupings = [['loader'], ['component']] +/** `/grouped`'s own groupings (over `splitBehavior` and `defaultBehavior`). */ +const routeGroupings: CodeSplitGroupings = [ + ['loader', 'component'], + ['pendingComponent'], + ['notFoundComponent', 'errorComponent'], +] + +const pluginOptions: RouterPluginOptions = { + codeSplittingOptions: { + deleteNodes: ['ssr', 'server', 'headers'], + defaultBehavior, + splitBehavior: ({ routeId }) => + routeId.startsWith('/behavior') ? behaviorGroupings : undefined, + }, +} + +/** The routes: id, the groupings that apply, and extra route options. */ +const routes = [ + { id: '/', groupings: defaultBehavior, extra: '' }, + { id: '/reverse', groupings: defaultBehavior, extra: '' }, + { + id: '/grouped', + groupings: routeGroupings, + extra: `\n codeSplitGroupings: ${JSON.stringify(routeGroupings)},`, + }, + { + id: '/grouped-reverse', + groupings: routeGroupings, + extra: `\n codeSplitGroupings: ${JSON.stringify(routeGroupings)},`, + }, + { id: '/behavior', groupings: behaviorGroupings, extra: '' }, + { id: '/behavior-reverse', groupings: behaviorGroupings, extra: '' }, + // `server` exists only with Start's types, so this plain router app has + // the other two options Start deletes. + { + id: '/deleted', + groupings: defaultBehavior, + extra: ` + ssr: false, + headers: () => ({ 'x-mark': 'MARK_DELETED_HEADER' }),`, + }, +] + +/** File name of a route (`/` is `index`). */ +const fileOf = (id: string) => (id === '/' ? 'index' : id.slice(1)) + +/** Marker text of a route's option module. */ +const markOf = (id: string, option: string) => + `MARK_${fileOf(id).replaceAll('-', '_').toUpperCase()}_${option.toUpperCase()}` + +/** + * The app: the route files, the marker modules their options import, and + * `app.tsx`, which exports the route tree and `renderAt(path, text)` + * (renders the app at `path` through the real router and returns its HTML + * once it shows `text`, or after 2 seconds). + */ +function appFiles() { + const files: Record<string, string> = { + 'routes/__root.tsx': `import { Outlet, createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ component: () => <Outlet /> }) +`, + 'app.tsx': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export { routeTree } +/** The routes as a router sees them (their public \`id\`). */ +export const router = createRouter({ + routeTree, + history: createMemoryHistory(), +}) +export async function renderAt(path: string, text: string) { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [path] }), + }) + const container = document.createElement('div') + document.body.appendChild(container) + const root = createRoot(container) + flushSync(() => root.render(createElement(RouterProvider, { router }))) + for (let tries = 0; tries < 200 && !container.innerHTML.includes(text); tries++) { + await new Promise((resolve) => setTimeout(resolve, 10)) + } + const html = container.innerHTML + root.unmount() + container.remove() + return html +} +`, + } + for (const { id, extra } of routes) { + const name = fileOf(id) + const imports = options + .map( + (option) => + `import { mark as ${option}Mark } from '../markers/${name}-${option}'`, + ) + .join('\n') + for (const option of options) { + files[`markers/${name}-${option}.ts`] = + `${loadMarker(`${id}:${option}`)}export const mark = '${markOf(id, option)}'\n` + } + files[`routes/${name}.tsx`] = `${routeHead()}${imports} +export const Route = createFileRoute('${id}')({ + loader: () => loaderMark, + component: () => <p>{componentMark} {Route.useLoaderData()}</p>, + errorComponent: () => <p>{errorComponentMark}</p>, + pendingComponent: () => <p>{pendingComponentMark}</p>, + notFoundComponent: () => <p>{notFoundComponentMark}</p>,${extra} +}) +` + } + return files +} + +/** The order a route's options are activated in by the observation. */ +const orderOf = (id: string) => + id.endsWith('-reverse') ? [...options].reverse() : [...options] + +/** + * Body of an async function observing, with `app` (`app.tsx`'s exports) in + * scope, for each route: which of its options are lazy (activating it loads + * its marker module, which had not loaded), which other options' modules + * activating it loads, what its loader returns, which of the options Start + * deletes from the client are there, and whether the route renders its + * component with its loader's data through the real router. + */ +const observe = `const loaded = () => [...${loadedModulesExpression}] +const options = ${JSON.stringify(options)} +const result = {} +for (const route of Object.values(app.router.routesById)) { + if (route.isRoot) continue + const id = route.id + const order = id.endsWith('-reverse') ? [...options].reverse() : options + const lazy = {} + const loadsWith = {} + let data + for (const option of order) { + const before = loaded() + const value = route.options[option] + if (option === 'loader') { + data = await (typeof value === 'function' ? value() : value?.handler?.()) + } else { + await value?.preload?.() + } + const after = loaded().filter((name) => !before.includes(name)) + lazy[option] = after.includes(id + ':' + option) + loadsWith[option] = options.filter((other) => other !== option && after.includes(id + ':' + other)).sort() + } + result[id] = { + serverOptions: ['ssr', 'server', 'headers'].filter((key) => key in route.options), + lazy, + loadsWith, + data, + } +} +for (const id of Object.keys(result)) { + result[id].html = await app.renderAt(id, result[id].data) +} +return result` + +type Observation = Record< + string, + { + serverOptions: Array<string> + lazy: Record<string, boolean> + loadsWith: Record<string, Array<string>> + data: string + renders: boolean + } +> + +/** + * An observation of the page, its routes' HTML read as whether each route + * rendered its component with its loader's data. + */ +function readObservation( + observed: Record<string, Observation[string] & { html?: string }>, +): Observation { + return Object.fromEntries( + Object.entries(observed).map(([id, { html = '', ...route }]) => [ + id, + { + ...route, + renders: + html.includes(markOf(id, 'component')) && html.includes(route.data), + }, + ]), + ) +} + +/** + * What the configuration asks for, per route: an option of a group is lazy + * when it is the first of its group the observation activates, and then + * loads the rest of its group and nothing else; an option in no group loads + * with the route module. + */ +function expectedObservation(): Observation { + const observation: Observation = {} + for (const { id, groupings } of routes) { + const done = new Set<string>() + const lazy: Record<string, boolean> = {} + const loadsWith: Record<string, Array<string>> = {} + for (const option of orderOf(id)) { + const group = groupings.find((members) => + (members as Array<string>).includes(option), + ) as Array<string> | undefined + const first = group !== undefined && !done.has(option) + lazy[option] = first + loadsWith[option] = first + ? group.filter((other) => other !== option).sort() + : [] + group?.forEach((member) => done.add(member)) + } + observation[id] = { + serverOptions: [], + lazy, + loadsWith, + data: markOf(id, 'loader'), + renders: true, + } + } + return observation +} + +/** Observes a production client build in a page (`app.run`). */ +async function observeBuild(app: { + run: (script: string) => Promise<{ result: unknown }> +}) { + const { result } = await app.run(`const app = entry\n${observe}`) + return readObservation(result as Observation) +} + +/** + * The page of a dev server: exposes `app.tsx`'s exports as + * `globalThis.__app` and shows `MARK_READY` (it renders no route, so + * nothing loads before the observation). + */ +const devPageFiles = { + 'index.html': `<!doctype html> +<html> + <body> + <div id="app"></div> + <script type="module" src="/main.tsx"></script> + </body> +</html> +`, + 'main.tsx': `import * as app from './app' +;(globalThis as any).__app = app +document.getElementById('app')!.textContent = 'MARK_READY' +`, +} + +/** + * The Vite page's entry: React Refresh's preamble first + * (`@vitejs/plugin-react`'s virtual module for entries of its own), as the + * route modules the tree imports are compiled with Fast Refresh. + */ +const vitePageFiles = { + ...devPageFiles, + 'main.tsx': `import '@vitejs/plugin-react/preamble'\n${devPageFiles['main.tsx']}`, +} + +/** Observes a dev server's client in a real page. */ +async function observeDevPage( + url: string, + registerCleanup: (cleanup: () => Promise<void>) => void, +) { + const page = await openPage(url, { registerCleanup }) + await page.waitForText('MARK_READY', { selector: '#app' }) + const result = await page.page.evaluate<Observation>( + `(async () => { const app = globalThis.__app\n${observe} })()`, + ) + expect(page.errors).toEqual([]) + return readObservation(result) +} + +describe('the split decision in dev and in a production build', () => { + const cleanups: Array<() => Promise<void>> = [] + const registerCleanup = (cleanup: () => Promise<void>) => { + cleanups.push(cleanup) + } + const observations: Record<string, Observation> = {} + /** Where the code of the deleted `headers` option is, per build. */ + const deletedCode: Record<string, string> = {} + + beforeAll(async () => { + const files = appFiles() + const entry = `export * from './app'\n` + // The dev servers first, one at a time, the builds after: a production + // build sets the process's `NODE_ENV` to `production` while it runs + // (as a build command does), and a dev server starting meanwhile would + // be configured from it. + const viteServer = await routerDevServer({ + browser: true, + registerCleanup, + files: { ...files, ...vitePageFiles }, + pluginOptions, + plugins: [react()], + config: { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + }, + }, + }) + observations.viteDev = await observeDevPage( + viteServer.url!, + registerCleanup, + ) + // One dev server at a time: a second one starting meanwhile changes + // the process's environment the first one is configured from. + const rsbuildServer = await createRsbuildDevServer({ + dir: harnessDir, + prefix: '.split-mode-parity-rsbuild-', + registerCleanup, + browser: true, + entry: 'main.tsx', + files: { ...files, 'main.tsx': devPageFiles['main.tsx'] }, + config: { html: { mountId: 'app' } }, + plugins: ({ root }) => [ + pluginReact(), + { + name: 'split-mode-parity', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push( + tanstackRouterRspack({ + target: 'react', + autoCodeSplitting: true, + // The Rspack plugin resolves relative paths from the + // working directory + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + ...pluginOptions, + }), + ) + }) + }, + } satisfies RsbuildPlugin, + ], + }) + observations.rsbuildDev = await observeDevPage( + rsbuildServer.url!, + registerCleanup, + ) + await Promise.all([ + (async () => { + const app = await build({ + bundler: 'vite', + env: 'client', + files: { ...files, 'entry.ts': entry }, + pluginOptions, + registerCleanup, + }) + observations.viteBuild = await observeBuild(app) + deletedCode.vite = app.where('MARK_DELETED_HEADER') + })(), + (async () => { + const app = await buildWithRsbuild({ + files: { ...files, 'entry.ts': entry }, + pluginOptions, + registerCleanup, + }) + observations.rsbuildBuild = await observeBuild(app) + deletedCode.rsbuild = app.where('MARK_DELETED_HEADER') + })(), + ]) + }, timeout) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + test.each(['vite', 'rsbuild'])( + '%s: the production build splits, groups and deletes as configured, and the routes work', + (bundler) => { + expect(observations[`${bundler}Build`]).toEqual(expectedObservation()) + // The deleted `headers` option's code is in no chunk of the client. + expect(deletedCode[bundler]).toBe('nowhere') + }, + ) + + test.each(['vite', 'rsbuild'])( + '%s: the dev server splits, groups and deletes like the production build', + (bundler) => { + expect(observations[`${bundler}Dev`]).toEqual( + observations[`${bundler}Build`], + ) + }, + ) +}) diff --git a/packages/router-plugin/tests/known-bugs-dev-server.test.ts b/packages/router-plugin/tests/known-bugs-dev-server.test.ts new file mode 100644 index 0000000000..3b54f39e9a --- /dev/null +++ b/packages/router-plugin/tests/known-bugs-dev-server.test.ts @@ -0,0 +1,135 @@ +/** + * Known router plugin bugs that only show on a running dev server, after + * edits. Each pin asserts correct behaviour for a bug on main and is marked + * .fails; remove .fails when the bug is fixed. Each pin has a control test + * that runs the same harness on a case that works. The ones observed in a + * real browser page: integration/known-bugs-dev-server.test.ts. + */ +import { describe, expect, test } from 'vitest' +import { + expectExportedRouteOptions, + expectSharedOverloads, + exportedComponentsLostWhenSplit, + rootRoute, + routerDevServer, +} from './dev-server' +import { head } from './route-app' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +const timeout = 30_000 + +describe('route module exports with automatic code splitting', () => { + // Controls: react-refresh-route-components.test.ts "route module exports + // with React HMR and autoCodeSplitting" (same harness), where these cases + // pass without automatic code splitting. + + // Bug: the code splitter moves a component the route module exports into + // its chunk and drops its export: a class cannot be split ("Unexpected + // splitNode type: ClassDeclaration") and loses its `export class`, and an + // aliased export list (`export { component as View }`) is left without its + // declaration (known-bugs-code-splitter.test.ts "class components" and "a + // split component that an export alias reads renders from both"). + // Impact: in development, modules importing the export get `undefined` + // (Vite SSR) or fail to load (browsers: "Export 'component' is not + // defined"), and the route's component chunk fails to compile. + // Source: #8504 react-refresh-route-components ("route module exports with + // React HMR and autoCodeSplitting=true"), where they pass. + test.fails.each(exportedComponentsLostWhenSplit)( + 'keep a $name component exported as the route option value', + async ({ declaration, options, exported }) => { + await expectExportedRouteOptions( + `${head}${declaration} +export const Route = createFileRoute('/page')({ ${options} })`, + exported, + true, + ) + }, + timeout, + ) + + // Bug: the overload signatures of a function that the route module and a + // split loader share stay next to its import, and the alias loses the + // binding (known-bugs-code-splitter.test.ts "an overloaded function the + // route module and a split loader share keeps working"). + // Impact: in development, `helperAlias` is undefined (Vite SSR) or the + // route module fails to load (browsers). + // Source: #8504 react-refresh-route-components ("keep exported overloads + // and their aliases that unsplit and split options call"), where it passes. + test.fails( + 'keep exported overloads and their aliases that unsplit and split options call', + async () => { + await expectSharedOverloads(true) + }, + timeout, + ) +}) + +describe('router config file', () => { + /** `tsr.config.json` with the harness's plugin options. */ + const config = (routesDirectory: string) => + JSON.stringify({ + target: 'react', + autoCodeSplitting: true, + routesDirectory, + generatedRouteTree: './routeTree.gen.ts', + }) + + const route = ( + path: string, + ) => `${head}export const Route = createFileRoute('${path}')({}) +` + + /** + * The route the app's generated route tree (`routeTree.gen.ts`) matches + * at `pathname`: the real router over the tree, in the dev server's SSR + * environment, after `router.load()`. + */ + async function matchedRoute(server: DevServer, pathname: string) { + const { routeTree } = await server.import('/routeTree.gen.ts') + const { createMemoryHistory, createRouter } = await server.import( + '@tanstack/react-router', + ) + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [pathname] }), + }) + await router.load() + return router.state.matches.at(-1)?.fullPath + } + + /** + * Starts with `tsr.config.json` reading the routes from `routes/`, then + * points it to `pages/`, with `edits`. Returns the route the route tree + * matches at `/about` afterwards (none before: `/about` is in `pages/`). + */ + async function moveRoutesDirectory(edits: Record<string, string>) { + const server = await routerDevServer({ + pluginOptions: null, + files: { + 'tsr.config.json': config('./routes'), + 'routes/index.tsx': route('/'), + 'pages/__root.tsx': rootRoute, + 'pages/about.tsx': route('/about'), + }, + }) + expect(await matchedRoute(server, '/about')).not.toBe('/about') + await server.edit({ 'tsr.config.json': config('./pages') }) + await server.edit(edits) + return matchedRoute(server, '/about') + } + + // The next route file edit generates the route tree with the new + // configuration. (Whether the `tsr.config.json` edit itself regenerates + // it is free: SPEC J1.10.) + test( + 'a route file edit after a tsr.config.json edit generates the route tree with the new configuration', + async () => { + expect( + await moveRoutesDirectory({ + 'pages/about.tsx': route('/about') + '\n', + }), + ).toBe('/about') + }, + timeout, + ) +}) diff --git a/packages/router-plugin/tests/known-bugs-route-hmr-bindings.test.ts b/packages/router-plugin/tests/known-bugs-route-hmr-bindings.test.ts new file mode 100644 index 0000000000..f2e7b8f41b --- /dev/null +++ b/packages/router-plugin/tests/known-bugs-route-hmr-bindings.test.ts @@ -0,0 +1,54 @@ +/** + * Known bug (SPEC G15, J3.8): code the router plugin injects for route HMR + * must not read a binding of the user's route file. With route HMR on + * (React, the dev server's default `addHmr`), the injected React Refresh + * bookkeeping constructs a `Map`; a route file that imports a class named + * `Map` of its own (a map widget's, e.g. a maps library) hands the injected + * code the user's class, and the route module throws when it loads, so the + * page cannot render the route. The bookkeeping is built by the first route + * module the page evaluates: the root route, which the route tree imports + * first, so the route file here is the app's root. Found in review while + * piloting the route app. + * + * Fix-agnostic: any fix that leaves the user's `Map` alone (a global + * reference that no user binding captures, another structure, no + * bookkeeping) makes the route render. + */ +import { expect, it } from 'vitest' +import { loadRoute } from './route-app' + +const mapsLibrary = { + 'node_modules/maps/package.json': JSON.stringify({ + name: 'maps', + type: 'module', + exports: './index.js', + }), + // A map widget's class named Map, not a key-value store + 'node_modules/maps/index.js': `export class Map { + constructor() { this.size = 0 } + get(key) { return undefined } +} +`, +} + +const route = `import { createRootRoute } from '@tanstack/react-router' +import { Map } from 'maps' +const cache = new Map() +export const Route = createRootRoute({ + loader: () => cache.size, + component: () => <p>MARK_PAGE {String(Route.useLoaderData())}</p>, +}) +` + +it('a route file importing a binding named Map renders without route HMR (control)', async () => { + const app = await loadRoute(route, { files: mapsLibrary }) + expect(await app.run('return renderRoute()')).toContain('MARK_PAGE 0') +}) + +it.fails( + 'a route file importing a binding named Map renders with route HMR', + async () => { + const app = await loadRoute(route, { files: mapsLibrary, hmr: true }) + expect(await app.run('return renderRoute()')).toContain('MARK_PAGE 0') + }, +) diff --git a/packages/router-plugin/tests/known-bugs-route-hmr.test.ts b/packages/router-plugin/tests/known-bugs-route-hmr.test.ts new file mode 100644 index 0000000000..6ae3200a7e --- /dev/null +++ b/packages/router-plugin/tests/known-bugs-route-hmr.test.ts @@ -0,0 +1,529 @@ +/** + * Known route HMR bugs of the modules the compiler emits for development. + * Each test asserts correct behaviour for a bug on main and is marked + * .fails; remove .fails when the bug is fixed. + * + * The route file, the modules the test gives and a module importing the + * route module run in a real page served by a Vite dev server with the + * router plugin and React's plugin (`route-app.ts`): the real hot context, + * React Refresh, the real router. + * + * Pins of what the page shows after an edit (React Refresh keeping state, + * lowercase, inline and exported components) run a real dev server and a + * real browser page (`route-hmr-page.ts`): + * integration/known-bugs-route-hmr.test.ts. + */ +import { parseSync } from 'vite' +import { describe, expect, test } from 'vitest' +import { expectValidModules, head, loadRoute } from './route-app' +import type { ESTree } from 'vite' + +/** Top-level names a module declares (an independent parse). */ +function topLevelNames(code: string) { + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + const names = new Set<string>() + const addPattern = (pattern: ESTree.Node | null | undefined): void => { + if (!pattern) { + return + } + switch (pattern.type) { + case 'Identifier': + names.add(pattern.name) + break + case 'ObjectPattern': + for (const property of pattern.properties) { + addPattern( + property.type === 'RestElement' + ? property.argument + : property.value, + ) + } + break + case 'ArrayPattern': + pattern.elements.forEach((element) => addPattern(element)) + break + case 'RestElement': + addPattern(pattern.argument) + break + case 'AssignmentPattern': + addPattern(pattern.left) + break + } + } + const addDeclaration = (node: ESTree.Node | null | undefined): void => { + if (!node) { + return + } + if (node.type === 'VariableDeclaration') { + node.declarations.forEach((declarator) => addPattern(declarator.id)) + } else if ( + (node.type === 'FunctionDeclaration' || + node.type === 'ClassDeclaration') && + node.id + ) { + names.add(node.id.name) + } + } + for (const statement of program.body) { + if (statement.type === 'ImportDeclaration') { + statement.specifiers.forEach((specifier) => + names.add(specifier.local.name), + ) + } else if ( + statement.type === 'ExportNamedDeclaration' || + statement.type === 'ExportDefaultDeclaration' + ) { + addDeclaration(statement.declaration as ESTree.Node) + } else { + addDeclaration(statement) + } + } + return names +} + +describe('generated code', () => { + // Control for the options-in-a-variable pins below (same harness). + test.each([ + { + name: 'an unsplittable root route', + code: `import { createRootRoute, Outlet } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: () => <Outlet />, +})`, + }, + { + name: 'a split file route', + code: `${head}export const Route = createFileRoute('/')({ + component: () => <p>home</p>, +})`, + }, + ])( + 'inline route options ($name) evaluate to a route with a component', + async ({ code }) => { + const route = await loadRoute(code, { hmr: true }) + expect(await route.run(`return typeof options.component`)).toBe( + 'function', + ) + }, + ) + + // Bug: when the route options are passed through a variable, the HMR + // transforms replace `component` in the options object with a generated + // binding declared after the object that reads it. + // Impact: the route module throws a TDZ ReferenceError in development. + test.fails.each([ + { + name: 'an unsplittable root route', + code: `import { createRootRoute, Outlet } from '@tanstack/react-router' +const options = { + component: () => <Outlet />, +} +export const Route = createRootRoute(options)`, + }, + { + name: 'a split file route', + code: `${head}const options = { + component: () => <p>home</p>, +} +export const Route = createFileRoute('/')(options)`, + }, + ])( + 'route options in a variable ($name) evaluate to a route with a component', + async ({ code }) => { + const route = await loadRoute(code, { hmr: true }) + expect(await route.run(`return typeof options.component`)).toBe( + 'function', + ) + }, + ) + + /** + * Names a user binding may take: `hot` (the binding of the bug report), + * and every top-level name the route module the page receives declares + * with HMR and not without it (adaptive: whatever names the compiler + * introduces for HMR, not one spelling of today's), except the names the + * tools introduce in any module of the app (Vite's hot context, React + * Refresh): those of a module that is not a route, with components, served + * by the same dev server. + */ + async function candidateNames() { + const code = `${head}const marker = 'marker' +export const Route = createFileRoute('/')({ + component: () => <p>{marker}</p>, +})` + const hmr = await loadRoute(code, { + hmr: true, + files: { + 'widgets.tsx': ['A', 'B', 'C', 'D'] + .map((name) => `export function ${name}() { return <p>${name}</p> }`) + .join('\n'), + }, + }) + const withHmr = await hmr.transform() + const tools = topLevelNames(await hmr.transform('/widgets.tsx')) + const without = topLevelNames( + await (await loadRoute(code, { hmr: false })).transform(), + ) + return [ + ...new Set([ + 'hot', + ...[...topLevelNames(withHmr)].filter( + (name) => !without.has(name) && !tools.has(name), + ), + ]), + ] + } + + // Bug: our `react-refresh-ignored-route-exports` compiler plugin injects a + // top-level `const hot = import.meta.hot` that collides with a user's + // top-level `hot` binding (compile error `Duplicate declaration "hot"`). + // Impact: the route cannot be served in development. + test.fails.each([ + { name: 'a constant', keyword: 'const', exported: false }, + { name: 'an exported constant', keyword: 'export const', exported: true }, + ])( + 'a user binding named hot ($name) does not collide with the injected HMR code', + async ({ keyword, exported }) => { + const results: Record<string, unknown> = {} + for (const name of await candidateNames()) { + const route = await loadRoute( + `${head}${keyword} ${name} = 'hot' +export const Route = createFileRoute('/')({ + component: () => <p>{${name}}</p>, +})`, + { + hmr: true, + files: exported + ? { 'importer.ts': `export { ${name} } from './route'\n` } + : {}, + }, + ) + try { + await expectValidModules(route) + results[name] = await route.run(`return [ + await render('component'), + ${exported ? `(await app('importer.ts'))[${JSON.stringify(name)}]` : `'hot'`}, +]`) + } catch (error) { + results[name] = String(error).split('\n')[0] + } + } + // Each module importing it gets the user's value. + expect(results).toEqual( + Object.fromEntries( + Object.keys(results).map((name) => [name, ['<p>hot</p>', 'hot']]), + ), + ) + }, + ) + + /** `./state`: `init` returns its argument and counts its calls. */ + const state = { + 'state.ts': `export let inits = 0 +export const init = (value: number) => { + inits++ + return value +} +`, + } + + /** + * Loads, with HMR, a route whose `page` component (declared by + * `declaration`) the code splitter shares: by default it is both the + * `component` and the `notFoundComponent`, which the default groupings + * split into two chunks; with `sharedWith: 'loader'` it is the split + * `component` and the loader, which stays in the route module, reads it. + * Renders the component, then the not-found component (or the component + * again). `page` counts its renders in a module-level `let` initialized by + * `init` from `./state`. Returns both renders and how many times `init` + * ran. + */ + async function renderSharedComponent( + declaration: string, + sharedWith: 'notFoundComponent' | 'loader' = 'notFoundComponent', + ) { + const route = await loadRoute( + `${head}import { init } from './state' +let renders = init(0) +${declaration} +export const Route = createFileRoute('/')({ + component: page, + ${sharedWith === 'loader' ? 'loader: () => page.name' : 'notFoundComponent: page'}, +})`, + { hmr: true, files: state }, + ) + return route.run(`return [ + await render('component'), + await render(${JSON.stringify(sharedWith === 'loader' ? 'component' : 'notFoundComponent')}), + (await app('state.ts')).inits, +]`) + } + + // Control for the lowercase shared component pin below (same harness). + test('a lowercase arrow component split into two chunks renders with the module state they share', async () => { + expect( + await renderSharedComponent(`const page = () => { + renders++ + return <p>{renders}</p> +}`), + ).toEqual(['<p>1</p>', '<p>2</p>', 1]) + }) + + // Bug: React HMR renames a lowercase `function` component in its split + // chunk even when the code splitter moved the component to the shared + // module, so the chunk exports `SplitComponent`, which nothing declares. + // Impact: in development, the route's component chunk fails to load + // (SyntaxError: Export 'SplitComponent' is not defined). + test.fails( + 'a lowercase function component split into two chunks renders with the module state they share', + async () => { + expect( + await renderSharedComponent(`function page() { + renders++ + return <p>{renders}</p> +}`), + ).toEqual(['<p>1</p>', '<p>2</p>', 1]) + }, + ) + + // SPEC J2.4, G1: the same, for a lowercase component that the split + // `component` and the loader (kept in the route module) share. + test('a lowercase arrow component shared with the loader renders with the module state it shares', async () => { + expect( + await renderSharedComponent( + `const page = () => { + renders++ + return <p>{renders}</p> +}`, + 'loader', + ), + ).toEqual(['<p>1</p>', '<p>2</p>', 1]) + }) + + // Bug: same root cause as the pin above, for a lowercase component that + // the split `component` and the loader share. + // Impact: in development, the route's component chunk fails to load. + test.fails( + 'a lowercase function component shared with the loader renders with the module state it shares', + async () => { + expect( + await renderSharedComponent( + `function page() { + renders++ + return <p>{renders}</p> +}`, + 'loader', + ), + ).toEqual(['<p>1</p>', '<p>2</p>', 1]) + }, + ) + + // Bug: same root cause as the pin above, for a lowercase component that + // the split `component` and the unsplit `pendingComponent` share. + // Impact: in development, the route's component chunk fails to load + // (SyntaxError: Export 'SplitComponent' is not defined). + // Source: #8504 react-refresh-route-components ("that is also the unsplit + // pendingComponent"). That edits of both show in place: the page pin in + // integration/known-bugs-route-hmr-components.test.ts. + test.fails( + 'a lowercase function component that is also the unsplit pendingComponent renders as both', + async () => { + const route = await loadRoute( + `${head}function page() { + return <p>hi</p> +} +export const Route = createFileRoute('/')({ component: page, pendingComponent: page })`, + { hmr: true }, + ) + await expectValidModules(route) + expect( + await route.run( + `return [await render('component'), await render('pendingComponent')]`, + ), + ).toEqual(['<p>hi</p>', '<p>hi</p>']) + }, + ) + + /** + * `./helpers`: `makeHelpers` returns a loader helper and a component, + * `make` returns a component; both count their calls. + */ + const helpers = { + 'helpers.tsx': `export let calls = 0 +export const makeHelpers = () => { + calls++ + return { read: () => 'MARK_READ', render: () => <p>rendered</p> } +} +export const make = () => { + calls++ + return () => <p>made</p> +} +`, + } + + // SPEC G1, J2.4: with React HMR, an unsplit component option + // (`pendingComponent` under the default groupings) given as a lowercase + // binding that a split option also reads: the modules parse, the route + // works, and the binding's initializer runs once. + // Bug: here the binding comes from a destructuring. React HMR renames the unsplit option's binding after the code + // splitter chose what the route module and its chunks share, so the route + // module keeps the renamed declaration and also imports the shared names: + // a destructuring then declares `read` twice ("Duplicate declaration"). + // Impact: in development, the route module does not compile (#8455). + test.fails( + 'a destructured binding that the loader, the split component and the unsplit pendingComponent share works and is created once', + async () => { + const route = await loadRoute( + `${head}import { makeHelpers } from './helpers' +const { read, render } = makeHelpers() +export const Route = createFileRoute('/')({ + loader: () => read(), + component: () => render(), + pendingComponent: render, +})`, + { hmr: true, files: helpers }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + await (await load('loader'))(), + await render('component'), + await render('pendingComponent'), + (await app('helpers.tsx')).calls, +]`), + ).toEqual(['MARK_READ', '<p>rendered</p>', '<p>rendered</p>', 1]) + }, + ) + + // SPEC G1, J2.4: the same with a plain `const` that holds the component + // the split `component` and the unsplit `pendingComponent` share. + test('a lowercase component created by a call that the split component and the unsplit pendingComponent share is created once', async () => { + const route = await loadRoute( + `${head}import { make } from './helpers' +const page = make() +export const Route = createFileRoute('/')({ component: page, pendingComponent: page })`, + { hmr: true, files: helpers }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + await render('component'), + await render('pendingComponent'), + (await app('helpers.tsx')).calls, +]`), + ).toEqual(['<p>made</p>', '<p>made</p>', 1]) + }) + + // Bug: same root cause as the destructuring pin above, for a plain `const` + // that the loader (kept in the route module) and the split component also + // read: the route module keeps the renamed declaration and the split + // component gets the shared one, so the initializer runs twice, with no + // error. + // Impact: in development, the loader and the component see different + // instances of the module's state. + test.fails( + 'a lowercase component created by a call that the loader, the split component and the unsplit pendingComponent share is created once', + async () => { + const route = await loadRoute( + `${head}import { make } from './helpers' +const page = make() +export const Route = createFileRoute('/')({ + loader: () => typeof page, + component: () => <div>{page()}</div>, + pendingComponent: page, +})`, + { hmr: true, files: helpers }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + await (await load('loader'))(), + await render('component'), + await render('pendingComponent'), + (await app('helpers.tsx')).calls, +]`), + ).toEqual(['function', '<div><p>made</p></div>', '<p>made</p>', 1]) + }, + ) + + // Bug: with React HMR, the code splitter moves a component exported by an + // export list (`export { page }`) into its chunk and leaves the export list + // in the route module (same root cause as known-bugs-code-splitter.test.ts + // "a split component that an export list reads renders from both"). + // Impact: in development, the route module fails to load + // (SyntaxError: Export 'page' is not defined). + // Source: ReactFreshBabelPlugin-test "registers top-level exported function + // declarations" (`export { Baz }`); #8504 react-refresh-route-components + // ("keeps a component exported by specifier in the route module"), where it + // passes. Whether the component is split is the code splitter's goal; either + // way a module importing the export and the route render the same + // component. That edits show in place: the page pin in + // integration/known-bugs-route-hmr-components.test.ts. + test.fails( + 'a component exported by an export list renders for a module importing it and as the route component', + async () => { + const route = await loadRoute( + `${head}const page = () => <p>hi</p> +export { page } +export const Route = createFileRoute('/')({ component: page })`, + { + hmr: true, + files: { 'importer.ts': `export { page } from './route'\n` }, + }, + ) + await expectValidModules(route) + expect( + await route.run(`return [ + await render('component'), + await renderComponent((await app('importer.ts')).page), +]`), + ).toEqual(['<p>hi</p>', '<p>hi</p>']) + }, + ) + + // Control for the lowercase shared component pins above: a lowercase + // `function` loader that the split component also calls. + test('a lowercase function loader the split component calls loads from its chunk', async () => { + const route = await loadRoute( + `${head}function getData() { + return 'data' +} +export const Route = createFileRoute('/')({ + loader: getData, + component: () => <p>{getData()}</p>, + codeSplitGroupings: [['loader'], ['component']], +})`, + { hmr: true }, + ) + await expectValidModules(route) + expect(await route.isLazy('loader')).toBe(true) + expect( + await route.run( + `return [await options.loader(), await render('component')]`, + ), + ).toEqual(['data', '<p>data</p>']) + }) + + // Control for the hoisted inline component pin (a real page: + // integration/known-bugs-route-hmr.test.ts "an inline pending component + // hoisted before a renamed lowercase component"): with the route HMR + // plugin (automatic code splitting off), an option that is not an inline + // component, reading a lowercase component a later option passes, gets + // that component. + test('an option reading a lowercase component a later option passes gets that component', async () => { + const route = await loadRoute( + `${head}const errorFallback = () => <p>error</p> +export const Route = createFileRoute('/')({ + staticData: { errorFallback }, + errorComponent: errorFallback, +})`, + { hmr: true, pluginOptions: { autoCodeSplitting: false } }, + ) + expect( + await route.run(`return [ + options.staticData.errorFallback === options.errorComponent, + await renderComponent(options.errorComponent), +]`), + ).toEqual([true, '<p>error</p>']) + }) +}) diff --git a/packages/router-plugin/tests/plugin-options.test.ts b/packages/router-plugin/tests/plugin-options.test.ts new file mode 100644 index 0000000000..4db549ff95 --- /dev/null +++ b/packages/router-plugin/tests/plugin-options.test.ts @@ -0,0 +1,33 @@ +/** + * Router plugin options and entry points: what each option changes in a + * real app, through the public plugins in a real Vite dev server. + */ +import { describe, expect, test } from 'vitest' +import { + captureThrow, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { head, loadRoute } from './route-app' + +describe('repeated options in split groupings', () => { + test('in a route are refused with an error naming the route file and the option', async () => { + const route = await loadRoute( + `${head}export const Route = createFileRoute('/')({ + codeSplitGroupings: [['loader'], ['loader', 'component']], + loader: () => 'data', + component: () => <p>page</p>, +}) +`, + { filename: 'groupings-route.tsx' }, + ) + // The error the compile throws, with what every channel reported (the + // wording and the channel are free, SPEC §5.7) + const thrown = await captureThrow(() => route.transform()) + expect(thrown).not.toEqual([]) + expectDiagnostic([...thrown, ...(await route.diagnostics())], { + severity: 'error', + file: 'groupings-route.tsx', + root: route.host.root, + }) + }) +}) diff --git a/packages/router-plugin/tests/production-bundle.ts b/packages/router-plugin/tests/production-bundle.ts new file mode 100644 index 0000000000..eb4b4e011f --- /dev/null +++ b/packages/router-plugin/tests/production-bundle.ts @@ -0,0 +1,231 @@ +/** + * Production client bundles carry nothing of the dev server's additions + * (route HMR, React Refresh support), per bundler and framework (SPEC G7): + * the checks of integration/build-production*.test.ts (one file per bundler + * group, to keep each file within its time budget). + * The build decides production by its own signal (the bundler's production + * mode), with `NODE_ENV` unset, and the plugin's default for `addHmr`. + * + * The decision is by purpose, through paired real builds: a build + * with route HMR off (`addHmr: false`, `NODE_ENV=production` when the + * plugin is created) is the control, which differs in the development + * features only. The production bundle renders the route in a real browser + * and is the control's output, chunk for chunk: whatever it ships beyond + * the control serves development. + */ +import { expect } from 'vitest' +import { + build, + buildWithRsbuild, + clientMountEntry, + routeApp, + routeHead, +} from './build-harness' +import type { + BuildResult, + Bundler, +} from '@tanstack/compiler-test-utils/build-harness' +import type { Framework } from './build-harness' + +export const timeout = 120_000 + +const route = ( + framework: Framework, +) => `${routeHead(framework)}function Page() { + return <p>MARK_PAGE</p> +} +function Failure() { + return <p>MARK_FAILURE</p> +} +export const Route = createFileRoute('/')({ + loader: () => 'data', + errorComponent: Failure, + component: Page, +}) +` + +/** + * The app files of `routeFile` for the client: a file route as the index + * route; a root route (`createRootRoute`, `createRootRouteWithContext`) as + * the root, which the entry then re-exports. + */ +function appOf(routeFile: string, framework: Framework) { + if (!/\bcreateRootRoute(?:WithContext)?\b/.test(routeFile)) { + return routeApp(routeFile, { env: 'client', framework }) + } + return routeApp( + `${routeHead(framework)}export const Route = createFileRoute('/')({})\n`, + { + env: 'client', + framework, + files: { + 'routes/__root.tsx': routeFile, + 'entry.ts': clientMountEntry.replace( + "'./routes/index'", + "'./routes/__root'", + ), + }, + }, + ) +} + +/** + * Builds the route for production: as an app builds it (`NODE_ENV` unset, + * the plugin's default `addHmr`), or as the control with route HMR off. + */ +async function productionBuild( + bundler: Bundler | 'rsbuild', + framework: Framework, + autoCodeSplitting: boolean, + control: boolean, + routeFile = route(framework), +) { + const pluginOptions = { + autoCodeSplitting, + codeSplittingOptions: { addHmr: control ? false : undefined }, + } + const nodeEnv = control ? 'production' : null + const files = appOf(routeFile, framework) + return bundler === 'rsbuild' + ? buildWithRsbuild({ nodeEnv, pluginOptions, files }) + : build({ + bundler, + framework, + env: 'client', + nodeEnv, + pluginOptions, + files, + }) +} + +/** The emitted chunks, by file name. */ +function output(result: BuildResult) { + return Object.fromEntries( + result.chunks.map((chunk) => [chunk.fileName, chunk.code]), + ) +} + +/** + * Builds the route (default: the module's own) for production and asserts + * that the bundle renders the route's component (`MARK_PAGE` for the + * module's own route) and equals the control's (see the module comment). + */ +export async function expectProductionClientBundle( + bundler: Bundler | 'rsbuild', + framework: Framework, + autoCodeSplitting: boolean, + routeFile?: string, +) { + const app = await productionBuild( + bundler, + framework, + autoCodeSplitting, + false, + routeFile, + ) + const control = await productionBuild( + bundler, + framework, + autoCodeSplitting, + true, + routeFile, + ) + const run = await app.run( + 'const { component } = entry.Route.options\nif (component) await entry.mount(component)', + ) + if (routeFile === undefined) { + expect(run.html).toContain('MARK_PAGE') + } + expect(output(app)).toEqual(output(control)) +} + +/** + * Routes whose route HMR compile differs (source: the add-hmr snapshot + * fixtures): split options, lowercase component names, root routes (with + * `shellComponent`, with context), an undefined component, a Solid route. + * The dev rows of integration/route-hmr-dev-addhmr-off.test.ts run every + * one; production builds run the React ones the plain route above does not + * stand for. + */ +const fileRoute = ( + options: string, + declarations = '', + framework: Framework = 'react', +) => `import { createFileRoute } from '@tanstack/${framework}-router' +${declarations} +export const Route = createFileRoute('/')({ + loader: () => 'data', + ${options} +})` + +const posts = `function PostsComponent() { + return <div>posts</div> +} +function PostsErrorComponent() { + return <div>Error loading posts</div> +}` + +export const routeShapes: Array<{ + name: string + route: string + targetFramework?: Framework +}> = [ + { + name: 'a split route', + route: fileRoute('component: PostsComponent,', posts), + }, + { + name: 'a route with two split components', + route: fileRoute( + 'component: PostsComponent,\n errorComponent: PostsErrorComponent,', + posts, + ), + }, + { + name: 'a route with lowercase components', + route: `${routeHead()}export const Route = createFileRoute('/')({ + pendingComponent: pendingComponent, + errorComponent: errorComponent, + component: component, +}) +function pendingComponent() { + return <div>Pending</div> +} +function errorComponent() { + return <div>Error</div> +} +function component() { + return <div>Hello</div> +}`, + }, + { + name: 'a root route', + route: `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ + shellComponent: ({ children }) => <html>{children}</html>, + component: () => <div>root</div>, +})`, + }, + { + name: 'a root route with context', + route: `import { createRootRouteWithContext } from '@tanstack/react-router' +interface MyRouterContext { + auth: boolean +} +export const Route = createRootRouteWithContext<MyRouterContext>()({ + component: RootComponent, +}) +function RootComponent() { + return <div>Hello</div> +}`, + }, + { + name: 'an explicitly undefined component', + route: `${routeHead()}export const Route = createFileRoute('/')({ component: undefined })`, + }, + { + name: 'a Solid route', + route: fileRoute('component: PostsComponent,', posts, 'solid'), + targetFramework: 'solid', + }, +] diff --git a/packages/router-plugin/tests/production-warnings.test.ts b/packages/router-plugin/tests/production-warnings.test.ts deleted file mode 100644 index 1ace6edf50..0000000000 --- a/packages/router-plugin/tests/production-warnings.test.ts +++ /dev/null @@ -1,209 +0,0 @@ -/** - * A production client build ships none of the code splitter's development - * warnings, whatever the build process's `NODE_ENV` (Vitest sets it to - * `test`, which behaves like a shell without it): the bundler's mode - * decides, and webpack and Rspack build in production when `mode` is left - * out. Such a warning would log in every visitor's console, with the - * absolute path of the route file on the build machine. - */ -import { - mkdir, - mkdtemp, - readFile, - readdir, - rm, - writeFile, -} from 'node:fs/promises' -import path from 'node:path' -import { rspack } from '@rsbuild/core' -import webpack from 'webpack' -import { describe, expect, test, vi } from 'vitest' - -const timeout = 60_000 - -/** - * The exported component stays in the route module unless the code splitter - * can split exports; the error component is split either way. - */ -const routeSource = `import { createFileRoute } from '@tanstack/react-router' - -export function ExportedPage() { - return 'MARK_EXPORTED_PAGE' -} - -function ErrorPage() { - return 'MARK_ERROR_PAGE' -} - -export const Route = createFileRoute('/')({ - component: ExportedPage, - errorComponent: ErrorPage, -}) -` - -const rootSource = `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({}) -` - -/** Writes `files` into a new app directory inside the package. */ -async function createApp(files: Record<string, string>) { - // Keep the app inside the package so runtime imports resolve. - const root = await mkdtemp(path.join(__dirname, '.production-warnings-')) - await mkdir(path.join(root, 'routes')) - for (const [file, code] of Object.entries(files)) { - await writeFile(path.join(root, file), code) - } - return root -} - -function routerOptions(root: string) { - return { - target: 'react', - routesDirectory: path.join(root, 'routes'), - generatedRouteTree: path.join(root, 'routeTree.gen.ts'), - autoCodeSplitting: true, - } as const -} - -/** A client build of `entry` in `mode` (left out when undefined), unminified. */ -function compilerConfig( - root: string, - entry: string, - mode: 'production' | undefined, -) { - return { - context: root, - ...(mode ? { mode } : {}), - target: 'web', - entry: `./${entry}`, - output: { path: path.join(root, 'dist') }, - optimization: { minimize: false }, - } as const -} - -interface Compiler { - run: ( - callback: ( - error: Error | null, - stats?: { - hasErrors: () => boolean - toString: (options: object) => string - }, - ) => void, - ) => void - close: (callback: (error?: Error | null) => void) => void -} - -/** Runs one build and settles once the compiler has closed. */ -function runCompiler(compiler: Compiler) { - return new Promise<void>((resolve, reject) => { - compiler.run((error, stats) => { - // The test removes the app afterwards: wait for the compiler to finish. - compiler.close((closeError) => { - if (error ?? closeError) { - reject(error ?? closeError) - } else if (stats?.hasErrors()) { - reject(new Error(stats.toString({ all: false, errors: true }))) - } else { - resolve() - } - }) - }) - }) -} - -const bundlers = [ - { - name: 'webpack', - // webpack parses no TypeScript: the router plugin is the only loader. - extension: 'js', - async build(root: string, entry: string, mode: 'production' | undefined) { - const { tanstackRouter } = await import('../src/webpack') - await runCompiler( - webpack({ - ...compilerConfig(root, entry, mode), - // The test app is not part of the package's TypeScript project. - resolve: { tsconfig: false }, - plugins: [tanstackRouter(routerOptions(root))], - }), - ) - }, - }, - { - name: 'rspack', - // As in Rsbuild: SWC compiles the router plugin's output. - extension: 'tsx', - async build(root: string, entry: string, mode: 'production' | undefined) { - const { tanstackRouter } = await import('../src/rspack') - await runCompiler( - rspack({ - ...compilerConfig(root, entry, mode), - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'builtin:swc-loader', - options: { - jsc: { parser: { syntax: 'typescript', tsx: true } }, - }, - type: 'javascript/auto', - }, - ], - }, - plugins: [tanstackRouter(routerOptions(root))], - }), - ) - }, - }, -] as const - -describe.each(bundlers)('$name build', (bundler) => { - test.each([ - { label: "mode: 'production'", mode: 'production' }, - { label: 'mode left out', mode: undefined }, - ] as const)( - 'with $label, the client JS logs no warning about an exported component', - async ({ mode }) => { - const routeFile = `routes/index.${bundler.extension}` - const entry = `entry.${bundler.extension}` - const root = await createApp({ - [`routes/__root.${bundler.extension}`]: rootSource, - [routeFile]: routeSource, - [entry]: `import { Route } from './${routeFile}'\nglobalThis.route = Route\n`, - }) - const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}) - try { - await bundler.build(root, entry, mode) - const warned = warn.mock.calls.some((args) => - args.some((arg) => String(arg).includes('ExportedPage')), - ) - const dist = path.join(root, 'dist') - const chunks = new Map<string, string>() - for (const file of await readdir(dist)) { - if (file.endsWith('.js')) { - chunks.set(file, await readFile(path.join(dist, file), 'utf8')) - } - } - expect( - chunks.get('main.js'), - 'the error component is split', - ).not.toContain('MARK_ERROR_PAGE') - // An exported component kept in the route module is reported. - const split = !chunks.get('main.js')!.includes('MARK_EXPORTED_PAGE') - expect(split || warned, 'split, or reported by the build').toBe(true) - // The app's directory name appears only in absolute paths. - const linesNamingTheApp = [...chunks].flatMap(([file, code]) => - code - .split('\n') - .filter((line) => line.includes(path.basename(root))) - .map((line) => `${file}: ${line.trim()}`), - ) - expect(linesNamingTheApp).toEqual([]) - } finally { - warn.mockRestore() - await rm(root, { recursive: true, force: true }) - } - }, - timeout, - ) -}) diff --git a/packages/router-plugin/tests/react-refresh-route-components.test.ts b/packages/router-plugin/tests/react-refresh-route-components.test.ts index b0c14b7d8f..e99e6961ab 100644 --- a/packages/router-plugin/tests/react-refresh-route-components.test.ts +++ b/packages/router-plugin/tests/react-refresh-route-components.test.ts @@ -1,281 +1,221 @@ /** * Route HMR keeps the previous `component` (and the other component options) - * so that React Refresh can patch it in place. That only works when the value - * is bound to a top-level name React Refresh registers. These tests compile - * route files with the HMR transforms, then run Vite's Oxc React Refresh - * transform (the one `@vitejs/plugin-react` uses) on the output to see which - * components are registered and how their hook signatures are computed. + * so that React Refresh can patch it in place. Whether an edit shows in + * place with the component's state is tested on a real page + * (integration/route-hmr-browser-names.test.ts, + * integration/route-hmr-browser-options.test.ts). Here: the route modules + * the HMR transforms emit keep the route's components working, and modules + * importing the route module's exports get the components the route uses: + * the real plugin in a Vite dev server with the real React plugin, the + * route module and a real importer module run in a real page + * (`route-app.ts`), with the real router and React Refresh. */ import { describe, expect, it } from 'vitest' import { - compileRouteModules, - declarationOf, - declaratorName, - evaluateModule, - expectRegisteredRouteOption, - exportedNames, - getRouteOption, - head, - importedNames, - parseModule, - reactRefresh, - topLevelDeclarators, - transformWithRouteHmrPlugin, -} from './regression-helpers' -import type { ESTree } from 'vite' + appTsconfig, + expectExportedRouteOptions, + expectSharedOverloads, + exportedComponentsLostWhenSplit, + exportsImporter, +} from './dev-server' +import { expectValidModules, head, loadRoute } from './route-app' +import type { ExportedRouteOptionsCase } from './dev-server' -/** Compiles every module the code splitter emits, with React HMR. */ -function compileWithCodeSplitting(code: string) { - return compileRouteModules(code, { hmr: true }).modules -} - -describe('React Refresh registers route components', () => { - // Source: React Refresh ReactFreshBabelPlugin-test "registers top-level - // variable declarations with function expressions" and "... with arrow functions" - it.each([ - ['an arrow function', `() => <p>hi</p>`], - ['an anonymous function expression', `function () { return <p>hi</p> }`], - ['a parenthesized arrow function', `(() => <p>hi</p>)`], - ])('written inline as %s', async (_, component) => { - const code = transformWithRouteHmrPlugin( - `${head}export const Route = createFileRoute('/')({ component: ${component} })`, - ) - await expectRegisteredRouteOption(code, 'component') - }) - - it('for every inline component option of a root route, under distinct names', async () => { - const options = { - component: '() => <p>component</p>', - pendingComponent: '() => <p>pending</p>', - errorComponent: '({ error }) => <p>{String(error)}</p>', - notFoundComponent: '() => <p>not found</p>', - shellComponent: '({ children }) => <html><body>{children}</body></html>', - } - const { reference } = compileWithCodeSplitting( - `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({ -${Object.entries(options) - .map(([key, value]) => ` ${key}: ${value},`) - .join('\n')} -})`, - ) - const bindings = new Set<string>() - for (const option of Object.keys(options)) { - bindings.add(await expectRegisteredRouteOption(reference!, option)) - } - expect(bindings.size).toBe(Object.keys(options).length) - }) - - // Source: ReactFreshBabelPlugin-test "only registers pascal case functions" - // and "uses original function declaration if it get reassigned" - it.each([ - ['a const arrow function', `const page = () => <p>hi</p>`], - [ - 'a function expression that names itself', - `const page = function page() { return <p>{typeof page}</p> }`, - ], - [ - 'a reassigned function declaration', - `import { connect } from './connect'\nfunction page() { return <p>hi</p> }\npage = connect(page)`, - ], - ])('declared lowercase as %s, by renaming it', async (_, declaration) => { - const code = transformWithRouteHmrPlugin( - `${head}${declaration}\nexport const Route = createFileRoute('/')({ component: page })`, - ) - const binding = await expectRegisteredRouteOption(code, 'component') - expect(binding).toMatch(/^[A-Z]/) - }) +/** + * The route HMR plugin `tanstackRouter` adds in development when automatic + * code splitting is off, with React Refresh. + */ +const unsplit = { hmr: true, pluginOptions: { autoCodeSplitting: false } } +describe('route HMR keeps route components working under their names', () => { // Source: ReactFreshBabelPlugin-test "registers top-level exported function - // declarations" and "registers top-level exported named arrow functions" + // declarations" and "registers top-level exported named arrow functions"; + // the former "renamed lowercase and exported (%s), keeping what importers + // get". That an edit shows in place: integration/route-hmr-browser + // -names.test.ts. it.each([ - ['export function page', `export function page() { return <p>hi</p> }`], - ['export { page }', `const page = () => <p>hi</p>\nexport { page }`], + [ + 'export function page', + `export function page() { return <p>hi</p> }`, + 'page', + ], + [ + 'export { page }', + `const page = () => <p>hi</p>\nexport { page }`, + 'page', + ], [ 'export default page', `function page() { return <p>hi</p> }\nexport default page`, + 'default', ], ])( - 'renamed lowercase and exported (%s), keeping the exports', - async (_, declaration) => { - const source = `${head}${declaration}\nexport const Route = createFileRoute('/')({ component: page })` - const code = transformWithRouteHmrPlugin(source) - await expectRegisteredRouteOption(code, 'component') - expect(exportedNames(code)).toEqual( - expect.arrayContaining(exportedNames(source)), + 'a lowercase component exported as %s is what a module importing it gets (autoCodeSplitting: false)', + async (_, declaration, name) => { + const route = await loadRoute( + `${head}${declaration}\nexport const Route = createFileRoute('/page')({ component: page })`, + { + ...unsplit, + routeId: '/page', + tsconfig: appTsconfig, + files: { 'importer.ts': exportsImporter }, + }, ) + expect( + await route.run(`const { bindings } = await app('importer.ts') +const value = bindings[${JSON.stringify(name)}] +return [value === Route.options.component, await renderComponent(value)]`), + ).toEqual([true, '<p>hi</p>']) }, ) // Source: ReactFreshBabelPlugin-test "does not consider require-like methods to be HOCs" - it('but leaves an imported lowercase component to the module that declares it', () => { - const code = transformWithRouteHmrPlugin( + it('leaves an imported lowercase component to the module that declares it', async () => { + const route = await loadRoute( `${head}import { page } from './page' export const Route = createFileRoute('/')({ component: page })`, + { + ...unsplit, + files: { 'page.tsx': `export const page = () => null\n` }, + }, ) - const { value } = getRouteOption(parseModule(code), 'component') - expect((value as ESTree.IdentifierReference).name).toBe('page') - expect(importedNames(code, './page')).toEqual(['page']) + expect( + await route.run( + `return options.component === (await app('page.tsx')).page`, + ), + ).toBe(true) }) - // Source: ReactFreshBabelPlugin-test "registers top-level function declarations" - it('renames only the component binding, not an inner binding with its name', async () => { - const code = transformWithRouteHmrPlugin( + // Source: ReactFreshBabelPlugin-test "registers top-level function + // declarations" (an inner binding with the component's name) + it('keeps an inner binding named like the lowercase component working', async () => { + const route = await loadRoute( `${head}function page() { const page = 'inner-marker' return <p>{page}</p> } export const Route = createFileRoute('/')({ component: page })`, + unsplit, ) - await expectRegisteredRouteOption(code, 'component') - const { Route } = await evaluateModule(code, { - '@tanstack/react-router': { - createFileRoute: () => (options: unknown) => ({ options }), + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe( + '<p>inner-marker</p>', + ) + }) +}) + +// Inline, root route, lowercase and exported route components, options +// added beside a component and custom hooks, as React Refresh patches them +// on a real page: integration/route-hmr-browser-names.test.ts and +// integration/route-hmr-browser-options.test.ts (they replace the checks of +// which names React Refresh's transform registered and of the hook +// signatures it computed). Split route components written inline +// in a memo / forwardRef call: route-hmr-browser.test.ts. A route file +// creates one route (SPEC §2.2, J2.1, J2.11): no test of components of other +// routes a function of the file creates. + +// A route module stays a React Refresh boundary in Vite: +// route-hmr-browser.test.ts (a real page). + +describe('route HMR leaves options React Refresh does not handle as they are', () => { + // Loosened: the method keeps working. Being refreshable is the goal pinned + // by the "method shorthand" rows of + // integration/known-bugs-route-hmr-components.test.ts. + it('keeps a method-shorthand component option working', async () => { + const route = await loadRoute( + `${head}export const Route = createFileRoute('/')({ + component() { + return <p>hi</p> + }, +})`, + unsplit, + ) + await expectValidModules(route) + expect(await route.run(`return render('component')`)).toBe('<p>hi</p>') + }) +}) + +/** + * React HMR renames and hoists route components, and may split them out of + * the route module. Modules that import the route module's exports still need + * them, as the same values the route options use. These tests load the + * route file and a module importing its exports in a real page + * (`expectExportedRouteOptions`). + * + * Source: #8504 react-refresh-route-components "route module exports with + * React HMR and autoCodeSplitting". The class, aliased and overload-alias + * cases fail with automatic code splitting; they are pinned in + * known-bugs-dev-server.test.ts. + */ +describe.each([true, false])( + 'route module exports with React HMR and autoCodeSplitting=%s', + (autoCodeSplitting) => { + const cases: Array<ExportedRouteOptionsCase> = [ + { + name: 'function', + declaration: + 'export function component() { see(component); return <p>function</p> }', + options: 'component', + exported: { component: ['component'] }, }, - }) - expect((Route as any).options.component()).toBe('<p>inner-marker</p>') - }) + { + name: 'overloaded function', + declaration: + "import type { ReactNode } from 'react'\nexport function component(): ReactNode\nexport function component() { see(component); return <p>overloaded</p> }", + options: 'component', + exported: { component: ['component'] }, + }, + { + name: 'function used by two options', + declaration: + 'export function component() { see(component); return <p>two options</p> }', + options: 'component, errorComponent: component', + exported: { component: ['component', 'errorComponent'] }, + }, + { + name: 'variable', + declaration: + 'export const component = () => { see(component); return <p>variable</p> }', + options: 'component', + exported: { component: ['component'] }, + }, + { + name: 'variables declared together', + declaration: + 'export const component = () => { see(component); return <p>component</p> }, pendingComponent = () => { see(pendingComponent); return <p>pending</p> }', + options: 'component, pendingComponent', + exported: { + component: ['component'], + pendingComponent: ['pendingComponent'], + }, + }, + { + name: 'default', + declaration: + 'export default function component() { see(component); return <p>default</p> }', + options: 'component', + exported: { default: ['component'] }, + }, + ...(autoCodeSplitting ? [] : exportedComponentsLostWhenSplit), + ] - // Source: ReactFreshIntegration-test "preserves state ..." (families are - // matched by registration name) - it('names hoisted components after their option, so adding options keeps the family', async () => { - const before = transformWithRouteHmrPlugin( - `${head}export const Route = createFileRoute('/')({ component: () => <p>v1</p> })`, + it.each(cases)( + 'keep a $name component exported as the route option value', + async ({ declaration, options, exported }) => { + await expectExportedRouteOptions( + `${head}${declaration} +export const Route = createFileRoute('/page')({ ${options} })`, + exported, + autoCodeSplitting, + ) + }, + 30_000, ) - const after = transformWithRouteHmrPlugin( - `${head}export const Route = createFileRoute('/')({ - pendingComponent: () => <p>pending</p>, - errorComponent: () => <p>error</p>, - component: () => <p>v2</p>, -})`, - ) - expect(await expectRegisteredRouteOption(after, 'component')).toBe( - await expectRegisteredRouteOption(before, 'component'), - ) - }) - // Source: ReactFreshBabelPlugin-test "includes custom hooks into the signatures" - it('with the hook signature of the component the user wrote, also in the split chunk', async () => { - const declarations = `import { useState } from 'react' -const format = (n: number) => String(n) -function useCounter() { - const [count] = useState(0) - return format(count) -}` - const component = `() => { - const count = useCounter() - return <p>{count}</p> -}` - const { signatures } = await reactRefresh( - `${declarations}\nconst Page = ${component}\nexport const Route = {}`, - ) - const expected = signatures.get('Page') - expect(expected).toBeDefined() - // The loader shares `format` with the component's hook. - const source = `${head}${declarations} -export const Route = createFileRoute('/')({ - loader: () => format(1), - component: ${component}, -})` - - const hmr = transformWithRouteHmrPlugin(source) - const hoisted = await expectRegisteredRouteOption(hmr, 'component') - expect((await reactRefresh(hmr)).signatures.get(hoisted)).toBe(expected) - - const modules = compileWithCodeSplitting(source) - expect(modules.shared).toMatch(declarationOf('format')) - const chunkSignatures = (await reactRefresh(modules['virtual component']!)) - .signatures - expect([...chunkSignatures.values()]).toContain(expected) - }) -}) - -describe('React Refresh hoisting picks names nothing else uses', () => { - it.each([ - [ - 'a top-level const', - `const TSRComponent = 'taken'`, - `<p>{TSRComponent}</p>`, - ], - ['an import', `import { TSRComponent } from './taken'`, `<TSRComponent />`], - [ - 'a function declared after the route', - ``, - `<p>{TSRComponent()}</p>`, - `\nfunction TSRComponent() { return 'taken' }`, - ], - ])('not a name held by %s', async (_, before, jsx, after = '') => { - const code = transformWithRouteHmrPlugin( - `${head}${before} -export const Route = createFileRoute('/')({ component: () => ${jsx} })${after}`, - ) - // A reused name would redeclare the user's binding (an invalid module). - const binding = await expectRegisteredRouteOption(code, 'component') - expect(binding).not.toBe('TSRComponent') - }) - - it('nor a global the component reads', async () => { - const code = transformWithRouteHmrPlugin( - `${head}export const Route = createFileRoute('/')({ - component: () => <p>{typeof TSRPendingComponent}</p>, - pendingComponent: () => <p>pending</p>, -})`, - ) - const pending = await expectRegisteredRouteOption(code, 'pendingComponent') - expect(pending).not.toBe('TSRPendingComponent') - // `TSRPendingComponent` must stay an unresolved global inside `component`. - expect(code).not.toMatch(declarationOf('TSRPendingComponent')) - }) -}) - -describe('React Refresh hoisting of inline route components', () => { - it('hoists the root route component but not the components of routes a function creates', async () => { - const { reference } = compileWithCodeSplitting(` -import { createRootRoute, createRoute } from '@tanstack/react-router' -export function makeChild(label: string) { - return createRoute({ - getParentRoute: () => Route, - path: label, - component: () => <div>{label}</div>, - }) -} -export const Route = createRootRoute({ component: () => <div /> }) -`) - const program = parseModule(reference!) - // `label` only exists inside `makeChild`; any other top-level statement - // that mentions it reads an undefined global at render time. - const statementsUsingLabel = program.body - .map((statement) => reference!.slice(statement.start, statement.end)) - .filter( - (statement) => - /\blabel\b/.test(statement) && - !statement.includes('function makeChild('), - ) - expect(statementsUsingLabel).toEqual([]) - // React Refresh can only register components bound to top-level names. - await expectRegisteredRouteOption(reference!, 'component') - }) - - it('declares hoisted components before the route that uses them', () => { - // The lowercase `page`, declared in the same statement as `Route`, is - // renamed for React Refresh as well. - const { reference } = compileWithCodeSplitting(` -import { createRootRoute } from '@tanstack/react-router' -export const page = () => <div />, Route = createRootRoute({ - component: page, - pendingComponent: () => <div />, -}) -`) - const program = parseModule(reference!) - const { route, value } = getRouteOption(program, 'pendingComponent') - expect(value.type).toBe('Identifier') - const name = (value as ESTree.IdentifierReference).name - const declaration = topLevelDeclarators(program).find( - (declarator) => declaratorName(declarator) === name, - ) - // A `const` used before its declaration throws a TDZ ReferenceError when - // the route is created. - expect(declaration).toBeDefined() - expect(declaration!.start).toBeLessThan(route.start) - }) -}) + if (!autoCodeSplitting) { + it('keep exported overloads and their aliases that unsplit and split options call', async () => { + await expectSharedOverloads(autoCodeSplitting) + }, 30_000) + } + }, +) diff --git a/packages/router-plugin/tests/regression-helpers.ts b/packages/router-plugin/tests/regression-helpers.ts deleted file mode 100644 index df482ffe78..0000000000 --- a/packages/router-plugin/tests/regression-helpers.ts +++ /dev/null @@ -1,476 +0,0 @@ -/** - * Helpers shared by the code-splitter and route HMR regression suites: compile - * a route file into every module the code splitter emits, drive the bundler - * plugins the way a bundler does, and inspect or evaluate an emitted module. - */ -import { execFile } from 'node:child_process' -import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' -import path from 'node:path' -import { pathToFileURL } from 'node:url' -import { promisify } from 'node:util' -import { build, parseSync, transformWithOxc } from 'vite' -import { expect } from 'vitest' -import { - compileCodeSplitReferenceRoute, - compileCodeSplitSharedRoute, - compileCodeSplitVirtualRoute, - computeSharedBindings, -} from '../src/core/code-splitter/compilers' -import { getFrameworkHmrCompilerPlugins } from '../src/core/code-splitter/plugins/framework-plugins' -import { defaultCodeSplitGroupings } from '../src/core/constants' -import { createRouterCodeSplitterPlugin } from '../src/core/router-code-splitter-plugin' -import { createRouterHmrPlugin } from '../src/core/router-hmr-plugin' -import { createRouterPluginContext } from '../src/core/router-plugin-context' -import { normalizePath } from '../src/core/utils' -import { getModuleErrors } from './validate-module' -import type { Config } from '../src/core/config' -import type { CodeSplitGroupings } from '../src/core/constants' -import type { HmrStyle } from '../src/core/hmr' -import type { TransformResult, UnpluginOptions } from 'unplugin' -import type { ESTree } from 'vite' - -export { declarationOf } from './validate-module' - -export const head = `import { createFileRoute } from '@tanstack/react-router'\n` - -/** - * Compiles a route file with the default groupings into every module the code - * splitter emits for it: `reference`, one `virtual <split>` chunk per grouping - * and, when bindings are shared, `shared`. - */ -export function compileRouteModules( - code: string, - options: { - filename?: string - targetFramework?: 'react' | 'solid' - /** Compile with route HMR and the framework's HMR compiler plugins. */ - hmr?: boolean - } = {}, -) { - const { - filename = 'route.tsx', - targetFramework = 'react', - hmr = false, - } = options - const groupings = defaultCodeSplitGroupings - const compilerPlugins = hmr - ? getFrameworkHmrCompilerPlugins({ targetFramework }) - : undefined - const computed = computeSharedBindings({ - code, - filename, - codeSplitGroupings: groupings, - }) - const sharedBindings = computed.size > 0 ? computed : undefined - const reference = compileCodeSplitReferenceRoute({ - code, - filename, - id: filename, - addHmr: hmr, - codeSplitGroupings: groupings, - targetFramework, - sharedBindings, - compilerPlugins, - }) - const modules: Record<string, string> = { - reference: reference?.code ?? code, - } - for (const targets of groupings) { - const split = targets.join('-') - modules[`virtual ${split}`] = compileCodeSplitVirtualRoute({ - code, - filename: `${filename}?tsr-split=${split}`, - splitTargets: targets, - sharedBindings, - compilerPlugins, - }).code - } - if (sharedBindings) { - modules.shared = compileCodeSplitSharedRoute({ - code, - sharedBindings, - filename: `${filename}?tsr-shared=1`, - }).code - } - return { modules, sharedBindings: [...computed].sort() } -} - -/** Compiles every module of a route file and returns the component chunk. */ -export function componentChunk(code: string) { - return compileRouteModules(code).modules['virtual component']! -} - -/** Asserts that every module is valid, reporting the errors by module name. */ -export async function expectValidModules(modules: Record<string, string>) { - const errors: Record<string, Array<string>> = {} - for (const [name, code] of Object.entries(modules)) { - errors[name] = await getModuleErrors(code) - } - expect(errors).toEqual( - Object.fromEntries(Object.keys(modules).map((name) => [name, []])), - ) -} - -function moduleRecord(code: string) { - return parseSync('module.tsx', code, { sourceType: 'module' }).module -} - -/** Sources a module imports, side-effect imports included, sorted. */ -export function importSources(code: string) { - return [ - ...new Set( - moduleRecord(code).staticImports.map( - (statement) => statement.moduleRequest.value, - ), - ), - ].sort() -} - -/** - * The values a module imports from `source`, sorted: `default`, `*` for a - * namespace import, or the imported name. Type-only specifiers are skipped. - */ -export function importedNames(code: string, source: string) { - return moduleRecord(code) - .staticImports.filter( - (statement) => statement.moduleRequest.value === source, - ) - .flatMap((statement) => - statement.entries - .filter((entry) => !entry.isType) - .map((entry) => - entry.importName.kind === 'Default' - ? 'default' - : entry.importName.kind === 'NamespaceObject' - ? '*' - : entry.importName.name!, - ), - ) - .sort() -} - -/** Value names a module exports (`default` for a default export), sorted. */ -export function exportedNames(code: string) { - return moduleRecord(code) - .staticExports.flatMap((statement) => - statement.entries - .filter((entry) => !entry.isType && entry.exportName.kind !== 'None') - .map((entry) => entry.exportName.name ?? 'default'), - ) - .sort() -} - -/** Absolute, normalized path of a route file in the package's `src/routes`. */ -export function routeFile(name: string) { - return normalizePath(path.join(process.cwd(), `src/routes/${name}.tsx`)) -} - -function runTransform(plugin: UnpluginOptions, code: string, id: string) { - const transform = plugin.transform - if (!transform || typeof transform === 'function') { - throw new Error('Expected object transform') - } - const result = transform.handler.call({} as never, code, id) as - | TransformResult - | null - | undefined - if (!result) { - return null - } - return typeof result === 'string' ? result : result.code -} - -const referencePluginName = - 'tanstack-router:code-splitter:compile-reference-file' -const virtualPluginName = 'tanstack-router:code-splitter:compile-virtual-file' -const sharedPluginName = 'tanstack-router:code-splitter:compile-shared-file' - -/** - * Drives the three code-splitter transforms the way a bundler does, for the - * given route files (absolute path to route id). `configPlugins` are the - * plugins of the resolved Vite config; by default the code splitter itself, - * so its plugin-order check runs. - */ -export async function createCodeSplitterTransforms( - options: Partial<Config>, - routes: Record<string, string>, - configPlugins: Array<{ name: string }> = [{ name: referencePluginName }], -) { - const context = createRouterPluginContext() - for (const [file, routeId] of Object.entries(routes)) { - context.routesByFile.set(file, { routeId }) - } - const plugins = createRouterCodeSplitterPlugin( - { target: 'react', autoCodeSplitting: true, ...options }, - context, - ) - const pluginArray = Array.isArray(plugins) ? plugins : [plugins] - const byName = (name: string) => { - const plugin = pluginArray.find((candidate) => candidate.name === name) - if (!plugin) { - throw new Error(`Code-splitter plugin "${name}" not found`) - } - return plugin - } - const hook = byName(referencePluginName).vite?.configResolved - const config = { - root: process.cwd(), - command: 'build', - plugins: configPlugins, - } as never - if (typeof hook === 'function') { - await hook.call({} as never, config) - } else if (hook) { - await hook.handler.call({} as never, config) - } - return { - reference: (code: string, id: string) => - runTransform(byName(referencePluginName), code, id), - virtual: (code: string, id: string) => - runTransform(byName(virtualPluginName), code, id), - shared: (code: string, id: string) => - runTransform(byName(sharedPluginName), code, id), - } -} - -/** - * Runs the route HMR plugin (used when automatic code splitting is off) on - * the route file `file`, registered under `routeId`. - */ -export function transformWithRouteHmrPlugin( - code: string, - options: Partial<Config> = { target: 'react' }, - route: { file: string; routeId: string } = { - file: routeFile('index'), - routeId: '/', - }, - hmrStyle?: HmrStyle, -) { - const context = createRouterPluginContext() - context.routesByFile.set(route.file, { routeId: route.routeId }) - const plugins = createRouterHmrPlugin(options, context, hmrStyle) - const plugin = Array.isArray(plugins) ? plugins[0]! : plugins - const output = runTransform(plugin, code, route.file) - if (output === null) { - throw new Error('expected the route HMR plugin to transform the route') - } - return output -} - -/** Renders JSX to text: intrinsic elements become tags, components are called. */ -const jsxToText = `const Fragment = Symbol('Fragment') -const h = (type, props, ...children) => { - const text = children.flat(Infinity).filter((c) => c != null && c !== false && c !== true).join('') - if (type === Fragment) { - return text - } - if (typeof type === 'function') { - return type({ ...props, children: text }) - } - if (typeof type !== 'string') { - throw new Error('cannot render ' + String(type)) - } - return '<' + type + '>' + text + '</' + type + '>' -} -` - -const stubsKey = '__regressionModuleStubs' -let evaluations = 0 - -/** - * Evaluates an emitted module like a bundler would: JSX becomes plain calls - * that render to text, and named imports are linked to `stubs`, keyed by - * specifier. Every call evaluates a fresh module instance. - */ -export async function evaluateModule( - code: string, - stubs: Record<string, Record<string, unknown>> = {}, -): Promise<Record<string, (...args: Array<any>) => any>> { - const { code: javascript } = await transformWithOxc(code, 'module.tsx', { - jsx: { runtime: 'classic', pragma: 'h', pragmaFrag: 'Fragment' }, - }) - const key = `${stubsKey}${evaluations++}` - ;(globalThis as Record<string, unknown>)[key] = stubs - // Imports are hoisted: link them before any other statement runs. - const imports: Array<string> = [] - const body = javascript.replace( - /^import\s+\{([^}]*)\}\s+from\s+(["'])(.+?)\2;?$/gm, - (_, named: string, __, source: string) => { - if (!(source in stubs)) { - throw new Error(`no stub for import ${source}`) - } - imports.push( - `const { ${named.replace(/\bas\b/g, ':')} } = globalThis.${key}[${JSON.stringify(source)}];`, - ) - return '' - }, - ) - return import( - /* @vite-ignore */ `data:text/javascript,${encodeURIComponent(`${jsxToText}${imports.join('\n')}\n${body}`)}` - ) -} - -/** - * Applies Vite's Oxc React Refresh transform (the one `@vitejs/plugin-react` - * uses) and returns the registered component names and the hook signature - * arguments of each signed binding. - */ -export async function reactRefresh(code: string) { - const result = await transformWithOxc(code, 'route.tsx', { - jsx: { - runtime: 'automatic', - development: true, - refresh: { emitFullSignatures: true }, - }, - }) - const registered = [ - ...result.code.matchAll(/\$RefreshReg\$\(\w+, "([^"]+)"\)/g), - ].map((match) => match[1]!) - const signatures = new Map( - [...result.code.matchAll(/\b_s\d*\((\w+), ([\s\S]*?)\);\n/g)].map( - (match) => [match[1]!, match[2]!] as const, - ), - ) - return { registered, signatures } -} - -/** Parses a module, asserting that it has no syntax errors. */ -export function parseModule(code: string) { - const { program, errors } = parseSync('route.tsx', code, { - sourceType: 'module', - }) - expect(errors).toEqual([]) - return program -} - -/** Declarators of the top-level variable declarations, exported or not. */ -export function topLevelDeclarators(program: ESTree.Program) { - return program.body.flatMap((statement) => { - const declaration = - statement.type === 'ExportNamedDeclaration' - ? statement.declaration - : statement - return declaration?.type === 'VariableDeclaration' - ? declaration.declarations - : [] - }) -} - -export function declaratorName(declarator: ESTree.VariableDeclarator) { - return declarator.id.type === 'Identifier' ? declarator.id.name : undefined -} - -/** The `Route` declarator and the value of its `option`. */ -export function getRouteOption(program: ESTree.Program, option: string) { - const route = topLevelDeclarators(program).find( - (declarator) => declaratorName(declarator) === 'Route', - ) - const options = - route?.init?.type === 'CallExpression' ? route.init.arguments[0] : null - if (options?.type !== 'ObjectExpression') { - throw new Error('expected `Route` to be created with an options object') - } - const property = options.properties.find( - (candidate) => - candidate.type === 'Property' && - candidate.key.type === 'Identifier' && - candidate.key.name === option, - ) - if (property?.type !== 'Property') { - throw new Error(`expected the \`${option}\` route option`) - } - return { route: route!, value: property.value } -} - -/** Asserts that `option` points to a binding React Refresh registers. */ -export async function expectRegisteredRouteOption( - code: string, - option: string, -) { - expect(await getModuleErrors(code)).toEqual([]) - const { value } = getRouteOption(parseModule(code), option) - expect(value.type).toBe('Identifier') - const binding = (value as ESTree.IdentifierReference).name - expect((await reactRefresh(code)).registered).toContain(binding) - return binding -} - -const runNode = promisify(execFile) - -/** - * Builds a small app with the real Vite plugin (code splitting on, default - * groupings unless `groupings` is given): `routes/index.tsx` holds `route`, - * and `entry.ts` re-exports the route module next to `render(component)`, - * which preloads a component and renders it to a string. `files` adds files - * or replaces `entry.ts`. Then imports the built entry in a separate Node - * process and returns the JSON value returned by `script`, which has the - * entry's exports in scope as `entry`. - */ -export async function buildAndRun( - route: string, - script: string, - options: { - files?: Record<string, string> - groupings?: CodeSplitGroupings - } = {}, -) { - const { tanstackRouter } = await import('../src/vite') - // Keep the temporary app inside the package so real runtime imports resolve. - const root = await mkdtemp(path.join(__dirname, '.regression-build-')) - try { - await mkdir(path.join(root, 'routes')) - const files: Record<string, string> = { - 'routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({})`, - 'routes/index.tsx': route, - 'entry.ts': `import { createElement } from 'react' -import { renderToString } from 'react-dom/server' -export * from './routes/index' -export async function render(component: any) { - await component.preload?.() - return renderToString(createElement(component)) -} -`, - ...options.files, - } - for (const [file, code] of Object.entries(files)) { - await writeFile(path.join(root, file), code) - } - await build({ - root, - configFile: false, - logLevel: 'silent', - plugins: [ - tanstackRouter({ - target: 'react', - routesDirectory: './routes', - generatedRouteTree: './routeTree.gen.ts', - autoCodeSplitting: true, - codeSplittingOptions: { - addHmr: false, - ...(options.groupings && { defaultBehavior: options.groupings }), - }, - }), - ], - build: { - ssr: path.join(root, 'entry.ts'), - outDir: 'dist', - minify: false, - rollupOptions: { - output: { entryFileNames: 'entry.mjs', chunkFileNames: '[name].mjs' }, - }, - }, - }) - const entryUrl = pathToFileURL(path.join(root, 'dist/entry.mjs')).href - const { stdout } = await runNode(process.execPath, [ - '--input-type=module', - '--eval', - `const entry = await import(${JSON.stringify(entryUrl)}) -const result = await (async () => { ${script} })() -process.stdout.write(JSON.stringify(result))`, - ]) - return JSON.parse(stdout) as unknown - } finally { - await rm(root, { recursive: true, force: true }) - } -} diff --git a/packages/router-plugin/tests/route-app.ts b/packages/router-plugin/tests/route-app.ts new file mode 100644 index 0000000000..2f9070cb1f --- /dev/null +++ b/packages/router-plugin/tests/route-app.ts @@ -0,0 +1,1447 @@ +/** + * A route file loaded the way an app loads it (SPEC §8: real tools only): + * the public composed `tanstackRouter` plugin and the framework's own Vite + * plugin run in a real Vite dev server + * (`@tanstack/compiler-test-utils/plugin-host`), on an app written to disk + * (`__root.tsx`, the route file, the files the test gives). The router + * plugin's own route generator registers the route (a virtual route config + * naming the route file: the public `virtualRouteConfig` option), so nothing + * of the compiler is assumed: no hook placement, no recorder, no module id, + * query or registration. + * + * Client semantics run in a real browser: every check is a script run in + * a run page of the test process (`runClient`: a page of the bounded pool + * of `@tanstack/compiler-test-utils/browser`, held by the run alone, a fresh + * document per run), which imports the route module from the dev server + * with real ES module linking, the real Vite client and the framework's + * refresh runtime, and renders with the real framework's client renderer + * and the real router. The test's own modules (what the route file imports) + * are files of the app; the page reads what they record. + * + * Laziness is observed through the router's public lazy contract (a route + * component's `preload()`, a loader call) and the modules the page actually + * requests from the dev server. Which of them the compilers emitted for the + * route is told by provenance, never by id or path (SPEC §5.3: whatever its + * id, wherever it is served from, `/@fs/` and `/node_modules/` included): + * the dev server observes the router plugin's own `load` and `transform` + * hooks (`observeEmitted`) and answers the page which requested modules got + * their code from them; a file the test wrote, a dependency, Vite's client + * or a refresh runtime gets none. Never by recognising the helper that + * builds a lazy value (J2.6, §5.8). + * + * Hosts are shared by the tests of a test process (across its files, in + * projects that keep modules across files), one configuration each (target, + * plugin options, the route's file and id, the app's tsconfig), and leased + * to one test at a time (`leaseHost`): a test holds the host it wrote a + * route into until it ends, and a concurrent test of the same configuration + * gets another host. Each `loadRoute` writes its files + * to the app as a dev server sees an edit (`edit`: written to disk, reported + * by Vite's watcher, settled on a bounded outcome), and removes the files of + * the previous route of that host. A route whose host has moved on to + * another route's files writes its own back before its next page run. + * Diagnostics are the dev server's merged channel (console, process + * streams, Vite's logger) since the route's files were written. Free hosts + * beyond `freeHostLimit` are closed; the others close with the process + * (their apps are removed when it exits). + */ +import path from 'node:path' +import react from '@vitejs/plugin-react' +import vueJsx from '@vitejs/plugin-vue-jsx' +import solid from 'vite-plugin-solid' +import { parseSync, transformWithOxc } from 'vite' +import { expect } from 'vitest' +import { createPluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import { currentTest } from '@tanstack/compiler-test-utils/test-scope' +import { DanglingNameError } from '@tanstack/compiler-test-utils/build-harness' +import { readNames } from '@tanstack/compiler-test-utils/free-names' +import { clientGlobals } from '@tanstack/compiler-test-utils/known-globals' +import { tanstackRouter } from '../src/vite' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { PageRun } from '@tanstack/compiler-test-utils/browser' +import type { BuildResult } from '@tanstack/compiler-test-utils/build-harness' +import type { PluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import type { ESTree, Plugin, PluginOption } from 'vite' +import type { Config, DeletableNodes } from '../src' + +/** A framework the router plugin targets. */ +export type TargetFramework = 'react' | 'solid' | 'vue' + +export interface RouteAppOptions { + /** Default `react`. */ + targetFramework?: TargetFramework + /** + * Path of the route file in the app (default `route.tsx`); its extension + * gives its language. + */ + filename?: string + /** + * Route id the route file is registered under (default `/`, an index + * route under the root). A route file creating a root route + * (`createRootRoute`, `createRootRouteWithContext`) is the app's root. + */ + routeId?: string + /** + * Compile for route HMR (`codeSplittingOptions.addHmr`, default `false` + * here: the dev server's own default is `true`). + */ + hmr?: boolean + /** + * Route options removed from the output, as Start configures the client + * (`['ssr', 'server', 'headers']`). + */ + deleteNodes?: Array<DeletableNodes> + /** + * Router plugin options over the harness's (`target`, `autoCodeSplitting: + * true`, the virtual route config, `codeSplittingOptions` merged with + * `hmr` and `deleteNodes`). + */ + pluginOptions?: Partial<Config> + /** + * Other Vite plugins, before and after the router plugin and the + * framework's plugin (a host of its own). + */ + plugins?: { + before?: Array<PluginOption> + after?: Array<PluginOption> + } + /** + * The other files of the app (what the route file imports), by path + * relative to the app root (the route file's directory by default): + * `{ 'config.ts': 'export const …' }` for `import … from './config'`. + */ + files?: Record<string, string> + /** + * `compilerOptions` of the app's `tsconfig.json` over the default + * (`verbatimModuleSyntax: true`): what Vite's TypeScript transform reads, + * e.g. `experimentalDecorators`, `jsx`. + */ + tsconfig?: Record<string, unknown> + /** A host of its own (a fresh dev server), not shared with other routes. */ + fresh?: boolean + /** + * Directory the app is created in (default this tests directory), e.g. + * another project root; bare imports resolve from there, so it must be + * inside this package. + */ + dir?: string + /** + * Other dependencies the app imports that the page needs pre-bundled, as + * Vite pre-bundles an app's installed dependencies (e.g. a CommonJS + * package, or `@emotion/react` and its JSX runtimes). + */ + prebundle?: Array<string> + /** + * Options of the framework's own Vite plugin, as an app gives them (e.g. + * `{ jsxRuntime: 'classic' }` for `@vitejs/plugin-react`: a project whose + * JSX runtime is classic). + */ + frameworkPluginOptions?: Record<string, unknown> + /** + * A script the app's page runs before the route module loads, in every + * page run of the route (as a `<script>` of the page defining globals the + * route reads); a run's `before` runs after it. + */ + pageScript?: string +} + +/** Route options the code splitter may split. */ +export const splittableOptions = [ + 'component', + 'errorComponent', + 'pendingComponent', + 'notFoundComponent', + 'loader', +] + +/** Dependencies the app imports, pre-bundled up front as Vite does for an app. */ +const prebundled: Record<TargetFramework, Array<string>> = { + react: [ + 'react', + 'react/jsx-runtime', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + solid: [ + 'solid-js', + 'solid-js/web', + 'solid-js/store', + '@tanstack/solid-router', + ], + vue: ['vue', '@tanstack/vue-router'], +} + +/** The framework's own Vite plugin, as an app adds it. */ +const frameworkPlugins: Record< + TargetFramework, + (options?: Record<string, unknown>) => PluginOption +> = { + react: (options) => react(options), + solid: (options) => solid(options), + vue: (options) => vueJsx(options), +} + +/** The page-side helper module every app holds (see `probeSource`). */ +export const probeFile = 'route-app-probe.ts' + +/** + * The app module the page imports the route module through, as the app's + * own modules import it (the route tree does): after an edit, Vite's import + * analysis gives every import of the edited module its HMR timestamp, so + * the split chunks import `/route.tsx?t=…`; a page importing + * `/route.tsx` itself would get a second instance of the route module. + */ +export const entryFile = 'route-app-entry.ts' + +const entrySource = (filename: string) => + `export * as route from './${filename.replace(/^\.\//, '')}'\n` + +/** + * The dev server's answer to the page: which requested modules the compilers + * emitted (see `emittedEndpointPlugin`). + */ +const emittedEndpoint = '/__route-app__/emitted' + +/** + * The modules the compilers emitted code for, by environment and module id: + * for each, the hooks that gave it its code (see `observeEmitted`). + */ +type EmittedModules = Map<string, Set<string>> + +const emittedKey = (environment: string, id: string) => `${environment}\0${id}` + +/** + * Observes the hooks of `option` (the router plugin as its public entry + * point returns it, or a plugin a harness control has stand in for a + * compiler), in place: a module whose code one of their `load` hooks + * returned, or whose code one of their `transform` hooks changed, is a + * module they emitted. The hooks run as before and their results pass + * through unchanged; nothing of their ids, queries or paths is assumed. + * Every plugin of the option is observed, however Vite gets it: in nested + * arrays, as a Promise (the option is returned with each Promise replaced + * by one that resolves to the same, observed, plugins), or returned by a + * plugin's `applyToEnvironment` for an environment. + */ +function observeEmitted( + option: PluginOption, + emitted: EmittedModules, +): PluginOption { + const record = ( + environment: string, + id: string, + hook: string, + gave: boolean, + ) => { + const key = emittedKey(environment, id) + const hooks = emitted.get(key) ?? new Set<string>() + if (gave) { + hooks.add(hook) + } else { + hooks.delete(hook) + } + emitted.set(key, hooks) + } + const environmentOf = (context: unknown, options: unknown) => + (context as { environment?: { name?: string } } | undefined)?.environment + ?.name ?? + ((options as { ssr?: boolean } | undefined)?.ssr ? 'ssr' : 'client') + const codeOf = (result: unknown) => + typeof result === 'string' + ? result + : (result as { code?: unknown } | null | undefined)?.code + const wrap = ( + hook: unknown, + after: (context: unknown, args: Array<unknown>, result: unknown) => void, + ) => { + if (!hook) { + return hook + } + const handler = ( + typeof hook === 'function' ? hook : (hook as { handler: unknown }).handler + ) as (...args: Array<unknown>) => unknown + async function observed(this: unknown, ...args: Array<unknown>) { + const result = await handler.apply(this, args) + after(this, args, result) + return result + } + return typeof hook === 'function' + ? observed + : { ...(hook as object), handler: observed } + } + const observed = new WeakSet<object>() + /** `value`, its plugins observed (a Promise: one resolving to them). */ + const visit = (value: unknown): unknown => { + if (Array.isArray(value)) { + value.forEach((item, index) => { + value[index] = visit(item) + }) + return value + } + if (value && typeof (value as { then?: unknown }).then === 'function') { + return Promise.resolve(value).then(visit) + } + if (!value || typeof value !== 'object' || observed.has(value)) { + return value + } + observed.add(value) + const plugin = value as Plugin + const name = plugin.name + // Plugins it returns for an environment (`applyToEnvironment` may + // return a plugin option instead of a boolean) + const applyToEnvironment = plugin.applyToEnvironment + if (typeof applyToEnvironment === 'function') { + plugin.applyToEnvironment = function (this: unknown, ...args) { + return visit(applyToEnvironment.apply(this, args)) as ReturnType< + NonNullable<Plugin['applyToEnvironment']> + > + } + } + plugin.load = wrap(plugin.load, (context, [id, options], result) => { + record( + environmentOf(context, options), + id as string, + `${name} load`, + typeof codeOf(result) === 'string', + ) + }) as Plugin['load'] + plugin.transform = wrap( + plugin.transform, + (context, [code, id, options], result) => { + const output = codeOf(result) + record( + environmentOf(context, options), + id as string, + `${name} transform`, + typeof output === 'string' && output !== code, + ) + }, + ) as Plugin['transform'] + return plugin + } + return visit(option) as PluginOption +} + +/** + * The URL Vite's module graph knows a served module by: decoded, and a + * virtual module's id out of the `/@id/` form Vite serves it under (`\0` + * spelled `__x00__`: Vite's documented convention for virtual modules). + */ +function servedId(url: string) { + const decoded = decodeURI(url).replaceAll('__x00__', '\0') + return decoded.startsWith('/@id/') ? decoded.slice('/@id/'.length) : decoded +} + +/** + * Answers the page's question (`emittedEndpoint`: a JSON list of requests, + * path and query) from what `observeEmitted` saw: for each, whether the + * module the client environment serves for it got its code from the + * compilers. + */ +function emittedEndpointPlugin(emitted: EmittedModules): Plugin { + return { + name: 'route-app:emitted-modules', + configureServer(server) { + server.middlewares.use(emittedEndpoint, (request, response) => { + let body = '' + request.on('data', (chunk) => { + body += chunk + }) + request.on('end', () => { + const graph = server.environments.client.moduleGraph + // (answered whatever happens: a request left open would hold one + // of the page's connections to the dev server) + Promise.resolve() + .then(() => + Promise.all( + (JSON.parse(body) as Array<string>).map(async (url) => { + const module = await graph.getModuleByUrl(servedId(url)) + return ( + module?.id != null && + (emitted.get(emittedKey('client', module.id))?.size ?? 0) > + 0 + ) + }), + ), + ) + .then( + (answers) => { + response.setHeader('content-type', 'application/json') + response.end(JSON.stringify(answers)) + }, + (error: unknown) => { + response.statusCode = 500 + response.end(String(error)) + }, + ) + }) + }) + }, + } +} + +/** + * The framework part of the page helper: `mount(target, el)` renders a + * component or the router into `el` with the framework's client renderer + * and throws what rendering threw; `element(component, props)`. + */ +const frameworkProbe: Record<TargetFramework, string> = { + react: `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/react-router' +export { RouterProvider, createMemoryHistory, createRouter } +export function mount(component: any, props: Record<string, unknown>, el: HTMLElement, caught: boolean) { + const errors: Array<unknown> = [] + const root = createRoot(el, { + onUncaughtError: (error) => errors.push(error), + onRecoverableError: (error) => errors.push(error), + ...(caught ? {} : { onCaughtError: (error: unknown) => errors.push(error) }), + }) + flushSync(() => root.render(createElement(component, props))) + return { errors, unmount: () => root.unmount() } +} +`, + solid: `import { createComponent } from 'solid-js' +import { render } from 'solid-js/web' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/solid-router' +export { RouterProvider, createMemoryHistory, createRouter } +export function mount(component: any, props: Record<string, unknown>, el: HTMLElement) { + const errors: Array<unknown> = [] + let unmount = () => {} + try { + unmount = render(() => createComponent(component, props), el) + } catch (error) { + errors.push(error) + } + return { errors, unmount } +} +`, + vue: `import { createApp, h } from 'vue' +import { RouterProvider, createMemoryHistory, createRouter } from '@tanstack/vue-router' +export { RouterProvider, createMemoryHistory, createRouter } +export function mount(component: any, props: Record<string, unknown>, el: HTMLElement) { + const errors: Array<unknown> = [] + const app = createApp({ render: () => h(component, props) }) + app.config.errorHandler = (error) => { + errors.push(error) + } + app.config.warnHandler = () => {} + try { + app.mount(el) + } catch (error) { + errors.push(error) + } + return { errors, unmount: () => app.unmount() } +} +`, +} + +/** + * The page-side helper: request observation (resource timing of the + * document), option triggers, rendering of a component or of the app + * through the generated route tree and the real router. + */ +function probeSource(framework: TargetFramework) { + return `${frameworkProbe[framework]} +performance.setResourceTimingBufferSize(1_000_000) + +/** Whether the compilers emitted a request, as the dev server observed it. */ +const emittedAnswers = new Map<string, boolean>() + +/** + * The requests so far whose modules the compilers emitted (asked of the dev + * server once per request and document: \`${emittedEndpoint}\`). + */ +async function emitted(requests: Array<string>) { + const unknown = requests.filter((request) => !emittedAnswers.has(request)) + if (unknown.length > 0) { + const response = await fetch('${emittedEndpoint}', { method: 'POST', body: JSON.stringify(unknown) }) + if (!response.ok) throw new Error('the dev server could not tell the emitted modules: ' + (await response.text())) + const answers: Array<boolean> = await response.json() + unknown.forEach((request, index) => emittedAnswers.set(request, answers[index]!)) + } + return requests.filter((request) => emittedAnswers.get(request)) +} + +/** + * Modules the compilers emitted that the document requested so far, in + * order (path and query): the route module, and every module the compilers + * emitted that is not a file of the test as written (\`own\`: their paths). + */ +export async function compiledRequests(routeUrl: string, own: Array<string>): Promise<Array<string>> { + const owned = new Set(own) + const requests = [...requestUrls().keys()] + const emittedRequests = new Set(await emitted(requests)) + return requests.filter((request) => request === routeUrl || (!owned.has(request) && emittedRequests.has(request))) +} + +/** + * App-local modules the document requested so far, in order (path and + * query): the compiled ones and the files of the test (\`own\`), whatever + * the query a tool serves them with (e.g. \`/data.json?import\`). + */ +export async function appRequests(routeUrl: string, own: Array<string>): Promise<Array<string>> { + const owned = new Set(own) + const compiled = new Set(await compiledRequests(routeUrl, own)) + return [...requestUrls().keys()].filter((request) => compiled.has(request) || owned.has(request.split('?')[0]!)) +} + +/** + * The app-local requests so far, each without the timestamp Vite's import + * analysis adds to imports of a file it hot-updated (\`t=\`), with the URL + * the page actually requested. + */ +function requestUrls(): Map<string, string> { + const seen = new Map<string, string>() + for (const entry of performance.getEntriesByType('resource')) { + const url = new URL(entry.name) + if (url.origin !== location.origin) continue + // Without Vite's HMR timestamp (the t= query, which import analysis adds to + // imports of a module an edit changed): one request per module + const actual = url.pathname + url.search + url.searchParams.delete('t') + const request = url.pathname + url.search + if (url.pathname === '/${probeFile}' || url.pathname === '/${entryFile}' || url.pathname === '${emittedEndpoint}') continue + if (!seen.has(request)) seen.set(request, actual) + } + return seen +} + +/** + * The URL to import an app module by to get the instance the page's other + * modules share: the URL they requested, or the plain one. (The import + * itself happens in the page's script: Vite rewrites the dynamic imports + * of the modules it serves.) + */ +export function requestUrl(request: string) { + return requestUrls().get(request) ?? request +} + +/** Starts loading a route option as the router does (errors ignored). */ +export async function trigger(route: any, option: string) { + const value = route?.options?.[option] + try { + if (option === 'loader') { + const loader = typeof value === 'function' ? value : value?.handler + if (typeof loader === 'function') await loader() + return + } + await value?.preload?.() + } catch {} +} + +/** + * Throws when a module of the app the document requested failed (an HTTP + * error: the dev server could not compile it). The router hides a failed + * route chunk until it renders the lazy component, and then reloads the + * page once (as after a deployment): rendering it would navigate the page + * away from the run instead of failing it. + */ +export function assertNoFailedRequests() { + const failed = performance + .getEntriesByType('resource') + .filter((entry: any) => entry.responseStatus >= 400) + .map((entry: any) => \`\${new URL(entry.name).pathname}\${new URL(entry.name).search} (HTTP \${entry.responseStatus})\`) + if (failed.length > 0) throw new Error(\`a module of the app failed to load: \${failed.join(', ')}\`) +} + +/** The option as the router uses it, once its module loaded. */ +export async function load(route: any, option: string) { + const value = route.options[option] + if (option !== 'loader') await value?.preload?.() + assertNoFailedRequests() + return value +} + +function settled(el: HTMLElement, isIdle: () => boolean, timeout: number) { + return new Promise<void>((resolve) => { + const deadline = performance.now() + timeout + let last = el.innerHTML + let stable = 0 + const check = () => { + const now = el.innerHTML + stable = now === last && isIdle() ? stable + 1 : 0 + last = now + if (stable >= 3 || performance.now() > deadline) resolve() + else setTimeout(check, 10) + } + setTimeout(check, 0) + }) +} + +/** Renders a component with the framework's client renderer: its HTML. */ +export async function renderComponent(component: any, props: Record<string, unknown> = {}) { + assertNoFailedRequests() + const el = document.createElement('div') + document.body.append(el) + const { errors, unmount } = mount(component, props, el, false) + if (errors.length > 0) throw errors[0] + await settled(el, () => true, 200) + const html = el.innerHTML + unmount() + el.remove() + return html +} + +/** + * Renders the app at \`at\`: the generated route tree, the real router + * (memory history), \`router.load()\`, then \`RouterProvider\`. + */ +export async function renderRoute(at: string, routerOptions: Record<string, unknown> = {}) { + // Imported by its URL when the app renders, not linked when this helper + // loads: a run that renders no route does not depend on the route tree + // (which a generator that rejects the route file never writes) + const routeTreeUrl = '/routeTree.gen.ts' + const { routeTree } = await import(/* @vite-ignore */ routeTreeUrl) + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [at] }), + ...routerOptions, + }) + await router.load() + assertNoFailedRequests() + const el = document.createElement('div') + document.body.append(el) + const { errors } = mount(RouterProvider, { router }, el, true) + if (errors.length > 0) throw errors[0] + await settled(el, () => router.state.status === 'idle' && !router.state.isLoading, 3000) + return { html: el.innerHTML, router } +} +` +} + +/** The app's root route, when the route file is not the root. */ +const rootRoute = (target: TargetFramework) => + `import { createRootRoute } from '@tanstack/${target}-router' +export const Route = createRootRoute({}) +` + +/** Whether a route file creates a root route (it is then the app's root). */ +const createsRootRoute = (code: string) => + /\bcreateRootRoute(?:WithContext)?\s*[(<]/.test(code) + +/** URL of an app file (relative to the app root). */ +export const appUrl = (file: string) => + `/${file.replace(/^\.\//, '').replaceAll('\\', '/')}` + +interface HostState { + host: PluginHost + /** Files the current route wrote (other than the fixed ones), by path. */ + current: Record<string, string> + /** The route whose files the app holds now. */ + owner: object | undefined + used: boolean +} + +/** + * A host of this test process: shared by the tests of one configuration + * (`hostKey`), one test at a time. The test that holds it (its lease) writes + * its routes into it; another test needing that configuration meanwhile (a + * concurrent test) gets a host of its own. A custom host (`fresh`, or + * `plugins`) serves only the test that created it, and closes when it ends. + */ +interface HostEntry { + key: string + custom: boolean + state: Promise<HostState> + /** The test holding the host, or `undefined` when it is free. */ + lease: object | undefined + /** When the host was last given back (to close the least recently used). */ + released: number +} + +const hostEntries: Array<HostEntry> = [] + +/** Free shared hosts a test process keeps for later tests, at most. */ +const freeHostLimit = 6 + +/** The holder of hosts taken outside any test (e.g. in a `beforeAll`). */ +const outsideTests = {} + +async function closeEntry(entry: HostEntry) { + const index = hostEntries.indexOf(entry) + if (index !== -1) { + hostEntries.splice(index, 1) + } + const resolved = await entry.state.catch(() => undefined) + await resolved?.host.close() +} + +/** Gives a host back; closes free hosts beyond `freeHostLimit`. */ +async function releaseEntry(entry: HostEntry) { + entry.lease = undefined + entry.released = performance.now() + if (entry.custom) { + await closeEntry(entry) + return + } + const free = hostEntries + .filter((candidate) => candidate.lease === undefined && !candidate.custom) + .sort((a, b) => b.released - a.released) + for (const extra of free.slice(freeHostLimit)) { + await closeEntry(extra) + } +} + +/** + * The host the current test writes a route of configuration `key` into: the + * one it holds, a free one, or a new one (`start`). + */ +function leaseHost( + key: string, + custom: boolean, + start: () => Promise<HostState>, +): { entry: HostEntry; created: boolean } { + const test = currentTest() + const holder = test ?? outsideTests + const take = (entry: HostEntry) => { + entry.lease = holder + test?.onTestFinished(() => releaseEntry(entry)) + } + if (!custom) { + const held = hostEntries.find( + (entry) => entry.key === key && entry.lease === holder, + ) + if (held) { + return { entry: held, created: false } + } + const free = hostEntries.find( + (entry) => entry.key === key && entry.lease === undefined, + ) + if (free) { + take(free) + return { entry: free, created: false } + } + } + const entry: HostEntry = { + key, + custom, + state: start(), + lease: undefined, + released: 0, + } + hostEntries.push(entry) + take(entry) + return { entry, created: true } +} + +/** + * The bound of one page run's script: a guard against a run that never + * settles (e.g. a page left suspended while a navigation is pending), well + * above what a run takes on a loaded machine. + */ +const pageRunBound = 10_000 + +function hostKey(options: RouteAppOptions, root: boolean) { + return JSON.stringify( + { + target: options.targetFramework ?? 'react', + filename: options.filename ?? 'route.tsx', + routeId: options.routeId ?? '/', + root, + hmr: options.hmr ?? false, + deleteNodes: options.deleteNodes, + pluginOptions: options.pluginOptions, + tsconfig: options.tsconfig, + prebundle: options.prebundle, + dir: options.dir, + // Vite's watcher does not watch `node_modules`: package stubs are + // written with the app, so each set of them has its own host + packages: packageFiles(options.files ?? {}), + frameworkPluginOptions: options.frameworkPluginOptions, + // A function option (e.g. `splitBehavior`) by its source: two routes + // with different functions get different hosts + }, + (_, value: unknown) => + typeof value === 'function' ? `function ${String(value)}` : value, + ) +} + +/** The files of `files` that are packages (under `node_modules/`). */ +function packageFiles(files: Record<string, string>) { + return Object.fromEntries( + Object.entries(files).filter(([file]) => isPackageFile(file)), + ) +} + +const isPackageFile = (file: string) => /^(?:\.\/)?node_modules\//.test(file) + +/** The router plugin's options for a route app. */ +function routerOptions( + options: RouteAppOptions, + root: boolean, + appRoot: string, +): Partial<Config> { + const target = options.targetFramework ?? 'react' + const filename = options.filename ?? 'route.tsx' + const routeId = options.routeId ?? '/' + const pluginOptions = options.pluginOptions ?? {} + return { + target, + routesDirectory: '.', + generatedRouteTree: './routeTree.gen.ts', + // The generator renames its temporary files into place: on the app's + // device + tmpDir: path.join(appRoot, '.tanstack/tmp'), + disableLogging: true, + virtualRouteConfig: root + ? { type: 'root', file: filename, children: [] } + : { + type: 'root', + file: '__root.tsx', + children: [ + routeId === '/' + ? { type: 'index', file: filename } + : { type: 'route', path: routeId, file: filename }, + ], + }, + autoCodeSplitting: true, + ...pluginOptions, + codeSplittingOptions: { + addHmr: options.hmr ?? false, + ...(options.deleteNodes && { deleteNodes: options.deleteNodes }), + ...pluginOptions.codeSplittingOptions, + }, + } as Partial<Config> +} + +async function startHost( + options: RouteAppOptions, + root: boolean, + files: Record<string, string>, +): Promise<HostState> { + const target = options.targetFramework ?? 'react' + const emitted: EmittedModules = new Map() + const host = await createPluginHost({ + dir: options.dir ?? import.meta.dirname, + prefix: '.route-app-', + files: { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { verbatimModuleSyntax: true, ...options.tsconfig }, + }), + ...(root ? {} : { '__root.tsx': rootRoute(target) }), + [probeFile]: probeSource(target), + [entryFile]: entrySource(options.filename ?? 'route.tsx'), + ...files, + }, + client: true, + config: { + optimizeDeps: { + noDiscovery: true, + include: [...prebundled[target], ...(options.prebundle ?? [])], + }, + }, + plugins: ({ root: appRoot }) => [ + emittedEndpointPlugin(emitted), + ...(options.plugins?.before ?? []), + observeEmitted( + tanstackRouter(routerOptions(options, root, appRoot)), + emitted, + ), + frameworkPlugins[target](options.frameworkPluginOptions), + ...(options.plugins?.after ?? []), + ], + }) + return { + host, + current: files, + owner: undefined, + used: false, + } +} + +/** + * Writes the files of a route into its host's app (an edit, as a dev + * server sees one), removing the files of the route the app held before. + */ +async function writeRoute( + state: HostState, + owner: object, + files: Record<string, string>, +) { + if (state.owner === owner) { + return + } + if (state.owner !== undefined || state.used) { + const edit: Record<string, string | null> = {} + // Package stubs are the host's own (see `hostKey`) + for (const file of Object.keys(state.current)) { + if (!(file in files) && !isPackageFile(file)) { + edit[file] = null + } + } + for (const [file, code] of Object.entries(files)) { + if (state.current[file] !== code && !isPackageFile(file)) { + edit[file] = code + } + } + if (Object.keys(edit).length > 0) { + await state.host.edit(edit) + } + } + state.current = files + state.owner = owner + state.used = true +} + +/** + * The URL each request is imported by from the app's modules: Vite's import + * analysis adds the time of a file's last hot update (`t=`) to the imports + * of that file, so that a page importing the plain URL would get a second + * instance. The page's own script imports by these URLs. + */ +async function stampedUrls(host: PluginHost, requests: Array<string>) { + const graph = host.dev.vite.environments.client.moduleGraph + const stamped: Record<string, string> = {} + for (const request of requests) { + const module = await graph.getModuleByUrl(request) + if (module && module.lastHMRTimestamp > 0) { + stamped[request] = + `${request}${request.includes('?') ? '&' : '?'}t=${module.lastHMRTimestamp}` + } + } + return stamped +} + +/** The page-side names a script runs with (see `RouteApp.run`). */ +function prelude( + routeUrl: string, + own: Array<string>, + at: string, + before: string, + stamped: Record<string, string>, +) { + return `const probe = module +const own = new Set(${JSON.stringify(own)}) +const routeUrl = ${JSON.stringify(routeUrl)} +/** The URLs the app's own modules import these by (see \`stampedUrls\`). */ +const stamped = ${JSON.stringify(stamped)} +const importUrl = (request) => stamped[request] ?? probe.requestUrl(request) +/** Modules the compilers emitted that the page requested so far (path and query; async). */ +const compiled = () => probe.compiledRequests(routeUrl, [...own]) +/** + * Every app-local module the page requested so far: compiled ones and the + * test's files, each once, by path (\`/data.json\`, whatever query a tool or + * a compiler requests it with; async). + */ +const requested = async () => [...new Set((await probe.appRequests(routeUrl, [...own])).map((request) => request.split('?')[0]))] +/** An app file the test wrote, as the page imports it (the instance the route gets). */ +const app = (file) => import(importUrl('/' + file.replace(/^\\.?\\//, ''))) +${before} +const exports = (await import(${JSON.stringify(`/${entryFile}`)})).route +const Route = exports.Route +const options = Route?.options +const trigger = (option) => probe.trigger(Route, option) +const load = (option) => probe.load(Route, option) +const renderComponent = (component, props) => probe.renderComponent(component, props) +const render = async (option, props) => probe.renderComponent(await probe.load(Route, option), props) +const renderRoute = async (input = {}) => (await probe.renderRoute(input.at ?? ${JSON.stringify(at)}, input.router)).html +/** Code of a module as the dev server serves it to the page. */ +const served = async (request) => (await fetch(request)).text() +` +} + +export interface RouteModules { + /** + * Code of each module the compilers emitted for the route, as the dev + * server serves it, by label: `reference` (the route module), `shared` + * (another module loading with it), `lazy <option>` (a module that loads + * when the option loads, labelled by the first option, in + * `splittableOptions` order, whose loading requests it). Where a label + * has several modules, each is labelled `<label> (<request>)`. + */ + modules: Record<string, string> + /** The request (path and query) of each label. */ + ids: Record<string, string> +} + +export interface RouteApp { + /** The route's host (its dev server and app). */ + host: PluginHost + /** Request of the route module (`/route.tsx`). */ + url: string + /** The route file as written. */ + code: string + /** + * Runs `body` (an async function body) in a fresh document of the shared + * page and returns its JSON value. In scope: `exports` and `Route` (the + * route module and its route, imported from the dev server), `options`, + * `trigger(option)`, `load(option)` (a component after `preload()`), + * `render(option, props?)` and `renderComponent(component, props?)` (the + * framework's client renderer: the HTML), `renderRoute({ at?, router? })` + * (the app at `at`, default the route's path, through the generated route + * tree and the real router: the HTML), `app(file)` (an app file the test + * wrote, the instance the route gets), `await requested()` and + * `await compiled()` (requests so far: the compiled ones and the test's + * files; the modules the compilers emitted only, by provenance), + * `served(request)`. `before` runs before the route module is imported + * (e.g. to set a global the route reads). + */ + run: <T = unknown>(body: string, options?: { before?: string }) => Promise<T> + /** + * The production client build of the app (its route tree as the input), + * for what ships after the bundler's tree-shaking (`locate`, `where`). + */ + production: () => Promise<BuildResult> + /** `run`, with the page's errors and console. */ + runPage: <T = unknown>( + body: string, + options?: { before?: string }, + ) => Promise<PageRun<T>> + /** + * Whether loading the option (its public trigger, awaited) requests a + * module the compilers emitted that did not load with the route module. + */ + isLazy: (option: string) => Promise<boolean> + /** + * Code of each module the compilers emitted that loading the option + * requests (one or more: facades and support modules are allowed); fails + * for an option that is not lazy. + */ + loadedBy: (option: string) => Promise<Array<string>> + /** + * The lazy options grouped by what loads together: once an option + * loaded, loading every other option of its group requests no new module + * holding user code (each pair observed in a fresh document): no file of + * the test, and no compiled module but one that only imports and + * re-exports (`forwardsOnly`: a small forwarding module over the group's + * module is allowed, SPEC J2.2). Groups sorted, each sorted. + */ + groups: () => Promise<Array<Array<string>>> + /** + * Every app-local module loading the route module requests (compiled + * modules and the test's files), each once, by path (`/config.ts`, + * whatever query it is requested with). + */ + requested: () => Promise<Array<string>> + /** Code of the compiled modules that load with the route module. */ + eagerModules: () => Promise<Array<string>> + /** The modules the compilers emitted for the route (see `RouteModules`). */ + modules: () => Promise<RouteModules> + /** + * The route module (or another request) as the dev server serves it to + * the client, without a page: rejects with the error compiling it threw. + */ + transform: (request?: string) => Promise<string> + /** + * What the dev server reported since the route's files were written, on + * every channel, once its work is done. + */ + diagnostics: () => Promise<Array<ChannelDiagnostic>> +} + +/** + * Writes a route file (and `options.files`) into a route app and returns + * the route, loaded on demand by page runs (see the module comment). + */ +export async function loadRoute( + code: string, + options: RouteAppOptions = {}, +): Promise<RouteApp> { + const filename = options.filename ?? 'route.tsx' + const root = createsRootRoute(code) + const files = { ...options.files, [filename]: code } + const own = new Set(Object.keys(options.files ?? {}).map(appUrl)) + own.add(appUrl(probeFile)) + own.add(appUrl(entryFile)) + if (!root) { + own.add(appUrl('__root.tsx')) + } + const url = appUrl(filename) + const at = root ? '/' : (options.routeId ?? '/') + + const custom = options.fresh || options.plugins !== undefined + const owner = {} + const { entry, created } = leaseHost(hostKey(options, root), custom, () => + startHost(options, root, files), + ) + const state = await entry.state + const mark = created ? 0 : state.host.diagnostics.length + if (created) { + state.current = files + state.owner = owner + state.used = true + } else { + await writeRoute(state, owner, files) + } + + const runPage = async <T>( + body: string, + runOptions: { before?: string } = {}, + ) => { + await writeRoute(state, owner, files) + const hmr = state.host.dev.hmr.length + try { + return await state.host.runClient<T>( + appUrl(probeFile), + `${prelude(url, [...own], at, `${options.pageScript ?? ''}\n${runOptions.before ?? ''}`, await stampedUrls(state.host, [...own]))} +// A run that never settles (e.g. a page left suspended while a navigation +// is pending) fails at a bound, instead of holding its page +return await Promise.race([ + (async () => { +${body} + })(), + new Promise((_, reject) => setTimeout(() => reject(new Error('the page run did not settle within ${pageRunBound} ms')), ${pageRunBound})), +])`, + ) + } catch (error) { + const sent = state.host.dev.hmr + .slice(hmr) + .map((message) => `${message.type} ${message.paths.join(', ')}`) + throw new Error( + `${(error as Error).message}\nHMR messages the dev server sent meanwhile:\n${sent.join('\n') || '(none)'}`, + { cause: error }, + ) + } + } + const run = async <T>(body: string, runOptions?: { before?: string }) => + (await runPage<T>(body, runOptions)).result + + const newlyCompiled = (option: string) => + run<Array<string>>(`const before = new Set(await compiled()) +await trigger(${JSON.stringify(option)}) +// A module the option requested that failed to compile is no lazily +// loaded module: the option is broken (fail, never count it as lazy) +probe.assertNoFailedRequests() +return (await compiled()).filter((request) => !before.has(request))`) + + /** + * The production client build of the app as it is now (`vite build` of + * the host), as the build harness describes it (`describeBuild`: chunk + * placement, and the dangling-name check, `DanglingNameError`, on the + * modules the compilers produced). Its input is the generated route tree, + * with its export kept, as an app's router reads it: each route's `Route` + * and what its options load, not the route file's other exports. Its + * output goes under `node_modules/`, which the dev server's watcher + * ignores. + */ + const production = async (): Promise<BuildResult> => { + await writeRoute(state, owner, files) + const outDir = path.join(state.host.root, 'node_modules/.route-app-build') + const built = await state.host.build({ + config: { + build: { + outDir, + emptyOutDir: true, + rollupOptions: { + input: path.join(state.host.root, 'routeTree.gen.ts'), + preserveEntrySignatures: 'exports-only', + }, + }, + }, + }) + return built.describe('client') + } + + /** The free names the production build's dangling-name check finds. */ + const shipped = async (): Promise<Array<string>> => { + try { + await production() + } catch (error) { + if (!(error instanceof DanglingNameError)) { + throw error + } + return [...new Set(Object.values(error.names).flat())] + } + return [] + } + + const route: RouteApp = { + host: state.host, + url, + code, + run, + runPage, + production, + isLazy: async (option) => (await newlyCompiled(option)).length > 0, + loadedBy: async (option) => { + const loaded = await run< + Array<string> + >(`const before = new Set(await compiled()) +await trigger(${JSON.stringify(option)}) +probe.assertNoFailedRequests() +const loaded = (await compiled()).filter((request) => !before.has(request)) +return Promise.all(loaded.map(served))`) + if (loaded.length === 0) { + throw new Error(`\`${option}\` loads no module of the route lazily`) + } + return loaded + }, + groups: async () => { + const present = await run<Array<string>>( + `return ${JSON.stringify(splittableOptions)}.filter((option) => options && option in options)`, + ) + const lazy: Array<string> = [] + for (const option of present) { + if ((await newlyCompiled(option)).length > 0) { + lazy.push(option) + } + } + const groups = new Map<string, Array<string>>() + for (const option of lazy) { + const group = [option] + for (const other of lazy) { + if (other === option) { + continue + } + const added = await run< + Array<{ request: string; code: string | undefined }> + >(`await trigger(${JSON.stringify(option)}) +const requests = () => probe.appRequests(routeUrl, [...own]) +const before = new Set(await requests()) +await trigger(${JSON.stringify(other)}) +const added = (await requests()).filter((request) => !before.has(request)) +return Promise.all(added.map(async (request) => ({ request, code: own.has(request.split('?')[0]) ? undefined : await served(request) })))`) + const userCode = added.filter( + ({ code: served }) => served === undefined || !forwardsOnly(served), + ) + if (userCode.length === 0) { + group.push(other) + } + } + group.sort() + groups.set(group.join('\0'), group) + } + return [...groups.values()].sort((a, b) => + a.join(',').localeCompare(b.join(',')), + ) + }, + requested: () => run<Array<string>>('return await requested()'), + eagerModules: () => + run<Array<string>>('return Promise.all((await compiled()).map(served))'), + modules: async () => { + const found = await run< + Array<{ request: string; label: string; code: string }> + >( + `const found = [] +for (const request of await compiled()) { + found.push({ request, label: request === routeUrl ? 'reference' : 'shared' }) +} +for (const option of ${JSON.stringify(splittableOptions)}) { + if (!options || !(option in options)) continue + const before = new Set(await compiled()) + await trigger(option) + for (const request of await compiled()) { + if (!before.has(request)) found.push({ request, label: 'lazy ' + option }) + } +} +return Promise.all(found.map(async (module) => ({ ...module, code: await served(module.request) })))`, + ) + const modules: Record<string, string> = {} + const ids: Record<string, string> = {} + // A label several modules have names each by its request, whatever + // the order the page requested them in (a cached module loads first) + const counts = new Map<string, number>() + for (const module of found) { + counts.set(module.label, (counts.get(module.label) ?? 0) + 1) + } + for (const module of found) { + const label = + counts.get(module.label)! > 1 + ? `${module.label} (${module.request})` + : module.label + modules[label] = module.code + ids[label] = module.request + } + routeSources.set(modules, { + code, + filename, + // Route HMR code runs in dev, on an update, and the production + // build drops it: a route compiled with HMR is checked on its + // modules alone + shipped: + options.hmr || + options.pluginOptions?.codeSplittingOptions?.addHmr === true + ? undefined + : shipped, + }) + return { modules, ids } + }, + transform: async (request = url) => { + await writeRoute(state, owner, files) + return state.host.transform(request, 'client') + }, + diagnostics: async () => { + await state.host.dev.idle() + return state.host.diagnostics.slice(mark) + }, + } + return route +} + +function isRouteApp(value: unknown): value is RouteApp { + return typeof (value as RouteApp).run === 'function' +} + +/** + * Route file each `modules()` result was compiled from, and the production + * build of its app (`shipped`). + */ +const routeSources = new WeakMap< + object, + { + code: string + filename: string + shipped: (() => Promise<Array<string>>) | undefined + } +>() + +/** + * Asserts that every module the compilers emitted for the route is a valid + * client module as the browser receives it (SPEC G1, G8 at module level): + * it parses, and reads no name it does not bind (`readNames`, Yuku's + * unresolved references) other than a browser global, a global the + * framework's refresh runtime installs in the page, or a name the route + * file itself reads free once its TypeScript is erased. + * + * Code the bundler deletes from the production build may dangle (G8, + * §5.9): when a module reads such a name, the production build of the same + * app decides, through the build harness's dangling-name check. A route + * compiled with route HMR (`hmr: true`) has no such build here (production + * drops its HMR code): its modules' free names count as they are. + */ +export async function expectValidModules( + route: RouteApp | RouteModules['modules'], +) { + const modules: Record<string, string> = isRouteApp(route) + ? (await route.modules()).modules + : route + const source = routeSources.get(modules) + // What the route file reads free at run time: its code with TypeScript + // erased (a `declare` binding has no runtime value), read in its language + // (JSX is allowed in a `.js` route file) + const sourceLang = /\.[cm]?ts$/.test(source?.filename ?? '') + ? 'ts' + : /\.tsx$/.test(source?.filename ?? '') + ? 'tsx' + : 'jsx' + const sourceReads = source + ? readNames( + ( + await transformWithOxc(source.code, `route.${sourceLang}`, { + jsx: 'preserve', + typescript: { onlyRemoveTypeImports: true }, + }) + ).code, + 'route.jsx', + ).free + : [] + const allowed = new Set([...clientGlobals, ...refreshGlobals, ...sourceReads]) + const errors: Record<string, Array<string>> = {} + const free: Record<string, Array<string>> = {} + for (const [name, code] of Object.entries(modules)) { + const read = readNames(code) + errors[name] = read.errors + free[name] = [...read.free].filter((found) => !allowed.has(found)) + } + if (source?.shipped && Object.values(free).some((names) => names.length)) { + const dangling = (await source.shipped()).filter( + (name) => !allowed.has(name), + ) + if (dangling.length > 0) { + errors['production build'] = dangling + } + } else { + for (const name of Object.keys(modules)) { + errors[name]!.push(...free[name]!) + } + } + expect(errors).toEqual( + Object.fromEntries(Object.keys(modules).map((name) => [name, []])), + ) +} + +/** Globals the refresh runtimes install in the page for the modules they compile. */ +const refreshGlobals = ['$RefreshReg$', '$RefreshSig$'] + +/** + * The decoded values of the string literals and template quasis of a module + * (an independent parse: a user marker is found whatever its quoting or + * escaping), for SPEC J2.5 checks that user code is absent from a module. The + * module specifiers of imports and exports are not values of the code (a + * request's query may name an option). Throws on code that does not parse: + * an absence check on it would prove nothing. + */ +function stringValues(code: string): Set<string> { + const { program, errors } = parseSync('module.js', code, { + sourceType: 'module', + }) + if (errors.length > 0) { + throw new Error( + `cannot read the string values of a module that does not parse (${errors.map((error) => error.message).join('; ')}):\n${code}`, + ) + } + const values = new Set<string>() + const visit = (node: unknown) => { + if (!node || typeof node !== 'object') { + return + } + if (Array.isArray(node)) { + node.forEach(visit) + return + } + const value = node as ESTree.Node & Record<string, unknown> + if (value.type === 'Literal' && typeof value.value === 'string') { + values.add(value.value) + } else if (value.type === 'TemplateElement') { + const cooked = (value.value as { cooked?: string | null }).cooked + if (typeof cooked === 'string') { + values.add(cooked) + } + } else if (value.type === 'JSXText') { + values.add(String(value.value)) + } + const specifier = + value.type === 'ImportDeclaration' || + value.type === 'ImportExpression' || + value.type === 'ExportAllDeclaration' || + value.type === 'ExportNamedDeclaration' + for (const key of Object.keys(value)) { + if ( + key !== 'type' && + key !== 'start' && + key !== 'end' && + !(specifier && key === 'source') + ) { + visit(value[key]) + } + } + } + visit(program) + return values +} + +/** + * Whether a served module only imports and re-exports (no statement of its + * own: a forwarding module, which holds no user code). + */ +function forwardsOnly(code: string) { + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + return (program.body as Array<Record<string, any>>).every( + (statement) => + statement.type === 'ImportDeclaration' || + statement.type === 'ExportAllDeclaration' || + (statement.type === 'ExportNamedDeclaration' && !statement.declaration), + ) +} + +/** + * The uncaught errors of a page run (`runPage`), without what the page + * logged with `console.error` (dev diagnostics are free, SPEC §5.11). + */ +export function uncaughtErrors(run: PageRun) { + return run.errors.filter((error) => !run.console.includes(`error: ${error}`)) +} + +/** Whether a module holds the user marker `marker` (a decoded string value). */ +export function holdsMarker(code: string, marker: string) { + for (const value of stringValues(code)) { + if (value.includes(marker)) { + return true + } + } + return false +} + +export const head = `import { createFileRoute } from '@tanstack/react-router'\n` diff --git a/packages/router-plugin/tests/route-hmr-edit.ts b/packages/router-plugin/tests/route-hmr-edit.ts new file mode 100644 index 0000000000..ad72dd4ea8 --- /dev/null +++ b/packages/router-plugin/tests/route-hmr-edit.ts @@ -0,0 +1,38 @@ +/** + * Shared by the route HMR page pins (integration/known-bugs-route-hmr*.test.ts): + * the outcome of an edit applied in place, and an edit of one route file + * on a real page (`route-hmr-page.ts`). + */ +import { openRouteHmrPage } from './route-hmr-page' +import type { TestContext } from 'vitest' +import type { EditResult, RouteHmrPageOptions } from './route-hmr-page' + +/** An edit that showed without a full reload and without errors. */ +export const inPlace = { reloaded: false, errors: [] } + +/** + * Opens an app whose route file `file` is `route('v1')`, waits until it + * shows `shows('v1')`, edits it to `route('v2')` and returns the result of + * the edit once the page shows `shows('v2')`. + */ +export async function editRoute( + { + file, + route, + shows, + ...options + }: Partial<RouteHmrPageOptions> & { + file: string + route: (version: string) => string + shows: (version: string) => string + }, + onTestFinished: TestContext['onTestFinished'], +): Promise<EditResult> { + const app = await openRouteHmrPage({ + ...options, + onTestFinished, + files: { ...options.files, [file]: route('v1') }, + ready: shows('v1'), + }) + return app.edit({ [file]: route('v2') }, shows('v2')) +} diff --git a/packages/router-plugin/tests/route-hmr-page.ts b/packages/router-plugin/tests/route-hmr-page.ts new file mode 100644 index 0000000000..9f14f2ccb0 --- /dev/null +++ b/packages/router-plugin/tests/route-hmr-page.ts @@ -0,0 +1,660 @@ +/** + * Route HMR as an app sees it: a real dev server (Vite with the router + * plugin and the framework's own Vite plugin, or Rsbuild with the router + * plugin's Rspack entry and the framework's Rsbuild plugin) serves a small + * file-based app with the real router package, a real browser page + * (headless Chromium) runs it with the dev server's own HMR client, and the + * test edits route files on disk, which the dev server's own file watcher + * reports. The test reads the page: what it shows, whether it reloaded, and + * what it logged. + * + * Nothing of the HMR path is modelled: the bundler decides which modules + * accept the update, the framework's refresh runtime (React Refresh, Solid + * Refresh, Vue's HMR runtime) patches components, and the route HMR code + * the router plugin emits updates the live router. The harness waits on the + * edit's outcome (`waitForOutcome`): the dev-server harnesses' + * `settle()`, then the page showing the edit with neither the dev server + * nor the page having work in flight (transforms, the page's requests, a + * reload), within one overall bound; never on how many hot updates or + * client events an edit takes. Warnings are diagnostics + * (`@tanstack/compiler-test-utils/diagnostics`): every channel of the dev + * server (its logger or the bundler's compilation, and what the process + * printed while doing this app's work) and the page's console. + */ +import { AsyncLocalStorage } from 'node:async_hooks' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { pluginBabel } from '@rsbuild/plugin-babel' +import { pluginReact } from '@rsbuild/plugin-react' +import { pluginSolid } from '@rsbuild/plugin-solid' +import { pluginVue } from '@rsbuild/plugin-vue' +import { pluginVueJsx } from '@rsbuild/plugin-vue-jsx' +import react from '@vitejs/plugin-react' +import vueJsx from '@vitejs/plugin-vue-jsx' +import solid from 'vite-plugin-solid' +import { expect } from 'vitest' +import { onTestFinished } from '@tanstack/compiler-test-utils/test-scope' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { openDiagnosticChannel } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { + diagnosticsOf, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { trackRequests } from '@tanstack/compiler-test-utils/hmr-sync' +import { waitForOutcome } from '@tanstack/compiler-test-utils/outcome' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { tanstackRouter as tanstackRouterRspack } from '../src/rspack' +import { getConfig, tanstackRouter } from '../src/vite' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import type { RsbuildPlugin } from '@rsbuild/core' +import type { PluginOption } from 'vite' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { Config } from '../src/vite' +import type { TargetFramework } from './route-app' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +/** + * How the app mounts the router into `#app`, per framework. The app keeps + * its own reference to its router (`window.__APP_ROUTER__`), which tests + * read. + */ +const mains: Record<TargetFramework, string> = { + react: `import { createRoot } from 'react-dom/client' +import { RouterProvider, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__APP_ROUTER__ = router +createRoot(document.getElementById('app')!).render(<RouterProvider router={router} />) +`, + solid: `import { render } from 'solid-js/web' +import { RouterProvider, createRouter } from '@tanstack/solid-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__APP_ROUTER__ = router +render(() => <RouterProvider router={router} />, document.getElementById('app')!) +`, + vue: `import { createApp } from 'vue' +import { RouterProvider, createRouter } from '@tanstack/vue-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +;(window as any).__APP_ROUTER__ = router +createApp({ setup: () => () => <RouterProvider router={router} /> }).mount('#app') +`, +} + +/** The framework's own Vite plugin, as an app adds it. */ +const frameworkVitePlugins: Record<TargetFramework, () => PluginOption> = { + react: () => react(), + solid: () => solid(), + vue: () => vueJsx(), +} + +/** + * The framework's own Rsbuild plugins, as an app adds them (the Solid and + * Vue JSX plugins compile JSX with Babel: `@rsbuild/plugin-babel`). + */ +const frameworkRsbuildPlugins: Record< + TargetFramework, + (options: RouteHmrPageOptions) => Array<RsbuildPlugin> +> = { + react: (options) => [ + pluginReact({ fastRefresh: options.reactRefresh ?? true }), + ], + solid: () => [pluginBabel({ include: /\.(?:jsx|tsx)$/ }), pluginSolid()], + vue: () => [ + pluginBabel({ include: /\.(?:jsx|tsx)$/ }), + pluginVue(), + pluginVueJsx(), + ], +} + +/** + * Dependencies the app imports, pre-bundled up front as Vite does for an app + * that installed them (the router package is a linked workspace package + * here, which Vite would otherwise serve as source and discover the + * dependencies of late, reloading the page). + */ +const prebundled: Record<TargetFramework, Array<string>> = { + react: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + solid: [], + vue: ['vue', '@tanstack/vue-router'], +} + +export interface RouteHmrPageOptions { + /** Default `vite`. */ + bundler?: 'vite' | 'rsbuild' + /** Default `react`. */ + target?: TargetFramework + /** + * Router plugin options over the defaults (`autoCodeSplitting: true`, the + * app's `routes/` directory and route tree); `null` gives the plugin no + * options (Vite only: it reads the app's `tsr.config.json`). + */ + pluginOptions?: Partial<Config> | null + /** + * Gives the router plugin its options as a function returning them, as + * `tanstackRouter(() => config)` allows (Vite only). Default: an object. + */ + pluginOptionsAsFunction?: boolean + /** + * Whether the app adds its framework's plugin (default `true`): + * `@vitejs/plugin-react`, `vite-plugin-solid` or `@vitejs/plugin-vue-jsx` + * with Vite, `@rsbuild/plugin-react`, `@rsbuild/plugin-solid` or + * `@rsbuild/plugin-vue` + `@rsbuild/plugin-vue-jsx` with Rsbuild. Without + * it, a React app runs without React Refresh (Vite compiles its JSX + * itself; Rsbuild's SWC does too). + */ + frameworkPlugin?: boolean + /** + * Rsbuild: `@rsbuild/plugin-react`'s `fastRefresh` (default `true`); a + * React app on Rsbuild without React Refresh sets it to `false`. + */ + reactRefresh?: boolean + /** + * App files relative to its root: route files in `routes/` + * (`routes/__root.tsx` defaults to an empty root route, which renders its + * child routes) and any other module they import. `main.tsx` defaults to + * an entry mounting the router into `#app`. + */ + files: Record<string, string> + /** Text the app shows once it rendered. */ + ready: string | RegExp + /** + * Registers the cleanup (closing the page and the dev server) to run when + * the test ends. Default: vitest's `onTestFinished`; a concurrent test + * passes the one of its test context. + */ + onTestFinished?: (cleanup: () => Promise<void>) => void +} + +export interface EditResult { + /** Whether the page reloaded, observed through the caller's final assertions. */ + reloaded: boolean + /** + * Uncaught errors of the page and what it logged with `console.error` + * since the edit began: the HMR client's and the framework's reports of a + * failed update, and whatever the app logs itself (a test with a route + * that deliberately throws leaves those out). + */ + errors: Array<string> +} + +export interface RouteHmrPage { + /** The browser page. */ + page: BrowserPage + /** The app's root on disk. */ + root: string + /** How many times the page loaded (its first load included). */ + loads: () => number + /** Clicks the first element matching `selector`. */ + click: (selector: string) => Promise<void> + /** + * Writes app files (`null` deletes one) for the dev server's watcher to + * pick up, waits until the dev server handled them (`settle()`), then for + * the edit's outcome (`waitForOutcome`): the app shows `expected` and + * neither the dev server (transforms) nor the page (requests, a reload) + * has work in flight, twice in a row; returns whether the page reloaded + * meanwhile and what it logged. One overall bound (15 s): how many updates or client events the edit takes is the + * compiler's business (a full reload shows `expected` once the page + * loaded again). An edit that leaves the page without `expected` while + * neither has anything of it in flight for 3 s (`editQuietFailure`) has + * reached its final state: it fails then. + */ + edit: ( + files: Record<string, string | null>, + expected: string | RegExp, + ) => Promise<EditResult> + /** + * Runs `script` in the page (e.g. reads the app's live router, + * `window.__APP_ROUTER__`) and returns its JSON value. + */ + evaluate: <T>(script: string) => Promise<T> + /** + * Warnings reported so far through the real channels, as diagnostics (read + * them with `findDiagnostics` / `expectDiagnostic`): every channel of the + * dev server (`appWarnings`: its logger or the bundler's compilation, and + * what the process printed while doing this app's work: concurrent pages + * share the process, and the async context of the app's dev server tells + * their output apart, whatever the warning's wording or path form), and + * what the page logged as a warning (e.g. a warning the compiler put into + * the served module). + */ + warnings: () => Array<Diagnostic> +} + +/** + * The async context of each app's dev server: everything a dev server does + * (its watcher, its HTTP requests, its compiles) runs in the context it was + * created in, so what the process prints meanwhile is that app's. + */ +const appScope = new AsyncLocalStorage<string>() +let apps = 0 + +/** The apps whose output `processOutput` is reading. */ +const openApps = new Set<string>() + +/** + * What the process printed (console, stdout/stderr) while doing the work of + * app `id` (`appScope`), from now on until the test ends. Pages of + * concurrent tests share the process's console; the context tells their + * output apart, so a warning counts whatever path form (absolute or + * project-relative) and wording it has. Output outside any app's context + * counts when it names the app's root (`root()`, once known), or, whatever + * path form it has, when it was printed while no other app was open. + */ +function processOutput( + id: string, + root: () => string | undefined, + registerCleanup: (cleanup: () => Promise<void>) => void, +) { + const channel = openDiagnosticChannel() + const scoped: Array<ChannelDiagnostic> = [] + const unscoped: Array<{ diagnostic: ChannelDiagnostic; alone: boolean }> = [] + openApps.add(id) + channel.onDiagnostic((diagnostic) => { + const store = appScope.getStore() + if (store === id) { + scoped.push(diagnostic) + } else if (store === undefined) { + unscoped.push({ diagnostic, alone: openApps.size === 1 }) + } + }) + registerCleanup(() => { + openApps.delete(id) + channel.close() + return Promise.resolve() + }) + return () => { + const appRoot = root() + return [ + ...scoped, + ...unscoped + .filter( + ({ diagnostic, alone }) => + alone || + (appRoot !== undefined && diagnostic.text.includes(appRoot)), + ) + .map(({ diagnostic }) => diagnostic), + ] + } +} + +/** + * The warnings of an app on every channel of its dev server: the + * bundler's and the dev server's own (`server`, from the server's own + * logger and compilations), and what the process printed doing the app's + * work (`printed`, see `processOutput`). + */ +function appWarnings( + server: Array<ChannelDiagnostic>, + printed: Array<ChannelDiagnostic>, +) { + return [ + ...server.filter( + (diagnostic) => + diagnostic.source === 'vite' || diagnostic.source === 'bundler', + ), + ...printed, + ] + .filter((diagnostic) => diagnostic.severity === 'warning') + .map((diagnostic) => diagnostic.text) +} + +/** The part of a dev server the page needs. */ +interface AppServer { + url: string + /** The app's root on disk. */ + root: string + /** + * What the dev server's own logger and compilations reported so far + * (`appWarnings` takes their warnings). + */ + diagnostics: () => Array<ChannelDiagnostic> + /** + * Writes files for the server's watcher and waits until the server + * handled them, by the harness's event-based `settle()` (Vite: the + * watcher reported each file, Vite handled each event, and the files + * plugins wrote meanwhile; Rsbuild: the compiles read every written file + * and nothing is compiling or pending). + */ + write: (files: Record<string, string | null>) => Promise<void> + /** Waits until the server has no work in flight. */ + idle: () => Promise<void> + /** Full reloads the server sent the page so far. */ + fullReloads: () => number +} + +const defaultEditTimeout = 15_000 + +/** + * How long the dev server and the page stay quiet (nothing of the edit in + * flight on either) while the page does not show the edit, before the edit + * counts as not shown (`waitForOutcome`'s `failWhenQuietFor`): an edit a + * compiler does not apply fails then, not at `defaultEditTimeout`. + */ +const editQuietFailure = 3_000 + +/** + * Starts a dev server on an app of `files` (see `RouteHmrPageOptions`), opens + * it in a browser page and waits until it shows `ready`. + */ +export async function openRouteHmrPage( + options: RouteHmrPageOptions, +): Promise<RouteHmrPage> { + const target = options.target ?? 'react' + const bundler = options.bundler ?? 'vite' + const files = { + 'main.tsx': mains[target], + 'routes/__root.tsx': `import { createRootRoute } from '@tanstack/${target}-router' +export const Route = createRootRoute({}) +`, + ...options.files, + } + // What the process prints doing this app's work (the compiler may warn + // there, e.g. about a route it leaves unsplit): the dev server is created + // in the app's async context, so its watcher, requests and compiles run + // there + const id = `route-hmr-page-${++apps}` + let appRoot: string | undefined + const printed = processOutput( + id, + () => appRoot, + options.onTestFinished ?? onTestFinished, + ) + const { server, page } = await (async () => { + const started = await appScope.run(id, () => + bundler === 'vite' + ? viteServer(target, files, options) + : rsbuildServer(target, files, options), + ) + appRoot = started.root + const opened = await openPage(started.url, { + registerCleanup: options.onTestFinished ?? onTestFinished, + }) + await opened.waitForText(options.ready, { selector: '#app' }) + await started.idle() + return { server: started, page: opened } + })() + + const text = async () => { + try { + return await page.text('#app') + } catch { + // The page is reloading + return '' + } + } + /** + * The page's requests in flight: module and hot-update fetches, and the + * document of a full reload. + */ + const pageRequests = trackRequests(page) + + const matches = (expected: string | RegExp, current: string) => + typeof expected === 'string' + ? current.includes(expected) + : expected.test(current) + const describe = (expected: string | RegExp, current: string) => + [ + `the page shows: ${JSON.stringify(current)}`, + `expected: ${String(expected)}`, + `page loads: ${page.loads()}`, + `errors:\n${page.errors.join('\n') || '(none)'}`, + `console:\n${page.console.join('\n') || '(none)'}`, + ].join('\n') + + return { + page, + root: server.root, + loads: () => page.loads(), + click: async (selector) => { + await page.page.locator(selector).first().click() + }, + edit: (edited, expected) => + (async () => { + const timeout = defaultEditTimeout + const start = { + loads: page.loads(), + errors: page.errors.length, + fullReloads: server.fullReloads(), + } + const reloaded = () => + page.loads() > start.loads || server.fullReloads() > start.fullReloads + const deadline = Date.now() + timeout + const files = Object.keys(edited).join(', ') + await server.write(edited) + + // Until the edit's outcome (`waitForOutcome`): the page shows + // the edit, and neither the dev server nor the page has work of it + // in flight, within one overall bound. How many hot updates, + // invalidations or `vite:afterUpdate` events the edit takes, and how + // soon after the first one the page shows it, are the compiler's + // business. + await waitForOutcome({ + timeout: Math.max(0, deadline - Date.now()), + // The server handled the edit (`write` settled): once neither it + // nor the page has anything of it in flight for this long, the + // page shows what the edit leads to + failWhenQuietFor: editQuietFailure, + applied: async () => matches(expected, await text()), + quiet: async () => { + await server.idle() + return pageRequests() === 0 + }, + describe: async () => + `edit of ${files}\n${describe(expected, await text())}`, + }) + return { + get reloaded() { + return reloaded() + }, + get errors() { + return page.errors.slice(start.errors) + }, + } + })(), + evaluate: (script) => page.page.evaluate(script), + warnings: () => [ + ...diagnosticsOf(appWarnings(server.diagnostics(), printed()), 'warning'), + ...diagnosticsOf( + page.console + .filter((message) => message.startsWith('warning: ')) + .map((message) => message.slice('warning: '.length)), + 'warning', + ), + ], + } +} + +/** The router plugin's options for an app at `root`. */ +function routerPluginOptions( + target: TargetFramework, + root: string, + options: RouteHmrPageOptions, +): Partial<Config> { + return { + target, + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + autoCodeSplitting: true, + ...options.pluginOptions, + } +} + +async function viteServer( + target: TargetFramework, + files: Record<string, string>, + options: RouteHmrPageOptions, +): Promise<AppServer> { + const server = await createDevServer({ + dir: harnessDir, + prefix: '.route-hmr-page-', + registerCleanup: options.onTestFinished ?? onTestFinished, + browser: true, + files: { + 'index.html': `<!doctype html> +<html> + <body> + <div id="app"></div> + <script type="module" src="/main.tsx"></script> + </body> +</html> +`, + ...files, + }, + config: { optimizeDeps: { include: prebundled[target] } }, + plugins: ({ root }) => [ + options.pluginOptions === null + ? tanstackRouter() + : options.pluginOptionsAsFunction + ? tanstackRouter(() => + getConfig(routerPluginOptions(target, root, options), root), + ) + : tanstackRouter(routerPluginOptions(target, root, options)), + ...(options.frameworkPlugin === false + ? [] + : [frameworkVitePlugins[target]()]), + ], + }) + const fullReloads = () => + server.hmr.filter( + (message) => + message.environment === 'client' && message.type === 'full-reload', + ).length + return { + url: server.url!, + write: async (edited) => { + await server.edit(edited) + }, + idle: () => server.idle(), + fullReloads, + root: server.root, + diagnostics: () => server.diagnostics, + } +} + +async function rsbuildServer( + target: TargetFramework, + files: Record<string, string>, + options: RouteHmrPageOptions, +): Promise<AppServer> { + if (options.pluginOptions === null || options.pluginOptionsAsFunction) { + throw new Error( + 'the Rsbuild page gives the router plugin its options as an object', + ) + } + const server = await createRsbuildDevServer({ + dir: harnessDir, + prefix: '.route-hmr-page-rsbuild-', + registerCleanup: options.onTestFinished ?? onTestFinished, + browser: true, + entry: 'main.tsx', + files, + config: { html: { mountId: 'app' } }, + plugins: ({ root }) => [ + ...(options.frameworkPlugin === false + ? [] + : frameworkRsbuildPlugins[target](options)), + { + name: 'route-hmr-page', + setup(api) { + api.modifyRspackConfig((config) => { + config.plugins.push( + tanstackRouterRspack(routerPluginOptions(target, root, options)), + ) + }) + }, + } satisfies RsbuildPlugin, + ], + }) + return { + url: server.url!, + write: async (edited) => { + // Until the edit's outcome on the server: a compile that read it + // ended and nothing compiles anymore + await server.write(edited) + await server.settle() + }, + idle: () => Promise.resolve(), + // Rsbuild's client reloads the page itself: the page's loads tell + fullReloads: () => 0, + root: server.root, + // Every compile's (the page's edits settle before they are read) + diagnostics: () => server.diagnostics, + } +} + +/** + * Whether a page error (`EditResult.errors`) is the app's own deliberate + * error `message` (\`throw new Error(message)\`): it reports that error + * (\`Error: <message>\`), not a report quoting the source that throws it (a + * transform or HMR error's code frame), which stays an error of the edit. + */ +export function isAppError(error: string, message: string) { + return ( + error.includes(`Error: ${message}`) && + !['"', "'", '`'].some((quote) => + error.includes(`Error(${quote}${message}${quote}`), + ) + ) +} + +/** + * A statement for the body of a React component (with `useState` in scope) + * that counts the component's mounts under `name` (`mountsOf`): a state + * initializer, which React runs when it mounts the component only. React + * Refresh keeps the state of a component it patches in place, so a body + * edit it patches mounts nothing anew; a remount counts again. + */ +export const countMounts = (name: string) => + `useState(() => { const mounts = (window.__mounts ??= {}); mounts[${JSON.stringify(name)}] = (mounts[${JSON.stringify(name)}] ?? 0) + 1 })` + +/** The mounts `countMounts` counted in the page, by name. */ +export function mountsOf(app: RouteHmrPage): Promise<Record<string, number>> { + return app.evaluate('window.__mounts ?? {}') +} + +/** + * Edits a route the compiler may handle, or leave to a reported fallback + * (an unsupported but user-fixable shape: SPEC J2.10, J2.8), and asserts what + * both outcomes share: the page shows the edit (`expected`: new loader data + * and component, also after a reload) without errors. A diagnostic never + * stands in for that. Without a warning naming `file` through a real + * channel (`app.warnings()`: the dev server's logger, its console, the + * page), the edit must also apply in place (no reload); with one (the + * fallback, e.g. the route left unsplit), a reload is allowed (SPEC G10). + * Returns which outcome it was. + */ +export async function expectEditShownOrReportedFallback( + app: RouteHmrPage, + edited: Record<string, string | null>, + expected: string | RegExp, + file: string, +): Promise<'in place' | 'reported fallback'> { + const result = await app.edit(edited, expected) + expect(result.errors, 'errors of the page during the edit').toEqual([]) + // (a warning: the page shows the edit, so nothing was refused) + const reported = + findDiagnostics(app.warnings(), { + severity: 'warning', + file, + root: app.root, + }).length > 0 + if (!reported) { + expect( + result.reloaded, + `without a warning naming ${file}, the edit applies in place`, + ).toBe(false) + return 'in place' + } + return 'reported fallback' +} diff --git a/packages/router-plugin/tests/router-plugin-context.test.ts b/packages/router-plugin/tests/router-plugin-context.test.ts deleted file mode 100644 index b03e5f6701..0000000000 --- a/packages/router-plugin/tests/router-plugin-context.test.ts +++ /dev/null @@ -1,406 +0,0 @@ -import path from 'node:path' -import * as t from '@babel/types' -import { describe, expect, it, vi } from 'vitest' -import { parseAst } from '@tanstack/router-utils' -import { createRouterCodeSplitterPlugin } from '../src/core/router-code-splitter-plugin' -import { unpluginRouterComposedFactory } from '../src/core/router-composed-plugin' -import { createRouterHmrPlugin } from '../src/core/router-hmr-plugin' -import { createRouterPluginContext } from '../src/core/router-plugin-context' -import { normalizePath } from '../src/core/utils' -import type { Config } from '../src/core/config' -import type { UnpluginOptions, TransformResult } from 'unplugin' - -const referencePluginName = - 'tanstack-router:code-splitter:compile-reference-file' -const virtualPluginName = 'tanstack-router:code-splitter:compile-virtual-file' - -function getCodeSplitterPlugin( - plugins: ReturnType<typeof createRouterCodeSplitterPlugin>, - pluginName: string, -): UnpluginOptions { - const pluginArray = Array.isArray(plugins) ? plugins : [plugins] - const plugin = pluginArray.find((item) => item.name === pluginName) - if (!plugin) { - throw new Error(`Code-splitter plugin "${pluginName}" not found`) - } - return plugin -} - -function getReferencePlugin( - plugins: ReturnType<typeof createRouterCodeSplitterPlugin>, -) { - return getCodeSplitterPlugin(plugins, referencePluginName) -} - -async function configurePlugin( - plugin: UnpluginOptions, - command: 'serve' | 'build' = 'serve', -) { - const hook = plugin.vite?.configResolved - if (!hook) { - return - } - - const config = { - root: process.cwd(), - command, - plugins: [{ name: referencePluginName }], - } as never - - if (typeof hook === 'function') { - await hook.call({} as never, config) - return - } - - await hook.handler.call({} as never, config) -} - -async function transformReferenceRoute( - plugin: UnpluginOptions, - code: string, - id: string, -): Promise<TransformResult | null | undefined> { - const transform = plugin.transform - if (!transform || typeof transform === 'function') { - throw new Error('Expected object transform') - } - return transform.handler.call({} as never, code, id) -} - -function getCode(result: TransformResult | null | undefined) { - if (!result) { - return null - } - if (typeof result === 'string') { - return result - } - return result.code -} - -/** How many times the route module accepts its own hot updates. */ -function countHotAccepts(code: string) { - return code.split('import.meta.hot.accept(').length - 1 -} - -describe('router plugin context', () => { - it('splits parenthesized route factories, option values, and grouping arrays', async () => { - const routeFile = normalizePath( - path.join(process.cwd(), 'src/routes/wrapped.tsx'), - ) - const context = createRouterPluginContext() - context.routesByFile.set(routeFile, { routeId: '/wrapped' }) - const plugins = createRouterCodeSplitterPlugin( - { - target: 'react', - autoCodeSplitting: true, - codeSplittingOptions: { addHmr: false }, - }, - context, - ) - await configurePlugin(getReferencePlugin(plugins), 'build') - const code = `import { createFileRoute } from '@tanstack/react-router' -const Component = () => 'wrapped component' -const loader = () => 'wrapped loader' -export const Route = (createFileRoute('/wrapped'))({ - component: (Component), loader: (loader), - codeSplitGroupings: (([(['component']), (['loader'])])), -})` - const reference = getCode( - await transformReferenceRoute( - getReferencePlugin(plugins), - code, - routeFile, - ), - ) - expect(reference).toContain('lazyRouteComponent') - expect(reference).toContain('lazyFn') - const virtual = getCode( - await transformReferenceRoute( - getCodeSplitterPlugin(plugins, virtualPluginName), - code, - `${routeFile}?tsr-split=component`, - ), - ) - expect(virtual).toContain('wrapped component') - expect(virtual).not.toContain('wrapped loader') - }) - - it('refreshes chunk ownership after source changes and isolates split settings', async () => { - const routeFile = normalizePath( - path.join(process.cwd(), 'src/routes/changing.tsx'), - ) - const source = (name: string, value: string) => ` -import { createFileRoute } from '@tanstack/react-router' -const ${name} = { value: ${JSON.stringify(value)} } -export const Route = createFileRoute('/changing')({ - loader: () => ${name}, - component: () => ${name}.value, -})` - const setup = async (combined: boolean) => { - const context = createRouterPluginContext() - context.routesByFile.set(routeFile, { routeId: '/changing' }) - const plugins = createRouterCodeSplitterPlugin( - { - target: 'react', - autoCodeSplitting: true, - codeSplittingOptions: { - addHmr: false, - defaultBehavior: combined - ? [['component', 'loader']] - : [['component'], ['loader']], - }, - }, - context, - ) - await configurePlugin(getReferencePlugin(plugins), 'build') - return async (code: string) => { - const reference = getCode( - await transformReferenceRoute( - getReferencePlugin(plugins), - code, - routeFile, - ), - )! - const virtual = getCode( - await transformReferenceRoute( - getCodeSplitterPlugin(plugins, virtualPluginName), - code, - `${routeFile}?tsr-split=${combined ? 'component---loader' : 'component'}`, - ), - )! - const shared = getCode( - await transformReferenceRoute( - getCodeSplitterPlugin( - plugins, - 'tanstack-router:code-splitter:compile-shared-file', - ), - code, - `${routeFile}?tsr-shared=1`, - ), - )! - return { reference, virtual, shared } - } - } - const separate = await setup(false) - const combined = await setup(true) - const first = await separate(source('firstState', 'first version')) - expect(first.reference).toContain('tsr-split=component') - const virtualImports = parseAst({ - code: first.virtual, - }).program.body.filter((statement) => t.isImportDeclaration(statement)) - expect(virtualImports).toEqual( - expect.arrayContaining([ - expect.objectContaining({ - source: expect.objectContaining({ - value: expect.stringContaining('tsr-shared'), - }), - specifiers: expect.arrayContaining([ - expect.objectContaining({ - type: 'ImportSpecifier', - imported: expect.objectContaining({ name: 'firstState' }), - local: expect.objectContaining({ name: 'firstState' }), - }), - ]), - }), - ]), - ) - expect(first.shared).toContain('first version') - - const second = await separate(source('secondState', 'second version')) - for (const output of Object.values(second)) { - expect(output).not.toContain('firstState') - } - expect(second.virtual).toContain('secondState') - expect(second.shared).toContain('second version') - const together = await combined(source('secondState', 'second version')) - expect(together.reference).not.toContain('tsr-shared') - expect(together.virtual).toContain('second version') - expect(together.virtual).not.toContain('tsr-shared') - expect(await separate(source('secondState', 'second version'))).toEqual( - second, - ) - }) - - it.each([ - { mode: 'production', production: true }, - { mode: 'development with addHmr disabled', production: false }, - ])( - 'does not run React HMR compiler plugins in $mode', - async ({ production }) => { - const routeFile = normalizePath( - path.join(process.cwd(), 'src/routes/lowercase.tsx'), - ) - const routeCode = ` -import { createFileRoute } from '@tanstack/react-router' - -export const Route = createFileRoute('/lowercase')({ component }) - -function component() { - return <div>Hello</div> -} -` - - const context = createRouterPluginContext() - context.routesByFile.set(routeFile, { routeId: '/lowercase' }) - - if (production) { - vi.stubEnv('NODE_ENV', 'production') - } - - try { - const plugins = createRouterCodeSplitterPlugin( - { - target: 'react', - autoCodeSplitting: true, - codeSplittingOptions: production ? undefined : { addHmr: false }, - }, - context, - ) - const referencePlugin = getReferencePlugin(plugins) - const virtualPlugin = getCodeSplitterPlugin(plugins, virtualPluginName) - - await configurePlugin(referencePlugin, production ? 'build' : 'serve') - - const referenceCode = getCode( - await transformReferenceRoute(referencePlugin, routeCode, routeFile), - ) - const virtualCode = getCode( - await transformReferenceRoute( - virtualPlugin, - routeCode, - `${routeFile}?tsr-split=component`, - ), - ) - - expect(referenceCode).not.toContain('TSRFastRefreshAnchor') - expect(virtualCode).toContain('function component()') - expect(virtualCode).toContain('export { component }') - expect(virtualCode).not.toContain('SplitComponent') - } finally { - if (production) { - vi.unstubAllEnvs() - } - } - }, - ) - - it('does not install the standalone route HMR plugin in production', () => { - vi.stubEnv('NODE_ENV', 'production') - - try { - const plugins = unpluginRouterComposedFactory( - { target: 'react', autoCodeSplitting: false }, - { framework: 'vite', versions: {} }, - ) - - const pluginArray = Array.isArray(plugins) ? plugins : [plugins] - expect( - pluginArray.some((plugin) => plugin.name === 'tanstack-router:hmr'), - ).toBe(false) - } finally { - vi.unstubAllEnvs() - } - }) - - it('keeps multiple code-splitter instances isolated by explicit context', async () => { - const routeFile = normalizePath( - path.join(process.cwd(), 'src/routes-a/owned.tsx'), - ) - const otherRouteFile = normalizePath( - path.join(process.cwd(), 'src/routes-b/other.tsx'), - ) - - const routeCode = ` -import { createFileRoute } from '@tanstack/react-router' - -function Component() { - return <div>Hello</div> -} - -export const Route = createFileRoute('/owned')({ - component: Component, -}) -` - - const contextA = createRouterPluginContext() - contextA.routesByFile.set(routeFile, { routeId: '/owned' }) - - const contextB = createRouterPluginContext() - contextB.routesByFile.set(otherRouteFile, { routeId: '/other' }) - - const configA = { - target: 'react', - routesDirectory: './src/routes-a', - generatedRouteTree: './src/routeTree-a.gen.ts', - autoCodeSplitting: true, - } satisfies Partial<Config> - - const configB = { - target: 'react', - routesDirectory: './src/routes-b', - generatedRouteTree: './src/routeTree-b.gen.ts', - autoCodeSplitting: true, - } satisfies Partial<Config> - - const splitterA = getReferencePlugin( - createRouterCodeSplitterPlugin(configA, contextA), - ) - const splitterB = getReferencePlugin( - createRouterCodeSplitterPlugin(configB, contextB), - ) - - await configurePlugin(splitterA) - await configurePlugin(splitterB) - - const firstResult = await transformReferenceRoute( - splitterA, - routeCode, - routeFile, - ) - const firstCode = getCode(firstResult) - - expect(firstCode).not.toBeNull() - expect(countHotAccepts(firstCode!)).toBe(1) - - const secondResult = await transformReferenceRoute( - splitterB, - firstCode!, - routeFile, - ) - - expect(secondResult).toBeNull() - }) - - it('normalizes HMR options before the first transform', async () => { - const routeFile = normalizePath( - path.join(process.cwd(), 'src/routes/owned.tsx'), - ) - - const routeCode = ` -import { createFileRoute } from '@tanstack/react-router' - -function Component() { - return <div>Hello</div> -} - -export const Route = createFileRoute('/owned')({ - component: Component, -}) -` - - const context = createRouterPluginContext() - context.routesByFile.set(routeFile, { routeId: '/owned' }) - - const hmrPlugin = createRouterHmrPlugin({}, context) - const hmrResult = await transformReferenceRoute( - Array.isArray(hmrPlugin) ? hmrPlugin[0]! : hmrPlugin, - routeCode, - routeFile, - ) - - const hmrCode = getCode(hmrResult) - - expect(hmrCode).not.toBeNull() - expect(hmrCode).toContain('TSRFastRefreshAnchor') - }) -}) diff --git a/packages/router-plugin/tests/served-code.ts b/packages/router-plugin/tests/served-code.ts new file mode 100644 index 0000000000..4685940572 --- /dev/null +++ b/packages/router-plugin/tests/served-code.ts @@ -0,0 +1,208 @@ +/** + * Independent observers of code as the dev server serves it to the page: + * an Oxc parse of the served JavaScript, for the few checks that SPEC states + * on modules (J2.5 dependency absence, directives), never on generated + * names, layout or printing. + */ +import { parseSync } from 'vite' + +/** + * The requests a module served to the page imports, statically or by a + * literal dynamic import, without their query (an independent parse of the + * served code: what Vite resolved each import to). + */ +export function servedImports(code: string): Array<string> { + const { module } = parseSync('module.js', code, { sourceType: 'module' }) + const requests: Array<string> = [] + for (const statement of module.staticImports) { + requests.push(statement.moduleRequest.value) + } + for (const statement of module.dynamicImports) { + const request = code.slice( + statement.moduleRequest.start, + statement.moduleRequest.end, + ) + const literal = /^(['"`])([^'"`\\$]*)\1$/.exec(request) + if (literal) { + requests.push(literal[2]!) + } + } + for (const statement of module.staticExports) { + for (const entry of statement.entries) { + if (entry.moduleRequest) { + requests.push(entry.moduleRequest.value) + } + } + } + return requests.map((request) => request.split('?')[0]!) +} + +type Node = Record<string, any> + +/** Visits every node of an ESTree tree. */ +function walk(node: unknown, visit: (node: Node, parent?: Node) => void) { + const go = (value: unknown, parent?: Node) => { + if (!value || typeof value !== 'object') { + return + } + if (Array.isArray(value)) { + for (const item of value) { + go(item, parent) + } + return + } + const current = value as Node + if (typeof current.type === 'string') { + visit(current, parent) + } + for (const key of Object.keys(current)) { + if (key !== 'type' && key !== 'start' && key !== 'end') { + go(current[key], typeof current.type === 'string' ? current : parent) + } + } + } + go(node) +} + +/** + * Whether a served module reads the binding `name` (any binding when + * `name` is left out) that it imports from `request` (its path, or a + * pattern of its request), by a named or default import, or as a member of + * a namespace import (a namespace read whole reads every binding), or + * re-exports it. An unused import specifier is free (SPEC §5.9: the + * bundler drops it); reading it would carry the code that reads it. + */ +export function readsImport( + code: string, + request: string | RegExp, + name?: string, +) { + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + const from = (source: Node | null | undefined) => + source !== null && + source !== undefined && + (typeof request === 'string' + ? String(source.value).split('?')[0] === request + : request.test(String(source.value))) + const exported = (node: Node) => (node.name ?? node.value) as string + const locals = new Set<string>() + const namespaces = new Set<string>() + let reExports = false + for (const statement of program.body as Array<Node>) { + if (statement.type === 'ImportDeclaration' && from(statement.source)) { + for (const specifier of statement.specifiers as Array<Node>) { + if (specifier.importKind === 'type') { + continue + } + if (specifier.type === 'ImportNamespaceSpecifier') { + namespaces.add(specifier.local.name) + } else if ( + name === undefined || + (specifier.type === 'ImportDefaultSpecifier' + ? name === 'default' + : exported(specifier.imported) === name) + ) { + locals.add(specifier.local.name) + } + } + } else if ( + (statement.type === 'ExportAllDeclaration' || + statement.type === 'ExportNamedDeclaration') && + from(statement.source) + ) { + reExports ||= + statement.type === 'ExportAllDeclaration' || + (statement.specifiers as Array<Node>).some( + (specifier) => + name === undefined || exported(specifier.local) === name, + ) + } + } + let reads = 0 + walk(program, (node, parent) => { + if ( + node.type !== 'Identifier' || + parent?.type === 'ImportSpecifier' || + parent?.type === 'ImportDefaultSpecifier' || + parent?.type === 'ImportNamespaceSpecifier' || + // A property name, not a read of the binding + (parent?.type === 'MemberExpression' && + parent.property === node && + !parent.computed) || + (parent?.type === 'Property' && + parent.key === node && + !parent.computed && + !parent.shorthand) + ) { + return + } + if (locals.has(node.name)) { + reads++ + } else if (namespaces.has(node.name)) { + const member = + parent?.type === 'MemberExpression' && parent.object === node + ? parent.computed + ? parent.property.type === 'Literal' + ? String(parent.property.value) + : undefined + : parent.property.name + : undefined + if (name === undefined || member === undefined || member === name) { + reads++ + } + } + }) + return reExports || reads > 0 +} + +const functionTypes = new Set([ + 'FunctionDeclaration', + 'FunctionExpression', + 'ArrowFunctionExpression', +]) + +/** + * For each function of a served module whose own body (nested functions + * left out) holds a string `marker`: the directive its body starts with, + * if any. Name- and form-independent (a declaration, an expression, an + * arrow with a block body). + */ +export function directivesOfFunctionsHolding(code: string, marker: string) { + const { program } = parseSync('module.js', code, { sourceType: 'module' }) + const found: Array<string | undefined> = [] + walk(program, (node) => { + if (!functionTypes.has(node.type) || node.body?.type !== 'BlockStatement') { + return + } + let holds = false as boolean + const visitOwn = (value: unknown) => { + if (!value || typeof value !== 'object') { + return + } + if (Array.isArray(value)) { + value.forEach(visitOwn) + return + } + const child = value as Node + if (functionTypes.has(child.type)) { + return + } + if (child.type === 'Literal' && child.value === marker) { + holds = true + } + for (const key of Object.keys(child)) { + if (key !== 'type' && key !== 'start' && key !== 'end') { + visitOwn(child[key]) + } + } + } + visitOwn(node.body.body) + if (holds) { + const [first] = node.body.body as Array<Node> + found.push( + first?.type === 'ExpressionStatement' ? first.directive : undefined, + ) + } + }) + return found +} diff --git a/packages/router-plugin/tests/shared-bindings-helpers.test.ts b/packages/router-plugin/tests/shared-bindings-helpers.test.ts deleted file mode 100644 index 3198c15fb9..0000000000 --- a/packages/router-plugin/tests/shared-bindings-helpers.test.ts +++ /dev/null @@ -1,1040 +0,0 @@ -import { describe, expect, it } from 'vitest' -import * as t from '@babel/types' -import { parseAst } from '@tanstack/router-utils' - -import { - addSharedSearchParamToFilename, - buildDeclarationMap, - buildDependencyGraph, - collectIdentifiersFromNode, - collectLocalBindingsFromStatement, - collectModuleLevelRefsFromNode, - computeSharedBindings, - expandDestructuredDeclarations, - expandTransitively, - removeBindingsDependingOnRoute, -} from '../src/core/code-splitter/compilers' -import { defaultCodeSplitGroupings } from '../src/core/constants' -import type { CodeSplitGroupings } from '../src/core/constants' - -// ─── Test helpers ────────────────────────────────────────── - -function parse(code: string) { - return parseAst({ code }) -} - -function collectBindings(code: string): Set<string> { - const ast = parse(code) - const bindings = new Set<string>() - for (const node of ast.program.body) { - collectLocalBindingsFromStatement(node, bindings) - } - return bindings -} - -/** Build a dep graph from code for convenience */ -function graphFromCode(code: string) { - const ast = parse(code) - const locals = new Set<string>() - for (const node of ast.program.body) { - collectLocalBindingsFromStatement(node, locals) - } - const declMap = buildDeclarationMap(ast) - return { - ast, - locals, - declMap, - depGraph: buildDependencyGraph(declMap, locals), - } -} - -// ─── addSharedSearchParamToFilename ──────────────────────── - -describe('addSharedSearchParamToFilename', () => { - it('should append tsr-shared=1 to bare filename', () => { - expect(addSharedSearchParamToFilename('src/routes/index.tsx')).toBe( - 'src/routes/index.tsx?tsr-shared=1', - ) - }) - - it('should strip existing query params', () => { - expect( - addSharedSearchParamToFilename( - 'src/routes/index.tsx?tsr-split=component', - ), - ).toBe('src/routes/index.tsx?tsr-shared=1') - }) -}) - -// ─── collectIdentifiersFromNode ─────────────────────────── - -describe('collectIdentifiersFromNode', () => { - it('should collect from a simple identifier', () => { - const ast = parse('const x = foo') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - expect(collectIdentifiersFromNode(init)).toEqual(new Set(['foo'])) - }) - - it('should collect from a binary expression', () => { - const ast = parse('const x = a + b') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - expect(collectIdentifiersFromNode(init)).toEqual(new Set(['a', 'b'])) - }) - - it('should ignore object literal keys', () => { - const ast = parse('const x = { key: value }') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - const ids = collectIdentifiersFromNode(init) - expect(ids).toContain('value') - expect(ids).not.toContain('key') - }) - - it('should ignore member expression properties', () => { - const ast = parse('const x = obj.prop + obj[dynamic]') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - const ids = collectIdentifiersFromNode(init) - expect(ids).toContain('obj') - expect(ids).toContain('dynamic') - expect(ids).not.toContain('prop') - }) - - it('should collect from a call expression', () => { - const ast = parse('const x = foo(bar, baz)') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - expect(collectIdentifiersFromNode(init)).toEqual( - new Set(['foo', 'bar', 'baz']), - ) - }) - - it('should collect from arrow function body', () => { - const ast = parse('const x = () => a + b') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - const ids = collectIdentifiersFromNode(init) - expect(ids).toContain('a') - expect(ids).toContain('b') - }) - - it('should collect from member expressions', () => { - const ast = parse('const x = obj.prop') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - const ids = collectIdentifiersFromNode(init) - expect(ids).toContain('obj') - // property name is not a referenced identifier - expect(ids).not.toContain('prop') - }) - - it('should collect from nested structures', () => { - const ast = parse('const x = { key: fn(val) }') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - const ids = collectIdentifiersFromNode(init) - expect(ids).toContain('fn') - expect(ids).toContain('val') - // object literal keys are not referenced identifiers - expect(ids).not.toContain('key') - }) - - it('should return empty set for a numeric literal', () => { - const ast = parse('const x = 42') - const decl = ast.program.body[0] as t.VariableDeclaration - const init = decl.declarations[0]!.init! - expect(collectIdentifiersFromNode(init).size).toBe(0) - }) - - it('should collect from function declaration body', () => { - const ast = parse('function foo() { return bar + baz }') - const fn = ast.program.body[0]! - const ids = collectIdentifiersFromNode(fn) - // function name is a binding, not a reference - expect(ids).not.toContain('foo') - expect(ids).toContain('bar') - expect(ids).toContain('baz') - }) -}) - -// ─── collectLocalBindingsFromStatement ───────────────────── - -describe('collectLocalBindingsFromStatement', () => { - it('should collect from const declaration', () => { - expect(collectBindings('const x = 1')).toEqual(new Set(['x'])) - }) - - it('should collect from let declaration', () => { - expect(collectBindings('let x = 1')).toEqual(new Set(['x'])) - }) - - it('should collect from multiple declarators', () => { - expect(collectBindings('const x = 1, y = 2')).toEqual(new Set(['x', 'y'])) - }) - - it('should collect from function declaration', () => { - expect(collectBindings('function foo() {}')).toEqual(new Set(['foo'])) - }) - - it('should collect from class declaration', () => { - expect(collectBindings('class Foo {}')).toEqual(new Set(['Foo'])) - }) - - it('should collect from exported variable declaration', () => { - expect(collectBindings('export const x = 1')).toEqual(new Set(['x'])) - }) - - it('should collect from exported function declaration', () => { - expect(collectBindings('export function foo() {}')).toEqual( - new Set(['foo']), - ) - }) - - it('should collect from exported class declaration', () => { - expect(collectBindings('export class Foo {}')).toEqual(new Set(['Foo'])) - }) - - it('should collect from object destructuring', () => { - expect(collectBindings('const { a, b } = obj')).toEqual(new Set(['a', 'b'])) - }) - - it('should collect from nested object destructuring', () => { - expect(collectBindings('const { a: { b, c } } = obj')).toEqual( - new Set(['b', 'c']), - ) - }) - - it('should collect from array destructuring', () => { - expect(collectBindings('const [a, b] = arr')).toEqual(new Set(['a', 'b'])) - }) - - it('should collect from destructuring with defaults', () => { - expect(collectBindings('const { a = 1, b = 2 } = obj')).toEqual( - new Set(['a', 'b']), - ) - }) - - it('should collect from destructuring with rest', () => { - expect(collectBindings('const { a, ...rest } = obj')).toEqual( - new Set(['a', 'rest']), - ) - }) - - it('should collect from exported destructuring', () => { - expect(collectBindings('export const { a, b } = fn()')).toEqual( - new Set(['a', 'b']), - ) - }) - - it('should NOT collect from import declarations', () => { - expect(collectBindings("import { a } from './mod'")).toEqual(new Set()) - }) - - it('should NOT collect from expression statements', () => { - expect(collectBindings('console.log("hello")')).toEqual(new Set()) - }) - - it('should collect from renamed destructuring', () => { - expect(collectBindings('const { a: renamedA } = obj')).toEqual( - new Set(['renamedA']), - ) - }) - - it('should collect from multiple statements', () => { - const code = ` -const x = 1 -function foo() {} -class Bar {} -` - expect(collectBindings(code)).toEqual(new Set(['x', 'foo', 'Bar'])) - }) -}) - -// ─── buildDeclarationMap ────────────────────────────────── - -describe('buildDeclarationMap', () => { - it('should map variable names to their declarator nodes', () => { - const ast = parse('const x = 1\nconst y = 2') - const map = buildDeclarationMap(ast) - expect(map.has('x')).toBe(true) - expect(map.has('y')).toBe(true) - expect(t.isVariableDeclarator(map.get('x'))).toBe(true) - }) - - it('should map function declarations', () => { - const ast = parse('function foo() {}') - const map = buildDeclarationMap(ast) - expect(map.has('foo')).toBe(true) - expect(t.isFunctionDeclaration(map.get('foo'))).toBe(true) - }) - - it('should map class declarations', () => { - const ast = parse('class Bar {}') - const map = buildDeclarationMap(ast) - expect(map.has('Bar')).toBe(true) - expect(t.isClassDeclaration(map.get('Bar'))).toBe(true) - }) - - it('should map exported declarations', () => { - const ast = parse('export const x = 1\nexport function foo() {}') - const map = buildDeclarationMap(ast) - expect(map.has('x')).toBe(true) - expect(map.has('foo')).toBe(true) - }) - - it('should map destructured bindings to same declarator', () => { - const ast = parse('const { a, b } = fn()') - const map = buildDeclarationMap(ast) - expect(map.has('a')).toBe(true) - expect(map.has('b')).toBe(true) - expect(map.get('a')).toBe(map.get('b')) - }) - - it('should not include imports', () => { - const ast = parse("import { x } from './mod'\nconst y = 1") - const map = buildDeclarationMap(ast) - expect(map.has('x')).toBe(false) - expect(map.has('y')).toBe(true) - }) -}) - -// ─── buildDependencyGraph ───────────────────────────────── - -describe('buildDependencyGraph', () => { - it('should detect direct dependency', () => { - const { depGraph } = graphFromCode('const a = 1\nconst b = a + 1') - expect(depGraph.get('b')).toEqual(new Set(['a'])) - expect(depGraph.get('a')).toEqual(new Set()) - }) - - it('should not include self-references', () => { - const { depGraph } = graphFromCode('const a = () => a()') - expect(depGraph.get('a')!.has('a')).toBe(false) - }) - - it('should not include imported identifiers', () => { - const { depGraph } = graphFromCode( - "import { ext } from './mod'\nconst a = ext + 1", - ) - // ext is not in locals, so not in deps - expect(depGraph.get('a')!.has('ext')).toBe(false) - }) - - it('should handle multiple deps', () => { - const { depGraph } = graphFromCode( - 'const a = 1\nconst b = 2\nconst c = a + b', - ) - expect(depGraph.get('c')).toEqual(new Set(['a', 'b'])) - }) - - it('should handle function declaration deps', () => { - const { depGraph } = graphFromCode( - 'const config = {}\nfunction init() { return config }', - ) - expect(depGraph.get('init')).toEqual(new Set(['config'])) - }) - - it('should handle chain deps (each link direct only)', () => { - const { depGraph } = graphFromCode('const a = 1\nconst b = a\nconst c = b') - expect(depGraph.get('c')).toEqual(new Set(['b'])) - expect(depGraph.get('b')).toEqual(new Set(['a'])) - expect(depGraph.get('a')).toEqual(new Set()) - }) -}) - -// ─── collectModuleLevelRefsFromNode ──────────────────────── - -describe('collectModuleLevelRefsFromNode', () => { - it('should find identifier reference in expression', () => { - const code = 'const x = 1\nconst y = x + 1' - const ast = parse(code) - const locals = new Set(['x', 'y']) - - const yDecl = ast.program.body[1] as t.VariableDeclaration - const valueNode = yDecl.declarations[0]!.init! - - const refs = collectModuleLevelRefsFromNode(valueNode, locals) - expect(refs).toContain('x') - expect(refs).not.toContain('y') - }) - - it('should return empty set when no local bindings referenced', () => { - const code = "import { foo } from './mod'\nconst x = foo()" - const ast = parse(code) - const locals = new Set(['x']) // foo is imported, not local - - const xDecl = ast.program.body[1] as t.VariableDeclaration - const valueNode = xDecl.declarations[0]!.init! - - const refs = collectModuleLevelRefsFromNode(valueNode, locals) - expect(refs.size).toBe(0) - }) - - it('should find multiple references', () => { - const code = 'const a = 1\nconst b = 2\nconst c = a + b' - const ast = parse(code) - const locals = new Set(['a', 'b', 'c']) - - const cDecl = ast.program.body[2] as t.VariableDeclaration - const valueNode = cDecl.declarations[0]!.init! - - const refs = collectModuleLevelRefsFromNode(valueNode, locals) - expect(refs).toContain('a') - expect(refs).toContain('b') - }) - - it('should find refs inside function call arguments', () => { - const code = 'const config = {}\nconst result = process(config)' - const ast = parse(code) - const locals = new Set(['config', 'result']) - - const resultDecl = ast.program.body[1] as t.VariableDeclaration - const valueNode = resultDecl.declarations[0]!.init! - - const refs = collectModuleLevelRefsFromNode(valueNode, locals) - expect(refs).toContain('config') - }) - - it('should only return direct refs (not transitive)', () => { - const code = 'const a = 1\nconst b = a\nconst c = b' - const ast = parse(code) - const locals = new Set(['a', 'b', 'c']) - - const cDecl = ast.program.body[2] as t.VariableDeclaration - const valueNode = cDecl.declarations[0]!.init! - - const refs = collectModuleLevelRefsFromNode(valueNode, locals) - // Only b is directly referenced, NOT a (transitive expansion is separate) - expect(refs).toContain('b') - expect(refs).not.toContain('a') - }) -}) - -// ─── expandTransitively ─────────────────────────────────── - -describe('expandTransitively', () => { - it('should expand shared set with deps of shared bindings', () => { - const { depGraph } = graphFromCode('const dep = 1\nconst shared = dep + 1') - const shared = new Set(['shared']) - - expandTransitively(shared, depGraph) - expect(shared).toContain('dep') - }) - - it('should handle multi-level transitive expansion', () => { - const { depGraph } = graphFromCode('const a = 1\nconst b = a\nconst c = b') - const shared = new Set(['c']) - - expandTransitively(shared, depGraph) - expect(shared).toContain('b') - expect(shared).toContain('a') - }) - - it('should not expand bindings not in graph', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('shared', new Set(['ext'])) - // ext has no entry in graph - const shared = new Set(['shared']) - - expandTransitively(shared, depGraph) - // ext added because it's a dep, even if it has no graph entry - expect(shared).toContain('ext') - expect(shared.size).toBe(2) - }) - - it('should not loop on circular references', () => { - const { depGraph } = graphFromCode( - 'const a = () => b()\nconst b = () => a()', - ) - const shared = new Set(['a']) - - expandTransitively(shared, depGraph) - expect(shared).toContain('a') - expect(shared).toContain('b') - }) - - it('should leave shared untouched when binding has no deps', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('x', new Set()) - const shared = new Set(['x']) - - expandTransitively(shared, depGraph) - expect(shared.size).toBe(1) - expect(shared).toContain('x') - }) - - it('should handle function declaration deps', () => { - const { depGraph } = graphFromCode( - 'const config = {}\nfunction init() { return config }', - ) - const shared = new Set(['init']) - - expandTransitively(shared, depGraph) - expect(shared).toContain('config') - }) - - it('should handle empty graph', () => { - const depGraph = new Map<string, Set<string>>() - const shared = new Set(['x']) - - expandTransitively(shared, depGraph) - expect(shared.size).toBe(1) - }) -}) - -// ─── expandDestructuredDeclarations ─────────────────────── - -describe('expandDestructuredDeclarations', () => { - it('should add all siblings when one destructured binding is shared', () => { - const ast = parse('const { a, b, c } = fn()') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('a') - expect(shared).toContain('b') - expect(shared).toContain('c') - }) - - it('should handle array destructuring', () => { - const ast = parse('const [x, y] = fn()') - const shared = new Set(['y']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('x') - expect(shared).toContain('y') - }) - - it('should not expand non-destructured declarations', () => { - const ast = parse('const a = 1\nconst b = 2') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('a') - expect(shared).not.toContain('b') - }) - - it('should handle exported destructured declarations', () => { - const ast = parse('export const { a, b } = fn()') - const shared = new Set(['b']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('a') - expect(shared).toContain('b') - }) - - it('should not touch declarations where no binding is shared', () => { - const ast = parse('const { a, b } = fn()\nconst { c, d } = other()') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('a') - expect(shared).toContain('b') - expect(shared).not.toContain('c') - expect(shared).not.toContain('d') - }) - - it('should handle nested destructuring', () => { - const ast = parse('const { a, b: { c } } = fn()') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('a') - expect(shared).toContain('c') - }) - - it('should handle destructuring with defaults', () => { - const ast = parse('const { a = 1, b = 2 } = fn()') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('b') - }) - - it('should handle destructuring with rest', () => { - const ast = parse('const { a, ...rest } = fn()') - const shared = new Set(['a']) - - expandDestructuredDeclarations(ast, shared) - expect(shared).toContain('rest') - }) -}) - -// ─── computeSharedBindings (integration) ────────────────── - -describe('computeSharedBindings', () => { - const defaultGroupings = defaultCodeSplitGroupings - - it('should return empty set when no route options exist', () => { - const code = 'const x = 1' - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result.size).toBe(0) - }) - - it('should return empty set for root routes (unsplittable)', () => { - const code = ` -import { createRootRoute } from '@tanstack/react-router' -const shared = 42 -export const Route = createRootRoute({ - component: () => shared, - beforeLoad: () => shared, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result.size).toBe(0) - }) - - it('should detect binding shared between split and non-split properties', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const sharedValue = 42 -export const Route = createFileRoute('/')({ - component: () => sharedValue, - beforeLoad: () => sharedValue, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('sharedValue') - }) - - it('should NOT mark binding as shared if only used by split properties', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const myComponent = () => <div /> -export const Route = createFileRoute('/')({ - component: myComponent, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result.size).toBe(0) - }) - - it('should NOT mark binding as shared if only used by non-split properties', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const validator = () => true -export const Route = createFileRoute('/')({ - component: () => <div />, - beforeLoad: validator, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result.size).toBe(0) - }) - - it('should detect shared function declaration', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -function helperFn() { return 42 } -export const Route = createFileRoute('/')({ - component: () => helperFn(), - beforeLoad: () => helperFn(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('helperFn') - }) - - it('should mark shared when binding used by two different split groups', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -class Config { value = 1 } -export const Route = createFileRoute('/')({ - component: () => new Config(), - loader: () => new Config(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: [['component'], ['loader']], - }) - // component and loader are in different split groups → Config is shared - expect(result).toContain('Config') - }) - - it('should detect shared class when used by split and non-split', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -class Config { value = 1 } -export const Route = createFileRoute('/')({ - component: () => new Config(), - beforeLoad: () => new Config(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('Config') - }) - - it('should expand transitive deps into shared set', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const BASE = 10 -const multiplier = BASE * 2 -export const Route = createFileRoute('/')({ - component: () => multiplier, - beforeLoad: () => multiplier, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('multiplier') - expect(result).toContain('BASE') - }) - - it('should expand destructured declarations', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const { a, b } = getValues() -export const Route = createFileRoute('/')({ - component: () => a, - beforeLoad: () => a, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('a') - expect(result).toContain('b') - }) - - it('should handle no local bindings gracefully', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ - component: () => <div />, - beforeLoad: () => {}, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result.size).toBe(0) - }) - - it('should not include imported bindings as shared (bundlers dedupe them)', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -import { helper } from './utils' -export const Route = createFileRoute('/')({ - component: () => helper(), - beforeLoad: () => helper(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).not.toContain('helper') - expect(result.size).toBe(0) - }) - - it('should handle multiple shared bindings', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const a = 1 -const b = 2 -export const Route = createFileRoute('/')({ - component: () => a + b, - beforeLoad: () => a + b, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('a') - expect(result).toContain('b') - }) - - it('should handle chained createFileRoute call pattern', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const data = { value: 42 } -export const Route = createFileRoute('/')({ - component: () => data.value, - validateSearch: () => data, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('data') - }) - - it('should handle loader in default groupings (not split by default)', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const config = { key: 'value' } -export const Route = createFileRoute('/')({ - component: () => config.key, - loader: () => config, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - // In default groupings, loader is NOT split → non-split - // component IS split → config referenced by both → shared - expect(result).toContain('config') - }) - - it('should handle custom groupings where loader and component are in different split groups', () => { - const groupings: CodeSplitGroupings = [['component'], ['loader']] - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const config = { key: 'value' } -export const Route = createFileRoute('/')({ - component: () => config.key, - loader: () => config, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: groupings, - }) - // component and loader are in different split groups → config is shared - expect(result).toContain('config') - }) - - it('should NOT mark shared when binding used by only one split group', () => { - const groupings: CodeSplitGroupings = [ - ['loader', 'component'], - ['errorComponent'], - ] - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const config = { key: 'value' } -export const Route = createFileRoute('/')({ - component: () => config.key, - loader: () => config, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: groupings, - }) - // component and loader are in the SAME split group → config only in one group → not shared - expect(result.size).toBe(0) - }) - - it('should handle custom groupings with non-split property referencing shared binding', () => { - const groupings: CodeSplitGroupings = [['component'], ['loader']] - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const config = { key: 'value' } -export const Route = createFileRoute('/')({ - component: () => config.key, - loader: () => config, - beforeLoad: () => config, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: groupings, - }) - // config used by component (split), loader (split), beforeLoad (non-split) - // In both splitRefs and nonSplitRefs → shared - expect(result).toContain('config') - }) - - it('should handle deep transitive chain with destructuring', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const base = 10 -const { x, y } = compute(base) -export const Route = createFileRoute('/')({ - component: () => x, - beforeLoad: () => x, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - // x is shared → y must be shared (destructured together) - // base is a transitive dep of {x, y} declaration → also shared - expect(result).toContain('x') - expect(result).toContain('y') - expect(result).toContain('base') - }) - - it('should NOT include bindings that transitively depend on Route', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const HEADER = 'Page' -function usePageTitle() { return HEADER + ' - ' + Route.fullPath } -export const Route = createFileRoute('/about')({ - loader: () => usePageTitle(), - component: () => usePageTitle(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - // usePageTitle references Route → cannot be shared - expect(result).not.toContain('usePageTitle') - // HEADER does NOT reference Route → still safe to share - expect(result).toContain('HEADER') - // Route must never be shared - expect(result).not.toContain('Route') - }) - - it('should remove entire transitive chain if it reaches Route', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const routeInfo = { path: '' } -function initRouteInfo() { routeInfo.path = Route.fullPath } -function getTitle() { initRouteInfo(); return routeInfo.path } -export const Route = createFileRoute('/test')({ - loader: () => getTitle(), - component: () => getTitle(), -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - // getTitle → initRouteInfo → Route: entire chain cannot be shared - expect(result).not.toContain('getTitle') - expect(result).not.toContain('initRouteInfo') - expect(result).not.toContain('Route') - // routeInfo doesn't reference Route directly, but initRouteInfo does - // routeInfo itself may or may not be shared depending on its own deps - }) - - it('should keep bindings that do NOT depend on Route alongside ones that do', () => { - const code = ` -import { createFileRoute } from '@tanstack/react-router' -const safeConfig = { timeout: 5000 } -function unsafeHelper() { return Route.fullPath } -export const Route = createFileRoute('/mixed')({ - loader: () => ({ config: safeConfig, path: unsafeHelper() }), - component: () => <div>{safeConfig.timeout} {unsafeHelper()}</div>, -}) -` - const result = computeSharedBindings({ - code, - codeSplitGroupings: defaultGroupings, - }) - expect(result).toContain('safeConfig') - expect(result).not.toContain('unsafeHelper') - expect(result).not.toContain('Route') - }) -}) - -// ─── removeBindingsDependingOnRoute ─────────────────────── - -describe('removeBindingsDependingOnRoute', () => { - it('should remove a binding that directly depends on Route', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('helper', new Set(['Route'])) - depGraph.set('Route', new Set()) - const shared = new Set(['helper']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).not.toContain('helper') - }) - - it('should remove a binding that transitively depends on Route', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('a', new Set(['b'])) - depGraph.set('b', new Set(['Route'])) - depGraph.set('Route', new Set()) - const shared = new Set(['a']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).not.toContain('a') - }) - - it('should keep a binding that does NOT depend on Route', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('safe', new Set(['dep'])) - depGraph.set('dep', new Set()) - depGraph.set('Route', new Set()) - const shared = new Set(['safe']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).toContain('safe') - }) - - it('should handle mixed: remove Route-dependent, keep safe bindings', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('safe', new Set(['dep'])) - depGraph.set('dep', new Set()) - depGraph.set('unsafe', new Set(['Route'])) - depGraph.set('Route', new Set()) - const shared = new Set(['safe', 'unsafe']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).toContain('safe') - expect(shared).not.toContain('unsafe') - }) - - it('should handle empty shared set', () => { - const depGraph = new Map<string, Set<string>>() - const shared = new Set<string>() - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared.size).toBe(0) - }) - - it('should handle binding with no graph entry', () => { - const depGraph = new Map<string, Set<string>>() - const shared = new Set(['orphan']) - - removeBindingsDependingOnRoute(shared, depGraph) - // No deps found → does not depend on Route → keep - expect(shared).toContain('orphan') - }) - - it('should handle circular deps that do NOT reach Route', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('a', new Set(['b'])) - depGraph.set('b', new Set(['a'])) - depGraph.set('Route', new Set()) - const shared = new Set(['a']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).toContain('a') - }) - - it('should handle circular deps that DO reach Route', () => { - const depGraph = new Map<string, Set<string>>() - depGraph.set('a', new Set(['b'])) - depGraph.set('b', new Set(['a', 'Route'])) - depGraph.set('Route', new Set()) - const shared = new Set(['a']) - - removeBindingsDependingOnRoute(shared, depGraph) - expect(shared).not.toContain('a') - }) -}) diff --git a/packages/router-plugin/tests/source-maps.test.ts b/packages/router-plugin/tests/source-maps.test.ts deleted file mode 100644 index 3217dd9aa3..0000000000 --- a/packages/router-plugin/tests/source-maps.test.ts +++ /dev/null @@ -1,322 +0,0 @@ -/** - * Source maps of split routes point at the route file the user wrote: a throw - * in a split component, or in code the route module and a split chunk share, - * maps to its line in the route file, in real webpack and Rspack builds and - * in Vite's dev server, and the map names the route file itself, not the - * `?tsr-split` / `?tsr-shared` module id. Issues #3828 and #6667. - */ -import { - mkdir, - mkdtemp, - readFile, - readdir, - rm, - writeFile, -} from 'node:fs/promises' -import { SourceMap } from 'node:module' -import path from 'node:path' -import { rspack } from '@rsbuild/core' -import { createServer } from 'vite' -import webpack from 'webpack' -import { describe, expect, test } from 'vitest' -import type { SourceMapPayload } from 'node:module' - -const timeout = 60_000 - -/** - * A route whose split component throws, and whose loader and component share - * a function that throws, each on its own line. - */ -function routeSource({ types }: { types: boolean }) { - const never = types ? ': never' : '' - return `import { createFileRoute } from '@tanstack/react-router' - -function fail()${never} { - throw new Error('MARK_SHARED_THROW') -} - -function Page()${never} { - throw new Error('MARK_PAGE_THROW ' + typeof fail) -} - -export const Route = createFileRoute('/')({ - loader: () => fail(), - component: Page, -}) -` -} - -const rootSource = `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute({}) -` - -/** The 1-based line of `marker` in `code`. */ -function lineOf(code: string, marker: string) { - return code.slice(0, code.indexOf(marker)).split('\n').length -} - -/** - * Where `code`'s source map sends the opening quote of the string `marker`: - * the source as `source` gives it, and the 1-based line. - */ -function originalPositionOf( - code: string, - map: SourceMapPayload, - marker: string, - source: (name: string) => string, -) { - const lines = code.slice(0, code.indexOf(marker) - 1).split('\n') - const entry = new SourceMap(map).findEntry( - lines.length - 1, - lines.at(-1)!.length, - ) - if (!('originalSource' in entry)) { - return undefined - } - return { - source: source(entry.originalSource), - line: entry.originalLine + 1, - } -} - -/** Writes `files` into a new app directory inside the package. */ -async function createApp(files: Record<string, string>) { - // Keep the app inside the package so runtime imports resolve. - const root = await mkdtemp(path.join(__dirname, '.source-maps-')) - await mkdir(path.join(root, 'routes')) - for (const [file, code] of Object.entries(files)) { - await writeFile(path.join(root, file), code) - } - return root -} - -function routerOptions(root: string) { - return { - target: 'react', - routesDirectory: path.join(root, 'routes'), - generatedRouteTree: path.join(root, 'routeTree.gen.ts'), - autoCodeSplitting: true, - codeSplittingOptions: { addHmr: false }, - } as const -} - -/** A client production build of `entry`, unminified, with source maps. */ -function compilerConfig(root: string, entry: string) { - return { - context: root, - mode: 'production', - target: 'web', - devtool: 'source-map', - entry: `./${entry}`, - output: { path: path.join(root, 'dist') }, - optimization: { minimize: false }, - } as const -} - -interface Compiler { - run: ( - callback: ( - error: Error | null, - stats?: { - hasErrors: () => boolean - toString: (options: object) => string - }, - ) => void, - ) => void - close: (callback: (error?: Error | null) => void) => void -} - -/** Runs one build and settles once the compiler has closed. */ -function runCompiler(compiler: Compiler) { - return new Promise<void>((resolve, reject) => { - compiler.run((error, stats) => { - // The test removes the app afterwards: wait for the compiler to finish. - compiler.close((closeError) => { - if (error ?? closeError) { - reject(error ?? closeError) - } else if (stats?.hasErrors()) { - reject(new Error(stats.toString({ all: false, errors: true }))) - } else { - resolve() - } - }) - }) - }) -} - -const bundlers = [ - { - name: 'webpack', - // webpack parses no TypeScript: the router plugin is the only loader. - extension: 'js', - async build(root: string, entry: string) { - const { tanstackRouter } = await import('../src/webpack') - await runCompiler( - webpack({ - ...compilerConfig(root, entry), - // The test app is not part of the package's TypeScript project. - resolve: { tsconfig: false }, - plugins: [tanstackRouter(routerOptions(root))], - }), - ) - }, - }, - { - name: 'rspack', - // As in Rsbuild: SWC compiles the router plugin's output. - extension: 'tsx', - async build(root: string, entry: string) { - const { tanstackRouter } = await import('../src/rspack') - await runCompiler( - rspack({ - ...compilerConfig(root, entry), - module: { - rules: [ - { - test: /\.tsx?$/, - loader: 'builtin:swc-loader', - options: { - jsc: { parser: { syntax: 'typescript', tsx: true } }, - }, - type: 'javascript/auto', - }, - ], - }, - plugins: [tanstackRouter(routerOptions(root))], - }), - ) - }, - }, -] as const - -describe.each(bundlers)('$name build', (bundler) => { - test( - 'a throw in a split component, and in code it shares, maps to its line in the route file', - async () => { - const route = routeSource({ types: bundler.extension === 'tsx' }) - const routeFile = `routes/index.${bundler.extension}` - const entry = `entry.${bundler.extension}` - const root = await createApp({ - [`routes/__root.${bundler.extension}`]: rootSource, - [routeFile]: route, - [entry]: `import { Route } from './${routeFile}'\nglobalThis.route = Route\n`, - }) - try { - await bundler.build(root, entry) - const dist = path.join(root, 'dist') - const chunks = new Map<string, string>() - for (const file of await readdir(dist)) { - if (file.endsWith('.js')) { - chunks.set(file, await readFile(path.join(dist, file), 'utf8')) - } - } - for (const marker of ['MARK_PAGE_THROW', 'MARK_SHARED_THROW']) { - const [file, code] = - [...chunks].find(([, chunk]) => chunk.includes(marker)) ?? [] - expect(file, `the chunk holding ${marker}`).toBeDefined() - if (marker === 'MARK_PAGE_THROW') { - expect(file, 'the component is split').not.toBe('main.js') - } - const map = JSON.parse( - await readFile(path.join(dist, `${file}.map`), 'utf8'), - ) as SourceMapPayload - expect( - originalPositionOf(code!, map, marker, (source) => - source.replace(/^webpack:\/\/[^/]*\/\.\//, ''), - ), - `${marker} in ${file}`, - ).toEqual({ source: routeFile, line: lineOf(route, marker) }) - } - } finally { - await rm(root, { recursive: true, force: true }) - } - }, - timeout, - ) -}) - -function inlineSourceMap(code: string) { - const data = - /\/\/# sourceMappingURL=data:application\/json;(?:charset=utf-8;)?base64,(\S+)\s*$/.exec( - code, - )?.[1] - expect(data, 'the module has an inline source map').toBeDefined() - return JSON.parse( - Buffer.from(data!, 'base64').toString('utf8'), - ) as SourceMapPayload -} - -/** - * The route module served at `routeUrl` and every module derived from it - * (imports of the route file's path with a query), by URL. - */ -async function routeModules(routeUrl: URL) { - const modules = new Map<string, string>() - const pending = [routeUrl.href] - while (pending.length > 0) { - const url = pending.pop()! - if (modules.has(url)) { - continue - } - const code = await (await fetch(url)).text() - modules.set(url, code) - for (const [, specifier] of code.matchAll(/["']([^"'\s]+)["']/g)) { - const derived = new URL(specifier!, url) - if (derived.pathname === routeUrl.pathname && derived.search) { - pending.push(derived.href) - } - } - } - return modules -} - -describe('vite dev', () => { - test( - 'the modules of a split route map a throw to its line in the route file, which their maps name as their source', - async () => { - const route = routeSource({ types: true }) - const root = await createApp({ - 'routes/__root.tsx': rootSource, - 'routes/index.tsx': route, - }) - const { tanstackRouter } = await import('../src/vite') - const server = await createServer({ - root, - configFile: false, - logLevel: 'silent', - plugins: [tanstackRouter(routerOptions(root))], - optimizeDeps: { noDiscovery: true, include: [] }, - server: { port: 0, hmr: false, ws: false }, - }) - try { - await server.listen() - const routeUrl = new URL( - '/routes/index.tsx', - server.resolvedUrls!.local[0], - ) - const modules = await routeModules(routeUrl) - for (const marker of ['MARK_PAGE_THROW', 'MARK_SHARED_THROW']) { - const [url, code] = - [...modules].find(([, module]) => module.includes(marker)) ?? [] - expect(url, `the module holding ${marker}`).toBeDefined() - if (marker === 'MARK_PAGE_THROW') { - expect(url, 'the component is split').not.toBe(routeUrl.href) - } - expect( - originalPositionOf( - code!, - inlineSourceMap(code!), - marker, - (source) => new URL(source, url).href, - ), - `${marker} in ${url}`, - ).toEqual({ source: routeUrl.href, line: lineOf(route, marker) }) - } - } finally { - await server.close() - await rm(root, { recursive: true, force: true }) - } - }, - timeout, - ) -}) diff --git a/packages/router-plugin/tests/code-splitter/test-files/react/shared-runtime.tsx b/packages/router-plugin/tests/test-files/shared-runtime.tsx similarity index 100% rename from packages/router-plugin/tests/code-splitter/test-files/react/shared-runtime.tsx rename to packages/router-plugin/tests/test-files/shared-runtime.tsx diff --git a/packages/router-plugin/tests/utils.test.ts b/packages/router-plugin/tests/utils.test.ts deleted file mode 100644 index 530880858e..0000000000 --- a/packages/router-plugin/tests/utils.test.ts +++ /dev/null @@ -1,141 +0,0 @@ -import * as babel from '@babel/core' -import { parseAst } from '@tanstack/router-utils' -import { describe, expect, it } from 'vitest' -import { - getUniqueProgramIdentifier, - normalizePath, - routeFactoryCallCodeFilter, -} from '../src/core/utils' -import type * as t from '@babel/types' -import type { NodePath } from '@babel/core' - -function matchesRouteFactoryCallCodeFilter(code: string) { - return routeFactoryCallCodeFilter.some((pattern) => { - const result = pattern.test(code) - pattern.lastIndex = 0 - return result - }) -} - -function getProgramPath(code: string): NodePath<t.Program> { - const ast = parseAst({ code }) - let programPath: NodePath<t.Program> | undefined - - babel.traverse(ast, { - Program(path: NodePath<t.Program>) { - programPath = path - path.stop() - }, - }) - - if (!programPath) { - throw new Error('Program path not found') - } - - return programPath -} - -describe('normalizePath', () => { - it('should convert Windows backslashes to forward slashes', () => { - expect(normalizePath('C:\\Users\\project\\src\\routes\\index.tsx')).toBe( - 'C:/Users/project/src/routes/index.tsx', - ) - }) - - it('should handle mixed slashes', () => { - expect(normalizePath('C:/Users\\project/src\\routes/index.tsx')).toBe( - 'C:/Users/project/src/routes/index.tsx', - ) - }) - - it('should leave forward slashes unchanged', () => { - expect(normalizePath('/home/user/project/src/routes/index.tsx')).toBe( - '/home/user/project/src/routes/index.tsx', - ) - }) - - it('should handle relative paths with backslashes', () => { - expect(normalizePath('src\\routes\\index.tsx')).toBe('src/routes/index.tsx') - }) - - it('should handle empty string', () => { - expect(normalizePath('')).toBe('') - }) - - it('should handle path with query string', () => { - expect(normalizePath('C:\\project\\file.tsx?tsr-split=component')).toBe( - 'C:/project/file.tsx?tsr-split=component', - ) - }) -}) - -describe('getUniqueProgramIdentifier', () => { - it('returns the base name when unused', () => { - const programPath = getProgramPath('const existing = 1') - - expect(getUniqueProgramIdentifier(programPath, 'TSRComponent').name).toBe( - 'TSRComponent', - ) - }) - - it('appends numeric suffixes for existing bindings', () => { - const programPath = getProgramPath( - 'const TSRComponent = 1\nconst TSRComponent2 = 2', - ) - - expect(getUniqueProgramIdentifier(programPath, 'TSRComponent').name).toBe( - 'TSRComponent3', - ) - }) - - it('avoids globals too', () => { - const programPath = getProgramPath('const existing = window') - - expect(getUniqueProgramIdentifier(programPath, 'window').name).toBe( - 'window2', - ) - }) - - it('avoids collisions across consecutive calls with the same base name', () => { - const programPath = getProgramPath('const existing = 1') - - const first = getUniqueProgramIdentifier(programPath, 'TSRComponent') - const second = getUniqueProgramIdentifier(programPath, 'TSRComponent') - - expect(first.name).toBe('TSRComponent') - expect(second.name).toBe('TSRComponent2') - expect(first.name).not.toBe(second.name) - }) -}) - -describe('routeFactoryCallCodeFilter', () => { - it('matches route factory calls with TypeScript type arguments', () => { - expect( - matchesRouteFactoryCallCodeFilter( - 'createRootRouteWithContext<MyContext>()({})', - ), - ).toBe(true) - }) - - it('matches route factory calls without TypeScript type arguments', () => { - expect( - matchesRouteFactoryCallCodeFilter('createRootRouteWithContext()({})'), - ).toBe(true) - expect(matchesRouteFactoryCallCodeFilter('createRootRoute({})')).toBe(true) - expect( - matchesRouteFactoryCallCodeFilter("createFileRoute('/posts')({})"), - ).toBe(true) - }) - - it('matches route factory calls with whitespace before invocation', () => { - expect( - matchesRouteFactoryCallCodeFilter( - 'createRootRouteWithContext <MyContext>()({})', - ), - ).toBe(true) - expect(matchesRouteFactoryCallCodeFilter('createRootRoute ({})')).toBe(true) - expect( - matchesRouteFactoryCallCodeFilter("createFileRoute ('/posts')({})"), - ).toBe(true) - }) -}) diff --git a/packages/router-plugin/tests/validate-module.ts b/packages/router-plugin/tests/validate-module.ts deleted file mode 100644 index 4e0884a436..0000000000 --- a/packages/router-plugin/tests/validate-module.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { stripVTControlCharacters } from 'node:util' -import { parseSync, transformWithOxc } from 'vite' - -/** - * Validates generated code the way a browser or bundler sees it, without using - * the compiler's own parser: erase TypeScript (keeping every value import) and - * parse the result as a JavaScript module with semantic checks. This rejects - * syntax errors, nameless function/class declarations, duplicate bindings - * (including an import redeclared by a local declaration) and exports of - * undeclared bindings. - * - * @returns the error messages; an empty array means the module is valid. - */ -export async function getModuleErrors( - code: string, - filename = 'module.tsx', -): Promise<Array<string>> { - let javascript: string - try { - const result = await transformWithOxc(code, filename, { - jsx: 'preserve', - typescript: { onlyRemoveTypeImports: true }, - }) - javascript = result.code - } catch (error) { - return [stripVTControlCharacters((error as Error).message)] - } - const { errors } = parseSync('module.jsx', javascript, { - sourceType: 'module', - showSemanticErrors: true, - }) - return errors.map((error) => error.message) -} - -/** Matches a declaration of `name` in generated code, however it is printed. */ -export function declarationOf(name: string): RegExp { - return new RegExp(String.raw`\b(?:const|let|var|function|class)\s+${name}\b`) -} diff --git a/packages/router-plugin/tests/webpack-hmr-page.ts b/packages/router-plugin/tests/webpack-hmr-page.ts new file mode 100644 index 0000000000..2395aafff5 --- /dev/null +++ b/packages/router-plugin/tests/webpack-hmr-page.ts @@ -0,0 +1,270 @@ +/** + * Route HMR of the router plugin's webpack entry as an app sees it: a real + * webpack dev server (`webpack-dev-server` with `hot: true`, the setup of the + * webpack quickstart example and `docs/router/installation/with-webpack.md`) + * serves a small file-based React app with the real router package, a real + * browser page (headless Chromium, `openPage`) runs it with webpack's own HMR + * client, and the test edits a route file on disk, which webpack's own + * watcher reports. The test reads the page: what it shows, whether it + * reloaded, and what it reported as an error. + * + * Nothing of the HMR path is modelled: webpack decides which modules accept + * the update, and its client (`webpack/hot/dev-server`) reloads the page when + * none does. The app's TypeScript compiles with `babel-loader` and + * `@babel/preset-typescript` (webpack has no TypeScript transform of its + * own); the app writes no JSX (`createElement`), so no JSX transform or React + * Refresh takes part: route HMR alone decides whether an edit applies in + * place. + * + * An edit settles on its outcome (`waitForOutcome`): first webpack compiled + * the written file (a compile that started after the write ended and nothing + * compiles), then the page shows the expected text with no request in + * flight, within one bound; never on how many compiles, hot updates or + * client messages it takes. + */ +import { utimes, writeFile } from 'node:fs/promises' +import { createRequire } from 'node:module' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import webpack from 'webpack' +import WebpackDevServer from 'webpack-dev-server' +import { createApp } from '@tanstack/compiler-test-utils/build-harness' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { trackRequests } from '@tanstack/compiler-test-utils/hmr-sync' +import { waitForOutcome } from '@tanstack/compiler-test-utils/outcome' +import { onTestFinished } from '@tanstack/compiler-test-utils/test-scope' +import { tanstackRouter } from '../src/webpack' +import type { AddressInfo } from 'node:net' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { Config } from '../src/webpack' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) +const require = createRequire(import.meta.url) + +const main = `import { createElement } from 'react' +import { createRoot } from 'react-dom/client' +import { RouterProvider, createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +const router = createRouter({ routeTree }) +createRoot(document.getElementById('app')!).render( + createElement(RouterProvider, { router }), +) +` + +const rootRoute = `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({}) +` + +const indexHtml = `<!doctype html> +<html> + <body> + <div id="app"></div> + <script src="/main.js"></script> + </body> +</html> +` + +export interface WebpackHmrPageOptions { + /** + * Router plugin options over the defaults (`target: 'react'`, + * `autoCodeSplitting: true`, the app's `routes/` directory and route tree). + */ + pluginOptions?: Partial<Config> + /** + * App files relative to its root: route files in `routes/` (TypeScript + * without JSX; `routes/__root.ts` defaults to an empty root route). + */ + files: Record<string, string> + /** Text the app shows once it rendered. */ + ready: string +} + +export interface WebpackEditResult { + /** Whether the page loaded again since the edit began. */ + reloaded: boolean + /** Uncaught errors and `console.error` messages of the page since the edit. */ + errors: Array<string> +} + +export interface WebpackHmrPage { + page: BrowserPage + /** + * Writes app files, waits until webpack compiled them, then until the page + * shows `expected` with no request in flight (one overall bound, 20 s). + */ + edit: ( + files: Record<string, string>, + expected: string, + ) => Promise<WebpackEditResult> +} + +const editTimeout = 20_000 + +/** + * How long webpack and the page stay quiet without the page showing the + * edit before the edit counts as not shown (`failWhenQuietFor`). + */ +const editQuietFailure = 3_000 + +/** + * Starts a webpack dev server on an app of `files`, opens it in a browser + * page and waits until it shows `ready`. The server, the page and the app's + * directory are disposed of when the test finishes. + */ +export async function openWebpackHmrPage( + options: WebpackHmrPageOptions, +): Promise<WebpackHmrPage> { + const app = await createApp({ + dir: harnessDir, + prefix: '.webpack-hmr-page-', + registerCleanup: onTestFinished, + files: { + 'public/index.html': indexHtml, + 'main.ts': main, + 'routes/__root.ts': rootRoute, + ...options.files, + }, + }) + const root = app.root + // Files older than the watcher's start: webpack's watcher reports a file + // modified right before it started as changed + const past = new Date(Date.now() - 60_000) + for (const file of ['main.ts', ...Object.keys(options.files)]) { + await utimes(path.join(root, file), past, past) + } + + const compiler = webpack({ + mode: 'development', + context: root, + entry: { main: './main.ts' }, + output: { path: path.join(root, 'dist'), publicPath: '/' }, + resolve: { extensions: ['.ts', '.js'] }, + module: { + rules: [ + { + test: /\.ts$/, + include: root, + loader: require.resolve('babel-loader'), + options: { + babelrc: false, + configFile: false, + presets: [require.resolve('@babel/preset-typescript')], + }, + }, + ], + }, + plugins: [ + tanstackRouter({ + target: 'react', + routesDirectory: path.join(root, 'routes'), + generatedRouteTree: path.join(root, 'routeTree.gen.ts'), + autoCodeSplitting: true, + ...options.pluginOptions, + }), + ], + infrastructureLogging: { level: 'none' }, + stats: 'none', + }) + + /** Compiles started and ended, whether one is running, and its errors. */ + let started = 0 + let compiling = false + let invalidated = false + let compileErrors: Array<string> = [] + compiler.hooks.invalid.tap('webpack-hmr-page', () => { + invalidated = true + }) + compiler.hooks.watchRun.tap('webpack-hmr-page', () => { + started++ + compiling = true + invalidated = false + }) + compiler.hooks.done.tap('webpack-hmr-page', (stats) => { + compiling = false + compileErrors = stats.hasErrors() + ? stats + .toJson({ all: false, errors: true }) + .errors!.map((error) => error.message) + : [] + }) + compiler.hooks.failed.tap('webpack-hmr-page', (error) => { + compiling = false + compileErrors = [error.stack ?? error.message] + }) + + const server = new WebpackDevServer( + { + host: '127.0.0.1', + port: 0, + hot: true, + static: { directory: path.join(root, 'public'), watch: false }, + historyApiFallback: true, + setupExitSignals: false, + client: { overlay: false, logging: 'warn' }, + }, + compiler, + ) + await server.start() + onTestFinished(() => server.stop()) + const port = (server.server!.address() as AddressInfo).port + + const page = await openPage(`http://127.0.0.1:${port}/`, { + registerCleanup: onTestFinished, + }) + await page.waitForText(options.ready, { selector: '#app' }) + + /** The page's requests in flight (hot-update fetches, a reload). */ + const requests = trackRequests(page) + const text = async () => { + try { + return await page.text('#app') + } catch { + // The page is reloading + return '' + } + } + const webpackQuiet = () => !compiling && !invalidated + + return { + page, + edit: async (files, expected) => { + const start = { + loads: page.loads(), + errors: page.errors.length, + compiles: started, + } + const deadline = Date.now() + editTimeout + for (const [file, code] of Object.entries(files)) { + await writeFile(path.join(root, file), code) + } + // Until webpack compiled the edit: a compile started after the write + // and nothing compiles or is pending + await waitForOutcome({ + timeout: deadline - Date.now(), + applied: () => started > start.compiles, + quiet: webpackQuiet, + describe: () => + `webpack did not compile the edit of ${Object.keys(files).join(', ')}`, + }) + // Until the page shows the edit, with nothing in flight + await waitForOutcome({ + timeout: Math.max(0, deadline - Date.now()), + failWhenQuietFor: editQuietFailure, + problems: () => compileErrors, + applied: async () => (await text()).includes(expected), + quiet: () => webpackQuiet() && requests() === 0, + describe: async () => + [ + `the page shows: ${JSON.stringify(await text())}`, + `expected: ${expected}`, + `page loads: ${page.loads()}`, + `console:\n${page.console.join('\n') || '(none)'}`, + ].join('\n'), + }) + return { + reloaded: page.loads() > start.loads, + errors: page.errors.slice(start.errors), + } + }, + } +} diff --git a/packages/router-plugin/vite.config.ts b/packages/router-plugin/vite.config.ts index e80f073d21..d55249a567 100644 --- a/packages/router-plugin/vite.config.ts +++ b/packages/router-plugin/vite.config.ts @@ -1,13 +1,98 @@ -import { defineConfig, mergeConfig } from 'vitest/config' +import path from 'node:path' +import os from 'node:os' +import { configDefaults, defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/vite-config' import packageJson from './package.json' +// Under Vitest: Node's compile cache for the test workers and the child +// Node runs they start (the harness passes this environment on). No outcome +// change; less time compiling the bundlers and the built apps again. +if (process.env.VITEST) { + process.env.NODE_COMPILE_CACHE ??= path.join( + os.tmpdir(), + 'node-compile-cache', + ) +} + +/** + * The projects whose tests check route apps in pages of a real browser + * (`tests/route-app.ts`): the tests of a file run concurrently, each on dev + * servers it holds alone (a test leases a host of the test process; a + * concurrent test of the same configuration gets another one) and on pages + * of the process's bounded page pool (`@tanstack/compiler-test-utils/ + * browser`). A test process keeps its browser and its free hosts across + * test files (`isolate: false`): a file starts only the hosts no earlier + * file left free. Both are bounded (Chromium's shared memory limits how + * many pages can be open at once). + */ +const pagesProject = { + extends: true, + test: { + sequence: { concurrent: true }, + isolate: false, + // Client checks run in a real browser page: the first run on a new dev + // server (dependency pre-bundling) takes seconds under load + testTimeout: 30_000, + }, +} as const + const config = defineConfig({ test: { name: packageJson.name, dir: './tests', watch: false, - typecheck: { enabled: true }, + // At most 4 test processes per Vitest run: each + // runs real bundlers, dev servers and its own browser, and Nx runs several + // packages' tiers at once. More workers add swap and load flakes, not + // speed. `--maxWorkers` on the command line still overrides it. + maxWorkers: 4, + reporters: ['default', '@tanstack/compiler-test-utils/budget-reporter'], + globalSetup: ['@tanstack/compiler-test-utils/run-directory'], + setupFiles: [ + '@tanstack/compiler-test-utils/test-scope-setup', + '@tanstack/compiler-test-utils/pins-setup', + ], + projects: [ + { + // Fast tier (`test:unit`): compiles in process; client checks run in + // pages of a real browser (see `pagesProject`). + ...pagesProject, + test: { + ...pagesProject.test, + name: 'unit', + exclude: [...configDefaults.exclude, 'integration/**'], + typecheck: { enabled: true }, + }, + }, + { + // Slow tier (`test:integration`): real builds, Rsbuild dev servers, + // child Node runs and browsers. + extends: true, + test: { + name: 'integration', + // A test process keeps its modules (and its browser) across test + // files; the setup file gives each file the environment it + // started with (see `test-scope-setup`) + isolate: false, + include: ['integration/**/*.test.ts'], + exclude: [...configDefaults.exclude, 'integration/pages/**'], + testTimeout: 30_000, + hookTimeout: 30_000, + }, + }, + { + // Slow tier too (`test:integration` runs both projects): route apps + // checked in pages of a real browser (`route-app.ts`), as the fast + // tier checks them, whose cost does not fit the fast tier's budget. + ...pagesProject, + test: { + ...pagesProject.test, + name: 'integration-pages', + include: ['integration/pages/**/*.test.ts'], + hookTimeout: 30_000, + }, + }, + ], }, }) diff --git a/packages/router-ssr-query-core/AGENTS.md b/packages/router-ssr-query-core/AGENTS.md index 76d3fe022f..a1799ae8f3 100644 --- a/packages/router-ssr-query-core/AGENTS.md +++ b/packages/router-ssr-query-core/AGENTS.md @@ -5,5 +5,5 @@ Register QueryClient teardown at SSR attachment, before loading/dehydration can For query retention or cleanup changes, enable the GC tests that normal unit runs skip. `RUN_SSR_GC_TESTS=1` configures forked workers with exposed GC. Bypass Nx cache so a previous run with the gate disabled cannot count as validation. ```sh -RUN_SSR_GC_TESTS=1 CI=1 NX_DAEMON=false pnpm nx run-many -p @tanstack/router-ssr-query-core -t test:unit --skipRemoteCache --skipNxCache -- tests/index.test.ts +RUN_SSR_GC_TESTS=1 CI=1 NX_DAEMON=false pnpm nx run @tanstack/router-ssr-query-core:test:unit --outputStyle=stream --skipRemoteCache --skipNxCache -- tests/index.test.ts ``` diff --git a/packages/router-utils/CHANGELOG.md b/packages/router-utils/CHANGELOG.md index 55ce3a571b..a7f04c5808 100644 --- a/packages/router-utils/CHANGELOG.md +++ b/packages/router-utils/CHANGELOG.md @@ -1,15 +1,5 @@ # @tanstack/router-utils -## 1.163.0 - -### Minor Changes - -- [#8855](https://github.com/TanStack/router/pull/8855) [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6) - Require Node `^20.19.0 || >=22.12.0` (was `>=20.19`), so the CommonJS builds can load ESM-only dependencies through `require(esm)`. Node 21 and Node 22.0–22.11 do not enable it by default, so they are no longer supported. - -### Patch Changes - -- [#8867](https://github.com/TanStack/router/pull/8867) [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69) - Parse decorators placed after `export` (`export @dec class Store {}`). A route file with one is now read by the route generator and split, instead of logging a parse error, leaving the route tree unwritten and the route unsplit. Start's compilers, which share the parser, accept it too. - ## 1.162.4 ### Patch Changes diff --git a/packages/router-utils/package.json b/packages/router-utils/package.json index 0ce243718f..a84002ef0d 100644 --- a/packages/router-utils/package.json +++ b/packages/router-utils/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-utils", - "version": "1.163.0", + "version": "1.162.4", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -33,7 +33,6 @@ "test:types:ts59": "node ../../node_modules/typescript59/lib/tsc.js", "test:types:ts60": "tsc6", "test:types:ts70": "tsc", - "test:unit": "vitest", "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", "build": "vite build" }, @@ -60,7 +59,7 @@ "src" ], "engines": { - "node": "^20.19.0 || >=22.12.0" + "node": ">=20.19" }, "dependencies": { "@babel/generator": "^7.29.8", @@ -77,7 +76,6 @@ "vite": "*", "@types/node": ">=20", "@tanstack/vite-config": "catalog:", - "vitest": "catalog:", "@arethetypeswrong/cli": "catalog:", "publint": "catalog:", "rimraf": "catalog:" diff --git a/packages/router-utils/src/ast.ts b/packages/router-utils/src/ast.ts index 6448adcbad..ae270e5785 100644 --- a/packages/router-utils/src/ast.ts +++ b/packages/router-utils/src/ast.ts @@ -38,8 +38,12 @@ function getDefaultParserPluginsForFilename( 'typescript', 'explicitResourceManagement', 'importAttributes', + // Import assertions (`assert { type: 'json' }`) are the older syntax that + // import attributes (`with { type: 'json' }`) replaced. They are still + // parsed for older code; support can be dropped once nobody uses them + // anymore. 'deprecatedImportAssert', - 'decorators', + ['decorators', { decoratorsBeforeExport: true }], 'decoratorAutoAccessors', ] diff --git a/packages/router-utils/tests/compiler-helpers.test.ts b/packages/router-utils/tests/compiler-helpers.test.ts deleted file mode 100644 index 00b75d67e5..0000000000 --- a/packages/router-utils/tests/compiler-helpers.test.ts +++ /dev/null @@ -1,249 +0,0 @@ -import * as t from '@babel/types' -import { describe, expect, test } from 'vitest' -import { - buildDeclarationMap, - collectIdentifiersFromNode, - collectLocalBindingsFromStatement, - extractModuleInfoFromAst, -} from '../src/compiler-helpers' -import { parseAst } from '../src/ast' - -function getVariableInit(code: string) { - const ast = parseAst({ code, filename: 'test.tsx' }) - const declaration = ast.program.body.find((node) => - t.isVariableDeclaration(node), - ) as t.VariableDeclaration - return declaration.declarations[0]!.init! -} - -function collectSortedIdentifiers(node: t.Node) { - return [...collectIdentifiersFromNode(node)].sort() -} - -function collectSortedStatementBindings(code: string) { - const ast = parseAst({ code, filename: 'test.tsx' }) - const bindings = new Set<string>() - for (const statement of ast.program.body) { - collectLocalBindingsFromStatement(statement, bindings) - } - return [...bindings].sort() -} - -function collectSortedDeclarationMapEntries(code: string) { - const ast = parseAst({ code, filename: 'test.tsx' }) - return [...buildDeclarationMap(ast)] - .map(([name, node]): [string, string] => [name, node.type]) - .sort((left, right) => (left[0] < right[0] ? -1 : 1)) -} - -function collectModuleInfoSnapshot(code: string) { - const ast = parseAst({ code, filename: 'test.tsx' }) - const info = extractModuleInfoFromAst(ast) - return { - bindings: [...info.bindings] - .map(([name, binding]) => [ - name, - binding.type === 'import' - ? `${binding.source}:${binding.importedName}` - : (binding.init?.type ?? null), - ]) - .sort((left, right) => (left[0]! < right[0]! ? -1 : 1)), - exports: [...info.exports].sort((left, right) => - left[0] < right[0] ? -1 : 1, - ), - reExportAllSources: info.reExportAllSources, - } -} - -describe('collectIdentifiersFromNode', () => { - test('collects free identifiers without reporting nested local bindings', () => { - const init = getVariableInit(` -const value = outer + (() => { - const local = dep - - function nested(param = fallback) { - const Inner = () => <LocalComponent value={param} /> - const LocalExpr = class NamedLocal { - method() { - return NamedLocal + local + param - } - } - - class LocalComponent {} - - return local + param + imported + Inner + LocalExpr - } - - return nested() -})() -`) - - expect(collectSortedIdentifiers(init)).toMatchInlineSnapshot(` - [ - "dep", - "fallback", - "imported", - "outer", - ] - `) - }) - - test('respects nested variable, parameter, catch, and import shadowing', () => { - const ast = parseAst({ - code: ` -import { external as localImport } from 'pkg' - -const value = (localParam = defaultValue) => { - const localShadow = factory(localImport) - - try { - throw thrown - } catch (thrown) { - const factory = () => localShadow + localParam + thrown - return factory() - } -} -`, - filename: 'test.ts', - }) - - expect(collectSortedIdentifiers(ast.program)).toMatchInlineSnapshot(` - [ - "defaultValue", - "factory", - "thrown", - ] - `) - }) -}) - -describe('collectLocalBindingsFromStatement', () => { - test('collects ids from named default function and class declarations', () => { - expect({ - class: collectSortedStatementBindings( - `export default class DefaultComponent {}`, - ), - function: collectSortedStatementBindings( - `export default function DefaultRoute() {}`, - ), - anonymous: collectSortedStatementBindings( - `export default function () {}`, - ), - }).toMatchInlineSnapshot(` - { - "anonymous": [], - "class": [ - "DefaultComponent", - ], - "function": [ - "DefaultRoute", - ], - } - `) - }) -}) - -describe('buildDeclarationMap', () => { - test('maps named default function and class declarations', () => { - expect({ - class: collectSortedDeclarationMapEntries( - `export default class DefaultComponent {}`, - ), - function: collectSortedDeclarationMapEntries( - `export default function DefaultRoute() {}`, - ), - anonymous: collectSortedDeclarationMapEntries(`export default class {}`), - }).toMatchInlineSnapshot(` - { - "anonymous": [], - "class": [ - [ - "DefaultComponent", - "ClassDeclaration", - ], - ], - "function": [ - [ - "DefaultRoute", - "FunctionDeclaration", - ], - ], - } - `) - }) -}) - -describe('extractModuleInfoFromAst', () => { - test('extracts imports, local exports, default exports, and re-export sources', () => { - expect( - collectModuleInfoSnapshot(` - import defaultImport, { named as localNamed } from 'pkg' - import * as ns from 'pkg-ns' - const local = localNamed - export const exported = local - export function loader() {} - export default class DefaultRoute {} - export { remote as renamed } from './remote' - export * from './all' - `), - ).toMatchInlineSnapshot(` - { - "bindings": [ - [ - "DefaultRoute", - null, - ], - [ - "defaultImport", - "pkg:default", - ], - [ - "exported", - "Identifier", - ], - [ - "loader", - null, - ], - [ - "local", - "Identifier", - ], - [ - "localNamed", - "pkg:named", - ], - [ - "ns", - "pkg-ns:*", - ], - [ - "remote", - "./remote:remote", - ], - ], - "exports": [ - [ - "default", - "DefaultRoute", - ], - [ - "exported", - "exported", - ], - [ - "loader", - "loader", - ], - [ - "renamed", - "remote", - ], - ], - "reExportAllSources": [ - "./all", - ], - } - `) - }) -}) diff --git a/packages/router-utils/tests/stripTypeExports.test.ts b/packages/router-utils/tests/stripTypeExports.test.ts deleted file mode 100644 index 32d25f1cbe..0000000000 --- a/packages/router-utils/tests/stripTypeExports.test.ts +++ /dev/null @@ -1,277 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { generateFromAst, parseAst, stripTypeExports } from '../src/ast' - -function transform(code: string): string { - const ast = parseAst({ code }) - stripTypeExports(ast) - return generateFromAst(ast, { - sourceFileName: 'test.ts', - filename: 'test.ts', - }).code -} - -describe('stripTypeExports', () => { - describe('import attributes parsing', () => { - test('parses import attributes with with syntax', () => { - const code = `import data from './data.json' with { type: 'json' } -export const value = data` - - expect(() => parseAst({ code })).not.toThrow() - }) - - test('parses import attributes with deprecated assert syntax', () => { - const code = `import data from './data.json' assert { type: 'json' } -export const value = data` - - expect(() => parseAst({ code })).not.toThrow() - }) - - test('parses angle-bracket type assertions in .ts files without JSX', () => { - const code = `export function cast<T>(value: any): T { - return <T>value -}` - - expect(() => parseAst({ code, filename: 'cast.ts' })).not.toThrow() - }) - }) - - describe('type alias declarations', () => { - test('preserves top-level type alias declaration (non-exported)', () => { - const code = `type Foo = string; -const value = 1;` - const result = transform(code) - expect(result).toContain('type Foo = string') - expect(result).toContain('const value = 1') - }) - - test('removes export type alias declaration', () => { - const code = `export type Foo = string; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('type Foo') - expect(result).toContain('export const value = 1') - }) - }) - - describe('interface declarations', () => { - test('preserves top-level interface declaration (non-exported)', () => { - const code = `interface Bar { x: number } -const value = 1;` - const result = transform(code) - expect(result).toContain('interface Bar') - expect(result).toContain('const value = 1') - }) - - test('removes export interface declaration', () => { - const code = `export interface Bar { x: number } -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('interface Bar') - expect(result).toContain('export const value = 1') - }) - }) - - describe('type re-exports', () => { - test('removes export type { X } from syntax', () => { - const code = `export type { Foo } from './other'; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('Foo') - expect(result).not.toContain('./other') - expect(result).toContain('export const value = 1') - }) - - test('removes export type { X as Y } from syntax', () => { - const code = `export type { Foo as Bar } from './other'; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('Foo') - expect(result).not.toContain('Bar') - expect(result).toContain('export const value = 1') - }) - - test('removes export type * from syntax', () => { - const code = `export type * from './types'; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('./types') - expect(result).toContain('export const value = 1') - }) - - test('removes export type * as namespace from syntax', () => { - const code = `export type * as Types from './types'; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('Types') - expect(result).not.toContain('./types') - expect(result).toContain('export const value = 1') - }) - - test('preserves regular export * from syntax', () => { - const code = `export * from './other'; -export const value = 1;` - const result = transform(code) - expect(result).toContain("export * from './other'") - expect(result).toContain('export const value = 1') - }) - }) - - describe('mixed exports with type specifiers', () => { - test('removes type specifiers from mixed export', () => { - const code = `const value = 1; -type TypeOnly = string; -export { value, type TypeOnly };` - const result = transform(code) - expect(result).toContain('export { value }') - expect(result).toContain('type TypeOnly = string') - }) - - test('removes entire export if all specifiers are type-only', () => { - const code = `type Foo = string; -type Bar = number; -export { type Foo, type Bar }; -export const value = 1;` - const result = transform(code) - expect(result).not.toContain('export { type Foo') - expect(result).toContain('type Foo = string') - expect(result).toContain('type Bar = number') - expect(result).toContain('export const value = 1') - }) - }) - - describe('type-only imports', () => { - test('removes import type declaration', () => { - const code = `import type { Foo } from './module'; -import { value } from './other';` - const result = transform(code) - expect(result).not.toContain('Foo') - expect(result).not.toContain('./module') - expect(result).toContain("import { value } from './other'") - }) - - test('removes import type * as namespace', () => { - const code = `import type * as Types from './module'; -import { value } from './other';` - const result = transform(code) - expect(result).not.toContain('Types') - expect(result).not.toContain('./module') - expect(result).toContain("import { value } from './other'") - }) - }) - - describe('mixed imports with type specifiers', () => { - test('removes type specifiers from mixed import', () => { - const code = `import { value, type TypeOnly } from './module';` - const result = transform(code) - expect(result).toContain("import { value } from './module'") - expect(result).not.toContain('TypeOnly') - }) - - test('removes entire import if all specifiers are type-only', () => { - const code = `import { type Foo, type Bar } from './module'; -import { value } from './other';` - const result = transform(code) - expect(result).not.toContain('./module') - expect(result).not.toContain('Foo') - expect(result).not.toContain('Bar') - expect(result).toContain("import { value } from './other'") - }) - }) - - describe('preserves non-type code', () => { - test('preserves regular exports', () => { - const code = `export const value = 1; -export function foo() { return 2; } -export class MyClass {}` - const result = transform(code) - expect(result).toContain('export const value = 1') - expect(result).toContain('export function foo()') - expect(result).toContain('export class MyClass') - }) - - test('preserves regular imports', () => { - const code = `import { foo, bar } from './module'; -import defaultExport from './other'; -import * as namespace from './third';` - const result = transform(code) - expect(result).toContain("import { foo, bar } from './module'") - expect(result).toContain("import defaultExport from './other'") - expect(result).toContain("import * as namespace from './third'") - }) - - test('preserves export with declaration', () => { - const code = `export const x = 1; -export function fn() {} -export class C {}` - const result = transform(code) - expect(result).toContain('export const x = 1') - expect(result).toContain('export function fn()') - expect(result).toContain('export class C') - }) - }) - - describe('complex scenarios', () => { - test('handles file with mixed type and value exports', () => { - const code = `import { z } from 'zod'; -import type { SomeType } from './types'; -import { helper, type HelperType } from './helpers'; - -type LocalType = string; -interface LocalInterface { x: number } - -export type ExportedType = z.infer<typeof schema>; -export interface ExportedInterface { y: string } - -const schema = z.object({ name: z.string() }); -export const myValue = 1; -export { helper, type HelperType };` - - const result = transform(code) - - // Should remove type imports - expect(result).not.toContain('SomeType') - expect(result).not.toContain('./types') - expect(result).not.toContain('HelperType') - - // Should preserve local type declarations - expect(result).toContain('type LocalType = string') - expect(result).toContain('interface LocalInterface') - - // Should remove exported type declarations - expect(result).not.toContain('type ExportedType') - expect(result).not.toContain('interface ExportedInterface') - - // Should preserve value imports and exports - expect(result).toContain("import { z } from 'zod'") - expect(result).toContain("import { helper } from './helpers'") - expect(result).toContain('export const myValue = 1') - expect(result).toContain('export { helper }') - }) - - test('handles the issue #6480 scenario - type export referencing imported enum', () => { - // This simulates the problematic case from the issue: - // export type CreatePostInput = z.infer<typeof postSchema>; - // where postSchema uses an imported enum - const code = `import { z } from 'zod'; -import { PostCategory } from './PostService'; - -const postSchema = z.object({ - category: z.nativeEnum(PostCategory) -}); - -export type CreatePostInput = z.infer<typeof postSchema>; - -export const serverFn = () => {};` - - const result = transform(code) - - // The type export should be removed - expect(result).not.toContain('export type CreatePostInput') - - // The value exports and imports should remain - expect(result).toContain("import { z } from 'zod'") - expect(result).toContain("import { PostCategory } from './PostService'") - expect(result).toContain('export const serverFn') - }) - }) -}) diff --git a/packages/router-utils/tsconfig.json b/packages/router-utils/tsconfig.json index 0506ca3d49..09d7037393 100644 --- a/packages/router-utils/tsconfig.json +++ b/packages/router-utils/tsconfig.json @@ -1,7 +1,6 @@ { "extends": "../../tsconfig.json", - "include": ["src", "vite.config.ts", "tests"], - "exclude": ["tests/generator/**/**"], + "include": ["src", "vite.config.ts"], "compilerOptions": { "types": ["node"] } diff --git a/packages/router-utils/vite.config.ts b/packages/router-utils/vite.config.ts index 5e305866b6..93a0007116 100644 --- a/packages/router-utils/vite.config.ts +++ b/packages/router-utils/vite.config.ts @@ -1,21 +1,7 @@ -import { defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/vite-config' -import packageJson from './package.json' -const config = defineConfig({ - test: { - name: packageJson.name, - dir: './tests', - watch: false, - typecheck: { enabled: true }, - }, +export default tanstackViteConfig({ + tsconfigPath: './tsconfig.build.json', + entry: './src/index.ts', + srcDir: './src', }) - -export default mergeConfig( - config, - tanstackViteConfig({ - tsconfigPath: './tsconfig.build.json', - entry: './src/index.ts', - srcDir: './src', - }), -) diff --git a/packages/router-vite-plugin/CHANGELOG.md b/packages/router-vite-plugin/CHANGELOG.md index 90d47e813e..86ba9885af 100644 --- a/packages/router-vite-plugin/CHANGELOG.md +++ b/packages/router-vite-plugin/CHANGELOG.md @@ -1,19 +1,5 @@ # @tanstack/router-vite-plugin -## 1.167.49 - -### Patch Changes - -- Updated dependencies [[`1ba19a0`](https://github.com/TanStack/router/commit/1ba19a04456983ee0f8adffd038b6b1194441e15), [`94f36c4`](https://github.com/TanStack/router/commit/94f36c4a9ecf3062b326a8eb772e73b00c0644d9), [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`533ca27`](https://github.com/TanStack/router/commit/533ca2704452f36c5fef5c5fe084554d9b5db1ab), [`13b6256`](https://github.com/TanStack/router/commit/13b625683030ea4ab359495ecda570e05e472587), [`b5e2ac9`](https://github.com/TanStack/router/commit/b5e2ac9c4cee4c5c6f464adc6cfddcddf6c84171), [`d250819`](https://github.com/TanStack/router/commit/d25081952dd04a5f5a44db7c8df5cbbf50fad054), [`f420d4a`](https://github.com/TanStack/router/commit/f420d4a6dacfaa81d306b7bbc9af8f1010d1a1bc)]: - - @tanstack/router-plugin@1.169.0 - -## 1.167.48 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`647cb73`](https://github.com/TanStack/router/commit/647cb737a5622813d276d6042766692ca5ae67ed)]: - - @tanstack/router-plugin@1.168.48 - ## 1.167.47 ### Patch Changes diff --git a/packages/router-vite-plugin/package.json b/packages/router-vite-plugin/package.json index 8e411904cb..0a89297ed6 100644 --- a/packages/router-vite-plugin/package.json +++ b/packages/router-vite-plugin/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/router-vite-plugin", - "version": "1.167.49", + "version": "1.167.47", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/solid-router-devtools/CHANGELOG.md b/packages/solid-router-devtools/CHANGELOG.md index 709d8cd23d..9684a0567d 100644 --- a/packages/solid-router-devtools/CHANGELOG.md +++ b/packages/solid-router-devtools/CHANGELOG.md @@ -1,12 +1,5 @@ # @tanstack/solid-router-devtools -## 1.167.3 - -### Patch Changes - -- Updated dependencies [[`bbf9b75`](https://github.com/TanStack/router/commit/bbf9b75808d8eee497a6dd1663f0cf08426512e0)]: - - @tanstack/router-devtools-core@1.168.3 - ## 1.167.2 ### Patch Changes diff --git a/packages/solid-router-devtools/package.json b/packages/solid-router-devtools/package.json index bcc006458f..80cdda7208 100644 --- a/packages/solid-router-devtools/package.json +++ b/packages/solid-router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-router-devtools", - "version": "1.167.3", + "version": "1.167.2", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/solid-router/CHANGELOG.md b/packages/solid-router/CHANGELOG.md index 3a40aa28c3..8c80a59d1c 100644 --- a/packages/solid-router/CHANGELOG.md +++ b/packages/solid-router/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/solid-router -## 1.170.43 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - ## 1.170.42 ### Patch Changes diff --git a/packages/solid-router/package.json b/packages/solid-router/package.json index 80840069ea..b14e9aa0af 100644 --- a/packages/solid-router/package.json +++ b/packages/solid-router/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-router", - "version": "1.170.43", + "version": "1.170.42", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/solid-start-client/CHANGELOG.md b/packages/solid-start-client/CHANGELOG.md index 9f5223d04d..3478a0c505 100644 --- a/packages/solid-start-client/CHANGELOG.md +++ b/packages/solid-start-client/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/solid-start-client -## 1.168.42 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/solid-router@1.170.43 - - @tanstack/start-client-core@1.170.39 - ## 1.168.41 ### Patch Changes diff --git a/packages/solid-start-client/package.json b/packages/solid-start-client/package.json index 3e30225764..c5ba81821c 100644 --- a/packages/solid-start-client/package.json +++ b/packages/solid-start-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-start-client", - "version": "1.168.42", + "version": "1.168.41", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/solid-start-server/CHANGELOG.md b/packages/solid-start-server/CHANGELOG.md index a1a8b33dad..6d65251bb7 100644 --- a/packages/solid-start-server/CHANGELOG.md +++ b/packages/solid-start-server/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/solid-start-server -## 1.167.50 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/solid-router@1.170.43 - - @tanstack/start-server-core@1.169.45 - ## 1.167.49 ### Patch Changes diff --git a/packages/solid-start-server/package.json b/packages/solid-start-server/package.json index a87cad7b94..17c98c42d8 100644 --- a/packages/solid-start-server/package.json +++ b/packages/solid-start-server/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-start-server", - "version": "1.167.50", + "version": "1.167.49", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/solid-start/CHANGELOG.md b/packages/solid-start/CHANGELOG.md index 4de784d03c..fb2c5e8449 100644 --- a/packages/solid-start/CHANGELOG.md +++ b/packages/solid-start/CHANGELOG.md @@ -1,35 +1,5 @@ # @tanstack/solid-start -## 1.169.6 - -### Patch Changes - -- Updated dependencies [[`3f22686`](https://github.com/TanStack/router/commit/3f226869e0af211ff7f1de5d7343e43462dbb101), [`559c7de`](https://github.com/TanStack/router/commit/559c7ded6e2a6eeda3f91c80d8c03f4cfeb9a206)]: - - @tanstack/start-plugin-core@1.171.57 - -## 1.169.5 - -### Patch Changes - -- [#8863](https://github.com/TanStack/router/pull/8863) [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c) - The Rsbuild plugin keeps the app's `server.compress` setting instead of always setting it to `false`. Compression stays off by default: a compressed streamed page reaches the browser only once the stream ends. The optional `@rsbuild/core` peer is now `^2.0.5`, the first version whose compression keeps SSR response headers intact. - -- Updated dependencies [[`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c), [`c5320d7`](https://github.com/TanStack/router/commit/c5320d7ca23eca82d720ac5629d2bad5cf7d9b02), [`545a8d3`](https://github.com/TanStack/router/commit/545a8d3790989ca502153c3292c6b1e8063257f4), [`da8c28c`](https://github.com/TanStack/router/commit/da8c28c498230a5730ce75b2693baeeb3ef68ac1)]: - - @tanstack/start-plugin-core@1.171.56 - -## 1.169.4 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`ed55775`](https://github.com/TanStack/router/commit/ed5577593a749b8c7193cc7b5d945fd084bfac2f), [`63a886d`](https://github.com/TanStack/router/commit/63a886da9040c4b039ea3bf5b3a841771375cddb), [`d9b07e8`](https://github.com/TanStack/router/commit/d9b07e8d3b724cdbfac0aa2fba4c1f7a3a241100)]: - - @tanstack/solid-router@1.170.43 - - @tanstack/start-client-core@1.170.39 - - @tanstack/start-server-core@1.169.45 - - @tanstack/start-plugin-core@1.171.55 - - @tanstack/solid-start-client@1.168.42 - - @tanstack/solid-start-server@1.167.50 - ## 1.169.3 ### Patch Changes diff --git a/packages/solid-start/package.json b/packages/solid-start/package.json index 2f378426cc..c96c97ea69 100644 --- a/packages/solid-start/package.json +++ b/packages/solid-start/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/solid-start", - "version": "1.169.6", + "version": "1.169.3", "description": "Modern and scalable routing for Solid applications", "author": "Tanner Linsley", "license": "MIT", @@ -142,7 +142,7 @@ "rimraf": "catalog:" }, "peerDependencies": { - "@rsbuild/core": "^2.0.5", + "@rsbuild/core": "^2.0.0", "solid-js": ">=1.0.0", "vite": ">=8.0.0" }, diff --git a/packages/start-client-core/CHANGELOG.md b/packages/start-client-core/CHANGELOG.md index 521960c1ac..c5f24720de 100644 --- a/packages/start-client-core/CHANGELOG.md +++ b/packages/start-client-core/CHANGELOG.md @@ -1,15 +1,5 @@ # @tanstack/start-client-core -## 1.170.39 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/start-storage-context@1.167.41 - ## 1.170.38 ### Patch Changes diff --git a/packages/start-client-core/package.json b/packages/start-client-core/package.json index c74dce13aa..0818f22705 100644 --- a/packages/start-client-core/package.json +++ b/packages/start-client-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/start-client-core", - "version": "1.170.39", + "version": "1.170.38", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/start-plugin-core/AGENTS.md b/packages/start-plugin-core/AGENTS.md index cd73bbf307..d229dec71a 100644 --- a/packages/start-plugin-core/AGENTS.md +++ b/packages/start-plugin-core/AGENTS.md @@ -4,4 +4,8 @@ - For import-protection changes, read the [shared internals](src/import-protection/INTERNALS.md) and [Vite lifecycle](src/vite/import-protection-plugin/INTERNALS.md). Preserve adapter-specific deferral and survival checks; development has no build-time tree-shaking, and Vite's error/mock modes differ. Cover actual leaks and safe boundaries in cold/warm development and builds. - Compiler output must match runtime contracts in `start-client-core`, `start-fn-stubs`, and `start-server-core`. For `createServerFn`, cover client, SSR caller, and server-provider output separately in [`tests/createServerFn/createServerFn.test.ts`](tests/createServerFn/createServerFn.test.ts). - Use a built Start e2e app to validate generated imports and runtime behavior together; compiler snapshots alone do not exercise that integration. -- The shared compiler serves both Vite and Rsbuild. For shared compiler changes, check the relevant adapter suites in `tests/vite/` and `tests/rsbuild/`, plus affected Start e2e modes for build, server-function, or HMR behavior. +- The shared compiler serves both Vite and Rsbuild. For shared compiler changes, check the relevant adapter suites in `tests/integration/rsbuild/` and the Vite and Rsbuild rows of the compiler tests, plus affected Start e2e modes for build, server-function, or HMR behavior. +- Tests run in two tiers. `test:unit` (fast tier, the inner loop) runs `tests/**` in process and depends on `^build` only. `test:integration` (slow tier) runs `tests/integration/**`: every test that starts a real build (`buildStart`), a dev server that links the built `@tanstack/react-start` (`startDevServer`, `startProtectedDevServer`, `linkStartRuntime`), an Rsbuild dev server, a child Node process or a browser page; its Nx target builds `@tanstack/react-start` first. Put such tests under `tests/integration/`; a file with tests of both kinds is split by test into files of the same name in both directories. Run both tiers before handing back. +- To run one test file or `-t` filter quickly, the slow-tier load gate and the test budgets: [compiler-test-utils/AGENTS.md](../compiler-test-utils/AGENTS.md). +- What these tests are, the spec they cite (`J4.12`, `G3`, `§5.7`) and the known bugs: [compiler-test-utils/oracle/README.md](../compiler-test-utils/oracle/README.md). +- `test:noncompiler` runs main's tests of features that are not compilers (manifest, sitemap, prerender, schema, entries, build output, dev styles), at main's paths and unchanged from main, listed in `tests/noncompiler-tests.json`; the compiler test projects and ESLint leave them out. Root PR/CI and the compiler platform jobs run it. Run it before handing back. diff --git a/packages/start-plugin-core/CHANGELOG.md b/packages/start-plugin-core/CHANGELOG.md index 3d705069c1..4be7db2915 100644 --- a/packages/start-plugin-core/CHANGELOG.md +++ b/packages/start-plugin-core/CHANGELOG.md @@ -1,50 +1,5 @@ # @tanstack/start-plugin-core -## 1.171.57 - -### Patch Changes - -- [#8889](https://github.com/TanStack/router/pull/8889) [`3f22686`](https://github.com/TanStack/router/commit/3f226869e0af211ff7f1de5d7343e43462dbb101) - fix: Rsbuild dev SSR now includes stylesheet links when the server environment runs outside the build process, such as in workerd with `rsbuild-plugin-cloudflare`. The dev manifest is written into the server's manifest module instead of being stored on the build process's `globalThis`. - -- [#8892](https://github.com/TanStack/router/pull/8892) [`559c7de`](https://github.com/TanStack/router/commit/559c7ded6e2a6eeda3f91c80d8c03f4cfeb9a206) - fix: Rsbuild dev with React Server Components includes stylesheet links in SSR again. The client and server compile concurrently, so the server's manifest module is now rebuilt once the client build is available, as in production builds. - -## 1.171.56 - -### Patch Changes - -- [#8863](https://github.com/TanStack/router/pull/8863) [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c) - The Rsbuild plugin keeps the app's `server.compress` setting instead of always setting it to `false`. Compression stays off by default: a compressed streamed page reaches the browser only once the stream ends. The optional `@rsbuild/core` peer is now `^2.0.5`, the first version whose compression keeps SSR response headers intact. - -- [#8805](https://github.com/TanStack/router/pull/8805) [`c5320d7`](https://github.com/TanStack/router/commit/c5320d7ca23eca82d720ac5629d2bad5cf7d9b02) - With `spa.enabled`, the Rsbuild dev server answers the SPA shell, as Vite's dev server does, instead of rendering the route and running its loaders on the server. - -- [#8871](https://github.com/TanStack/router/pull/8871) [`545a8d3`](https://github.com/TanStack/router/commit/545a8d3790989ca502153c3292c6b1e8063257f4) - Require `exsolve` `^1.1.3`: a failed lookup that exsolve caches no longer keeps its callers alive, so Start's cached failed lookups no longer hold on to each build's objects. Entry lookups bypass exsolve's process-wide cache, so a dev server restart finds an entry file (such as `src/start.ts`) created since. - -- [#8861](https://github.com/TanStack/router/pull/8861) [`da8c28c`](https://github.com/TanStack/router/commit/da8c28c498230a5730ce75b2693baeeb3ef68ac1) - Start's router options now reach the route generator and the code splitter as they do in a router app: - - Generator plugins given as `router.plugins` run ([#7768](https://github.com/TanStack/router/issues/7768)). Start's own generator plugins used to replace them. - - A function-form `router.routeTreeFileFooter` is called at every print of the route tree. Start's Vite plugin used to print its first result for the whole dev server. - - Start's Rsbuild plugin keeps `router.codeSplittingOptions.deleteNodes` for the server build. It used to drop the option there. - - Start's Vite plugin finds the client route tree by its exact module id ([#8839](https://github.com/TanStack/router/issues/8839)). With a regular-expression character in the project path, such as `+`, the client used to get the full route tree, server-only routes included; a file whose name differed from the route tree's by one character (`routeTree-gen.ts`) was replaced by the client route tree. - -- Updated dependencies [[`1ba19a0`](https://github.com/TanStack/router/commit/1ba19a04456983ee0f8adffd038b6b1194441e15), [`94f36c4`](https://github.com/TanStack/router/commit/94f36c4a9ecf3062b326a8eb772e73b00c0644d9), [`446ce1b`](https://github.com/TanStack/router/commit/446ce1b30650d85f1fc78f2d1ee42712e40b75c6), [`ad5b3b7`](https://github.com/TanStack/router/commit/ad5b3b7a0990eed7351d672ea6695d341108e0d6), [`533ca27`](https://github.com/TanStack/router/commit/533ca2704452f36c5fef5c5fe084554d9b5db1ab), [`13b6256`](https://github.com/TanStack/router/commit/13b625683030ea4ab359495ecda570e05e472587), [`b5e2ac9`](https://github.com/TanStack/router/commit/b5e2ac9c4cee4c5c6f464adc6cfddcddf6c84171), [`d250819`](https://github.com/TanStack/router/commit/d25081952dd04a5f5a44db7c8df5cbbf50fad054), [`f420d4a`](https://github.com/TanStack/router/commit/f420d4a6dacfaa81d306b7bbc9af8f1010d1a1bc), [`ff157f0`](https://github.com/TanStack/router/commit/ff157f0079982e90d62be7fdeecfb77e4fdcec69)]: - - @tanstack/router-plugin@1.169.0 - - @tanstack/router-generator@1.168.0 - - @tanstack/router-utils@1.163.0 - -## 1.171.55 - -### Patch Changes - -- [#8748](https://github.com/TanStack/router/pull/8748) [`ed55775`](https://github.com/TanStack/router/commit/ed5577593a749b8c7193cc7b5d945fd084bfac2f) - Skip the Rsbuild import-protection loader and its plugins when import protection is disabled, so modules no longer pass through the loader. - -- [#8750](https://github.com/TanStack/router/pull/8750) [`63a886d`](https://github.com/TanStack/router/commit/63a886da9040c4b039ea3bf5b3a841771375cddb) - Skip the server function resolver rebuild in Rsbuild dev when the resolver has not changed, so most edits no longer rebuild the whole server chunk graph. - -- [#8758](https://github.com/TanStack/router/pull/8758) [`d9b07e8`](https://github.com/TanStack/router/commit/d9b07e8d3b724cdbfac0aa2fba4c1f7a3a241100) - Stop resolving top-level calls such as `z.object()` whose receiver is not a namespace import. They can never be a `createServerOnlyFn` or `createClientOnlyFn` call, and resolving them made the dev compiler load and parse the receiver's module (all of zod, for example). - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`647cb73`](https://github.com/TanStack/router/commit/647cb737a5622813d276d6042766692ca5ae67ed)]: - - @tanstack/router-core@1.171.39 - - @tanstack/router-plugin@1.168.48 - - @tanstack/start-server-core@1.169.45 - - @tanstack/router-generator@1.167.46 - ## 1.171.54 ### Patch Changes diff --git a/packages/start-plugin-core/eslint.config.js b/packages/start-plugin-core/eslint.config.js index 8ce6ad05fc..8cd5b8bfdb 100644 --- a/packages/start-plugin-core/eslint.config.js +++ b/packages/start-plugin-core/eslint.config.js @@ -1,5 +1,13 @@ // @ts-check import rootConfig from '../../eslint.config.js' +import noncompilerTests from './tests/noncompiler-tests.json' with { type: 'json' } -export default [...rootConfig] +export default [ + ...rootConfig, + { + // Main's tests of features that are not compilers, unchanged from main, + // which does not lint its tests (`test:noncompiler` runs them). + ignores: noncompilerTests.map((file) => `tests/${file}`), + }, +] diff --git a/packages/start-plugin-core/package.json b/packages/start-plugin-core/package.json index 1945ab7ba6..d50539caa6 100644 --- a/packages/start-plugin-core/package.json +++ b/packages/start-plugin-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/start-plugin-core", - "version": "1.171.57", + "version": "1.171.54", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", @@ -27,10 +27,11 @@ "scripts": { "clean": "rimraf ./dist && rimraf ./coverage", "clean:snapshots": "rimraf **/*snapshot* --glob", - "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit && pnpm test:integration", + "test": "pnpm test:eslint && pnpm test:types && pnpm test:build && pnpm test:unit && pnpm test:integration && pnpm test:noncompiler", "test:unit": "vitest --project unit", - "test:integration": "vitest --project integration", - "test:eslint": "eslint ./src", + "test:integration": "vitest --project integration --project integration-pages", + "test:integration:smoke": "vitest --project integration integration/importProtection/build.test.ts -t \"build.*a denied re-export barrel the client uses fails the build\"", + "test:eslint": "eslint ./src ./tests", "test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"", "test:types:ts56": "node ../../node_modules/typescript56/lib/tsc.js", "test:types:ts57": "node ../../node_modules/typescript57/lib/tsc.js", @@ -39,26 +40,47 @@ "test:types:ts60": "tsc6", "test:types:ts70": "tsc", "test:build": "publint --strict && attw --ignore-rules no-resolution --pack .", - "build": "vite build" + "build": "vite build", + "test:noncompiler": "vitest --project noncompiler" }, "nx": { "targets": { + "test:unit": { + "dependsOn": [ + "^build", + { + "projects": [ + "@tanstack/react-start", + "@tanstack/solid-start", + "@tanstack/vue-start" + ], + "target": "build" + } + ] + }, "test:integration": { - "cache": true, "dependsOn": [ "^build", "build", + { + "projects": [ + "@tanstack/react-start", + "@tanstack/solid-start", + "@tanstack/vue-start" + ], + "target": "build" + } + ] + }, + "test:integration:smoke": { + "dependsOn": [ + "^build", { "projects": [ "@tanstack/react-start" ], "target": "build" } - ], - "inputs": [ - "default", - "^production", - "dependentTaskOutputs" ] } } @@ -131,21 +153,36 @@ "zod": "catalog:" }, "devDependencies": { + "@mdx-js/loader": "^3.1.1", + "@mdx-js/rollup": "^3.1.1", "@rsbuild/core": "catalog:", + "@rsbuild/plugin-babel": "^1.1.2", + "@rsbuild/plugin-react": "^2.0.0", + "@rsbuild/plugin-solid": "^1.2.2", "@types/babel__code-frame": "^7.0.6", "@types/babel__core": "^7.20.5", "@types/node": ">=20", "@types/picomatch": "^4.0.2", - "prettier": "^3.9.6", + "miniflare": "4.20260317.0", "vite": "*", + "vite-plugin-solid": "catalog:", + "@tanstack/compiler-test-utils": "workspace:*", + "@tanstack/react-router": "workspace:*", "@tanstack/vite-config": "catalog:", + "@vitejs/plugin-react": "catalog:", + "@vitejs/plugin-vue": "^6.0.5", + "@vitejs/plugin-vue-jsx": "catalog:", + "react": "catalog:", + "react-dom": "catalog:", + "solid-js": "catalog:", + "vite-tsconfig-paths": "^6.1.1", "vitest": "catalog:", "@arethetypeswrong/cli": "catalog:", "publint": "catalog:", "rimraf": "catalog:" }, "peerDependencies": { - "@rsbuild/core": "^2.0.5", + "@rsbuild/core": "^2.0.0", "vite": ">=8.0.0" }, "peerDependenciesMeta": { diff --git a/packages/start-plugin-core/src/resolve-entries.ts b/packages/start-plugin-core/src/resolve-entries.ts index 23eb4c651c..dd28815fa0 100644 --- a/packages/start-plugin-core/src/resolve-entries.ts +++ b/packages/start-plugin-core/src/resolve-entries.ts @@ -13,10 +13,6 @@ function resolveModule(opts: ResolveModuleOptions): string | undefined { from: opts.from, extensions: ['.ts', '.js', '.mts', '.mjs', '.tsx', '.jsx'], try: true, - // exsolve's default cache is process-wide and keeps misses: a dev server - // restart would not see an entry created since. The plugin already - // resolves the entries once per instance. - cache: false, }) } diff --git a/packages/start-plugin-core/src/rsbuild/normalized-client-build.ts b/packages/start-plugin-core/src/rsbuild/normalized-client-build.ts index a7dae0c379..591d6b0113 100644 --- a/packages/start-plugin-core/src/rsbuild/normalized-client-build.ts +++ b/packages/start-plugin-core/src/rsbuild/normalized-client-build.ts @@ -219,7 +219,6 @@ function computeDynamicImports(chunk: RspackCompilationChunk): Array<string> { function computeStaticDependencyChunks( compilation: RspackCompilation, chunk: RspackCompilationChunk, - chunksOfModule: (module: RspackModule) => Array<RspackCompilationChunk>, ): Array<RspackCompilationChunk> { const importedChunks: Array<RspackCompilationChunk> = [] const seen = new Set<RspackCompilationChunk>([chunk]) @@ -231,56 +230,31 @@ function computeStaticDependencyChunks( // A shared chunk can belong to several route groups. Group membership // limits where dependencies can be loaded from; it does not establish // an import from the shared chunk back to every route in those groups. - // A chunk counts as available only when every group of this chunk (or - // one of its ancestors) has it: a module duplicated into each route's - // chunk is satisfied per group, by that group's own chunk, so neither - // route's chunk is a dependency of the shared chunk (#8780). - let availableChunks: Set<RspackCompilationChunk> | undefined - for (const group of chunk.groupsIterable) { - const groupChunks = new Set<RspackCompilationChunk>() - const ancestors = new Set([group]) - for (const ancestor of ancestors) { - for (const availableChunk of ancestor.chunks) { - groupChunks.add(availableChunk) - } - for (const parent of ancestor.getParents()) { - ancestors.add(parent) - } + const availableChunks = new Set<RspackCompilationChunk>() + const groups = new Set(chunk.groupsIterable) + for (const group of groups) { + for (const availableChunk of group.chunks) { + availableChunks.add(availableChunk) } - if (availableChunks === undefined) { - availableChunks = groupChunks - } else { - for (const availableChunk of availableChunks) { - if (!groupChunks.has(availableChunk)) { - availableChunks.delete(availableChunk) - } - } + for (const parent of group.getParents()) { + groups.add(parent) } } - availableChunks ??= new Set() - // Every connection to a module adds the same chunks, so a module counts - // once, from its first active connection (an inactive one adds nothing and - // leaves the module to a later active one). - const counted = new Set<RspackModule>() for (const module of modules) { for (const dependency of module.dependencies) { const connection = compilation.moduleGraph.getConnection(dependency) const importedModule = connection?.module - if ( - !connection || - !importedModule || - localModules.has(importedModule) || - counted.has(importedModule) - ) { + if (!connection || !importedModule || localModules.has(importedModule)) { continue } if (connection.getActiveState(runtime) === false) { continue } - counted.add(importedModule) - for (const importedChunk of chunksOfModule(importedModule)) { + for (const importedChunk of compilation.chunkGraph.getModuleChunksIterable( + importedModule, + )) { if (availableChunks.has(importedChunk) && !seen.has(importedChunk)) { seen.add(importedChunk) importedChunks.push(importedChunk) @@ -299,34 +273,17 @@ type GetStaticDependencyChunks = ( /** * Memoize static dependency resolution per chunk. Every chunk is resolved once * for its own `imports`, and CSS-only chunks are resolved again from each - * importer that reaches them. A module's chunks are read once, for every chunk - * that imports it. Both memos live as long as the resolver, which is created - * per normalized compilation. + * importer that reaches them. */ function createStaticDependencyChunkResolver( compilation: RspackCompilation, ): GetStaticDependencyChunks { const cache = new Map<RspackCompilationChunk, Array<RspackCompilationChunk>>() - const moduleChunks = new Map<RspackModule, Array<RspackCompilationChunk>>() - const chunksOfModule = (module: RspackModule) => { - let chunks = moduleChunks.get(module) - if (!chunks) { - chunks = Array.from( - compilation.chunkGraph.getModuleChunksIterable(module), - ) - moduleChunks.set(module, chunks) - } - return chunks - } return (chunk) => { let importedChunks = cache.get(chunk) if (!importedChunks) { - importedChunks = computeStaticDependencyChunks( - compilation, - chunk, - chunksOfModule, - ) + importedChunks = computeStaticDependencyChunks(compilation, chunk) cache.set(chunk, importedChunks) } return importedChunks diff --git a/packages/start-plugin-core/src/rsbuild/plugin.ts b/packages/start-plugin-core/src/rsbuild/plugin.ts index c4660728b4..5989580d69 100644 --- a/packages/start-plugin-core/src/rsbuild/plugin.ts +++ b/packages/start-plugin-core/src/rsbuild/plugin.ts @@ -1,5 +1,5 @@ import { existsSync, readdirSync, realpathSync, statSync } from 'node:fs' -import { dirname, isAbsolute, join, resolve } from 'node:path' +import { dirname, join, resolve } from 'node:path' import { fileURLToPath } from 'node:url' import { joinURL } from 'ufo' import { @@ -113,15 +113,10 @@ export function tanStackStartRsbuild( // 1. modifyRsbuildConfig — resolve config, set up environments // --------------------------------------------------------------- api.modifyRsbuildConfig((rsbuildConfig, { mergeRsbuildConfig }) => { - // Rsbuild passes `root` on as written; its resolved root (against its - // `cwd`) is `rootPath`. Canonical (no trailing separator), as the - // virtual modules' paths must match Rspack's module paths. - const root = resolve( - typeof rsbuildConfig.root === 'string' && - isAbsolute(rsbuildConfig.root) + const root = + typeof rsbuildConfig.root === 'string' ? rsbuildConfig.root - : api.context.rootPath, - ) + : process.cwd() const serverBase = rsbuildConfig.server?.base const assetPrefix = rsbuildConfig.output?.assetPrefix @@ -215,18 +210,6 @@ export function tanStackStartRsbuild( 'process.env.TSS_ROUTER_BASEPATH': JSON.stringify(routerBasepath), 'import.meta.env.TSS_ROUTER_BASEPATH': JSON.stringify(routerBasepath), - // In dev, SPA mode answers the shell (as Vite's dev server); - // a build leaves it to the prerendered shell (#8543) - ...(isDev - ? { - 'process.env.TSS_SHELL': JSON.stringify( - startConfig.spa?.enabled ? 'true' : 'false', - ), - 'import.meta.env.TSS_SHELL': JSON.stringify( - startConfig.spa?.enabled ? 'true' : 'false', - ), - } - : {}), 'process.env.TSS_DEV_SERVER': JSON.stringify( isDev ? 'true' : 'false', ), @@ -268,15 +251,9 @@ export function tanStackStartRsbuild( rsbuildConfig.server.printUrls === true ? { printUrls: ({ urls }: { urls: Array<string> }) => urls } : {}), - // Off unless the app turns it on (#8544): compressed SSR streams - // reach the browser only when they end (the SSR middleware's - // srvx response does not flush the compression middleware), and - // @rsbuild/core < 2.0.5 corrupted the SSR response headers. - // `rsbuildConfig` already holds Rsbuild's default (`true`), so - // read the app's own config. - ...(api.getRsbuildConfig('original').server?.compress === undefined - ? { compress: false } - : {}), + // Rsbuild compression currently treats Node's raw header array + // writeHead form as an object, which corrupts SSR response headers. + compress: false, // SSR apps render every route on the server — disable HTML // fallback so rsbuild doesn't intercept /_serverFn/ URLs. htmlFallback: false, @@ -344,7 +321,7 @@ export function tanStackStartRsbuild( // RSC runtime, RSC HMR // --------------------------------------------------------------- const virtualModuleState = registerVirtualModules(api, { - getRoot: () => resolvedStartConfig.root, + root: resolvedStartConfig.root || process.cwd(), getConfig, serverFnsById, providerEnvName: serverFnProviderEnv, @@ -403,9 +380,11 @@ export function tanStackStartRsbuild( // patching emitted server assets afterwards. // --------------------------------------------------------------- if (api.context.action !== 'dev') { - // (read when a module is transformed: the virtual paths need the resolved root) + const normalizedManifestPath = normalizePath( + virtualModuleState.manifestPath, + ) const matchesManifestPath = (id: string) => - normalizePath(id) === normalizePath(virtualModuleState.manifestPath) + normalizePath(id) === normalizedManifestPath api.transform( { @@ -581,50 +560,36 @@ export function tanStackStartRsbuild( }, }) - config.plugins.push({ - apply(compiler: RspackCompiler) { - // Dev manifest write count this compiler last rebuilt from. - let rebuiltAtWriteCount: number | undefined + if (api.context.action !== 'dev') { + config.plugins.push({ + apply(compiler: RspackCompiler) { + compiler.hooks.finishMake.tapPromise( + { + name: 'TanStackStartRscManifestRebuild', + // The native RSC ServerPlugin completes the client-entry + // handoff during its finishMake hook. Rebuild the manifest + // after that point so the transform hook can emit the final + // manifest source instead of the placeholder. + stage: 10, + }, + async (compilation: RspackCompilationExtended) => { + const clientBuild = getClientBuild() - compiler.hooks.finishMake.tapPromise( - { - name: 'TanStackStartRscManifestRebuild', - // The native RSC ServerPlugin completes the client-entry - // handoff during its finishMake hook. Rebuild the manifest - // after that point so it reflects the client build: the - // build transform emits the final source instead of the - // placeholder, and dev picks up a manifest written while - // this compilation was already running. - stage: 10, - }, - async (compilation: RspackCompilationExtended) => { - const clientBuild = getClientBuild() - - if (!clientBuild) { - return - } - - virtualModuleState.updateManifest(clientBuild) - - if (api.context.action === 'dev') { - // Only rebuild when the manifest changed: rebuilding an - // unchanged module can rebuild the whole chunk graph. - const writeCount = - virtualModuleState.getDevManifestWriteCount() - if (writeCount === rebuiltAtWriteCount) { + if (!clientBuild) { return } - rebuiltAtWriteCount = writeCount - } - await rebuildModulesContaining( - compilation, - virtualModuleState.manifestPath, - ) - }, - ) - }, - }) + virtualModuleState.updateManifest(clientBuild) + + await rebuildModulesContaining( + compilation, + virtualModuleState.manifestPath, + ) + }, + ) + }, + }) + } } if (isClientEnv) { diff --git a/packages/start-plugin-core/src/rsbuild/start-router-plugin.ts b/packages/start-plugin-core/src/rsbuild/start-router-plugin.ts index 7c3106be28..40dfb9e42a 100644 --- a/packages/start-plugin-core/src/rsbuild/start-router-plugin.ts +++ b/packages/start-plugin-core/src/rsbuild/start-router-plugin.ts @@ -1,9 +1,12 @@ +import path from 'pathe' import { createRouterPluginContext } from '@tanstack/router-plugin/context' import { TanStackRouterCodeSplitterRspack, TanStackRouterGeneratorRspack, } from '@tanstack/router-plugin/rspack' -import { startGeneratorConfig } from '../start-router-plugin/generator-config' +import { routesManifestPlugin } from '../start-router-plugin/generator-plugins/routes-manifest-plugin' +import { prerenderRoutesPlugin } from '../start-router-plugin/generator-plugins/prerender-routes-plugin' +import { buildRouteTreeFileFooterFromConfig } from '../start-router-plugin/route-tree-footer' import { RSBUILD_ENVIRONMENT_NAMES } from './planning' import type { RsbuildPluginAPI } from '@rsbuild/core' import type { GetConfigFn, TanStackStartCoreOptions } from '../types' @@ -35,11 +38,25 @@ export function registerRouterPlugins( // Generator only runs once — register for the client environment if (envName === RSBUILD_ENVIRONMENT_NAMES.client) { const generatorPlugin = TanStackRouterGeneratorRspack( - startGeneratorConfig({ - getConfig: opts.getConfig, - corePluginOpts: opts.corePluginOpts, - prerender: opts.startPluginOpts.prerender?.enabled === true, - }), + { + ...routerConfig, + target: opts.corePluginOpts.framework, + routeTreeFileFooter: () => { + return buildRouteTreeFileFooterFromConfig({ + generatedRouteTreePath: path.resolve( + routerConfig.generatedRouteTree, + ), + getConfig: opts.getConfig, + corePluginOpts: opts.corePluginOpts, + }) + }, + plugins: [ + routesManifestPlugin(), + ...(opts.startPluginOpts.prerender?.enabled === true + ? [prerenderRoutesPlugin()] + : []), + ], + }, routerPluginContext, ) utils.appendPlugins(generatorPlugin) @@ -56,9 +73,7 @@ export function registerRouterPlugins( target: opts.corePluginOpts.framework, codeSplittingOptions: { ...routerConfig.codeSplittingOptions, - deleteNodes: isClient - ? ['ssr', 'server', 'headers'] - : routerConfig.codeSplittingOptions?.deleteNodes, + deleteNodes: isClient ? ['ssr', 'server', 'headers'] : undefined, addHmr: isClient, }, }, diff --git a/packages/start-plugin-core/src/rsbuild/swc-rsc.ts b/packages/start-plugin-core/src/rsbuild/swc-rsc.ts index 534a7860bb..16e21145b5 100644 --- a/packages/start-plugin-core/src/rsbuild/swc-rsc.ts +++ b/packages/start-plugin-core/src/rsbuild/swc-rsc.ts @@ -3,7 +3,6 @@ import type { ModifyRspackConfigFn, Rspack } from '@rsbuild/core' type RspackConfig = Parameters<ModifyRspackConfigFn>[0] type RspackRule = Rspack.RuleSetRule -type Falsy = false | 0 | '' | null | undefined /** * Walk the rspack config's module.rules and inject @@ -28,12 +27,7 @@ export function enableSwcReactServerComponents( return [] } - const loaders = - typeof use === 'function' ? [] : Array.isArray(use) ? use : [use] - // Rspack allows falsy entries in `use` for conditionally disabled loaders. - return loaders.filter( - (loader): loader is Exclude<typeof loader, Falsy> => !!loader, - ) + return typeof use === 'function' ? [] : Array.isArray(use) ? use : [use] } const getLoaderPath = ( loader: ReturnType<typeof getRuleLoaders>[number], @@ -72,9 +66,7 @@ export function enableSwcReactServerComponents( } if (Array.isArray(use)) { - return use.map((loader) => - loader ? cloneLoader(loader) : loader, - ) as RspackRule['use'] + return use.map((loader) => cloneLoader(loader)) as RspackRule['use'] } return cloneLoader(use) as RspackRule['use'] diff --git a/packages/start-plugin-core/src/rsbuild/virtual-modules.ts b/packages/start-plugin-core/src/rsbuild/virtual-modules.ts index c5e28e96c7..960b2152f3 100644 --- a/packages/start-plugin-core/src/rsbuild/virtual-modules.ts +++ b/packages/start-plugin-core/src/rsbuild/virtual-modules.ts @@ -28,6 +28,7 @@ const RSC_HMR_VIRTUAL_ID = 'virtual:tanstack-rsc-hmr' const RSC_BROWSER_DECODE_VIRTUAL_ID = 'virtual:tanstack-rsc-browser-decode' const RSC_SSR_DECODE_VIRTUAL_ID = 'virtual:tanstack-rsc-ssr-decode' export const START_MANIFEST_PLACEHOLDER = '__TSS_START_MANIFEST_PLACEHOLDER__' +const DEV_START_MANIFEST_GLOBAL = '__TSS_DEV_START_MANIFEST__' /** * VirtualModulesPlugin resolves module paths relative to compiler.context. * Prefix them under the app root so they are unique and watcher-friendly. @@ -42,8 +43,6 @@ function virtualPath(root: string, moduleId: string): string { export interface VirtualModuleState { /** Call to update manifest content after client build completes */ updateManifest: (clientBuild: NormalizedClientBuild) => void - /** Number of times the dev manifest module was written */ - getDevManifestWriteCount: () => number /** Call to update server fn resolver content after compilation discovers fns */ updateServerFnResolver: () => void /** Write explicit server resolver content; queues if env not ready */ @@ -84,24 +83,36 @@ function getEntryScriptAttrs( : `{ async: true, src: '${entryUrl}' }` } -/** - * Dev manifest used until the first client build completes. The server bundle - * may run outside the build process (e.g. in workerd), so the real manifest is - * written into this module rather than shared through build-process globals. - */ -function generateFallbackManifestModuleDev( +function generateManifestModuleDev( devClientEntryUrl: string, scriptFormat: ScriptFormat, ): string { const scriptFormatProperty = getScriptFormatProperty(scriptFormat) - return `export const tsrStartManifest = () => ({ + return `const fallbackManifest = { ${scriptFormatProperty} routes: { __root__: { preloads: ['${devClientEntryUrl}'], scripts: [{ attrs: ${getEntryScriptAttrs(devClientEntryUrl, scriptFormat)} }], }, }, -})` +} +export const tsrStartManifest = () => globalThis[${JSON.stringify(DEV_START_MANIFEST_GLOBAL)}] ?? fallbackManifest` +} + +function buildStartManifestData( + clientBuild: NormalizedClientBuild, + publicBase: string, + inlineCss: InlineCssOptions, + scriptFormat: ScriptFormat, +) { + const routeTreeRoutes = globalThis.TSS_ROUTES_MANIFEST + return buildStartManifest({ + clientBuild, + routeTreeRoutes, + basePath: publicBase, + inlineCss, + scriptFormat, + }) } function serializeStartManifestData( @@ -111,13 +122,7 @@ function serializeStartManifestData( scriptFormat: ScriptFormat, ): string { return JSON.stringify( - buildStartManifest({ - clientBuild, - routeTreeRoutes: globalThis.TSS_ROUTES_MANIFEST, - basePath: publicBase, - inlineCss, - scriptFormat, - }), + buildStartManifestData(clientBuild, publicBase, inlineCss, scriptFormat), ) } @@ -218,8 +223,7 @@ export function setupRscHmr() { // --------------------------------------------------------------------------- export interface RegisterVirtualModulesOptions { - /** The resolved project root (read when the first Rspack config is built, after `modifyRsbuildConfig`). */ - getRoot: () => string + root: string getConfig: GetConfigFn serverFnsById: Record<string, ServerFn> providerEnvName: string @@ -247,51 +251,31 @@ export function registerVirtualModules( opts: RegisterVirtualModulesOptions, ): VirtualModuleState { const isDev = api.context.action === 'dev' - // Virtual module paths keyed by module ID, under the resolved root (never `process.cwd()`) - let resolvedPaths: - | { - manifest: string - serverFnResolver: string - pluginAdapters: string - rsc: { - rscRuntime: string - rscHmr: string - rscBrowserDecode: string - rscSsrDecode: string - } | null - } - | undefined - const pathsOf = () => { - if (!resolvedPaths) { - const root = opts.getRoot() - resolvedPaths = { - manifest: virtualPath(root, VIRTUAL_MODULES.startManifest), - serverFnResolver: virtualPath(root, VIRTUAL_MODULES.serverFnResolver), - pluginAdapters: virtualPath(root, VIRTUAL_MODULES.pluginAdapters), - rsc: opts.rscEnabled - ? { - rscRuntime: virtualPath(root, RSC_RUNTIME_VIRTUAL_ID), - rscHmr: virtualPath(root, RSC_HMR_VIRTUAL_ID), - rscBrowserDecode: virtualPath( - root, - RSC_BROWSER_DECODE_VIRTUAL_ID, - ), - rscSsrDecode: virtualPath(root, RSC_SSR_DECODE_VIRTUAL_ID), - } - : null, - } - } - return resolvedPaths + const root = opts.root + + // Virtual module paths keyed by module ID + const paths = { + manifest: virtualPath(root, VIRTUAL_MODULES.startManifest), + serverFnResolver: virtualPath(root, VIRTUAL_MODULES.serverFnResolver), + pluginAdapters: virtualPath(root, VIRTUAL_MODULES.pluginAdapters), } + // RSC virtual module paths (only defined when RSC is enabled) + const rscPaths = opts.rscEnabled + ? { + rscRuntime: virtualPath(root, RSC_RUNTIME_VIRTUAL_ID), + rscHmr: virtualPath(root, RSC_HMR_VIRTUAL_ID), + rscBrowserDecode: virtualPath(root, RSC_BROWSER_DECODE_VIRTUAL_ID), + rscSsrDecode: virtualPath(root, RSC_SSR_DECODE_VIRTUAL_ID), + } + : null + // Track VirtualModulesPlugin instances per environment for dynamic updates const vmPlugins: Record<string, RspackVirtualModulesPlugin> = {} const readyVmPlugins: Record<string, boolean> = {} const pendingWrites = new Map<string, Map<string, string>>() let clientBuild: NormalizedClientBuild | undefined - let lastDevManifestContent: string | undefined - let devManifestWriteCount = 0 const lastResolverContentByEnvironment: Record<string, string | undefined> = {} const resolverWriteCountByEnvironment: Record<string, number> = {} @@ -328,7 +312,7 @@ export function registerVirtualModules( lastResolverContentByEnvironment[environmentName] = content resolverWriteCountByEnvironment[environmentName] = (resolverWriteCountByEnvironment[environmentName] ?? 0) + 1 - tryWriteModule(environmentName, pathsOf().serverFnResolver, content) + tryWriteModule(environmentName, paths.serverFnResolver, content) } } @@ -391,8 +375,6 @@ export function registerVirtualModules( function getInitialContent(environmentName: string): Record<string, string> { // Safe to call getConfig() here — this runs inside modifyRspackConfig const { resolvedStartConfig, startConfig } = opts.getConfig() - const paths = pathsOf() - const rscPaths = paths.rsc const isServerEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.server const isClientEnv = environmentName === RSBUILD_ENVIRONMENT_NAMES.client const content: Record<string, string> = {} @@ -403,10 +385,7 @@ export function registerVirtualModules( resolvedStartConfig.basePaths.publicBase, ) content[paths.manifest] = isDev - ? generateFallbackManifestModuleDev( - devClientEntryUrl, - opts.scriptFormat, - ) + ? generateManifestModuleDev(devClientEntryUrl, opts.scriptFormat) : generateManifestModuleBuild( clientBuild, resolvedStartConfig.basePaths.publicBase, @@ -471,22 +450,21 @@ export function createFromReadableStream() { throw new Error('RSC SSR decode is // Build a map from virtual module IDs to their virtual file paths. // Scheme-like IDs are rewritten with NormalModuleReplacementPlugin because // rspack validates request schemes before normal alias resolution. - const aliasMapOf = (): Record<string, string> => { - const paths = pathsOf() - const aliasMap: Record<string, string> = { - [VIRTUAL_MODULES.startManifest]: paths.manifest, - [VIRTUAL_MODULES.serverFnResolver]: paths.serverFnResolver, - } - if (hasSerializationAdapters) { - aliasMap[VIRTUAL_MODULES.pluginAdapters] = paths.pluginAdapters - } - if (paths.rsc) { - aliasMap[RSC_RUNTIME_VIRTUAL_ID] = paths.rsc.rscRuntime - aliasMap[RSC_HMR_VIRTUAL_ID] = paths.rsc.rscHmr - aliasMap[RSC_BROWSER_DECODE_VIRTUAL_ID] = paths.rsc.rscBrowserDecode - aliasMap[RSC_SSR_DECODE_VIRTUAL_ID] = paths.rsc.rscSsrDecode - } - return aliasMap + const aliasMap: Record<string, string> = { + [VIRTUAL_MODULES.startManifest]: paths.manifest, + [VIRTUAL_MODULES.serverFnResolver]: paths.serverFnResolver, + } + + if (hasSerializationAdapters) { + aliasMap[VIRTUAL_MODULES.pluginAdapters] = paths.pluginAdapters + } + + // Add RSC virtual module aliases + if (rscPaths) { + aliasMap[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime + aliasMap[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr + aliasMap[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode + aliasMap[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode } // Register VirtualModulesPlugin per environment via modifyRspackConfig @@ -517,7 +495,6 @@ export function createFromReadableStream() { throw new Error('RSC SSR decode is }) // Rewrite scheme-like IDs to the VirtualModulesPlugin-backed file paths. - const aliasMap = aliasMapOf() for (const [moduleId, virtualFilePath] of Object.entries(aliasMap)) { const NMR = utils.rspack.NormalModuleReplacementPlugin config.plugins.push( @@ -527,20 +504,23 @@ export function createFromReadableStream() { throw new Error('RSC SSR decode is const resolve = config.resolve const resolveAlias = (resolve.alias ??= {}) as Record<string, string> - for (const [moduleId, virtualFilePath] of Object.entries(aliasMap)) { - if (moduleId !== VIRTUAL_MODULES.startManifest) { - resolveAlias[moduleId] = virtualFilePath - } + resolveAlias[VIRTUAL_MODULES.serverFnResolver] = paths.serverFnResolver + if (hasSerializationAdapters) { + resolveAlias[VIRTUAL_MODULES.pluginAdapters] = paths.pluginAdapters + } + + // Add RSC-specific resolve aliases + if (rscPaths) { + resolveAlias[RSC_RUNTIME_VIRTUAL_ID] = rscPaths.rscRuntime + resolveAlias[RSC_HMR_VIRTUAL_ID] = rscPaths.rscHmr + resolveAlias[RSC_BROWSER_DECODE_VIRTUAL_ID] = rscPaths.rscBrowserDecode + resolveAlias[RSC_SSR_DECODE_VIRTUAL_ID] = rscPaths.rscSsrDecode } }) return { - get serverFnResolverPath() { - return pathsOf().serverFnResolver - }, - get manifestPath() { - return pathsOf().manifest - }, + serverFnResolverPath: paths.serverFnResolver, + manifestPath: paths.manifest, vmPlugins, generateCurrentResolverContent(forProvider?: boolean): string { @@ -581,26 +561,18 @@ export function createFromReadableStream() { throw new Error('RSC SSR decode is updateManifest(newClientBuild: NormalizedClientBuild) { clientBuild = newClientBuild - if (!isDev) { - return - } - // Safe to call getConfig() here — runs after client build const { resolvedStartConfig } = opts.getConfig() - const content = `export const tsrStartManifest = () => (${serializeStartManifestData( - clientBuild, - resolvedStartConfig.basePaths.publicBase, - { enabled: false, transformAssets: false }, - opts.scriptFormat, - )})` - // Only rewrite on change: each write rebuilds the server environment. - if (content !== lastDevManifestContent) { - lastDevManifestContent = content - devManifestWriteCount++ - tryWriteModule( - RSBUILD_ENVIRONMENT_NAMES.server, - pathsOf().manifest, - content, + if (isDev) { + ;( + globalThis as typeof globalThis & { + [DEV_START_MANIFEST_GLOBAL]?: ReturnType<typeof buildStartManifest> + } + )[DEV_START_MANIFEST_GLOBAL] = buildStartManifestData( + clientBuild, + resolvedStartConfig.basePaths.publicBase, + { enabled: false, transformAssets: false }, + opts.scriptFormat, ) } }, @@ -627,16 +599,12 @@ export function createFromReadableStream() { throw new Error('RSC SSR decode is writeResolverContent(RSBUILD_ENVIRONMENT_NAMES.server, content) }, - getDevManifestWriteCount(): number { - return devManifestWriteCount - }, - getServerFnResolverWriteCount(environmentName: string): number { return resolverWriteCountByEnvironment[environmentName] ?? 0 }, getVirtualPath(moduleId: string): string { - return virtualPath(opts.getRoot(), moduleId) + return virtualPath(root, moduleId) }, } } diff --git a/packages/start-plugin-core/src/start-compiler/compiler.ts b/packages/start-plugin-core/src/start-compiler/compiler.ts index 13193f7249..64dc24df34 100644 --- a/packages/start-plugin-core/src/start-compiler/compiler.ts +++ b/packages/start-plugin-core/src/start-compiler/compiler.ts @@ -16,11 +16,6 @@ import { handleCreateIsomorphicFn } from './handleCreateIsomorphicFn' import { handleEnvOnlyFn } from './handleEnvOnly' import { handleClientOnlyJSX } from './handleClientOnlyJSX' import { cleanId } from './utils' -import { - customIdCheck, - customIdError, - customIdWarning, -} from './server-fn-id-check' import type { CompilationContext, DevServerFnModuleSpecifierEncoder, @@ -636,15 +631,11 @@ export class StartCompiler { * In dev mode, uses a base64-encoded JSON with file path and export name. * In build mode, uses SHA256 hash or custom generator. */ - private generateFunctionId( - opts: { - filename: string - functionName: string - variableName: string - extractedFilename: string - }, - warn: ((message: string) => void) | undefined, - ): string { + private generateFunctionId(opts: { + filename: string + functionName: string + extractedFilename: string + }): string { if (this.mode === 'dev') { // In dev, encode the file path and export name for direct lookup. // Each bundler adapter supplies its own strategy for encoding @@ -682,25 +673,11 @@ export class StartCompiler { functionId = knownFn.functionId } - if (functionId === undefined && this.options.generateFunctionId) { - functionId = this.options.generateFunctionId({ + if (this.options.generateFunctionId) { + functionId ??= this.options.generateFunctionId({ filename: opts.filename, functionName: opts.functionName, }) - if (functionId) { - const subject = { - name: opts.variableName, - functionName: opts.functionName, - rootRel: opts.filename, - } - const check = customIdCheck(functionId) - if (check === 'error') { - throw new Error(customIdError(subject, functionId)) - } - if (check === 'deprecated') { - warn?.(customIdWarning(subject, functionId)) - } - } } if (!functionId) { functionId = crypto.createHash('sha256').update(entryId).digest('hex') @@ -1423,7 +1400,7 @@ export class StartCompiler { })(), warn: warnFn, - generateFunctionId: (opts) => this.generateFunctionId(opts, warnFn), + generateFunctionId: (opts) => this.generateFunctionId(opts), getKnownServerFns: this.options.getKnownServerFns, serverFnProviderModuleDirectives: this.options.serverFnProviderModuleDirectives, diff --git a/packages/start-plugin-core/src/start-compiler/handleCreateServerFn.ts b/packages/start-plugin-core/src/start-compiler/handleCreateServerFn.ts index dd152bdaa4..dd441bcc24 100644 --- a/packages/start-plugin-core/src/start-compiler/handleCreateServerFn.ts +++ b/packages/start-plugin-core/src/start-compiler/handleCreateServerFn.ts @@ -255,7 +255,6 @@ export function handleCreateServerFn( const functionId = context.generateFunctionId({ filename: relativeFilename, functionName, - variableName: existingVariableName, extractedFilename, }) diff --git a/packages/start-plugin-core/src/start-compiler/server-fn-id-check.ts b/packages/start-plugin-core/src/start-compiler/server-fn-id-check.ts deleted file mode 100644 index 7ddaafce5b..0000000000 --- a/packages/start-plugin-core/src/start-compiler/server-fn-id-check.ts +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Which ids a custom `serverFns.generateFunctionId` may return. The client - * puts the id after `TSS_SERVER_FN_BASE` unencoded and the server reads that - * path segment back, so an id has to survive that trip whole. - */ - -interface CustomIdSubject { - /** The server function's variable name. */ - name: string - /** The `functionName` the generator received. */ - functionName: string - /** The defining file, relative to the root. */ - rootRel: string -} - -/** - * `error`: the id never reached its handler: a character that splits or - * ends the path or that a client percent-encodes, a dot segment, which URL - * parsing removes, or a percent-encoding the server decodes to another id - * or rejects (`readBack`). `deprecated`: an ASCII character outside RFC - * 3986's unreserved set and `$`, which reaches the server but which proxies - * and servers may encode or normalise. - */ -export function customIdCheck(id: string): 'ok' | 'deprecated' | 'error' { - if ( - id === '.' || - id === '..' || - /[^\x21-\x7e]|["#/<>?\\^`{}]/.test(id) || - (id.includes('%') && readBack(id) !== id) - ) { - return 'error' - } - return /^[A-Za-z0-9\-._~$]+$/.test(id) ? 'ok' : 'deprecated' -} - -/** - * The id the server reads from the URL of an id holding `%`: the request - * URL's path, decoded as Start's server does when the path holds `%` - * (router-core `getNormalizedURL`, `decodePath`: `decodeURI` keeping `%25` - * and `%5C`, then control characters and `"<>\`{}` encoded again) and - * parsed again; `undefined` when the decode throws (the server answers 400). - */ -function readBack(id: string): string | undefined { - const base = '/_/' - const { pathname } = new URL(base + id, 'http://localhost') - let decoded = '' - try { - for (const part of pathname.split(/(%25|%5C)/i)) { - decoded += /^%(25|5C)$/i.test(part) - ? part - : decodeURI(part).replace( - // eslint-disable-next-line no-control-regex - /[\x00-\x1f\x7f"<>`{}]/g, - (ch) => - `%${ch.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0')}`, - ) - } - } catch { - return undefined - } - const read = new URL(decoded, 'http://localhost').pathname - return read.startsWith(base) - ? read.slice(base.length).split('/')[0] - : undefined -} - -/** The build error of a custom id `customIdCheck` refuses. */ -export function customIdError(fn: CustomIdSubject, id: string): string { - return `[tanstack-start] serverFns.generateFunctionId returned ${JSON.stringify(id)} for the server function ${fn.name} (functionName "${fn.functionName}") of ${fn.rootRel}. A server function id is one path segment of its URL: it cannot hold whitespace, control or non-ASCII characters or any of " # / < > ? \\ ^ \` { }, cannot be "." or "..", and cannot hold a percent-encoding the server reads as another id ("%41") or rejects. Use ASCII letters, digits, "-", ".", "_", "~" and "$".` -} - -/** The build warning of a custom id `customIdCheck` deprecates. */ -export function customIdWarning(fn: CustomIdSubject, id: string): string { - return `[tanstack-start] serverFns.generateFunctionId returned ${JSON.stringify(id)} for the server function ${fn.name} (functionName "${fn.functionName}") of ${fn.rootRel}. Server function ids with characters other than ASCII letters, digits, "-", ".", "_", "~" and "$" are deprecated, and the next major version of TanStack Start rejects them: proxies and servers may encode or normalise them in the URL.` -} diff --git a/packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts b/packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts index 2d50376a39..d03bec3341 100644 --- a/packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts +++ b/packages/start-plugin-core/src/start-compiler/server-fn-resolver-module.ts @@ -31,8 +31,7 @@ export function generateServerFnResolverModule( ? `,\n isClientReferenced: ${fn.isClientReferenced ?? true}` : '' - // (a custom id can hold `'`) - return `'${id.replace(/[\\']/g, '\\$&')}': { + return `'${id}': { functionName: '${fn.functionName}', ${moduleAccess}${clientReferenced} }` diff --git a/packages/start-plugin-core/src/start-compiler/types.ts b/packages/start-plugin-core/src/start-compiler/types.ts index 91b39f5f8a..0dde184961 100644 --- a/packages/start-plugin-core/src/start-compiler/types.ts +++ b/packages/start-plugin-core/src/start-compiler/types.ts @@ -90,8 +90,6 @@ export interface ServerFn { export type GenerateFunctionIdFn = (opts: { filename: string functionName: string - /** The server function's variable name, for diagnostics. */ - variableName: string extractedFilename: string }) => string @@ -99,10 +97,7 @@ export type GenerateFunctionIdFn = (opts: { * Optional version that allows returning undefined to use default ID generation. */ export type GenerateFunctionIdFnOptional = ( - opts: Omit< - Parameters<GenerateFunctionIdFn>[0], - 'extractedFilename' | 'variableName' - >, + opts: Omit<Parameters<GenerateFunctionIdFn>[0], 'extractedFilename'>, ) => string | undefined /** diff --git a/packages/start-plugin-core/src/start-router-plugin/generator-config.ts b/packages/start-plugin-core/src/start-router-plugin/generator-config.ts deleted file mode 100644 index 3d3e5ea086..0000000000 --- a/packages/start-plugin-core/src/start-router-plugin/generator-config.ts +++ /dev/null @@ -1,41 +0,0 @@ -import path from 'pathe' -import { buildRouteTreeFileFooterFromConfig } from './route-tree-footer' -import { routesManifestPlugin } from './generator-plugins/routes-manifest-plugin' -import { prerenderRoutesPlugin } from './generator-plugins/prerender-routes-plugin' -import type { GeneratorPlugin } from '@tanstack/router-generator' -import type { Config } from '@tanstack/router-plugin' -import type { GetConfigFn, TanStackStartCoreOptions } from '../types' - -/** - * The route generator configuration of a Start app, the same for the Vite - * and Rsbuild plugins: the app's router options as the Start config parsed - * them, the framework's target, Start's route tree footer (the router and - * Start config types, then the app's own lines; computed at every print, as - * a router app's function-form `routeTreeFileFooter` is), and the generator - * plugins: the client route tree (Vite), the routes manifest, prerendering - * when enabled, and the app's own (#7768). - */ -export function startGeneratorConfig(opts: { - getConfig: GetConfigFn - corePluginOpts: TanStackStartCoreOptions - prerender: boolean - clientRouteTree?: GeneratorPlugin -}): Config { - const router = opts.getConfig().startConfig.router - return { - ...router, - target: opts.corePluginOpts.framework, - routeTreeFileFooter: () => - buildRouteTreeFileFooterFromConfig({ - generatedRouteTreePath: path.resolve(router.generatedRouteTree), - getConfig: opts.getConfig, - corePluginOpts: opts.corePluginOpts, - }), - plugins: [ - ...(opts.clientRouteTree ? [opts.clientRouteTree] : []), - routesManifestPlugin(), - ...(opts.prerender ? [prerenderRoutesPlugin()] : []), - ...(router.plugins ?? []), - ], - } -} diff --git a/packages/start-plugin-core/src/vite/plugin.ts b/packages/start-plugin-core/src/vite/plugin.ts index 5e5bca4a2e..5fd9356f1f 100644 --- a/packages/start-plugin-core/src/vite/plugin.ts +++ b/packages/start-plugin-core/src/vite/plugin.ts @@ -1,5 +1,3 @@ -import { realpathSync } from 'node:fs' -import { resolve } from 'node:path' import { crawlFrameworkPkgs } from 'vitefu' import { applyResolvedBaseAndOutput, @@ -142,11 +140,7 @@ export function tanStackStartVite( // see https://github.com/vitejs/vite/blob/557f797d29422027e8c451ca50dd84bf8c41b5f0/packages/vite/src/node/optimizer/index.ts#L1282 const crawlFrameworkPkgsResult = await crawlFrameworkPkgs({ - // (the configured root, which can be relative: resolved as Vite does, - // then physical, as Vite resolves the app's imports from there) - root: realpathSync( - viteConfig.root ? resolve(viteConfig.root) : process.cwd(), - ), + root: process.cwd(), isBuild: command === 'build', isFrameworkPkgByJson(pkgJson) { const peerDependencies = pkgJson['peerDependencies'] diff --git a/packages/start-plugin-core/src/vite/start-router-plugin/plugin.ts b/packages/start-plugin-core/src/vite/start-router-plugin/plugin.ts index 8df06af4f5..e4f06893a7 100644 --- a/packages/start-plugin-core/src/vite/start-router-plugin/plugin.ts +++ b/packages/start-plugin-core/src/vite/start-router-plugin/plugin.ts @@ -6,10 +6,11 @@ import { import path from 'pathe' import { normalizePath } from 'vite' import { VITE_ENVIRONMENT_NAMES } from '../../constants' -import { startGeneratorConfig } from '../../start-router-plugin/generator-config' +import { routesManifestPlugin } from '../../start-router-plugin/generator-plugins/routes-manifest-plugin' +import { prerenderRoutesPlugin } from '../../start-router-plugin/generator-plugins/prerender-routes-plugin' +import { buildRouteTreeFileFooterFromConfig } from '../../start-router-plugin/route-tree-footer' import { pruneServerOnlySubtrees } from '../../start-router-plugin/pruneServerOnlySubtrees' import { SERVER_PROP } from '../../start-router-plugin/constants' -import { escapeRegExp } from '../../utils' import type { GetConfigFn } from '../../types' import type { TanStackStartVitePluginCoreOptions } from '../types' import type { @@ -71,6 +72,22 @@ export function tanStackStartRouter( }, } + let routeTreeFileFooter: Array<string> | null = null + + function getRouteTreeFileFooter() { + if (routeTreeFileFooter) { + return routeTreeFileFooter + } + routeTreeFileFooter = [ + ...buildRouteTreeFileFooterFromConfig({ + generatedRouteTreePath: getGeneratedRouteTreePath(), + getConfig, + corePluginOpts, + }), + ] + return routeTreeFileFooter + } + let resolvedGeneratedRouteTreePath: string | null = null const clientTreePlugin: Plugin = { name: 'tanstack-start:route-tree-client-plugin', @@ -87,13 +104,8 @@ export function tanStackStartRouter( resolvedGeneratedRouteTreePath = normalizePath( getGeneratedRouteTreePath(), ) - // The route tree module itself, by its exact id (a query aside) ;(clientTreePlugin.load as LoadObjectHook).filter = { - id: { - include: new RegExp( - `^${escapeRegExp(resolvedGeneratedRouteTreePath)}(?:\\?.*)?$`, - ), - }, + id: { include: new RegExp(resolvedGeneratedRouteTreePath) }, } }, @@ -101,13 +113,7 @@ export function tanStackStartRouter( filter: { // this will be set in the config hook above since it relies on `config` hook being called first }, - async handler(id) { - if ( - normalizePath(id.replace(/\?.*$/, '')) !== - resolvedGeneratedRouteTreePath - ) { - return null - } + async handler() { if (!generatorInstance) { throw new Error('Generator instance not initialized') } @@ -138,16 +144,19 @@ export function tanStackStartRouter( } return [ clientTreePlugin, - tanstackRouterGenerator( - () => - startGeneratorConfig({ - getConfig, - corePluginOpts, - prerender: startPluginOpts.prerender?.enabled === true, - clientRouteTree: clientTreeGeneratorPlugin, - }), - routerPluginContext, - ), + tanstackRouterGenerator(() => { + const routerConfig = getConfig().startConfig.router + const plugins = [clientTreeGeneratorPlugin, routesManifestPlugin()] + if (startPluginOpts.prerender?.enabled === true) { + plugins.push(prerenderRoutesPlugin()) + } + return { + ...routerConfig, + target: corePluginOpts.framework, + routeTreeFileFooter: getRouteTreeFileFooter, + plugins, + } + }, routerPluginContext), tanStackRouterCodeSplitter(() => { const routerConfig = getConfig().startConfig.router return { diff --git a/packages/start-plugin-core/tests/binding-names.ts b/packages/start-plugin-core/tests/binding-names.ts new file mode 100644 index 0000000000..66b911eeb9 --- /dev/null +++ b/packages/start-plugin-core/tests/binding-names.ts @@ -0,0 +1,70 @@ +/** + * The binding names of a module's code (an independent parse, Oxc through + * Vite's `parseSync`): what an adaptive hygiene probe offers user code as + * names, after reading them from what the compiler served (SPEC G15). + */ +import { parseSync } from 'vite' + +type Node = { type: string; [key: string]: unknown } + +function isNode(value: unknown): value is Node { + return ( + typeof value === 'object' && + value !== null && + typeof (value as Node).type === 'string' + ) +} + +/** + * Names that refer to bindings in `code` (declared or read): identifiers and + * JSX component names, but not property names, object keys, JSX attribute + * names or the names other modules export. + */ +export function bindingNames(code: string) { + const parsed = parseSync('module.tsx', code, { sourceType: 'module' }) + if (parsed.errors.length > 0) { + throw new Error(`Cannot parse module: ${parsed.errors[0]!.message}`) + } + const names = new Set<string>() + const visit = (node: unknown, parent?: Node, key?: string) => { + if (Array.isArray(node)) { + for (const child of node) { + visit(child, parent, key) + } + return + } + if (!isNode(node)) { + return + } + const nonReference = + (parent?.type === 'MemberExpression' && + key === 'property' && + !parent.computed) || + (parent?.type === 'Property' && + key === 'key' && + !parent.computed && + !parent.shorthand) || + ((parent?.type === 'MethodDefinition' || + parent?.type === 'PropertyDefinition') && + key === 'key' && + !parent.computed) || + (parent?.type === 'ImportSpecifier' && key === 'imported') || + (parent?.type === 'ExportSpecifier' && key === 'exported') || + (parent?.type === 'JSXAttribute' && key === 'name') || + (parent?.type === 'JSXMemberExpression' && key === 'property') + if ( + !nonReference && + (node.type === 'Identifier' || + (node.type === 'JSXIdentifier' && /^[A-Z_$]/.test(node.name as string))) + ) { + names.add(node.name as string) + } + for (const child in node) { + if (child !== 'type') { + visit(node[child], node, child) + } + } + } + visit(parsed.program) + return names +} diff --git a/packages/start-plugin-core/tests/build-harness.ts b/packages/start-plugin-core/tests/build-harness.ts new file mode 100644 index 0000000000..9d0d2ccc93 --- /dev/null +++ b/packages/start-plugin-core/tests/build-harness.ts @@ -0,0 +1,1062 @@ +/** + * Real-build harness for Start goal tests whose outcome the bundler decides + * (e.g. "server code never reaches the client bundle"). Builds an app the + * way `vite build` or `rsbuild build` builds a Start app: with the plugins + * its `vite.config.ts` or `rsbuild.config.ts` lists, `tanstackStart()` of + * the built framework package (`@tanstack/react-start/plugin/vite` or + * `/plugin/rsbuild`, `@tanstack/solid-start` for a Solid app; see + * `start-plugins.ts`) and the framework's own plugin (`@vitejs/plugin-react`, + * `@rsbuild/plugin-react`; a Solid app's comes from the test). The + * `test:integration` target builds the packages first. So the framework + * package's configuration, Start's environments (client, then SSR, which is + * the server fn provider), the Start compiler, import protection, the + * router generator and code splitter, and the generated server fn resolver + * are Start's, and Rspack loads Start's loaders from the package as in an + * installed app. The output of each environment is described and run with + * the shared build harness (`@tanstack/compiler-test-utils/build-harness`). + * The temporary apps stand in for apps in this directory + * (`@tanstack/compiler-test-utils/app-directory`). + * + * `@tanstack/react-start` is the real package (`startRuntimeLinks`), and + * `@tanstack/react-router` the real one too (a dependency of this package, + * which the apps resolve like any dependency): both builds bundle and run + * Start's runtime and the router. The server bundle's entry is Start's own + * server entry, over a real router whose route tree has a probe server route + * (`request-probe.ts`): an SSR script runs inside a real request of the app, + * which that server entry serves (`inAppRequest`). What the test process + * cannot do is stood in for: a client script + * observes the requests a server fn call sends (`requestsOfPrelude`). An SSR + * script calls a server fn by id through Start's own server entry and client + * RPC (`callByIdPrelude`). The app's entries are the harness's unless the app + * has its own (`src/client.*`, `src/server.*`), given to Start through its + * documented options (`client.entry`, `server.entry`): the client entry + * imports the app's documented router entry (`src/router.ts`, the harness's + * real router unless the app has one; the client entry only the app's own), + * its start entry (`src/start.ts` when the app has one; otherwise Start uses + * the framework package's default) and the test's entry module, whose + * exports `run()` gives the script as `entry`; the server entry is Start's + * own (`@tanstack/<framework>-start/server-entry`). Vite builds run in the + * app's directory, as `vite build` does. + * + * Everything a build reports, on every channel (the bundler's warnings and + * errors, Vite's logger, `console.*` and the process streams; SPEC §5.7), + * is in `StartBuild.diagnostics`, and a failed build rejects with a + * `StartBuildError` carrying the same (`diagnostics`). + * + * Import protection is on, with Start's defaults unless the test configures + * it; it checks the modules of the source directory (`src`) only. + */ +import { mkdir, rm, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import { + linkWorkspacePackages, + workspacePackageLinks, +} from '@tanstack/compiler-test-utils/workspace-packages' +import { + BuildError, + bundlerReports, + chunksOfBundle, + chunksOfStats, + createApp, + describeBuild, + parsedModules, + pluginNames, + recordParsedModules, + recordViteModules, + statsDiagnostics, + statsMessages, + statsOptions, + stripAnsi, + withBuildEnvironment, +} from '@tanstack/compiler-test-utils/build-harness' +import { + rsbuildLogger, + trackCompiles, +} from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import react from '@vitejs/plugin-react' +import { pluginReact } from '@rsbuild/plugin-react' +import { onTestFinished } from 'vitest' +import { inProbeRequest, requestFiles } from './request-probe' +import { startPlugins, startRsbuildPlugin } from './start-plugins' +import type { + BuildMode, + BuildResult, + EmittedChunk, + ParsedModules, + StatsJson, +} from '@tanstack/compiler-test-utils/build-harness' +import type { + ChannelDiagnostic, + DiagnosticChannel, +} from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { TanStackStartInputConfig } from '../src' +import type { ViolationInfo } from './importProtection/public-types' +import type { RsbuildConfig, RsbuildPlugin } from '@rsbuild/core' +import type { InlineConfig, Plugin } from 'vite' + +/** + * Links (`AppOptions.symlinks`) that give an app Start's real runtime: + * `node_modules/@tanstack/react-start` is the workspace package + * (`workspacePackageLinks`), so the app bundles and runs the built package + * with its own export conditions. Its dependencies + * (`@tanstack/start-client-core`, `@tanstack/start-server-core`, ...) + * resolve from its real path, as in an installed app. A Solid app also + * gets the built `@tanstack/solid-start` and `@tanstack/solid-router`. + */ +export function startRuntimeLinks( + framework: 'react' | 'solid' = 'react', +): Record<string, string> { + return workspacePackageLinks([ + '@tanstack/react-start', + ...(framework === 'solid' + ? ['@tanstack/solid-start', '@tanstack/solid-router'] + : []), + ]) +} + +/** Creates the `startRuntimeLinks()` of an app made without `createApp`. */ +export function linkStartRuntime(root: string) { + return linkWorkspacePackages(root, ['@tanstack/react-start']) +} + +/** + * Wraps a script of the SSR build's `run()` so that it runs inside a real + * request of the app (`request-probe.ts`): the child process imports the + * server bundle's entry the way a host does (its default export, Start's + * server entry: `fetch`, or the module of a CommonJS bundle carrying it) + * and sends it a request for the app's probe route, whose handler runs the + * script while Start serves the request. Start's request context is then + * the one its server entry opens for that request: the app's start options + * and request middleware, its router. + */ +const inAppRequest = (serverEntryFile: string, script: string) => + `const inProbeRequest = ${inProbeRequest.toString()} +const serverModule = await import(${JSON.stringify(pathToFileURL(serverEntryFile).href)}) +const serverEntry = typeof serverModule.default?.fetch === 'function' ? serverModule.default : serverModule.default?.default +if (typeof serverEntry?.fetch !== 'function') { + throw new Error(${JSON.stringify(`${serverEntryFile} does not export a server entry`)}) +} +return await inProbeRequest( + (path) => serverEntry.fetch(new Request(new URL(path, 'http://localhost'))), + async () => { +${script} + }, +)` + +/** + * Exports of an SSR entry whose script calls server fns by id + * (`callByIdPrelude`): Start's default server entry (the HTTP handler of a + * Start app) and Start's client RPC. + */ +export const callByIdExports = `export { default as startServerEntry } from '@tanstack/react-start/server-entry' +export { createClientRpc } from '@tanstack/react-start/client-rpc' +` + +/** + * Prelude of an SSR script whose entry has `callByIdExports`: + * `callById(id, data, method)` sends the request (`method`, default GET) of + * a client call of the server fn `id` (Start's client RPC) to Start's + * server entry, as a page of the + * same origin does (the browser adds `Sec-Fetch-Site`, which Start's CSRF + * middleware checks), and gives the decoded result or throws the decoded + * error, like the client's server fn. + * + * `serverFnId(fn)` is the id of a server fn (or of its URL) as its public + * `url` carries it: the server fn base (`createClientRpc(id).url` is the + * base, then the id), then the id. It throws for a value without such a URL, + * outside any `try` of the script: a server fn object is identified by + * `url` alone (SPEC J4.1), never by Start's own metadata fields (§5.19). + */ +export const callByIdPrelude = `const serverFnBase = entry.createClientRpc('').url +const serverFnId = (fnOrUrl) => { + const url = typeof fnOrUrl === 'string' ? fnOrUrl : fnOrUrl?.url + if ( + typeof url !== 'string' || + !url.startsWith(serverFnBase) || + url.length === serverFnBase.length + ) { + throw new Error('not a server fn URL: ' + String(url)) + } + return url.slice(serverFnBase.length) +} +const callById = async (id, data, method = 'GET') => { + const fetch = (url, init) => { + const headers = new Headers(init.headers) + headers.set('sec-fetch-site', 'same-origin') + return entry.startServerEntry.fetch( + new Request(new URL(url, 'http://localhost'), { ...init, headers }), + ) + } + const reply = await entry.createClientRpc(id)({ data, method, fetch }) + if ('error' in reply) { + throw reply.error + } + return reply.result +} +` + +/** + * Calls the client's server fn `fn` (with `options`, e.g. its `data`) and + * gives the requests it sends. A test's client has no server: the call's + * `fetch` option (Start's public API) records each request and fails it. + * Self-contained: client scripts run its source (`requestsOfPrelude`). + */ +export async function requestsOf( + fn: (options: Record<string, unknown>) => Promise<unknown>, + options: Record<string, unknown> = {}, +): Promise<Array<{ url: string; method: string | undefined }>> { + const requests: Array<{ url: string; method: string | undefined }> = [] + const fetch = (url: string | URL, init?: RequestInit) => { + requests.push({ url: String(url), method: init?.method }) + return Promise.reject(new Error('no server in the client run')) + } + await fn({ ...options, fetch }).catch(() => {}) + return requests +} + +/** Prelude of a client script: `requestsOf(fn, options)` (see above). */ +export const requestsOfPrelude = `const requestsOf = ${requestsOf.toString()} +` + +export type StartBundler = 'vite' | 'rsbuild' + +/** Every bundler Start has a plugin for. */ +export const startBundlers: ReadonlyArray<StartBundler> = ['vite', 'rsbuild'] + +export interface StartBuildOptions { + /** Default `vite`. */ + bundler?: StartBundler + /** + * The Start framework package of the app (default `react`): Start's + * plugin is that package's `tanstackStart()`, and `solid` links the + * built `@tanstack/solid-start` and `@tanstack/solid-router` too (the + * dependencies of a Solid Start app). The app's JSX plugin (e.g. + * `vite-plugin-solid`) comes from `viteConfig`. + */ + framework?: 'react' | 'solid' + /** App files by path relative to the app root. */ + files: Record<string, string> + /** + * The test's entry module of both environments, or of each, relative to + * the app root (default `entry.ts`). + */ + entry?: string | { client: string; ssr: string } + /** The app's `package.json` (see `AppOptions.packageJson`). */ + packageJson?: Record<string, unknown> | null + /** Shorthand for `packageJson.sideEffects`. */ + sideEffects?: boolean | Array<string> + /** + * Symbolic links of the app besides Start's runtime (`startRuntimeLinks`), + * by path relative to the app root (see `AppOptions.symlinks`), e.g. a + * workspace package a library of the app depends on, or a package + * directory of the app linked into its `node_modules`. + */ + symlinks?: Record<string, string> + mode?: BuildMode + /** Default `mode === 'production'`. */ + minify?: boolean + /** + * Emits a source map for each chunk (`Chunk.map` of both results). Default + * `false`. + */ + sourcemap?: boolean + /** Start's plugin options (`tanstackStart(options)`). */ + start?: TanStackStartInputConfig + /** + * Registers the removal of the app (default: when the current test + * finishes). A build shared by several tests keeps the cleanup and runs + * it in `afterAll`. + */ + registerCleanup?: (cleanup: () => Promise<void>) => void + /** + * Builds the app this many times in a row, in the same directory and with + * a new plugin instance each time (default 1). The results describe the + * last build, e.g. one Rsbuild restores from its persistent cache + * (`rsbuildConfig: { performance: { buildCache: true } }`). + */ + builds?: number + /** Rsbuild configuration merged over the harness's (Rsbuild builds). */ + rsbuildConfig?: RsbuildConfig + /** + * Vite configuration merged over the harness's (Vite builds), e.g. an + * app's `experimental.bundledDev`, which stays set for `vite build`. + */ + viteConfig?: InlineConfig + /** + * Rsbuild builds: builds in watch mode (`rsbuild build --watch`), applies + * these app file edits (`null` deletes a file) once the first build is + * done, and describes the rebuild they cause (its errors reject). + */ + watchEdits?: Record<string, string | null> + /** + * Vite builds: the working directory of the build (default: the app's, as + * `vite build` run in the app directory). + */ + cwd?: string + /** + * Directory name prefix of the temporary app (default + * `.start-build-harness-<bundler>-`), e.g. one with characters a project + * path may carry. + */ + prefix?: string +} + +export interface StartBuild { + client: BuildResult + ssr: BuildResult + /** App root on disk (paths in reports are relative to it or absolute). */ + root: string + /** + * Everything the build reported, on every channel, in order (SPEC §5.7): + * the bundler's warnings of both environments, Vite's logger, `console.*` + * and the process streams. A report names its environment (J6.5), which + * tells the environments apart; `client.warnings`/`ssr.warnings` hold only + * what each environment's bundler reported. + */ + diagnostics: Array<ChannelDiagnostic> + /** + * Every import-protection violation the build reported through Start's + * public `onViolation` callback, in order (the app's own `onViolation`, + * when it has one, still decides: one it allows is not listed). + */ + violations: Array<ViolationInfo> + /** + * Builds the same app again, in the same directory with the same options + * and a new plugin instance, after writing `edits` (app files by path; + * `null` deletes one). The output directories are reused: read what this + * build's results need before rebuilding. + */ + rebuild: (edits?: Record<string, string | null>) => Promise<StartBuild> + /** + * Rsbuild builds: serves the build as `rsbuild preview` does in the app's + * directory (the same plugins; Start's own middleware runs the built + * server entry). `registerCleanup` receives the server's `close` (default: + * when the current test finishes). Vite builds: `createStartHost({ serve: + * false })` and its `preview()`. + */ + preview: ( + registerCleanup?: (cleanup: () => Promise<void>) => void, + ) => Promise<{ url: string }> +} + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +/** Global the harness entries assign the test entry's exports to. */ +const entryGlobal = '__tssBuildHarnessEntry' + +/** The router package of each framework a build can use. */ +const routerPackages = { + react: '@tanstack/react-router', + solid: '@tanstack/solid-router', +} as const + +/** + * The client entry of the app: imports the app's documented entries that + * Start's default client entry imports, when the app has them (the router + * entry `src/router.ts` and the start entry `src/start.ts`; Start's + * defaults, as no test moves them), and the test's entry module. + */ +const clientEntry = (testEntry: string, start: boolean, router: boolean) => + `${start ? `import * as start from '../src/start'\n` : ''}${router ? `import * as router from '../src/router'\n` : ''}import * as entry from ${JSON.stringify(`../${testEntry}`)} +globalThis.__tssBuildHarnessApp = { ${[start && 'start', router && 'router'].filter(Boolean).join(', ')} } +globalThis.${entryGlobal} = entry +` + +/** + * The server entry of the app: Start's own server entry + * (`@tanstack/<framework>-start/server-entry`, its default export, which + * loads the app's router and start entries itself and serves the app's + * requests: `inAppRequest`), and the test's entry module. + */ +const serverEntry = (testEntry: string, framework: 'react' | 'solid') => + `import * as entry from ${JSON.stringify(`../${testEntry}`)} +globalThis.${entryGlobal} = entry +export { default } from '@tanstack/${framework}-start/server-entry' +` + +/** + * `harness/render.ts` of every app: `renderPath(routeTree, pathname)` + * renders the app's route tree at `pathname` through the real router and + * React (`createRouter` over the tree, `router.load()`, which runs the + * loaders and loads the split route options, then `<RouterProvider>` to + * HTML), and React's `createElement` and `renderToString` render a + * component on its own (e.g. a loaded split component, whose render error + * `renderToString` throws). A test's entry re-exports what its scripts use + * (`export { renderPath } from '../harness/render'`: `entry.renderPath(...)`). + */ +const renderFile = `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { + RouterProvider, + createMemoryHistory, + createRouter, +} from '@tanstack/react-router' +import type { AnyRoute } from '@tanstack/react-router' + +export { createElement, renderToString } + +export async function renderPath( + routeTree: AnyRoute, + pathname: string, +): Promise<string> { + const router = createRouter({ + routeTree, + history: createMemoryHistory({ initialEntries: [pathname] }), + }) + await router.load() + return renderToString(createElement(RouterProvider, { router })) +} +` + +/** + * The files the harness adds to every app, unless the app has them: the + * entries, the render helper, and what a request of the app needs + * (`requestFiles`: a real router over the generated route tree, its root + * route and the probe route; the router only when the app has no router + * entry of its own). + */ +const harnessFiles = ( + entries: { client: string; ssr: string }, + files: Record<string, string>, + framework: 'react' | 'solid', +) => { + const ownStart = 'src/start.ts' in files + const ownRouter = Object.keys(files).some((file) => + /^src\/router\.[cm]?[jt]sx?$/.test(file), + ) + const { 'src/router.ts': router, ...routes } = requestFiles( + routerPackages[framework], + ) + return { + 'harness/client-entry.ts': clientEntry(entries.client, ownStart, ownRouter), + 'harness/server-entry.ts': serverEntry(entries.ssr, framework), + 'harness/render.ts': renderFile, + ...(!ownRouter && { 'src/router.ts': router }), + ...routes, + } +} + +/** The harness's entries of an app (used where the app has none). */ +const harnessEntries = (root: string) => ({ + client: path.join(root, 'harness/client-entry.ts'), + server: path.join(root, 'harness/server-entry.ts'), +}) + +/** + * Builds the app with Start's plugin of `bundler` (client, then SSR) and + * describes the output of each environment. Both results share the build's + * duration and console messages; warnings are per environment. + */ +export async function buildStart( + options: StartBuildOptions, +): Promise<StartBuild> { + const { bundler = 'vite', entry = 'entry.ts', files } = options + const entries = + typeof entry === 'object' ? entry : { client: entry, ssr: entry } + const app = await createApp({ + dir: harnessDir, + prefix: options.prefix ?? `.start-build-harness-${bundler}-`, + registerCleanup: options.registerCleanup ?? onTestFinished, + packageJson: options.packageJson, + sideEffects: options.sideEffects, + files: { + ...harnessFiles(entries, files, options.framework ?? 'react'), + ...files, + }, + symlinks: { + ...startRuntimeLinks(options.framework), + ...options.symlinks, + }, + }) + const mode = options.mode ?? 'production' + const violations: Array<ViolationInfo> = [] + const start = options.start ?? {} + const userOnViolation = start.importProtection?.onViolation + const target: BuildTarget = { + root: app.root, + framework: options.framework ?? 'react', + mode, + minify: options.minify ?? mode === 'production', + sourcemap: options.sourcemap ?? false, + // Records what Start's public `onViolation` receives + start: { + ...start, + importProtection: { + ...start.importProtection, + onViolation: async (info) => { + const verdict = await userOnViolation?.(info) + // (`false` allows the import: Start reports nothing) + if (verdict !== false) { + violations.push(info as ViolationInfo) + } + return verdict + }, + }, + }, + violations, + rsbuildConfig: options.rsbuildConfig, + viteConfig: options.viteConfig, + watchEdits: options.watchEdits, + cwd: options.cwd, + } + return buildAt(app, bundler, target, options.builds ?? 1) +} + +/** + * Builds the app at `app.root` `builds` times in a row (a new plugin + * instance each time) and describes the last build. Its `rebuild` writes + * edits into the same directory and builds again. + */ +async function buildAt( + app: Awaited<ReturnType<typeof createApp>>, + bundler: StartBundler, + target: BuildTarget, + builds: number, +): Promise<StartBuild> { + const { mode } = target + const warnings = { client: [], ssr: [] } as Record< + Env, + Array<ChannelDiagnostic> + > + const consoleMessages: Array<ChannelDiagnostic> = [] + let diagnostics: Array<ChannelDiagnostic> = [] + /** One build, recording what it reports on every channel. */ + const build = async () => { + warnings.client.length = 0 + warnings.ssr.length = 0 + consoleMessages.length = 0 + target.violations.length = 0 + // The build's own channel (`withBuildEnvironment`): its async scope + // and its app root (output a bundler prints from native callbacks) + let channel: Channel | undefined + /** What the build described reported (a watch build: the rebuild's). */ + const described = () => + channel ? channel.since(describedFrom.get(channel) ?? 0) : [] + try { + return await withBuildEnvironment(mode, consoleMessages, (scoped) => { + channel = scoped + scoped.claim(app.root) + return builders[bundler](target, warnings, scoped) + }) + } catch (error) { + if (error instanceof BuildError) { + const reported = described() + // The failure itself, unless the compilation reported its errors + // (Rsbuild: recorded from the compilation, once) + const thrown: Array<ChannelDiagnostic> = reported.some( + ({ severity, source }) => + severity === 'error' && source === 'bundler', + ) + ? [] + : [ + { + severity: 'error', + text: stripAnsi(error.message), + raw: error, + source: 'thrown', + }, + ] + throw new StartBuildError( + error, + app.root, + [...reported, ...thrown], + [...target.violations], + ) + } + throw error + } finally { + diagnostics = described() + } + } + let started = performance.now() + let outputs = await build() + for (let index = 1; index < builds; index++) { + started = performance.now() + outputs = await build() + } + const duration = performance.now() - started + const describe = (env: Env) => + describeBuild({ + bundler: bundler === 'vite' ? 'vite' : 'rspack', + env, + mode, + esModules: outputs[env].esModules, + parsedModules: outputs[env].parsedModules, + root: app.root, + outDir: outputs[env].outDir, + chunks: outputs[env].chunks, + sourcemap: target.sourcemap, + warnings: warnings[env], + consoleMessages, + duration, + dispose: app.dispose, + entryGlobal, + }) + const ssr = await describe('ssr') + const serverEntryFile = path.join(ssr.outDir, ssr.entry.fileName) + return { + client: await describe('client'), + ssr: { + ...ssr, + run: (script = '') => ssr.run(inAppRequest(serverEntryFile, script)), + }, + root: app.root, + diagnostics, + violations: [...target.violations], + rebuild: async (edits = {}) => { + for (const [file, content] of Object.entries(edits)) { + const absolute = path.join(app.root, file) + if (content === null) { + await rm(absolute, { force: true }) + } else { + await mkdir(path.dirname(absolute), { recursive: true }) + await writeFile(absolute, content) + } + } + return buildAt(app, bundler, target, 1) + }, + preview: (registerCleanup = onTestFinished) => { + if (bundler !== 'rsbuild') { + throw new Error( + 'preview() serves Rsbuild builds: use createStartHost({ serve: false }) for Vite', + ) + } + return previewWithRsbuild(target, registerCleanup) + }, + } +} + +/** + * A failed Start build: the bundler's errors (`BuildError`), and everything + * the build reported on every channel, the error included (`diagnostics`; + * SPEC §5.7: a compiler may print the details of a failure to the console + * and fail the build with a short error). + */ +export class StartBuildError extends BuildError { + constructor( + error: BuildError, + /** App root on disk. */ + readonly root: string, + readonly diagnostics: Array<ChannelDiagnostic>, + /** What Start's `onViolation` received (`StartBuild.violations`). */ + readonly violations: Array<ViolationInfo>, + ) { + super(error.bundler, error.errors, error.warnings) + this.name = 'StartBuildError' + } +} + +type Env = 'client' | 'ssr' + +type Channel = DiagnosticChannel + +/** + * Where in its channel the build a result describes starts: a watch mode + * build describes the rebuild its edits cause, not the first build. + */ +const describedFrom = new WeakMap<Channel, number>() + +interface BuildTarget { + root: string + framework: 'react' | 'solid' + mode: BuildMode + minify: boolean + sourcemap: boolean + start: TanStackStartInputConfig + /** What `start`'s `onViolation` received during the current build. */ + violations: Array<ViolationInfo> + rsbuildConfig: RsbuildConfig | undefined + viteConfig?: InlineConfig + watchEdits?: Record<string, string | null> + cwd?: string +} + +type Outputs = Record< + Env, + { + outDir: string + chunks: Array<EmittedChunk> + /** Whether the chunks are ES modules (Rsbuild's `output.module`). */ + esModules?: boolean + /** Production client: `describeBuild`'s `parsedModules`. */ + parsedModules?: ParsedModules + } +> + +const builders: Record< + StartBundler, + ( + target: BuildTarget, + warnings: Record<Env, Array<ChannelDiagnostic>>, + channel: Channel, + ) => Promise<Outputs> +> = { + vite: buildWithVite, + rsbuild: buildWithRsbuild, +} + +/** + * Builds with Vite. Bundler and logger warnings go to `warnings` (per + * environment) and to `channel`; errors reach the channel through the + * rejection (`buildAt`), which carries them. + */ +async function buildWithVite( + target: BuildTarget, + warnings: Record<Env, Array<ChannelDiagnostic>>, + channel: Channel, +): Promise<Outputs> { + const { createBuilder, mergeConfig } = await import('vite') + const outputs: Partial<Outputs> = {} + const errors: Array<string> = [] + /** The evidence of the client's dangling-name check (`describeBuild`). */ + const clientParsedModules = parsedModules() + /** Records what each environment emitted. */ + const outputPlugin: Plugin = { + name: 'start-build-harness:outputs', + writeBundle(_options, bundle) { + const env = this.environment.name as Env + outputs[env] = { + outDir: path.resolve(target.root, this.environment.config.build.outDir), + chunks: chunksOfBundle(Object.values(bundle)), + ...(env === 'client' && { parsedModules: clientParsedModules }), + } + }, + } + /** + * The app's own handler of bundler warnings: `build.rolldownOptions.onwarn` + * as the app's config and plugins resolve it (e.g. `@vitejs/plugin-react` + * drops the warnings about React's `"use client"` directives). Each + * environment's warnings go through it, and what it passes on to Vite is + * what the build reports, as `vite build` prints it. + */ + let appOnwarn: Onwarn | undefined + const appOnwarnPlugin: Plugin = { + name: 'start-build-harness:app-onwarn', + configResolved(config) { + const resolved = config.build.rolldownOptions.onwarn as Onwarn | undefined + // (also called with each environment's config, whose handler is the + // harness's own) + if (resolved && !recorders.has(resolved)) { + appOnwarn = resolved + } + }, + } + const recorders = new WeakSet<Onwarn>() + /** The build options of `env`, which records its bundler warnings. */ + const environmentBuild = (env: Env) => { + const record = (warning: { message: string }) => { + warnings[env].push(...bundlerReports([warning.message], 'warning')) + channel.report(stripAnsi(warning.message), 'warning', 'bundler') + } + const onwarn: Onwarn = (warning) => + appOnwarn ? appOnwarn(warning, record) : record(warning) + recorders.add(onwarn) + return { + build: { + minify: target.minify, + sourcemap: target.sourcemap, + emptyOutDir: true, + target: 'esnext', + rolldownOptions: { onwarn }, + }, + } + } + /** Vite's own warnings do not name the environment. */ + const warnBoth = (message: string) => { + warnings.client.push(...bundlerReports([message], 'warning', 'vite')) + warnings.ssr.push(...bundlerReports([message], 'warning', 'vite')) + channel.report(stripAnsi(message), 'warning', 'vite') + } + // `vite build` runs in the app's directory: Start's plugin reads the + // dependencies of the working directory's package.json (Start libraries + // it bundles in SSR, `crawlFrameworkPkgs`). + const cwd = process.cwd() + process.chdir(target.cwd ?? target.root) + try { + const builder = await createBuilder( + mergeConfig<InlineConfig, InlineConfig>( + { + root: target.root, + configFile: false, + envDir: false, + publicDir: false, + mode: target.mode, + logLevel: 'warn', + customLogger: { + info: () => {}, + warn: warnBoth, + warnOnce: warnBoth, + error: (message) => { + if (!/Build failed in/.test(message)) { + errors.push(message) + } + }, + clearScreen: () => {}, + hasErrorLogged: () => false, + hasWarned: false, + }, + environments: { + client: environmentBuild('client'), + ssr: environmentBuild('ssr'), + }, + plugins: [ + startPlugins( + target.framework, + target.root, + target.start, + harnessEntries(target.root), + ), + // A React app's own Vite plugin, as in every React Start app, + // unless the test configures it + ...(target.framework === 'react' && + !pluginNames(target.viteConfig?.plugins).some((name) => + name.startsWith('vite:react'), + ) + ? [react()] + : []), + outputPlugin, + appOnwarnPlugin, + ...(target.mode === 'production' + ? [ + recordViteModules(clientParsedModules, { + environment: 'client', + }), + ] + : []), + ], + }, + target.viteConfig ?? {}, + ), + ) + await builder.buildApp() + } catch (error) { + throw new BuildError( + 'vite', + [...errors, error instanceof Error ? error.message : String(error)].map( + stripAnsi, + ), + warnings.client, + ) + } finally { + process.chdir(cwd) + } + return checkOutputs(outputs) +} + +/** A handler of Rolldown warnings (`build.rolldownOptions.onwarn`). */ +type Onwarn = ( + warning: { message: string; code?: string }, + handler?: (warning: { message: string }) => void, +) => void + +/** + * Builds with Rsbuild. Compilation warnings go to `warnings` (per + * environment) and to `channel`; errors reach the channel through the + * rejection (`buildAt`), which carries them. + */ +async function buildWithRsbuild( + target: BuildTarget, + warnings: Record<Env, Array<ChannelDiagnostic>>, + channel: Channel, +): Promise<Outputs> { + const { createRsbuild, mergeRsbuildConfig } = await import('@rsbuild/core') + const outputs: Partial<Outputs> = {} + const errors: Array<string> = [] + /** The compiles of a watch mode build. */ + const compiles = trackCompiles() + /** The evidence of the client's dangling-name check (`describeBuild`). */ + const clientParsedModules = parsedModules() + /** Records what each environment emitted. */ + const outputPlugin: RsbuildPlugin = { + name: 'start-build-harness:outputs', + setup(api) { + api.modifyRspackConfig((config, { environment }) => { + if (environment.name === 'client' && target.mode === 'production') { + config.plugins.push(recordParsedModules(clientParsedModules)) + } + }) + api.onAfterCreateCompiler(({ compiler }) => { + compiles.track(compiler) + for (const child of 'compilers' in compiler + ? compiler.compilers + : [compiler]) { + channel.scopeRspack(child) + // Each compile's report, once, before Rsbuild's logger prints its + // summary of it (`reportLogged`) + child.hooks.done.tap( + { name: 'start-build-harness:report', stage: -100 }, + (stats) => { + // (each message with the module it is about, as Rspack's + // stats name it) + const json = stats.toJson(statsOptions) as StatsJson + channel.reportCompilation({ + errors: statsMessages(json.errors), + warnings: statsMessages(json.warnings), + }) + }, + ) + } + }) + api.onAfterBuild(() => { + compiles.done() + }) + api.onAfterEnvironmentCompile(({ stats, environment }) => { + const env = environment.name as Env + if (!stats) { + errors.push(`[${env}] no compilation stats`) + return + } + const json = stats.toJson(statsOptions) as StatsJson + warnings[env].push(...statsDiagnostics(json.warnings, 'warning')) + errors.push( + ...statsMessages(json.errors).map((message) => `[${env}] ${message}`), + ) + outputs[env] = { + outDir: environment.distPath, + chunks: chunksOfStats(json, { + entry: configuredEntry(environment.entry, env), + extension: '.js', + }), + esModules: environment.config.output.module, + ...(env === 'client' && { parsedModules: clientParsedModules }), + } + }) + }, + } + try { + const rsbuild = await createRsbuild({ + cwd: target.root, + loadEnv: false, + rsbuildConfig: mergeRsbuildConfig( + { + root: target.root, + mode: target.mode, + // Rsbuild prints nothing; its logger feeds the channel + logLevel: 'silent', + customLogger: rsbuildLogger(channel), + output: { + minify: target.minify, + sourceMap: target.sourcemap ? { js: 'source-map' } : false, + cleanDistPath: true, + }, + plugins: [...rsbuildAppPlugins(target), outputPlugin], + }, + target.rsbuildConfig ?? {}, + ), + }) + if (target.watchEdits) { + const watching = await rsbuild.build({ watch: true }) + try { + await compiles.first(watchTimeout) + errors.length = 0 + warnings.client.length = 0 + warnings.ssr.length = 0 + describedFrom.set(channel, channel.mark()) + // (the violations the rebuild reports) + target.violations.length = 0 + await compiles.edit(target.root, target.watchEdits, watchTimeout) + } finally { + await watching.close() + } + } else { + await rsbuild.build() + } + } catch (error) { + throw new BuildError( + 'rspack', + errors.length + ? errors + : [error instanceof Error ? error.message : String(error)], + warnings.client, + ) + } + if (errors.length) { + throw new BuildError('rspack', errors, warnings.client) + } + return checkOutputs(outputs) +} + +/** The plugins of the app's `rsbuild.config.ts`. */ +function rsbuildAppPlugins(target: BuildTarget) { + return [ + // A React app's own Rsbuild plugin, as in every React Start app, + // unless the test configures it + ...(target.framework === 'react' && + !pluginNames(target.rsbuildConfig?.plugins).includes('rsbuild:react') + ? [pluginReact()] + : []), + startRsbuildPlugin( + target.framework, + target.root, + target.start, + harnessEntries(target.root), + ), + ] +} + +/** + * Serves the last Rsbuild build of the app as `rsbuild preview` does in the + * app's directory, with the app's configuration of the build. + */ +async function previewWithRsbuild( + target: BuildTarget, + registerCleanup: (cleanup: () => Promise<void>) => void, +): Promise<{ url: string }> { + const { createRsbuild, mergeRsbuildConfig } = await import('@rsbuild/core') + const rsbuild = await createRsbuild({ + cwd: target.root, + loadEnv: false, + rsbuildConfig: mergeRsbuildConfig( + { + root: target.root, + mode: target.mode, + logLevel: 'silent', + server: { host: '127.0.0.1' }, + // Absolute: Start's preview middleware imports the server build + // from the output directory, which it resolves against the + // process's working directory when the first request comes + output: { distPath: { root: path.join(target.root, 'dist') } }, + plugins: rsbuildAppPlugins(target), + }, + target.rsbuildConfig ?? {}, + ), + }) + const { server, urls } = await rsbuild.preview({ getPortSilently: true }) + registerCleanup(() => server.close()) + const url = urls[0] + if (!url) { + throw new Error('the preview server does not listen') + } + return { url } +} + +/** + * The name of the one entry Start configured for an environment (Rsbuild's + * `environment.entry`, the configured inputs), whose chunks the page or the + * server loads first. + */ +function configuredEntry(entry: Record<string, unknown>, env: Env): string { + const names = Object.keys(entry) + if (names.length !== 1) { + throw new Error( + `expected one configured entry of the ${env} environment, got ${names.join(', ') || 'none'}`, + ) + } + return names[0]! +} + +/** + * How long a watch mode build waits for a compile: only a guard against a + * compile that never comes (see `trackCompiles`). + */ +const watchTimeout = 20_000 + +function checkOutputs(outputs: Partial<Outputs>): Outputs { + if (!outputs.client || !outputs.ssr) { + throw new Error( + `expected client and SSR outputs, got ${Object.keys(outputs).join(', ') || 'none'}`, + ) + } + return outputs as Outputs +} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts index fa48668a38..06545af30b 100644 --- a/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts +++ b/packages/start-plugin-core/tests/clientOnlyJSX/clientOnlyJSX.test.ts @@ -1,105 +1,228 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' import { describe, expect, test } from 'vitest' +import { renderServer, renderSource, useHydrateHost } from '../render' -import { - detectKindsInCode, - StartCompiler, -} from '../../src/start-compiler/compiler' -import { formatSnapshot } from '../format-snapshot' +const hosts = useHydrateHost() -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', +// On the server, `<ClientOnly>` (of a TanStack router package) renders its +// fallback: the server output drops its children and the imports only they +// use, whatever the imported module is (packages and neutral project +// modules here), so the server never loads them (SPEC J4.11, G16): in the +// Start app, the libraries the children use throw when they load. +// Rendered by the SSR environment of the public Start plugin with React's +// server renderer and the real `ClientOnly` of `@tanstack/react-router` +// (which renders its fallback whenever it renders on a server), the server +// output renders what the uncompiled source renders there (a plain Vite +// host, `render.ts`). The client keeps the children: it renders them once +// the page hydrated (integration/clientOnlyJSX.test.ts). Other components +// named ClientOnly are left alone. +// Replaces the former snapshot fixtures of this directory. +describe('<ClientOnly> children', () => { + /** + * The libraries the fixtures import (plain text components): the source + * of each export, by module (packages of the app, or project modules). + */ + const libraries: Record<string, Record<string, string>> = { + 'heavy-chart-library': { Chart: `() => 'chart'` }, + './utils': { formatData: `() => 'data'` }, + 'video-player-lib': { VideoPlayer: `() => 'video'` }, + 'audio-viz-lib': { AudioVisualizer: `() => 'audio'` }, + 'animation-library': { HeavyAnimation: `() => 'animation'` }, + './WindowSize': { WindowSize: `() => 'size'` }, + 'outer-lib': { OuterWidget: `() => 'outer'` }, + 'inner-lib': { InnerWidget: `() => 'inner'` }, + 'some-other-package': { ClientOnly: `(props) => props.children ?? null` }, } -} - -async function compile(opts: { - env: 'client' | 'server' - code: string - id: string -}) { - const compiler = new StartCompiler({ - ...opts, - ...getDefaultTestOptions(opts.env), - loadModule: async () => { - // do nothing in test - }, - lookupKinds: new Set(['ClientOnlyJSX']), - lookupConfigurations: [ - // ClientOnly JSX component from TanStack router packages - { - libName: '@tanstack/react-router', - rootExport: 'ClientOnly', - kind: 'ClientOnlyJSX', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (id) => { - return id - }, - }) - const result = await compiler.compile({ - code: opts.code, - id: opts.id, - }) - return result -} - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('ClientOnlyJSX compiles correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), + /** + * The app files of the libraries: a package of the case's own + * `node_modules` for a bare specifier, a project module otherwise. The + * libraries of `childModules` throw when they load, as the server must + * never load them. + */ + const libraryFiles = (childModules: Array<string> = []) => + Object.fromEntries( + Object.entries(libraries).flatMap(([specifier, exports]) => { + const exported = Object.entries(exports) + .map(([name, value]) => `export const ${name} = ${value}\n`) + .join('') + const source = childModules.includes(specifier) + ? `throw new Error('client-only module loaded during SSR: ${specifier}')\n${exported}` + : exported + if (specifier.startsWith('./')) { + return [[`${specifier}.ts`, source]] + } + return [ + [ + `node_modules/${specifier}/package.json`, + JSON.stringify({ + name: specifier, + type: 'module', + exports: './index.js', + }), + ], + [`node_modules/${specifier}/index.js`, source], + ] + }), ) - const code = file.toString() + const render = 'h(m.MyComponent)' - // ClientOnlyJSX is only transformed on server - test(`should compile for ${filename} server`, async () => { - const compiledResult = await compile({ - env: 'server', - code, - id: filename, + test.each([ + { + // Source: snapshot fixture clientOnlyBasic.tsx + name: 'a fallback', + code: `import { ClientOnly } from '@tanstack/react-router' +import { Chart } from 'heavy-chart-library' +import { formatData } from './utils' +export function MyComponent() { + return ( + <div> + <ClientOnly fallback={<div>Loading...</div>}> + <Chart data={formatData()} /> + </ClientOnly> + </div> + ) +}`, + childModules: ['./utils', 'heavy-chart-library'], + ssr: '<div><div>Loading...</div></div>', + }, + { + // Source: snapshot fixture clientOnlyMultiple.tsx + name: 'two boundaries', + code: `import { ClientOnly } from '@tanstack/react-router' +import { VideoPlayer } from 'video-player-lib' +import { AudioVisualizer } from 'audio-viz-lib' +export function MyComponent() { + return ( + <div> + <ClientOnly fallback={<span>Loading video...</span>}> + <VideoPlayer src="/video.mp4" /> + </ClientOnly> + <p>Some server content</p> + <ClientOnly fallback={<span>Loading audio...</span>}> + <AudioVisualizer frequency={440} /> + </ClientOnly> + </div> + ) +}`, + childModules: ['audio-viz-lib', 'video-player-lib'], + ssr: '<div><span>Loading video...</span><p>Some server content</p><span>Loading audio...</span></div>', + }, + { + // Source: snapshot fixture clientOnlyNested.tsx + name: 'a nested boundary', + code: `import { ClientOnly } from '@tanstack/react-router' +import { OuterWidget } from 'outer-lib' +import { InnerWidget } from 'inner-lib' +export function MyComponent() { + return ( + <div> + <ClientOnly fallback={<div>Outer loading</div>}> + <div> + Outer content + <OuterWidget /> + <ClientOnly fallback={<span>Inner loading</span>}> + <InnerWidget /> + </ClientOnly> + </div> + </ClientOnly> + </div> + ) +}`, + childModules: ['inner-lib', 'outer-lib'], + ssr: '<div><div>Outer loading</div></div>', + }, + { + // Source: snapshot fixture clientOnlyNoFallback.tsx + name: 'no fallback', + code: `import { ClientOnly } from '@tanstack/react-router' +import { HeavyAnimation } from 'animation-library' +export function MyComponent() { + return ( + <div> + <ClientOnly> + <HeavyAnimation type="fade" /> + </ClientOnly> + </div> + ) +}`, + childModules: ['animation-library'], + ssr: '<div></div>', + }, + { + // Source: snapshot fixture clientOnlyRenamed.tsx + name: 'a renamed import', + code: `import { ClientOnly as CO } from '@tanstack/react-router' +import { WindowSize } from './WindowSize' +export function MyComponent() { + return ( + <div> + <CO fallback={<div>Loading...</div>}> + <WindowSize /> + </CO> + </div> + ) +}`, + childModules: ['./WindowSize'], + ssr: '<div><div>Loading...</div></div>', + }, + ])( + 'a boundary with $name renders its fallback on the server without loading its children', + async ({ code, childModules, ssr }) => { + const started = await hosts() + const source = await renderSource(started, code, { + render, + files: libraryFiles(), }) + const server = await renderServer(started, code, { + render, + files: libraryFiles(childModules), + }) + expect(server.html).toBe(source.html) + expect(server.html).toBe(ssr) + }, + ) - if (compiledResult) { - await expect( - await formatSnapshot(compiledResult.code, filename), - ).toMatchFileSnapshot(`./snapshots/server/${filename}`) - } else { - // No transformation - for files where ClientOnly is not from TanStack - await expect('no-transform').toMatchFileSnapshot( - `./snapshots/server/${filename}`, - ) - } + test.each([ + { + // Source: snapshot fixture clientOnlyNotFromTanstack.tsx + name: 'a ClientOnly of another package', + code: `import { ClientOnly } from 'some-other-package' +export function MyComponent() { + return ( + <div> + <ClientOnly fallback={<div>Loading...</div>}> + <div>This should remain as-is</div> + </ClientOnly> + </div> + ) +}`, + html: '<div><div>This should remain as-is</div></div>', + }, + { + // Source: snapshot fixture clientOnlyWrongImportName.tsx, with + // `CatchBoundary` instead of `Link`: the real `Link` needs a router + // around it, `CatchBoundary` renders its children anywhere. + name: 'another router component imported as ClientOnly', + code: `import { CatchBoundary as ClientOnly } from '@tanstack/react-router' +export function MyComponent() { + return ( + <div> + <ClientOnly getResetKey={() => 'about'}>Go to About</ClientOnly> + </div> + ) +}`, + html: '<div>Go to About</div>', + }, + ])('the server renders the children of $name', async ({ code, html }) => { + const started = await hosts() + const source = await renderSource(started, code, { + render, + files: libraryFiles(), }) - }) - - test('ClientOnlyJSX should not be detected on client', () => { - const code = ` - import { ClientOnly } from '@tanstack/react-router' - <ClientOnly>test</ClientOnly> - ` - const detectedKinds = detectKindsInCode(code, 'client') - expect(detectedKinds.has('ClientOnlyJSX')).toBe(false) - }) - - test('ClientOnlyJSX should be detected on server', () => { - const code = ` - import { ClientOnly } from '@tanstack/react-router' - <ClientOnly>test</ClientOnly> - ` - const detectedKinds = detectKindsInCode(code, 'server') - expect(detectedKinds.has('ClientOnlyJSX')).toBe(true) + const server = await renderServer(started, code, { + render, + files: libraryFiles(), + }) + expect(server.html).toBe(source.html) + expect(server.html).toBe(html) }) }) diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx deleted file mode 100644 index 96de7844f6..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyBasic.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<div>Loading...</div>} /> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx deleted file mode 100644 index 6b95090d3f..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyMultiple.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<span>Loading video...</span>} /> - <p>Some server content</p> - <ClientOnly fallback={<span>Loading audio...</span>} /> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx deleted file mode 100644 index f3d5d3b526..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNested.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<div>Outer loading</div>} /> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx deleted file mode 100644 index 40551a6dad..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNoFallback.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -export function MyComponent() { - return ( - <div> - <ClientOnly /> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNotFromTanstack.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNotFromTanstack.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyNotFromTanstack.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx deleted file mode 100644 index 9a537448b0..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyRenamed.tsx +++ /dev/null @@ -1,9 +0,0 @@ -// Test: ClientOnly imported with an alias should still be transformed -import { ClientOnly as CO } from '@tanstack/react-router' -export function MyComponent() { - return ( - <div> - <CO fallback={<div>Loading...</div>} /> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyWrongImportName.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyWrongImportName.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/snapshots/server/clientOnlyWrongImportName.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyBasic.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyBasic.tsx deleted file mode 100644 index 29cc888830..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyBasic.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -import { Chart } from 'heavy-chart-library' -import { formatData } from './utils' - -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<div>Loading...</div>}> - <Chart data={formatData()} /> - </ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyMultiple.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyMultiple.tsx deleted file mode 100644 index f3712aa7b3..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyMultiple.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -import { VideoPlayer } from 'video-player-lib' -import { AudioVisualizer } from 'audio-viz-lib' - -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<span>Loading video...</span>}> - <VideoPlayer src="/video.mp4" /> - </ClientOnly> - <p>Some server content</p> - <ClientOnly fallback={<span>Loading audio...</span>}> - <AudioVisualizer frequency={440} /> - </ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNested.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNested.tsx deleted file mode 100644 index 222def8795..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNested.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' - -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<div>Outer loading</div>}> - <div> - Outer content - <ClientOnly fallback={<span>Inner loading</span>}> - <span>Inner client only</span> - </ClientOnly> - </div> - </ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNoFallback.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNoFallback.tsx deleted file mode 100644 index a76c0fde46..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNoFallback.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { ClientOnly } from '@tanstack/react-router' -import { HeavyAnimation } from 'animation-library' - -export function MyComponent() { - return ( - <div> - <ClientOnly> - <HeavyAnimation type="fade" /> - </ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNotFromTanstack.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNotFromTanstack.tsx deleted file mode 100644 index 06fc40a1b9..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyNotFromTanstack.tsx +++ /dev/null @@ -1,12 +0,0 @@ -// This should NOT be transformed because ClientOnly is not from @tanstack/*-router -import { ClientOnly } from 'some-other-package' - -export function MyComponent() { - return ( - <div> - <ClientOnly fallback={<div>Loading...</div>}> - <div>This should remain as-is</div> - </ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyRenamed.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyRenamed.tsx deleted file mode 100644 index 311c9e1b86..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyRenamed.tsx +++ /dev/null @@ -1,13 +0,0 @@ -// Test: ClientOnly imported with an alias should still be transformed -import { ClientOnly as CO } from '@tanstack/react-router' -import { WindowSize } from './WindowSize' - -export function MyComponent() { - return ( - <div> - <CO fallback={<div>Loading...</div>}> - <WindowSize /> - </CO> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyWrongImportName.tsx b/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyWrongImportName.tsx deleted file mode 100644 index 4bd777c079..0000000000 --- a/packages/start-plugin-core/tests/clientOnlyJSX/test-files/clientOnlyWrongImportName.tsx +++ /dev/null @@ -1,11 +0,0 @@ -// Test: A different component imported from TanStack should NOT be transformed -// even if aliased to "ClientOnly" - we check the original import name -import { Link as ClientOnly } from '@tanstack/react-router' - -export function MyComponent() { - return ( - <div> - <ClientOnly to="/about">Go to About</ClientOnly> - </div> - ) -} diff --git a/packages/start-plugin-core/tests/compiler-inputs.ts b/packages/start-plugin-core/tests/compiler-inputs.ts new file mode 100644 index 0000000000..2c394c5cbb --- /dev/null +++ b/packages/start-plugin-core/tests/compiler-inputs.ts @@ -0,0 +1,631 @@ +/** + * Inputs of Start compiler rows that run in both modes: on the dev server + * (start-compiler-factories.test.ts, compiler.test.ts, + * createServerFn/handler-scope.test.ts, createServerFn/createServerFn.test.ts, + * integration/pages/start-compiler-import-forms.test.ts, and the dev edits + * of known-bugs-start-compiler.test.ts) and in production builds + * (integration/start-compiler-build-inputs.test.ts; the edits in an Rsbuild + * watch build). Each gives the modules a user writes and what its rows + * expect; how each mode observes it is the test file's. + */ +import { throwsError } from './diagnostics' +import type { Plugin } from 'vite' + +/** The server-only module the factory rows read (`./db.server`). */ +export const factoryDb = { + 'db.server.ts': `export const db = { x: () => 'x', y: () => 'y', w: () => 'w', log: () => {} }\n`, +} + +/** + * A factory or builder that a project module defines or re-exports, and a + * module (`code`) that uses it: the client loads no server-only module + * (`output: 'client'`), and the module gives its importers `serverFns` + * server fns (`fn`, whose handler returns `'x'`); `iso`, where the module + * has it, runs each environment's implementation (`'client'`, `'w'`). + */ +export interface FactoryRow { + name: string + output: 'client' | 'ssr' + files: Record<string, string> + code: string + serverFns: number +} + +export const factoryRows: Array<FactoryRow> = [ + { + name: 'a default-exported middleware builder imported as default', + output: 'client', + files: { + 'mw.ts': `import { createMiddleware } from '@tanstack/react-start' +export default createMiddleware({ type: 'function' })`, + }, + // Known limitation on main: middleware is detected by the + // `createMiddleware` text, so a module that only calls an imported + // builder is not compiled and needs this import. + code: `import { createMiddleware } from '@tanstack/react-start' +import mw from './mw' +import { db } from './db.server' +export const logged = mw.server(async ({ next }) => { +db.log() +return next() +})`, + serverFns: 0, + }, + { + name: 'a default-exported server fn builder declared by identifier', + output: 'client', + files: { + 'builders.ts': `import { createServerFn } from '@tanstack/react-start' +const authed = createServerFn({ method: 'POST' }) +export default authed`, + }, + code: `import authed from './builders' +import { db } from './db.server' +export const fn = authed.handler(async () => db.x())`, + serverFns: 1, + }, + ...(['client', 'ssr'] as const).map((output) => ({ + name: 'a namespace import of a module re-exporting the factories', + output, + files: { + 'factories.ts': `export { createServerFn, createIsomorphicFn } from '@tanstack/react-start'`, + }, + code: `import * as F from './factories' +import { db } from './db.server' +export const fn = F.createServerFn().handler(async () => db.x()) +export const iso = F.createIsomorphicFn().server(() => db.w()).client(() => 'client')`, + serverFns: 1, + })), + { + name: 'a namespace import of a module re-exporting createMiddleware', + output: 'client', + files: { + 'middleware.ts': `export { createMiddleware } from '@tanstack/react-start'`, + }, + code: `import * as M from './middleware' +import { db } from './db.server' +export const logged = M.createMiddleware({ type: 'function' }).server(async ({ next }) => { +db.log() +return next() +})`, + serverFns: 0, + }, + { + name: 'renamed re-exports next to a type-only re-export', + output: 'client', + files: { + 'f.ts': `export { createServerFn as csf, createServerOnlyFn as so } from '@tanstack/react-start' +export type { Register } from '@tanstack/react-start' +export type * as types from '@tanstack/react-start'`, + }, + code: `import { csf, so } from './f' +import type * as F from './f' +import { db } from './db.server' +export const fn = csf().handler(async () => db.x() as F.types.Register) +export const s = so(() => db.y())`, + serverFns: 1, + }, + { + // Replaces createServerFn.test.ts "should use slow path for factory + // pattern". + name: 'a server fn factory const-aliased in another module', + output: 'client', + files: { + 'factory.ts': `import { createServerFn } from '@tanstack/react-start' +export const createFooServerFn = createServerFn`, + }, + code: `import { createFooServerFn } from './factory' +import { db } from './db.server' +export const fn = createFooServerFn().handler(async () => db.x())`, + serverFns: 1, + }, +] + +/** + * A module importing createServerFn and createServerOnlyFn through `./start`, + * an `export *` chain (`exportStarRows`): its server fn `fn` returns `'x'`, + * and `serverOnly` is the server-only fn of the package where the chain + * resolves to it (`resolvesServerOnlyFn`), else the project's own plain + * function. + */ +export const exportStarModule = `import { createServerFn, createServerOnlyFn } from './start' +import { db } from './db.server' +export const fn = createServerFn().handler(async () => db.x()) +export const serverOnly = createServerOnlyFn(() => 'server-only-marker')` + +export interface ExportStarRow { + name: string + files: Record<string, string> + resolvesServerOnlyFn: boolean +} + +// Source: @vitejs/plugin-rsc expand-export-all fixtures (per row) +export const exportStarRows: Array<ExportStarRow> = [ + { + // expand-export-all/explicit-wins + name: 'a local export that overrides the star export', + files: { + 'start.ts': `export * from '@tanstack/react-start' +export function createServerOnlyFn(fn) { +return fn +}`, + }, + resolvesServerOnlyFn: false, + }, + { + // expand-export-all/nested-conflict-explicit-reexport-wins + name: 'an explicit re-export that overrides a star export', + files: { + 'start.ts': `export * from './custom' +export { createServerFn, createServerOnlyFn } from '@tanstack/react-start'`, + 'custom.ts': `export function createServerOnlyFn(fn) { +return fn +}`, + }, + resolvesServerOnlyFn: true, + }, + { + // expand-export-all/bad-resolve. The star export names a module the + // bundler's resolver gives no id for (Vite resolves no `data:` URL; the + // browser and Node import it themselves), so a compiler following the + // chain cannot read it and must go on with the other star export. A + // star export to a missing file is not usable: it fails every real + // build and every dev page. + name: 'an unresolvable star export next to the package', + files: { + 'start.ts': `export * from 'data:text/javascript,export const unrelated = 1' +export * from '@tanstack/react-start'`, + 'data-modules.d.ts': `declare module 'data:text/javascript,*' { +export const unrelated: number +} +`, + }, + resolvesServerOnlyFn: true, + }, + { + // expand-export-all/duplicate-star-same-source + name: 'the same module re-exported twice', + files: { + 'start.ts': `export * from './inner' +export * from './inner'`, + 'inner.ts': `export * from '@tanstack/react-start'`, + }, + resolvesServerOnlyFn: true, + }, + { + // expand-export-all/namespace-same-binding + name: 'two star exports that each forward part of the package', + files: { + 'start.ts': `export * from './a' +export * from './b'`, + 'a.ts': `export { createServerFn } from '@tanstack/react-start'`, + 'b.ts': `export { createServerOnlyFn } from '@tanstack/react-start'`, + }, + resolvesServerOnlyFn: true, + }, +] + +/** + * Only createServerOnlyFn appears in the module's text; createClientOnlyFn + * comes through an aliased re-export (`./env`). On the server, `serverValue` + * returns `'secret'` and calling `clientValue` throws. + */ +export const aliasedClientOnlyFiles = { + 'module.tsx': `import { createServerOnlyFn } from '@tanstack/react-start' +import { clientOnly } from './env' +import { secret } from './secret.server' +import { readWindow } from './browser' +export const serverValue = createServerOnlyFn(() => secret()) +export const clientValue = clientOnly(() => readWindow())`, + 'env.ts': `export { createClientOnlyFn as clientOnly } from '@tanstack/react-start'`, + 'secret.server.ts': `export const secret = () => 'secret'\n`, + 'browser.ts': `export const readWindow = () => 'window'\n`, +} + +/** + * Third-party packages of the app that import Start's factories from + * `@tanstack/start-client-core` (TanStack/router#6583): real packages in the + * app's `node_modules`, which the app compiles with its own code (a library + * shipping Start factories is left out of dependency pre-bundling and SSR + * externalization, as such an app configures it). + */ +export const libraryPackages = { + 'node_modules/@third-party/lib/package.json': JSON.stringify({ + name: '@third-party/lib', + type: 'module', + main: './index.js', + peerDependencies: { '@tanstack/start-client-core': '*' }, + }), + 'node_modules/@third-party/lib/index.js': `import { createIsomorphicFn, createClientOnlyFn } from '@tanstack/start-client-core' + +export const getThemeData = createIsomorphicFn() + .client(() => 'client-theme') + .server(() => 'server-theme') + +export const initClientFeature = createClientOnlyFn(() => { + console.log('client only initialization') + return 'initialized' +}) +`, + 'node_modules/@another-intermediate/pkg/package.json': JSON.stringify({ + name: '@another-intermediate/pkg', + type: 'module', + main: './index.js', + peerDependencies: { '@tanstack/start-client-core': '*' }, + }), + 'node_modules/@another-intermediate/pkg/index.js': `export { createIsomorphicFn } from '@tanstack/start-client-core'\n`, +} +export const compiledLibraries = [ + '@third-party/lib', + '@another-intermediate/pkg', +] + +/** + * What the exports of `@third-party/lib` give in each environment, through + * its re-export chain to Start's package (`libraryPackages`). + */ +export const libraryChainRows: Array<{ + env: 'client' | 'server' + fn: string + /** What the export returns, or the error it throws. */ + value: unknown + /** Implementation code the served library must not contain. */ + absent?: string +}> = [ + { + env: 'client', + fn: 'createIsomorphicFn', + value: 'client-theme', + absent: 'server-theme', + }, + { + env: 'server', + fn: 'createIsomorphicFn', + value: 'server-theme', + absent: 'client-theme', + }, + { + env: 'client', + fn: 'createClientOnlyFn', + value: 'initialized', + }, + { + env: 'server', + fn: 'createClientOnlyFn', + value: throwsError, + absent: 'client only initialization', + }, +] + +/** + * A module importing createIsomorphicFn through another intermediate package + * (`@another-intermediate/pkg`): the client runs `'deep-client'`, and the + * server implementation (`'deep-server'`) is not in the client. + */ +export const deeperChainModule = `import { createIsomorphicFn } from '@another-intermediate/pkg' +export const deepFn = createIsomorphicFn() + .client(() => 'deep-client') + .server(() => 'deep-server')` + +/** + * Re-export cycles a module imports createServerOnlyFn through + * (`cycleModule`): they never reach a Start factory (they cannot even link + * as ES modules), so compiling settles, with a result or an error, instead + * of looping. + */ +export const cycleModule = `import { createServerOnlyFn } from './factory-a' +export const myFn = createServerOnlyFn(() => 'server-only-value')` + +export const reexportCycles: Array<{ + name: string + files: Record<string, string> +}> = [ + { + name: 'named re-export cycle', + files: { + 'factory-a.ts': `export { createServerOnlyFn } from './factory-b'\n`, + 'factory-b.ts': `export { createServerOnlyFn } from './factory-a'\n`, + }, + }, + { + name: 'import alias cycle', + files: { + 'factory-a.ts': `import { createServerOnlyFn } from './factory-b' +export { createServerOnlyFn } +`, + 'factory-b.ts': `import { createServerOnlyFn } from './factory-a' +export { createServerOnlyFn } +`, + }, + }, + { + name: 'export-star cycle', + files: { + 'factory-a.ts': `export * from './factory-b'\n`, + 'factory-b.ts': `export * from './factory-a'\n`, + }, + }, +] + +/** The server-only modules the handler rows may read, as real files. */ +export const handlerFiles = { + 'db.server.ts': `export const db = { x: () => 'x', y: () => 'y' }\n`, + 'auth.server.ts': `export const withAuth = (fn: (opts: unknown) => Promise<unknown>) => async (opts: unknown) => 'auth:' + (await fn(opts))\n`, + 'users.server.ts': `export const getUsers = async () => 'users'\n`, +} +export const handlerModules = ['./db.server', './auth.server', './users.server'] + +/** + * The module of a handler row: `code` (which declares the server fn `fn`) + * after its imports of createServerFn and, when it reads `db`, of + * `./db.server`. + */ +export const handlerModule = (code: string) => + `import { createServerFn } from '@tanstack/react-start'\n${code.includes('db.') ? `import { db } from './db.server'\n` : ''}${code}` + +/** + * How a handler may be written: the server fn `fn` of `handlerModule(code)` + * returns `expected` (an async iterable of its values with `iterate`), + * whoever calls it. + */ +export interface HandlerRow { + name: string + code: string + expected: unknown + iterate?: boolean +} + +export const handlerRows: Array<HandlerRow> = [ + { + // Source: Next.js server-actions fixtures server-graph/7, /44 + name: 'a named function expression', + code: `export const fn = createServerFn().handler(async function deleteItem() { + return deleteItem.name + db.x() +})`, + expected: 'deleteItemx', + }, + { + // Start calls the handler with one argument, its context (`this` is + // runtime-defined: Start calls it as a method of its options). + // Source: Next.js server-actions fixtures server-graph/59 + name: 'a function using arguments and new.target', + code: `export const fn = createServerFn().handler(async function () { + return [arguments.length, new.target === undefined, db.x()] +})`, + expected: [1, true, 'x'], + }, + { + // Source: Next.js server-actions fixtures server-graph/14 (streaming) + name: 'an async generator', + code: `export const fn = createServerFn().handler(async function* () { + yield db.x() + yield 'done' +})`, + iterate: true, + expected: ['x', 'done'], + }, + { + // Source: Next.js server-actions fixtures server-graph/31 + name: 'an object literal method', + code: `const handlers = { + async f() { + return db.x() + }, +} +export const fn = createServerFn().handler(handlers.f)`, + expected: 'x', + }, + { + // Source: Next.js server-actions fixtures server-graph/21, /26 + name: 'a wrapper call', + code: `import { withAuth } from './auth.server' +export const fn = createServerFn().handler(withAuth(async () => db.x()))`, + expected: 'auth:x', + }, + { + // Source: Next.js server-actions fixtures server-graph/25 + name: 'a function declared after the server fn', + code: `export const fn = createServerFn().handler(impl) +async function impl() { + return inner() + async function inner() { + return db.x() + } +}`, + expected: 'x', + }, + { + // Source: Next.js server-actions fixtures server-graph/28, /30 + name: 'a call of a server fn declared later', + code: `export const fn = createServerFn().handler(async () => (await later()) + db.x()) +export const later = createServerFn().handler(async () => 'later:')`, + expected: 'later:x', + }, + { + // Replaces createServerFn.test.ts "should remove imports used only as + // caller handler identifiers". + name: 'an imported function', + code: `import { getUsers } from './users.server' +export const fn = createServerFn().handler(getUsers)`, + expected: 'users', + }, + { + name: 'an initializer cast with as unknown as', + code: `export const fn = createServerFn().handler(async () => db.x()) as unknown as () => Promise<string>`, + expected: 'x', + }, + { + // Source: TanStack/router#3698 + name: 'a body calling other methods named handler', + code: `const local = { handler: (value: string) => value + '!' } +export const fn = createServerFn().handler(async () => + local.handler([db].map((source) => ({ handler: source.y }))[0]!.handler() + db.x()), +)`, + expected: 'yx!', + }, +] + +/** + * A user plugin serving two virtual modules that differ only by their + * `variant` query: the public one re-exports the factory the + * implementation one defines. It reads its own query parameter and ignores + * any other (a plugin of query-bearing modules does). + */ +export function virtualFactories(): Plugin { + const prefix = '\0virtual:server-fn-factory?' + const modules: Record<string, string> = { + public: `import { createIssueServerFn } from 'virtual:server-fn-factory?variant=implementation' +export { createIssueServerFn }`, + implementation: `import { createServerFn } from '@tanstack/react-start' +export const createIssueServerFn = createServerFn`, + } + return { + name: 'test:virtual-server-fn-factories', + resolveId: (source) => + source.startsWith('virtual:server-fn-factory?') ? `\0${source}` : null, + load: (id) => { + if (!id.startsWith(prefix)) { + return null + } + const variant = new URLSearchParams(id.slice(prefix.length)).get( + 'variant', + ) + return variant ? (modules[variant] ?? null) : null + }, + } +} + +/** + * A module whose server fn builder comes from the public module of + * `virtualFactories` (`issueServerFn`, whose handler returns + * `'issue-handler'`). + */ +export const queryDistinctModule = `import { createIssueServerFn } from 'virtual:server-fn-factory?variant=public' +export const issueServerFn = createIssueServerFn().handler(async () => 'issue-handler')` + +/** + * Server fn builders with middleware called as factories (one chained off + * another): `myAuthedFn` and `deleteUserFn` return their name and the + * context their factory chain's middleware gives (`{ auth }`, then + * `{ auth, admin }`), and their handler bodies (`MARK_*_HANDLER_BODY`) stay + * off the client; the look-alike `createFakeFn().handler` is left alone + * (`x` is `'fakeFn'`). + */ +export const factoryBuilderModule = `import { createServerFn, createMiddleware } from '@tanstack/react-start' +const authMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => next({ context: { auth: 'auth' } }), +) +const adminMiddleware = createMiddleware({ type: 'function' }).server( + ({ next }) => next({ context: { admin: 'admin' } }), +) +export const createAuthServerFn = createServerFn().middleware([authMiddleware]) +const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) +export const myAuthedFn = createAuthServerFn().handler(({ context }) => { + return ['myAuthedFn', context, 'MARK_AUTHED_HANDLER_BODY'].slice(0, 2) +}) +export const deleteUserFn = createAdminServerFn().handler(({ context }) => { + return ['deleteUserFn', context, 'MARK_DELETE_HANDLER_BODY'].slice(0, 2) +}) +function createFakeFn() { + return { + handler: (cb) => { + return cb() + }, + } +} +export const x = createFakeFn().handler(() => { + return 'fakeFn' +})` + +/** + * The import forms of integration/pages/start-compiler-import-forms.test.ts: + * the real modules its constructs read, and how a construct's factory is + * imported and its call written. + */ +export const moduleFiles = { + 'db.server.ts': `export const db = { x: () => 'x' }\n`, + 'chart.client.ts': `export const chart = () => 'chart'\nexport const Chart = () => '<chart>'\n`, +} + +/** How the factory `name` of `pkg` is imported and its call written. */ +export interface Form { + imports: (pkg: string, name: string) => string + callee: (name: string) => string + wrap: (expression: string) => string +} + +export const forms: Record<string, Form> = { + 'a renamed import': { + imports: (pkg, name) => `import { ${name} as renamed } from '${pkg}'`, + callee: () => 'renamed', + wrap: (expression) => expression, + }, + 'a namespace member': { + imports: (pkg) => `import * as Start from '${pkg}'`, + callee: (name) => `Start.${name}`, + wrap: (expression) => expression, + }, + 'a call result wrapped in as': { + imports: (pkg, name) => `import { ${name} as renamed } from '${pkg}'`, + callee: () => 'renamed', + wrap: (expression) => `(${expression}) as any`, + }, + 'a call result wrapped in satisfies': { + imports: (pkg, name) => `import { ${name} as renamed } from '${pkg}'`, + callee: () => 'renamed', + wrap: (expression) => `(${expression}) satisfies unknown`, + }, +} + +/** The imports a construct's code reads, besides the factory. */ +export const moduleImports = `import { db } from './db.server' +import { chart } from './chart.client'` + +/** + * The createServerFn construct: the export `fn`, created by calling + * `callee` with `method: 'POST'`, whose handler returns `'x'`. + */ +export const serverFnConstruct = (callee: string, wrap: Form['wrap']) => + `export const fn = ${wrap(`${callee}({ method: 'POST' }).handler(async () => db.x())`)}` + +/** + * Edits of a module a factory comes from, which the module using the factory + * does not import directly (`files`, then `edit`): `reexportChain` (the + * module a re-export chain ends in now re-exports createClientOnlyFn under + * the createServerOnlyFn name: `myFn` of `module.tsx` becomes client-only, + * so calling it on the server throws) and `aliasedEnvOnly` (the module that + * renames an env-only factory for a server fn module whose source only + * mentions createServerFn now renames createClientOnlyFn: `serverFn`, which + * returned `'server-only-value'`, throws). + */ +export const factoryEdits = { + reexportChain: { + files: { + 'factory.ts': `export { createServerOnlyFn } from './factory-inner'\n`, + 'factory-inner.ts': `export { createServerOnlyFn } from '@tanstack/react-start'\n`, + 'module.tsx': `import { createServerOnlyFn } from './factory' +export const myFn = createServerOnlyFn(() => 'server-only-value') +`, + }, + edit: { + 'factory-inner.ts': `export { createClientOnlyFn as createServerOnlyFn } from '@tanstack/react-start'\n`, + }, + }, + aliasedEnvOnly: { + files: { + 'factory.ts': `export { createServerOnlyFn as createServerFnHmrFactory } from '@tanstack/react-start'\n`, + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +import { createServerFnHmrFactory } from './factory' + +const serverOnlyImpl = createServerFnHmrFactory(() => 'server-only-value') + +export const serverFn = createServerFn().handler(async () => { + return serverOnlyImpl() +}) +`, + }, + edit: { + 'factory.ts': `export { createClientOnlyFn as createServerFnHmrFactory } from '@tanstack/react-start'\n`, + }, + }, +} diff --git a/packages/start-plugin-core/tests/compiler.test.ts b/packages/start-plugin-core/tests/compiler.test.ts index 68e193204f..f8564a8b09 100644 --- a/packages/start-plugin-core/tests/compiler.test.ts +++ b/packages/start-plugin-core/tests/compiler.test.ts @@ -1,795 +1,186 @@ +/** + * Start compiler behaviour across the modules of one app, re-export chains + * (project modules and packages), dev edits and call-expression forms, + * through the public Start host (`./start-host`). + * + * Main's tests that drove the internal compiler (one compiler instance, + * `invalidateModule`, throwing host hooks, a synthetic `compilerTransforms` + * hook) are not kept: the outcomes they stood for are decided here. + */ import { describe, expect, test } from 'vitest' import { - StartCompiler, - detectKindsInCode, - getLookupKindsForEnv, -} from '../src/start-compiler/compiler' -import { getLookupConfigurationsForEnv } from '../src/start-compiler/config' -import type { LookupConfig, LookupKind } from '../src/start-compiler/compiler' -import type { StartCompilerImportTransform } from '../src/types' + callFromClient, + callServerFnThroughCallers, + fromPage, + inPage, + serveCase, + serverFnUrls, + settle, + throwsError, + useStartHost, +} from './regression-helpers' +import { shapeOf } from './page-values' +import { + compiledLibraries, + cycleModule, + deeperChainModule, + libraryChainRows, + libraryPackages, + reexportCycles, +} from './compiler-inputs' +import type { PageSettled } from './regression-helpers' -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - } -} - -// Helper to create a compiler with all kinds enabled -function createFullCompiler( - env: 'client' | 'server', - opts?: { - serverFnProviderModuleDirectives?: ReadonlyArray<string> | undefined +const host = useStartHost({ + links: ['@tanstack/start-client-core'], + files: libraryPackages, + config: { + optimizeDeps: { exclude: compiledLibraries }, + ssr: { noExternal: compiledLibraries }, }, -) { - const lookupKinds: Set<LookupKind> = - env === 'client' - ? new Set([ - 'ServerFn', - 'Middleware', - 'IsomorphicFn', - 'ServerOnlyFn', - 'ClientOnlyFn', - ]) - : new Set(['ServerFn', 'IsomorphicFn', 'ServerOnlyFn', 'ClientOnlyFn']) - - const lookupConfigurations: Array<LookupConfig> = [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - { - libName: '@tanstack/react-start', - rootExport: 'createMiddleware', - kind: 'Root', - }, - { - libName: '@tanstack/react-start', - rootExport: 'createIsomorphicFn', - kind: 'IsomorphicFn', - }, - { - libName: '@tanstack/react-start', - rootExport: 'createServerOnlyFn', - kind: 'ServerOnlyFn', - }, - { - libName: '@tanstack/react-start', - rootExport: 'createClientOnlyFn', - kind: 'ClientOnlyFn', - }, - ] - - return new StartCompiler({ - env, - ...getDefaultTestOptions(env), - lookupKinds, - lookupConfigurations, - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (id) => id, - mode: 'build', - serverFnProviderModuleDirectives: opts?.serverFnProviderModuleDirectives, - }) -} - -function createExternalTransformCompiler() { - const compilerTransforms: Array<StartCompilerImportTransform> = [ - { - name: 'test-render-option-injection', - environment: 'server', - imports: [ - { - libName: '@example/runtime', - rootExport: 'renderThing', - }, - ], - detect: /\brenderThing\b/, - transform: (candidates, context) => { - const t = context.types - for (const candidate of candidates) { - const args = candidate.path.node.arguments - if (args.length !== 1) continue - args.push( - t.objectExpression([ - t.objectProperty( - t.identifier('injected'), - context.parseExpression('loadThing()'), - ), - ]), - ) - } - }, - }, - ] - - return new StartCompiler({ - env: 'server', - envName: 'server', - root: '/test', - framework: 'react', - providerEnvName: 'server', - lookupKinds: getLookupKindsForEnv('server', { compilerTransforms }), - lookupConfigurations: getLookupConfigurationsForEnv('server', 'react', { - compilerTransforms, - }), - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (id) => id, - mode: 'build', - compilerTransforms, - }) -} - -describe('detectKindsInCode', () => { - describe('detects individual kinds correctly', () => { - test('detects ServerFn via .handler(', () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - const fn = createServerFn().handler(() => 'hello') - ` - expect(detectKindsInCode(code, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code, 'server')).toEqual(new Set(['ServerFn'])) - }) - - test('detects Middleware', () => { - const code = ` - import { createMiddleware } from '@tanstack/react-start' - const mw = createMiddleware().server(({ next }) => next()) - ` - // Middleware is only valid on client - expect(detectKindsInCode(code, 'client')).toEqual(new Set(['Middleware'])) - expect(detectKindsInCode(code, 'server')).toEqual(new Set()) - }) - - test('detects IsomorphicFn', () => { - const code = ` - import { createIsomorphicFn } from '@tanstack/react-start' - const fn = createIsomorphicFn().client(() => 'c').server(() => 's') - ` - expect(detectKindsInCode(code, 'client')).toEqual( - new Set(['IsomorphicFn']), - ) - expect(detectKindsInCode(code, 'server')).toEqual( - new Set(['IsomorphicFn']), - ) - }) - - test('detects ServerOnlyFn', () => { - const code = ` - import { createServerOnlyFn } from '@tanstack/react-start' - const fn = createServerOnlyFn(() => 'server only') - ` - expect(detectKindsInCode(code, 'client')).toEqual( - new Set(['ServerOnlyFn']), - ) - expect(detectKindsInCode(code, 'server')).toEqual( - new Set(['ServerOnlyFn']), - ) - }) - - test('detects ClientOnlyFn', () => { - const code = ` - import { createClientOnlyFn } from '@tanstack/react-start' - const fn = createClientOnlyFn(() => 'client only') - ` - expect(detectKindsInCode(code, 'client')).toEqual( - new Set(['ClientOnlyFn']), - ) - expect(detectKindsInCode(code, 'server')).toEqual( - new Set(['ClientOnlyFn']), - ) - }) - - test('resets external transform regex state between detections', () => { - const compilerTransforms: Array<StartCompilerImportTransform> = [ - { - name: 'global-detect', - environment: 'server', - imports: [{ libName: '@example/runtime', rootExport: 'renderThing' }], - detect: /\brenderThing\b/g, - transform: () => {}, - }, - ] - const code = ` - import { renderThing } from '@example/runtime' - renderThing() - ` - - expect(detectKindsInCode(code, 'server', { compilerTransforms })).toEqual( - new Set(['External:global-detect']), - ) - expect(detectKindsInCode(code, 'server', { compilerTransforms })).toEqual( - new Set(['External:global-detect']), - ) - }) - }) - - describe('detects multiple kinds in same file', () => { - test('detects ServerFn and IsomorphicFn', () => { - const code = ` - import { createServerFn, createIsomorphicFn } from '@tanstack/react-start' - const serverFn = createServerFn().handler(() => 'hello') - const isoFn = createIsomorphicFn().client(() => 'client') - ` - expect(detectKindsInCode(code, 'client')).toEqual( - new Set(['ServerFn', 'IsomorphicFn']), - ) - }) - - test('detects all kinds on client', () => { - const code = ` - import { createServerFn, createMiddleware, createIsomorphicFn, createServerOnlyFn, createClientOnlyFn } from '@tanstack/react-start' - const a = createServerFn().handler(() => {}) - const b = createMiddleware().server(({ next }) => next()) - const c = createIsomorphicFn() - const d = createServerOnlyFn(() => {}) - const e = createClientOnlyFn(() => {}) - ` - expect(detectKindsInCode(code, 'client')).toEqual( - new Set([ - 'ServerFn', - 'Middleware', - 'IsomorphicFn', - 'ServerOnlyFn', - 'ClientOnlyFn', - ]), - ) - }) - - test('detects all valid kinds on server (excludes Middleware)', () => { - const code = ` - import { createServerFn, createMiddleware, createIsomorphicFn, createServerOnlyFn, createClientOnlyFn } from '@tanstack/react-start' - const a = createServerFn().handler(() => {}) - const b = createMiddleware().server(({ next }) => next()) - const c = createIsomorphicFn() - const d = createServerOnlyFn(() => {}) - const e = createClientOnlyFn(() => {}) - ` - // Middleware should NOT be detected on server - expect(detectKindsInCode(code, 'server')).toEqual( - new Set(['ServerFn', 'IsomorphicFn', 'ServerOnlyFn', 'ClientOnlyFn']), - ) - }) - }) - - describe('handles edge cases', () => { - test('returns empty set for code with no matching patterns', () => { - const code = ` - const foo = 'bar' - function hello() { return 'world' } - ` - expect(detectKindsInCode(code, 'client')).toEqual(new Set()) - expect(detectKindsInCode(code, 'server')).toEqual(new Set()) - }) - - test('handles .handler with whitespace variations', () => { - const code1 = `fn.handler(() => {})` - const code2 = `fn.handler (() => {})` - const code3 = `fn.handler\n(() => {})` - const code4 = `fn.handler\t(() => {})` - - expect(detectKindsInCode(code1, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code2, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code3, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code4, 'client')).toEqual(new Set(['ServerFn'])) - }) - - test('handles whitespace between . and handler (reformatted code)', () => { - // When Vite/Babel reformats code, the dot can end up on a previous line - const code1 = `fn.\nhandler(() => {})` - const code2 = `fn.\n handler(() => {})` - const code3 = `fn. \n handler(() => {})` - - expect(detectKindsInCode(code1, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code2, 'client')).toEqual(new Set(['ServerFn'])) - expect(detectKindsInCode(code3, 'client')).toEqual(new Set(['ServerFn'])) - }) - - test('detects createServerFn() call directly', () => { - // The pattern should match createServerFn() calls, not just .handler() - const code = ` - import { createServerFn } from '@tanstack/react-start' - const fn = createServerFn() - ` - expect(detectKindsInCode(code, 'client')).toEqual(new Set(['ServerFn'])) - }) - - test('does not false positive on similar function names', () => { - // Only exact createServerFn( should match, not variations - const code = ` - const fn = createServerFnExample() - const fn2 = createServerFnLike() - const fn3 = mycreateServerFn() - const fn4 = _createServerFn() - ` - expect(detectKindsInCode(code, 'client')).toEqual(new Set()) - }) - - test('does not false positive on similar names', () => { - const code = ` - const myCreateServerFn = () => {} - const createServerFnLike = () => {} - // But this should match: - createServerFn().handler(() => {}) - ` - // Should only match because of .handler(, not because of variable names - expect(detectKindsInCode(code, 'client')).toEqual(new Set(['ServerFn'])) - }) - }) }) -describe('compiler handles multiple files with different kinds', () => { - test('single compiler instance correctly processes files with different kinds in succession', async () => { - const compiler = createFullCompiler('client') +/** + * What `settle` gave in the page for the function `fn` (a page + * expression), as the test reads it. + */ +async function settledInPage( + served: Awaited<ReturnType<typeof serveCase>>, + fn: string, +) { + return fromPage(await inPage<PageSettled>(served, `return settle(${fn})`)) +} +describe('several modules of one app, of different kinds, compile correctly', () => { + test('modules with different kinds in one app', async () => { + const started = await host() // File 1: ServerFn only - const result1 = await compiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const fn = createServerFn().handler(() => 'hello') - `, - id: 'file1.ts', + const file1 = await serveCase( + started, + { + 'file1.ts': `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(() => 'hello')`, + }, + { file: 'file1.ts' }, + ) + expect( + await inPage(file1, 'return typeof module.fn.url', { file: 'file1.ts' }), + ).toBe('string') - detectedKinds: new Set(['ServerFn']), - }) - expect(result1).not.toBeNull() - expect(result1!.code).toContain('createClientRpc') // Client should have RPC stub - expect(result1!.code).not.toContain('createMiddleware') - expect(result1!.code).not.toContain('createIsomorphicFn') - - // File 2: Middleware only - const result2 = await compiler.compile({ - code: ` - import { createMiddleware } from '@tanstack/react-start' - export const mw = createMiddleware().server(({ next }) => { - console.log('server only') - return next() - }) - `, - id: 'file2.ts', - - detectedKinds: new Set(['Middleware']), - }) - expect(result2).not.toBeNull() - // .server() should be stripped on client - expect(result2!.code).not.toContain('console.log') - expect(result2!.code).not.toContain('createServerFn') + // File 2: Middleware only. The client middleware keeps no `.server()`. + const file2 = await serveCase( + started, + { + 'file2.ts': `import { createMiddleware } from '@tanstack/react-start' +export const mw = createMiddleware().server(({ next }) => { + console.log('server only') + return next() +})`, + }, + { file: 'file2.ts' }, + ) + expect( + await inPage(file2, 'return module.mw.options.server === undefined', { + file: 'file2.ts', + }), + ).toBe(true) // File 3: IsomorphicFn only - const result3 = await compiler.compile({ - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - export const fn = createIsomorphicFn() - .client(() => 'client-value') - .server(() => 'server-value') - `, - id: 'file3.ts', - - detectedKinds: new Set(['IsomorphicFn']), - }) - expect(result3).not.toBeNull() - // Client should have client implementation - expect(result3!.code).toContain('client-value') - expect(result3!.code).not.toContain('server-value') + const file3 = await serveCase( + started, + { + 'file3.ts': `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn = createIsomorphicFn() + .client(() => 'client-value') + .server(() => 'server-value')`, + }, + { file: 'file3.ts' }, + ) + expect( + await inPage(file3, 'return module.fn()', { file: 'file3.ts' }), + ).toBe('client-value') // File 4: ServerOnlyFn only - const result4 = await compiler.compile({ - code: ` - import { createServerOnlyFn } from '@tanstack/react-start' - export const fn = createServerOnlyFn(() => 'server only value') - `, - id: 'file4.ts', - - detectedKinds: new Set(['ServerOnlyFn']), - }) - expect(result4).not.toBeNull() - // Client should have error throw - expect(result4!.code).toContain('throw new Error') - expect(result4!.code).not.toContain('server only value') + const file4 = await serveCase( + started, + { + 'file4.ts': `import { createServerOnlyFn } from '@tanstack/react-start' +export const fn = createServerOnlyFn(() => 'server only value')`, + }, + { file: 'file4.ts' }, + ) + expect( + fromPage( + await inPage<PageSettled>(file4, 'return settle(module.fn)', { + file: 'file4.ts', + }), + ), + ).toEqual(throwsError) // File 5: Mix of ServerFn and IsomorphicFn - const result5 = await compiler.compile({ - code: ` - import { createServerFn, createIsomorphicFn } from '@tanstack/react-start' - export const serverFn = createServerFn().handler(() => 'hello') - export const isoFn = createIsomorphicFn().client(() => 'client-iso') - `, - id: 'file5.ts', - - detectedKinds: new Set(['ServerFn', 'IsomorphicFn']), - }) - expect(result5).not.toBeNull() - expect(result5!.code).toContain('createClientRpc') // ServerFn RPC - expect(result5!.code).toContain('client-iso') // IsomorphicFn client impl + const file5 = await serveCase( + started, + { + 'file5.ts': `import { createServerFn, createIsomorphicFn } from '@tanstack/react-start' +export const serverFn = createServerFn().handler(() => 'hello') +export const isoFn = createIsomorphicFn().client(() => 'client-iso')`, + }, + { file: 'file5.ts' }, + ) + expect( + await inPage( + file5, + 'return [typeof module.serverFn.url, module.isoFn()]', + { file: 'file5.ts' }, + ), + ).toEqual(['string', 'client-iso']) }) - test('compiler works correctly when processing same kind multiple times', async () => { - const compiler = createFullCompiler('client') - - // First file with IsomorphicFn - const result1 = await compiler.compile({ - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - export const fn1 = createIsomorphicFn().client(() => 'first') - `, - id: 'first.ts', - - detectedKinds: new Set(['IsomorphicFn']), - }) - expect(result1!.code).toContain('first') - - // Second file with different IsomorphicFn - const result2 = await compiler.compile({ - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - export const fn2 = createIsomorphicFn().client(() => 'second') - `, - id: 'second.ts', - - detectedKinds: new Set(['IsomorphicFn']), - }) - expect(result2!.code).toContain('second') - expect(result2!.code).not.toContain('first') // Should not leak from previous file - }) - - test('server environment excludes Middleware from detected kinds', async () => { - const compiler = createFullCompiler('server') - - // Even if Middleware is in detectedKinds, server env should ignore it - const result = await compiler.compile({ - code: ` - import { createMiddleware } from '@tanstack/react-start' - export const mw = createMiddleware().server(({ next }) => next()) - `, - id: 'middleware.ts', - - // Intentionally including Middleware even though it's server env - detectedKinds: new Set(['Middleware']), - }) - // Should return null since Middleware is not valid on server - expect(result).toBeNull() + test('two modules of the same kind in one app', async () => { + const started = await host() + const first = await serveCase( + started, + { + 'first.ts': `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn1 = createIsomorphicFn().client(() => 'first')`, + }, + { file: 'first.ts' }, + ) + const second = await serveCase( + started, + { + 'second.ts': `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn2 = createIsomorphicFn().client(() => 'second')`, + }, + { file: 'second.ts' }, + ) + expect( + await inPage(first, 'return module.fn1()', { file: 'first.ts' }), + ).toBe('first') + expect( + await inPage(second, 'return module.fn2()', { file: 'second.ts' }), + ).toBe('second') }) }) -describe('compiler handles external import transforms', () => { - test('runs configured direct-call transforms before server function extraction', async () => { - const compiler = createExternalTransformCompiler() - - const result = await compiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - import { renderThing as renderAlias } from '@example/runtime' - - export const getComponent = createServerFn({ method: 'GET' }).handler(async () => { - return renderAlias(<ServerCard />) - }) - `, - id: '/test/src/routes/card.tsx?tss-serverfn-split', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('injected: loadThing()') - expect(result!.code).toContain('renderAlias(<ServerCard />,') +test('a server fn module importing an empty module compiles', async () => { + // In dev, `./empty` is a file the user just emptied (only whitespace + // left). Resolving `base` (a builder in the shape of a server fn) loads + // it. (The module no longer links: `./empty` exports nothing. What is + // checked is the compiler's output for it.) + const startCase = await ( + await host() + ).case({ + 'empty.ts': ' \n\t ', + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +import { base } from './empty' +export const other = base.handler(async () => 'not a server fn') +export const fn = createServerFn().handler(async () => 'server-secret')`, }) - - test('runs configured direct-call transforms for namespace imports', async () => { - const compiler = createExternalTransformCompiler() - - const result = await compiler.compile({ - code: ` - import * as runtime from '@example/runtime' - - export const component = runtime.renderThing(<ServerCard />) - `, - id: '/test/src/routes/card.tsx', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('injected: loadThing()') - expect(result!.code).toContain('runtime.renderThing(<ServerCard />,') - }) - - test('does not run external transforms for shadowed import names', async () => { - const compiler = createExternalTransformCompiler() - - const result = await compiler.compile({ - code: ` - import { renderThing } from '@example/runtime' - - export function component() { - const renderThing = (node: React.ReactNode) => node - return renderThing(<LocalCard />) - } - `, - id: '/test/src/routes/card.tsx', - }) - - expect(result).toBeNull() - }) - - // Source: @vitejs/plugin-rsc transform fixtures (per row) - test.each([ - { - // hoist/function-hoist-block.js: block-level functions are block scoped - name: 'past a function declared in a nested block', - body: `{ - function renderThing() {} - } - return renderThing(<Card />)`, - transformed: true, - }, - { - // scope/param-default-var-hoisting.js - name: 'in a parameter default next to a var of the same name', - params: `element = renderThing(<Card />)`, - body: `var renderThing = null - return element`, - transformed: true, - }, - { - // hoist/catch-binding-shadow.js - name: 'in a try block whose catch parameter shadows it', - body: `try { - return renderThing(<Card />) - } catch (renderThing) { - return renderThing - }`, - transformed: true, - }, - { - // hoist/var-hoist-block.js - name: 'after a var in a nested block shadows it', - body: `if (Math.random() < 2) { - var renderThing = (element) => element - } - return renderThing(<Card />)`, - transformed: false, - }, - { - // scope/fn-decl-hoisting.js - name: 'before a hoisted function declaration shadows it', - body: `return renderThing(<Card />) - function renderThing(element) { - return element - }`, - transformed: false, - }, - { - // scope/catch-param.js - name: 'in a catch block whose parameter shadows it', - body: `try { - throw (element) => element - } catch (renderThing) { - return renderThing(<Card />) - }`, - transformed: false, - }, - ])( - 'runs external transforms on a call $name only if it reads the import', - async ({ params = '', body, transformed }) => { - const compiler = createExternalTransformCompiler() - - // The top-level call keeps the module transformed in every row. - const result = await compiler.compile({ - code: ` - import { renderThing } from '@example/runtime' - export const transformed = renderThing(<Card />) - export function render(${params}) { - ${body} - } - `, - id: '/test/src/routes/card.tsx', - }) - - expect(result).not.toBeNull() - const renderStart = result!.code.indexOf('function render(') - expect(renderStart).toBeGreaterThanOrEqual(0) - const render = result!.code.slice(renderStart) - expect(render.includes('injected: loadThing()')).toBe(transformed) - }, - ) -}) - -describe('server function provider module directives', () => { - test.each([ - 'export const Route = { component: Page }', - 'export function Route() { return Page() }', - 'export default function Route() { return Page() }', - ])( - 'removes browser-only dependencies of stripped exports: %s', - async (route) => { - const compiler = createFullCompiler('server') - const result = await compiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const getMessage = createServerFn().handler(() => 'server message') - const browserState = { window } - function Page() { return browserState } - ${route} - `, - id: '/test/src/routes/message.tsx?tss-serverfn-split', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('server message') - expect(result!.code).toContain('createServerRpc') - expect(result!.code).not.toContain('window') - expect(result!.code).not.toContain('browserState') - expect(result!.code).not.toContain('Page') - expect(result!.code).not.toContain('Route') - }, - ) - - const code = ` - import { createServerFn } from '@tanstack/react-start' - - export const getMessage = createServerFn({ method: 'GET' }).handler(() => { - return 'hello' - }) - ` - - test('does not add module directives without compiler configuration', async () => { - const compiler = createFullCompiler('server') - - const result = await compiler.compile({ - code, - id: '/test/src/routes/message.tsx?tss-serverfn-split', - }) - - expect(result).not.toBeNull() - expect(result!.code).not.toContain('"use server-entry"') - }) - - test('adds configured module directives to provider files only', async () => { - const compiler = createFullCompiler('server', { - serverFnProviderModuleDirectives: ['use server-entry'], - }) - - const providerResult = await compiler.compile({ - code, - id: '/test/src/routes/message.tsx?tss-serverfn-split', - }) - const callerResult = await compiler.compile({ - code, - id: '/test/src/routes/message.tsx', - }) - - expect(providerResult).not.toBeNull() - expect(providerResult!.code).toContain('"use server-entry";') - expect(callerResult).not.toBeNull() - expect(callerResult!.code).not.toContain('"use server-entry"') - }) -}) - -describe('edge cases for detectedKinds', () => { - test('empty detectedKinds returns null (no candidates to process)', async () => { - const compiler = createFullCompiler('client') - - const result = await compiler.compile({ - code: ` - // This file somehow passed Vite filter but has no actual kinds - const foo = 'bar' - // Maybe a false positive match like "handler(" in a comment - // .handler( in string - `, - id: 'empty.ts', - - detectedKinds: new Set(), // Empty set - }) - - expect(result).toBeNull() - }) - - test('detectedKinds not provided falls back to all valid kinds', async () => { - const compiler = createFullCompiler('client') - - // When detectedKinds is not provided, should check all valid kinds - const result = await compiler.compile({ - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - export const fn = createIsomorphicFn().client(() => 'works') - `, - id: 'no-detected.ts', - - // No detectedKinds provided - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('works') - }) - - test('detectedKinds with invalid kinds for env are filtered out', async () => { - const compiler = createFullCompiler('server') - - // Passing Middleware (invalid for server) along with valid kind - const result = await compiler.compile({ - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - export const fn = createIsomorphicFn().server(() => 'server-impl') - `, - id: 'filtered.ts', - - detectedKinds: new Set(['Middleware', 'IsomorphicFn']), // Middleware should be filtered - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('server-impl') - }) -}) - -test('ingestModule handles empty code gracefully', () => { - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (id) => id, - }) - - // Should not throw when ingesting empty module - expect(() => { - compiler.ingestModule({ code: '', id: 'empty-types.ts' }) - }).not.toThrow() - - // Should also handle whitespace-only modules - expect(() => { - compiler.ingestModule({ code: ' \n\t ', id: 'whitespace.ts' }) - }).not.toThrow() -}) - -test('compile caches modules without detected candidates for transitive importer traversal', async () => { - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (source, importer) => { - if (source === './leaf' && importer === '/src/plain.ts') { - return '/src/leaf.ts' - } - - if (source === './plain' && importer === '/src/parent.ts') { - return '/src/plain.ts' - } - - return null - }, - }) - - await compiler.compile({ - id: '/src/plain.ts', - code: ` - import { value } from './leaf' - export const plain = value - `, - detectedKinds: new Set(), - }) - - await compiler.compile({ - id: '/src/parent.ts', - code: ` - import { plain } from './plain' - export const parent = plain - `, - detectedKinds: new Set(), - }) - - expect(await compiler.getTransitiveImporters('/src/leaf.ts')).toEqual( - new Set(['/src/plain.ts', '/src/parent.ts']), - ) - expect(await compiler.getTransitiveImporters(['/src/leaf.ts'])).toEqual( - new Set(['/src/plain.ts', '/src/parent.ts']), - ) + const client = await startCase.served() + // The server fn is extracted; the call on `base`, which is not one, is + // left to run on the client as written. + expect(client).not.toContain('server-secret') + expect(client).toContain('not a server fn') }) describe('calling result of createServerOnlyFn/createClientOnlyFn', () => { @@ -800,736 +191,184 @@ describe('calling result of createServerOnlyFn/createClientOnlyFn', () => { // The var binding holds the RESULT of the factory, not the factory itself. test('invocation of createServerOnlyFn result is not treated as a candidate', async () => { - const compiler = createFullCompiler('server') + // Compiling must not throw "createServerOnlyFn() must be called with a + // function!", and the handler reads the value the call returned. + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' - const code = ` - import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' +const createRandomNumber = createServerOnlyFn(() => Math.floor(Math.random() * 100)) +const randomNumber = createRandomNumber() - const createRandomNumber = createServerOnlyFn(() => Math.floor(Math.random() * 100)) - const randomNumber = createRandomNumber() - - export const personServerFn = createServerFn({ method: 'GET' }) - .handler(({ data: name }) => { - return { name, randomNumber } - }) - ` - - // Should NOT throw "createServerOnlyFn() must be called with a function!" - // The main file output is the split-file version (createServerFn splits the handler), - // so we just verify it compiles without error and produces valid output. - const result = await compiler.compile({ code, id: 'test-6643.ts' }) - expect(result).not.toBeNull() - // The output should contain the personServerFn export (with SSR RPC reference) - expect(result!.code).toContain('personServerFn') +export const personServerFn = createServerFn({ method: 'GET' }) + .handler(({ data: name }) => { + return { name, randomNumber } + })`, + }) + expect( + await callFromClient(served, 'module.personServerFn', 'Ada'), + ).toEqual({ name: 'Ada', randomNumber: expect.any(Number) }) }) test('invocation of createClientOnlyFn result is not treated as a candidate', async () => { - const compiler = createFullCompiler('client') + const served = await serveCase(await host(), { + 'module.tsx': `import { createClientOnlyFn, createServerFn } from '@tanstack/react-start' - const code = ` - import { createClientOnlyFn, createServerFn } from '@tanstack/react-start' +const getWindowWidth = createClientOnlyFn(() => window.innerWidth) +export function readWidth() { + const width = getWindowWidth() + return width +} - const getWindowWidth = createClientOnlyFn(() => window.innerWidth) - const width = getWindowWidth() - - export const personServerFn = createServerFn({ method: 'GET' }) - .handler(({ data: name }) => { - return { name } - }) - ` - - const result = await compiler.compile({ code, id: 'test-6643-client.ts' }) - expect(result).not.toBeNull() - expect(result!.code).toContain('window.innerWidth') - expect(result!.code).toContain('getWindowWidth()') +export const personServerFn = createServerFn({ method: 'GET' }) + .handler(({ data: name }) => { + return { name } + })`, + }) + expect( + await inPage( + served, + 'return [module.readWidth() === window.innerWidth, typeof module.personServerFn.url]', + ), + ).toEqual([true, 'string']) + expect(await serverFnUrls(served)).toHaveLength(1) }) test('re-exported createServerOnlyFn still resolves correctly', async () => { - // Ensure the fix doesn't break re-export chain resolution (issue #6583) - const virtualModules: Record<string, string> = { - '@tanstack/start-client-core': ` - export { createServerOnlyFn } from '@tanstack/start-fn-stubs' - `, - } - - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return virtualModules[id] ? id : null - }, + // Ensure the fix doesn't break re-export chain resolution (issue #6583): + // the factory imported from `@tanstack/start-client-core`. + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerOnlyFn } from '@tanstack/start-client-core' +export const myFn = createServerOnlyFn(() => 'server-only-value')`, }) - - const code = ` - import { createServerOnlyFn } from '@tanstack/start-client-core' - const myFn = createServerOnlyFn(() => 'server-only-value') - ` - - const result = await compiler.compile({ code, id: 'reexport-test.ts' }) - expect(result).not.toBeNull() - expect(result!.code).toContain('server-only-value') + expect(served.code.client).not.toContain('server-only-value') + expect(await settledInPage(served, 'module.myFn')).toEqual(throwsError) }) test('aliased factory is still detected as a candidate', async () => { // `const createSO = createServerOnlyFn` is an alias, not an invocation. // `createSO(() => ...)` should still be treated as ServerOnlyFn. - const compiler = createFullCompiler('server') + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerOnlyFn } from '@tanstack/react-start' - const code = ` - import { createServerOnlyFn } from '@tanstack/react-start' - - const createSO = createServerOnlyFn - const myFn = createSO(() => 'aliased-server-only') - ` - - const result = await compiler.compile({ code, id: 'alias-test.ts' }) - expect(result).not.toBeNull() - // The factory should be unwrapped on server env - expect(result!.code).toContain('aliased-server-only') +const createSO = createServerOnlyFn +export const myFn = createSO(() => 'aliased-server-only')`, + }) + expect(served.code.client).not.toContain('aliased-server-only') + expect(await settledInPage(served, 'module.myFn')).toEqual(throwsError) }) }) describe('re-export chain resolution', () => { // This tests the fix for https://github.com/TanStack/router/issues/6583 - // Third-party packages may import from @tanstack/start-client-core (which re-exports - // from @tanstack/start-fn-stubs) rather than directly from @tanstack/react-start. - // The compiler should correctly resolve these imports via the slow path. + // Third-party packages may import from @tanstack/start-client-core rather + // than directly from @tanstack/react-start (`packages` above: + // @third-party/lib -> @tanstack/start-client-core). The compiler should + // correctly resolve these imports. - // Virtual module contents for simulating the re-export chain: - // @third-party/lib -> @tanstack/start-client-core -> @tanstack/start-fn-stubs - // - // Note: We don't need a virtual module for @tanstack/start-fn-stubs because - // init() hardcodes it in knownRootImports. When the slow path resolution reaches - // that package, it uses the fast path lookup and never needs to parse the module. - const virtualModules: Record<string, string> = { - // The client-core package that re-exports from stubs - '@tanstack/start-client-core': ` - export { createIsomorphicFn, createServerOnlyFn, createClientOnlyFn } from '@tanstack/start-fn-stubs' - `, - // A third-party package that imports from start-client-core - '@third-party/lib': ` - import { createIsomorphicFn, createClientOnlyFn } from '@tanstack/start-client-core' - - export const getThemeData = createIsomorphicFn() - .client(() => 'client-theme') - .server(() => 'server-theme') - - export const initClientFeature = createClientOnlyFn(() => { - console.log('client only initialization') - return 'initialized' - }) - `, - } - - function createCompilerWithVirtualModules(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - const lookupKinds: Set<LookupKind> = new Set([ - 'IsomorphicFn', - 'ServerOnlyFn', - 'ClientOnlyFn', - ]) - - // Note: We use empty lookupConfigurations because this test is specifically - // testing the slow path resolution through re-export chains. The compiler - // should still work because @tanstack/start-fn-stubs is hardcoded in - // knownRootImports during init(). - const compiler: StartCompiler = new StartCompiler({ - env, - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds, - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return virtualModules[id] ? id : null - }, - }) - - return compiler - } - - const testCases: Array<{ - env: 'client' | 'server' - fn: string - shouldContain: Array<string> - shouldNotContain: Array<string> - }> = [ - { - env: 'client', - fn: 'createIsomorphicFn', - shouldContain: ['client-theme'], - shouldNotContain: ['server-theme'], - }, - { - env: 'server', - fn: 'createIsomorphicFn', - shouldContain: ['server-theme'], - shouldNotContain: ['client-theme'], - }, - { - env: 'client', - fn: 'createClientOnlyFn', - shouldContain: ['client only initialization'], - shouldNotContain: [], - }, - { - env: 'server', - fn: 'createClientOnlyFn', - shouldContain: ['throw new Error'], - shouldNotContain: ['client only initialization'], - }, - ] - - test.each(testCases)( + test.each(libraryChainRows)( 'resolves $fn via re-export chain on $env', - async ({ env, shouldContain, shouldNotContain }) => { - const compiler = createCompilerWithVirtualModules(env) - const code = virtualModules['@third-party/lib']! - - const result = await compiler.compile({ - code, - id: '@third-party/lib', + async ({ env, fn, value, absent }) => { + const started = await host() + const served = await serveCase(started, { + 'module.tsx': `export { getThemeData, initClientFeature } from '@third-party/lib'\n`, }) - - expect(result).not.toBeNull() - for (const str of shouldContain) { - expect(result!.code).toContain(str) + const exported = + fn === 'createIsomorphicFn' ? 'getThemeData' : 'initClientFeature' + if (absent) { + const library = await started.host.transform( + '/node_modules/@third-party/lib/index.js', + env === 'client' ? 'client' : 'ssr', + ) + expect(library).not.toContain(absent) } - for (const str of shouldNotContain) { - expect(result!.code).not.toContain(str) + if (env === 'client') { + expect(await settledInPage(served, `module.${exported}`)).toEqual(value) + } else { + const ssr = await served.ssr() + expect(settle(ssr[exported] as () => unknown)).toEqual(value) } }, ) test('handles deeper re-export chains', async () => { - // Add another level to the chain - const deeperVirtualModules: Record<string, string> = { - ...virtualModules, - // Another intermediate package - '@another-intermediate/pkg': ` - export { createIsomorphicFn } from '@tanstack/start-client-core' - `, - '@deep-third-party/lib': ` - import { createIsomorphicFn } from '@another-intermediate/pkg' - export const deepFn = createIsomorphicFn() - .client(() => 'deep-client') - .server(() => 'deep-server') - `, - } - - const compiler: StartCompiler = new StartCompiler({ - env: 'client', - envName: 'client', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['IsomorphicFn', 'ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = deeperVirtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return deeperVirtualModules[id] ? id : null - }, + // Another intermediate package between the importer and Start's package. + const served = await serveCase(await host(), { + 'module.tsx': deeperChainModule, }) - - const result = await compiler.compile({ - code: deeperVirtualModules['@deep-third-party/lib']!, - id: '@deep-third-party/lib', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('deep-client') - expect(result!.code).not.toContain('deep-server') + expect(served.code.client).not.toContain('deep-server') + expect(await inPage(served, 'return module.deepFn()')).toBe('deep-client') }) + test.each(reexportCycles)( + 'handles circular import chain: $name', + async ({ files }) => { + // The cycle never reaches a Start factory (it cannot even link as ES + // modules): serving the module settles, with a result or an error, + // instead of looping. + const startCase = await ( + await host() + ).case({ + ...files, + 'module.tsx': cycleModule, + }) + const settled = await Promise.race([ + startCase.served('module.tsx', 'ssr').then( + () => 'settled', + () => 'settled', + ), + new Promise((resolve) => setTimeout(resolve, 2_000, 'still compiling')), + ]) + expect(settled).toBe('settled') + }, + ) + + // The dev-edit concepts of this suite (an edited module a re-export + // chain ends in recompiles its importers) are pinned through real dev + // edits in known-bugs-start-compiler.test.ts "dev edits". + + // A binding whose initializer reads itself (code saved mid-edit): serving + // the module settles, with a result or an error, instead of looping. test.each([ - { - name: 'named re-export cycle', - virtualModules: { - './factory-a': ` - export { createServerOnlyFn } from './factory-b' - `, - './factory-b': ` - export { createServerOnlyFn } from './factory-a' - `, - }, - }, - { - name: 'import alias cycle', - virtualModules: { - './factory-a': ` - import { createServerOnlyFn } from './factory-b' - export { createServerOnlyFn } - `, - './factory-b': ` - import { createServerOnlyFn } from './factory-a' - export { createServerOnlyFn } - `, - }, - }, - { - name: 'export-star cycle', - virtualModules: { - './factory-a': ` - export * from './factory-b' - `, - './factory-b': ` - export * from './factory-a' - `, - }, - }, - ])('handles circular import chain: $name', async ({ virtualModules }) => { - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['ServerOnlyFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id as keyof typeof virtualModules] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return id in virtualModules ? id : null - }, - mode: 'build', - }) - - const result = await compiler.compile({ - id: 'circular-import-test.ts', - code: ` - import { createServerOnlyFn } from './factory-a' - const myFn = createServerOnlyFn(() => 'server-only-value') - `, - }) - - expect(result).toBeNull() - }) - - test('ingestModule populates module metadata for later resolution', async () => { - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['ServerOnlyFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async () => {}, - resolveId: async (id) => { - return id === '@tanstack/start-client-core' ? id : null - }, - mode: 'build', - }) - - compiler.ingestModule({ - id: '@tanstack/start-client-core', - code: ` - export { createServerOnlyFn } from '@tanstack/start-fn-stubs' - `, - }) - - const result = await compiler.compile({ - id: 'cached-module-test.ts', - code: ` - import { createServerOnlyFn } from '@tanstack/start-client-core' - const myFn = createServerOnlyFn(() => 'cached-server-only-value') - `, - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('cached-server-only-value') - }) - - test('invalidateModule clears cached module resolution state', async () => { - const virtualModules: Record<string, string> = { - './factory': ` - export { createServerOnlyFn } from './factory-inner' - `, - './factory-inner': ` - export { createServerOnlyFn } from '@tanstack/start-fn-stubs' - `, - } - - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return virtualModules[id] ? id : null - }, - mode: 'build', - }) - - const source = ` - import { createServerOnlyFn } from './factory' - const myFn = createServerOnlyFn(() => 'server-only-value') - ` - - const initialResult = await compiler.compile({ - id: 'transitive-invalidation-test.ts', - code: source, - }) - - expect(initialResult).not.toBeNull() - expect(initialResult!.code).toContain('server-only-value') - expect(initialResult!.code).not.toContain('throw new Error') - - virtualModules['./factory-inner'] = ` - export { createClientOnlyFn as createServerOnlyFn } from '@tanstack/start-fn-stubs' - ` - - expect(compiler.invalidateModule('./factory-inner')).toBe(true) - - const updatedResult = await compiler.compile({ - id: 'transitive-invalidation-test.ts', - code: source, - }) - - expect(updatedResult).not.toBeNull() - expect(updatedResult!.code).toContain('throw new Error') - expect(updatedResult!.code).not.toContain('server-only-value') - }) - - test('invalidateModule preserves root lookup metadata while clearing importer memoization', async () => { - const virtualModules: Record<string, string> = { - './factory': ` - export { createServerOnlyFn } from './factory-inner' - `, - './factory-inner': ` - export { createServerOnlyFn } from '@tanstack/start-fn-stubs' - `, - } - - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - lookupKinds: new Set(['ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerOnlyFn', - kind: 'ServerOnlyFn', - }, - { - libName: '@tanstack/react-start', - rootExport: 'createClientOnlyFn', - kind: 'ClientOnlyFn', - }, - ], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return virtualModules[id] ? id : null - }, - }) - - const source = ` - import { createServerOnlyFn } from './factory' - const myFn = createServerOnlyFn(() => 'server-only-value') - ` - - const initialResult = await compiler.compile({ - id: 'memoized-invalidation-test.ts', - code: source, - }) - - expect(initialResult).not.toBeNull() - expect(initialResult!.code).toContain('server-only-value') - - virtualModules['./factory-inner'] = ` - export { createClientOnlyFn as createServerOnlyFn } from '@tanstack/start-fn-stubs' - ` - - expect(compiler.invalidateModule('./factory-inner')).toBe(true) - - const updatedResult = await compiler.compile({ - id: 'memoized-invalidation-test.ts', - code: source, - }) - - expect(updatedResult).not.toBeNull() - expect(updatedResult!.code).toContain('throw new Error') - expect(updatedResult!.code).not.toContain('server-only-value') - }) - - test('recompiles aliased env-only direct calls when only server function syntax is detected', async () => { - const virtualModules: Record<string, string> = { - './factory': ` - export { createServerOnlyFn } from '@tanstack/start-fn-stubs' - `, - } - - const compiler: StartCompiler = new StartCompiler({ - env: 'server', - envName: 'ssr', - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - mode: 'build', - lookupKinds: new Set(['ServerFn', 'ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - return virtualModules[id] ? id : null - }, - }) - - const source = ` - import { createServerFn } from '@tanstack/react-start' - import { createServerOnlyFn as createServerFnHmrFactory } from './factory' - - const serverOnlyImpl = createServerFnHmrFactory(() => 'server-only-value') - - export const serverFn = createServerFn().handler(async () => { - return serverOnlyImpl() - }) - ` - - const providerId = 'aliased-env-only-server-fn.ts?tss-serverfn-split' - - const initialResult = await compiler.compile({ - id: providerId, - code: source, - detectedKinds: new Set(['ServerFn']), - }) - - expect(initialResult).not.toBeNull() - expect(initialResult!.code).toContain('server-only-value') - expect(initialResult!.code).not.toContain('throw new Error') - - virtualModules['./factory'] = ` - export { createClientOnlyFn as createServerOnlyFn } from '@tanstack/start-fn-stubs' - ` - - expect(compiler.invalidateModule('./factory')).toBe(true) - - const updatedResult = await compiler.compile({ - id: providerId, - code: source, - detectedKinds: new Set(['ServerFn']), - }) - - expect(updatedResult).not.toBeNull() - expect(updatedResult!.code).toContain('throw new Error') - expect(updatedResult!.code).not.toContain('server-only-value') + `import { createServerFn } from '@tanstack/react-start' +export const fn: any = fn.handler(async () => 'x') +export const real = createServerFn().handler(async () => 'y')`, + ])('compiling a self-referencing binding settles: %#', async (code) => { + const startCase = await (await host()).case({ 'module.tsx': code }) + const settled = await Promise.race([ + startCase.served().then( + () => 'settled', + () => 'settled', + ), + new Promise((resolve) => setTimeout(resolve, 2_000, 'still compiling')), + ]) + expect(settled).toBe('settled') }) }) -test('leaves unrelated SSR middleware chains to the bundler when a server function factory is present', async () => { - const compiler = new StartCompiler({ - ...getDefaultTestOptions('server'), - env: 'server', - mode: 'build', - lookupKinds: getLookupKindsForEnv('server'), - lookupConfigurations: getLookupConfigurationsForEnv('server', 'react'), - getKnownServerFns: () => ({}), - resolveId: async () => { - throw new Error( - 'SSR host has no package import conditions for this unrelated binding', - ) - }, - loadModule: async () => { - throw new Error('Unexpected compiler dependency load') - }, - }) - const code = `import { createMiddleware, createServerFn } from '@tanstack/react-start'; +test('leaves unrelated SSR middleware chains as written when a server function factory is present', async () => { + const served = await serveCase( + await host(), + { + 'auth-wrapper.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start'; const middleware = createMiddleware({ type: 'function' }).server(({ next }) => next({ context: { role: 'admin' } })); -export const factory = createServerFn().middleware([middleware]);` - await expect( - compiler.compile({ - id: '/test/auth-wrapper.ts', - code, - detectedKinds: detectKindsInCode(code, 'server'), +export const factory = createServerFn().middleware([middleware]);`, + // The factory's user: a server fn of another module, whose handler + // gives what the factory's middleware put into its context. + 'uses-factory.ts': `import { factory } from './auth-wrapper'; +export const role = factory.handler(async ({ context }) => context.role);`, + }, + { file: 'auth-wrapper.ts' }, + ) + // The server keeps the middleware chain as written: Start runs it for a + // call of the factory's server fn, from the client (over HTTP) and from + // server code (inside a real request). + expect( + await callServerFnThroughCallers(served, 'module.role', undefined, { + file: 'uses-factory.ts', }), - ).resolves.toBeNull() + ).toBe('admin') }) -describe.each(['build', 'dev'] as const)( - 'top-level member calls in %s mode', - (mode) => { - function createCompilerWithModules( - env: 'client' | 'server', - virtualModules: Record<string, string>, - ) { - const resolved: Array<string> = [] - const loaded: Array<string> = [] - const compiler: StartCompiler = new StartCompiler({ - ...getDefaultTestOptions(env), - env, - mode, - devServerFnModuleSpecifierEncoder: ({ extractedFilename, root }) => - `/@id${extractedFilename.slice(root.length)}`, - lookupKinds: getLookupKindsForEnv(env), - lookupConfigurations: getLookupConfigurationsForEnv(env, 'react'), - getKnownServerFns: () => ({}), - resolveId: async (id) => { - resolved.push(id) - return id in virtualModules ? id : null - }, - loadModule: async (id) => { - loaded.push(id) - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - }) - return { compiler, resolved, loaded } - } - - describe.each(['fast', 'full'] as const)('%s traversal', (traversal) => { - // An isomorphic function requires full traversal; server functions alone - // use the compiler's fast path. Let normal code detection choose the path. - const traversalCode = - traversal === 'full' - ? `import { createIsomorphicFn } from '@tanstack/react-start' - export const iso = createIsomorphicFn().client(() => 'client').server(() => 'server')` - : '' - - test.each(['client', 'ssr', 'provider'] as const)( - 'does not resolve or load named-import receivers in %s output', - async (output) => { - const env = output === 'client' ? 'client' : 'server' - const { compiler, resolved, loaded } = createCompilerWithModules( - env, - { - zod: `export const z = { object: (shape) => shape, string: () => ({}) }`, - './api': `export const api = { users: () => [] }`, - }, - ) - const code = ` - ${traversalCode} - import { createServerFn } from '@tanstack/react-start' - import { z } from 'zod' - import { api } from './api' - - const Input = z.object({ id: z.string() }) - const users = api.users() - - export const getUser = createServerFn() - .validator(Input) - .handler(async ({ data }) => ({ id: data.id, users })) - ` - - const result = await compiler.compile({ - id: - '/test/get-user.ts' + - (output === 'provider' ? '?tss-serverfn-split' : ''), - code, - detectedKinds: detectKindsInCode(code, env), - }) - - expect(result).not.toBeNull() - const rpc = { - client: 'createClientRpc', - ssr: 'createSsrRpc', - provider: 'createServerRpc', - } - expect(result!.code).toContain(rpc[output]) - expect(resolved).toEqual([]) - expect(loaded).toEqual([]) - }, - ) - - test.each(['client', 'server'] as const)( - 'still compiles a renamed env-only factory called through a namespace import on %s', - async (env) => { - const { compiler } = createCompilerWithModules(env, { - './factory': `export { createServerOnlyFn as serverOnly } from '@tanstack/start-fn-stubs'`, - }) - const code = ` - ${traversalCode} - import { createServerFn } from '@tanstack/react-start' - import * as factory from './factory' - - export const impl = factory.serverOnly(() => 'server-only-value') - - export const fn = createServerFn().handler(async () => impl()) - ` - - const result = await compiler.compile({ - id: '/test/namespace-factory.ts', - code, - detectedKinds: detectKindsInCode(code, env), - }) - - expect(result).not.toBeNull() - if (env === 'server') { - expect(result!.code).toContain('server-only-value') - expect(result!.code).not.toContain('factory.serverOnly') - } else { - expect(result!.code).not.toContain('server-only-value') - expect(result!.code).toContain('throw new Error') - } - }, - ) - }) - }, -) - test.each([ `(createServerOnlyFn)(() => 'server-value')`, `(createIsomorphicFn)().server(() => 'server-value').client(() => 'client-value')`, @@ -1537,61 +376,103 @@ test.each([ ])( 'compiles transparent parentheses around native call chains: %s', async (expression) => { - const compiler = createFullCompiler('server') - const result = await compiler.compile({ - id: '/test/parenthesized.ts', - code: `import { createServerOnlyFn, createIsomorphicFn } from '@tanstack/react-start'; export const fn = ${expression}`, - }) - - expect(result).not.toBeNull() - const evaluate = new Function( - `${result!.code.replace(/^import .+;$/gm, '').replace(/\bexport (?=const)/g, '')}\nreturn fn`, + const served = await serveCase( + await host(), + { + 'parenthesized.ts': `import { createServerOnlyFn, createIsomorphicFn } from '@tanstack/react-start'; export const fn = ${expression}`, + }, + { file: 'parenthesized.ts' }, ) - expect(evaluate()()).toBe('server-value') + const { fn } = await served.ssr('parenthesized.ts') + expect(fn()).toBe('server-value') }, ) test('compiles a server function through a parenthesized namespace receiver', async () => { - const compiler = createFullCompiler('client') - const result = await compiler.compile({ - id: '/test/namespace-parenthesized.ts', - code: `import * as Start from '@tanstack/react-start'; export const fn = (Start).createServerFn().handler(() => 'private-server-body')`, - }) - expect(result).not.toBeNull() - expect(result!.code).not.toContain('private-server-body') - expect(result!.code).toContain('createClientRpc') + const served = await serveCase( + await host(), + { + 'namespace-parenthesized.ts': `import * as Start from '@tanstack/react-start'; export const fn = (Start).createServerFn().handler(() => 'private-server-body')`, + }, + { file: 'namespace-parenthesized.ts' }, + ) + expect(served.code.client).not.toContain('private-server-body') + expect( + await serverFnUrls(served, 'module', { + file: 'namespace-parenthesized.ts', + }), + ).toHaveLength(1) + expect( + await callFromClient(served, 'module.fn', undefined, { + file: 'namespace-parenthesized.ts', + }), + ).toBe('private-server-body') }) -// The compiler currently mistakes the local parameter for the namespace import. -// Keep the intended behavior executable until binding resolution is corrected. -test.fails( - 'preserves a shadowed parenthesized namespace receiver', - async () => { - const compiler = createFullCompiler('client') - const code = `import * as Start from '@tanstack/react-start'; export function fn(Start) { return (Start).createServerFn().handler(() => 'local-runtime-body') }` - const result = await compiler.compile({ - id: '/test/shadowed-namespace.ts', - code, - }) - const output = result?.code ?? code - expect(output).toContain('local-runtime-body') - expect(output).not.toContain('createClientRpc') - }, -) +// Source: #8504 compiler.test.ts "preserves a shadowed parenthesized +// namespace receiver" +test('leaves a server fn of a parameter shadowing the namespace receiver alone', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import * as Start from '@tanstack/react-start' +export function make(Start) { + return (Start).createServerFn().handler(() => 'local-runtime-body') +}`, + }) + expect( + await inPage( + served, + `const local = { createServerFn: () => ({ handler: (fn) => fn }) } +return module.make(local)()`, + ), + ).toBe('local-runtime-body') +}) -test.each([ - `(Start).createServerOnlyFn(() => 'private-server-body')`, - `(Start).createIsomorphicFn().server(() => 'private-server-body').client(() => 'client-value')`, - `(Start).createMiddleware().server(() => 'private-server-body')`, +// The client output keeps no server implementation; each export still +// evaluates to what the client runtime gives. +test.each<{ + expression: string + /** A page script reading `module.fn`; its result is checked by `expected`. */ + script: string + expected: unknown +}>([ + { + expression: `(Start).createServerOnlyFn(() => 'private-server-body')`, + script: 'return settle(module.fn)', + expected: throwsError, + }, + { + expression: `(Start).createIsomorphicFn().server(() => 'private-server-body').client(() => 'client-value')`, + script: 'return { value: module.fn() }', + expected: 'client-value', + }, + { + // A real middleware (Start's runtime object, its options), whose + // `.client()` still runs and whose `.server()` is gone. + expression: `(Start).createMiddleware({ type: 'function' }).client(({ next }) => next({ sendContext: { from: 'client-value' } })).server(() => 'private-server-body')`, + script: `return { value: [ + module.fn.options.type, + module.fn.options.server === undefined, + shapeOf(await module.fn.options.client({ next: (result) => result })), +] }`, + expected: ['function', true, { sendContext: { from: 'client-value' } }], + }, ])( - 'removes server-only code through a parenthesized namespace: %s', - async (expression) => { - const compiler = createFullCompiler('client') - const result = await compiler.compile({ - id: '/test/namespace-builtins.ts', - code: `import * as Start from '@tanstack/react-start'; export const fn = ${expression}`, - }) - expect(result).not.toBeNull() - expect(result!.code).not.toContain('private-server-body') + 'removes server-only code through a parenthesized namespace: $expression', + async ({ expression, script, expected }) => { + const served = await serveCase( + await host(), + { + 'namespace-builtins.ts': `import * as Start from '@tanstack/react-start'; export const fn = ${expression}`, + }, + { file: 'namespace-builtins.ts' }, + ) + expect(served.code.client).not.toContain('private-server-body') + expect( + fromPage( + await inPage<PageSettled>(served, `${shapeOf}\n${script}`, { + file: 'namespace-builtins.ts', + }), + ), + ).toEqual(expected) }, ) diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts index 0b6a5aa26a..fcdd979cec 100644 --- a/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts +++ b/packages/start-plugin-core/tests/createIsomorphicFn/createIsomorphicFn.test.ts @@ -1,100 +1,288 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { inPage, serveCase, useStartHost } from '../regression-helpers' +import type { ServedCase } from '../regression-helpers' -import { StartCompiler } from '../../src/start-compiler/compiler' -import { formatSnapshot } from '../format-snapshot' +const host = useStartHost() -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', +/** What a call returned, `undefined` spelled out (results cross JSON). */ +const UNDEFINED = '<undefined>' + +/** Calls the named exports of the case module in the page (the client). */ +function callOnClient(served: ServedCase, names: Array<string>) { + return inPage( + served, + `return Object.fromEntries(${JSON.stringify(names)}.map((name) => { + const value = module[name]() + return [name, value === undefined ? ${JSON.stringify(UNDEFINED)} : value] +}))`, + ) +} + +/** Calls the named exports of the module the SSR environment evaluated. */ +async function callOnServer(served: ServedCase, names: Array<string>) { + const module = await served.ssr() + return Object.fromEntries( + names.map((name) => { + const value = module[name]() + return [name, value === undefined ? UNDEFINED : value] + }), + ) +} + +// Each output runs only its environment's implementation; an isomorphic fn +// without one for that environment is a no-op returning undefined, and the +// client has no server implementation. `noImpl` stays a runtime call. +// Replaces the former snapshot fixtures of this directory. +describe('each output runs the implementation of its environment', () => { + const files = { + 'x.server.ts': `export const server = (value: string) => value\n`, + 'x.client.ts': `export const client = (value: string) => value\n`, } + + /** Imports of the modules below whose implementations read `./x.*`. */ + const envImports = `import { server } from './x.server' +import { client } from './x.client' +` + + /** + * The client does not load the server module, and the SSR environment + * does not load the `.client` module (SPEC J4.9, J4.11). + */ + async function expectEnvImports(served: ServedCase) { + expectNotLoaded(await served.loads(), ['./x.server']) + expectNotLoaded(await served.serverLoads(), ['./x.client']) + } + + /** + * A case of `code` with the `./x.*` modules, which both environments + * serve and evaluate. + */ + async function evaluateOutputs(code: string) { + return serveCase(await host(), { 'module.tsx': code, ...files }) + } + + // Source: snapshot fixtures createIsomorphicFnDestructured.tsx (and its + // Rename / StarImport variants) + test('one implementation, both orders and function references', async () => { + const served = + await evaluateOutputs(`import { createIsomorphicFn } from '@tanstack/react-start' +export const noImpl = createIsomorphicFn() +export const serverOnlyFn = createIsomorphicFn().server(() => 'server') +export const clientOnlyFn = createIsomorphicFn().client(() => 'client') +export const serverThenClientFn = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') +export const clientThenServerFn = createIsomorphicFn() + .client(() => 'client') + .server(() => 'server') +function abstractedServerFn() { + return 'SERVER_IMPL' } - -async function compile(opts: { - env: 'client' | 'server' - code: string - id: string -}) { - const compiler = new StartCompiler({ - ...opts, - ...getDefaultTestOptions(opts.env), - loadModule: async () => { - // do nothing in test - }, - lookupKinds: new Set(['IsomorphicFn']), - lookupConfigurations: [ - { - libName: `@tanstack/react-start`, - rootExport: 'createIsomorphicFn', - kind: 'IsomorphicFn', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (id) => { - return id - }, - }) - const result = await compiler.compile({ - code: opts.code, - id: opts.id, - }) - return result +export const serverOnlyFnAbstracted = createIsomorphicFn().server(abstractedServerFn) +function abstractedClientFn() { + return 'client' } - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('createIsomorphicFn compiles correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each(['client', 'server'] as const)( - `should compile for ${filename} %s`, - async (env) => { - const compiledResult = await compile({ - env, - code, - id: filename, - }) - - await expect( - await formatSnapshot(compiledResult!.code, filename), - ).toMatchFileSnapshot(`./snapshots/${env}/${filename}`) - }, - ) +export const clientOnlyFnAbstracted = createIsomorphicFn().client(abstractedClientFn) +export const serverThenClientFnAbstracted = createIsomorphicFn() + .server(abstractedServerFn) + .client(abstractedClientFn) +export const clientThenServerFnAbstracted = createIsomorphicFn() + .client(abstractedClientFn) + .server(abstractedServerFn)`) + const names = [ + 'noImpl', + 'serverOnlyFn', + 'clientOnlyFn', + 'serverThenClientFn', + 'clientThenServerFn', + 'serverOnlyFnAbstracted', + 'clientOnlyFnAbstracted', + 'serverThenClientFnAbstracted', + 'clientThenServerFnAbstracted', + ] + expect(await callOnClient(served, names)).toEqual({ + noImpl: UNDEFINED, + serverOnlyFn: UNDEFINED, + clientOnlyFn: 'client', + serverThenClientFn: 'client', + clientThenServerFn: 'client', + serverOnlyFnAbstracted: UNDEFINED, + clientOnlyFnAbstracted: 'client', + serverThenClientFnAbstracted: 'client', + clientThenServerFnAbstracted: 'client', + }) + expect(await callOnServer(served, names)).toEqual({ + noImpl: UNDEFINED, + serverOnlyFn: 'server', + clientOnlyFn: UNDEFINED, + serverThenClientFn: 'server', + clientThenServerFn: 'server', + serverOnlyFnAbstracted: 'SERVER_IMPL', + clientOnlyFnAbstracted: UNDEFINED, + serverThenClientFnAbstracted: 'SERVER_IMPL', + clientThenServerFnAbstracted: 'SERVER_IMPL', + }) + expect(served.code.client).not.toContain('SERVER_IMPL') }) - test('should error if implementation not provided', async () => { - await expect( - compile({ - env: 'client', - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - const clientOnly = createIsomorphicFn().client()`, - id: 'no-fn.ts', - }), - ).rejects.toThrowError() + // Source: snapshot fixture createIsomorphicFnFactory.tsx + test('isomorphic fns returned by factories', async () => { + const served = + await evaluateOutputs(`import { createIsomorphicFn } from '@tanstack/react-start' +${envImports}export function createPlatformFn(platform: string) { + return createIsomorphicFn() + .client(() => client(\`client-\${platform}\`)) + .server(() => server(\`server-\${platform}\`)) +} +export const createServerImplFn = (name: string) => { + return createIsomorphicFn().server(() => server(\`server-\${name}\`)) +} +export const createClientImplFn = (name: string) => { + return createIsomorphicFn().client(() => client(\`client-\${name}\`)) +} +export function createNoImplFn() { + return createIsomorphicFn() +} +export const topLevelIsomorphicFn = createIsomorphicFn() + .client(() => client('client')) + .server(() => server('server'))`) + const callFactories = `[ + module.createPlatformFn('web')(), + module.createServerImplFn('a')(), + module.createClientImplFn('b')(), + module.createNoImplFn()(), + module.topLevelIsomorphicFn(), +].map((value) => (value === undefined ? ${JSON.stringify(UNDEFINED)} : value))` + expect(await inPage(served, `return ${callFactories}`)).toEqual([ + 'client-web', + UNDEFINED, + 'client-b', + UNDEFINED, + 'client', + ]) + const ssr = await served.ssr() + expect(new Function('module', `return ${callFactories}`)(ssr)).toEqual([ + 'server-web', + 'server-a', + UNDEFINED, + UNDEFINED, + 'server', + ]) + await expectEnvImports(served) + }) - await expect( - compile({ - env: 'server', - code: ` - import { createIsomorphicFn } from '@tanstack/react-start' - const serverOnly = createIsomorphicFn().server()`, - id: 'no-fn.ts', - }), - ).rejects.toThrowError() + // Source: snapshot fixture createIsomorphicFnInline.tsx + test('isomorphic fns created and called inside functions', async () => { + const served = + await evaluateOutputs(`import { createIsomorphicFn } from '@tanstack/react-start' +${envImports}export function getPlatformValue() { + const fn = createIsomorphicFn() + .client(() => client('client-value')) + .server(() => server('server-value')) + return fn() +} +export const getEnvironment = () => { + const envFn = createIsomorphicFn() + .server(() => server('running on server')) + .client(() => client('running on client')) + return envFn() +} +export function getDirectValue() { + return createIsomorphicFn() + .client(() => client('direct-client')) + .server(() => server('direct-server'))() +} +export function getMultipleValues() { + const first = createIsomorphicFn() + .client(() => client('first-client')) + .server(() => server('first-server')) + const second = createIsomorphicFn() + .client(() => client('second-client')) + .server(() => server('second-server')) + return [first(), second()] +} +export function getServerOnlyValue() { + const fn = createIsomorphicFn().server(() => server('server-only-value')) + return fn() +} +export function getClientOnlyValue() { + const fn = createIsomorphicFn().client(() => client('client-only-value')) + return fn() +} +export const moduleLevel = getEnvironment()`) + const names = [ + 'getPlatformValue', + 'getEnvironment', + 'getDirectValue', + 'getMultipleValues', + 'getServerOnlyValue', + 'getClientOnlyValue', + ] + expect(await callOnClient(served, names)).toEqual({ + getPlatformValue: 'client-value', + getEnvironment: 'running on client', + getDirectValue: 'direct-client', + getMultipleValues: ['first-client', 'second-client'], + getServerOnlyValue: UNDEFINED, + getClientOnlyValue: 'client-only-value', + }) + expect(await callOnServer(served, names)).toEqual({ + getPlatformValue: 'server-value', + getEnvironment: 'running on server', + getDirectValue: 'direct-server', + getMultipleValues: ['first-server', 'second-server'], + getServerOnlyValue: 'server-only-value', + getClientOnlyValue: UNDEFINED, + }) + // Called while the module evaluates, at its top level. + expect([ + await inPage(served, 'return module.moduleLevel'), + (await served.ssr()).moduleLevel, + ]).toEqual(['running on client', 'running on server']) + await expectEnvImports(served) + }) +}) + +describe('isomorphic fns next to other code', () => { + test('a top-level call next to a server fn returns the value of each environment', async () => { + const code = `import { createServerFn, createIsomorphicFn } from '@tanstack/react-start' +const getEnv = createIsomorphicFn().server(() => 'server').client(() => 'client') +export const env = getEnv() +export const fn = createServerFn().handler(async () => 'x')` + const served = await serveCase(await host(), { 'module.tsx': code }) + expect(await inPage(served, 'return module.env')).toBe('client') + expect((await served.ssr()).env).toBe('server') + }) + + test('a builder kept in a variable', async () => { + const code = `import { createIsomorphicFn } from '@tanstack/react-start' +import { db } from './db.server' +const iso = createIsomorphicFn() +export const fn = iso.server(() => db.x()).client(() => 'client')` + const served = await serveCase(await host(), { + 'module.tsx': code, + 'db.server.ts': `export const db = { x: () => 'server' }\n`, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await inPage(served, 'return module.fn()')).toBe('client') + }) + + test('a .client() call on a global object is left alone', async () => { + const code = `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn = createIsomorphicFn().server(() => 'server').client(() => 'client') +export const viaGlobal = () => ws.client()` + const served = await serveCase(await host(), { 'module.tsx': code }) + expect( + await inPage( + served, + `globalThis.ws = { client: () => 'global' } +try { + return [module.fn(), module.viaGlobal()] +} finally { + delete globalThis.ws +}`, + ), + ).toEqual(['client', 'global']) }) }) diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts deleted file mode 100644 index 7e8ade3201..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/call-at-module-level.ts +++ /dev/null @@ -1,5 +0,0 @@ -const getEnvironment = () => { - console.log('[CLIENT] getEnvironment called') - return 'client' -} -const moduleLevel = getEnvironment() diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx deleted file mode 100644 index 20fbb3d4dc..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' -const noImpl = createIsomorphicFn() -const serverOnlyFn = () => {} -const clientOnlyFn = () => 'client' -const serverThenClientFn = () => 'client' -const clientThenServerFn = () => 'client' -const serverOnlyFnAbstracted = () => {} -function abstractedClientFn() { - return 'client' -} -const clientOnlyFnAbstracted = abstractedClientFn -const serverThenClientFnAbstracted = abstractedClientFn -const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index d8f76d94b0..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start' -const noImpl = isomorphicFn() -const serverOnlyFn = () => {} -const clientOnlyFn = () => 'client' -const serverThenClientFn = () => 'client' -const clientThenServerFn = () => 'client' -const serverOnlyFnAbstracted = () => {} -function abstractedClientFn() { - return 'client' -} -const clientOnlyFnAbstracted = abstractedClientFn -const serverThenClientFnAbstracted = abstractedClientFn -const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx deleted file mode 100644 index 08772a9178..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnFactory.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' -// Isomorphic function factory - returns a createIsomorphicFn with .client() and .server() calls -export function createPlatformFn(platform: string) { - return () => `client-${platform}` -} -// Arrow function factory with only server implementation -export const createServerImplFn = (name: string) => { - return () => {} -} -// Arrow function factory with only client implementation -export const createClientImplFn = (name: string) => { - return () => { - console.log(`Client: ${name}`) - return `client-${name}` - } -} -// Factory returning no-implementation isomorphic fn -export function createNoImplFn() { - return createIsomorphicFn() -} -// Top-level isomorphic fn for comparison -export const topLevelIsomorphicFn = () => 'client' diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx deleted file mode 100644 index 28930701bd..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnInline.tsx +++ /dev/null @@ -1,33 +0,0 @@ -// Create and immediately invoke isomorphic fn inside a function -export function getPlatformValue() { - const fn = () => 'client-value' - return fn() -} -// Arrow function that creates and invokes isomorphic fn -export const getEnvironment = () => { - const envFn = () => 'running on client' - return envFn() -} -// Create isomorphic fn inline without assigning to variable -export function getDirectValue() { - return (() => 'direct-client')() -} -// Multiple isomorphic fns created and used in same function -export function getMultipleValues() { - const first = () => 'first-client' - const second = () => 'second-client' - return { first: first(), second: second() } -} -// Isomorphic fn with server-only implementation used inline -export function getServerOnlyValue() { - const fn = () => {} - return fn() -} -// Isomorphic fn with client-only implementation used inline -export function getClientOnlyValue() { - const fn = () => { - console.log('client side effect') - return 'client-only-value' - } - return fn() -} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx deleted file mode 100644 index f8604d9723..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/client/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' -const noImpl = TanStackStart.createIsomorphicFn() -const serverOnlyFn = () => {} -const clientOnlyFn = () => 'client' -const serverThenClientFn = () => 'client' -const clientThenServerFn = () => 'client' -const serverOnlyFnAbstracted = () => {} -function abstractedClientFn() { - return 'client' -} -const clientOnlyFnAbstracted = abstractedClientFn -const serverThenClientFnAbstracted = abstractedClientFn -const clientThenServerFnAbstracted = abstractedClientFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts deleted file mode 100644 index 66c327f562..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/call-at-module-level.ts +++ /dev/null @@ -1,5 +0,0 @@ -const getEnvironment = () => { - console.log('[SERVER] getEnvironment called') - return 'server' -} -const moduleLevel = getEnvironment() diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx deleted file mode 100644 index ee54120ca1..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' -const noImpl = createIsomorphicFn() -const serverOnlyFn = () => 'server' -const clientOnlyFn = () => {} -const serverThenClientFn = () => 'server' -const clientThenServerFn = () => 'server' -function abstractedServerFn() { - return 'server' -} -const serverOnlyFnAbstracted = abstractedServerFn -const clientOnlyFnAbstracted = () => {} -const serverThenClientFnAbstracted = abstractedServerFn -const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index 11289136e9..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start' -const noImpl = isomorphicFn() -const serverOnlyFn = () => 'server' -const clientOnlyFn = () => {} -const serverThenClientFn = () => 'server' -const clientThenServerFn = () => 'server' -function abstractedServerFn() { - return 'server' -} -const serverOnlyFnAbstracted = abstractedServerFn -const clientOnlyFnAbstracted = () => {} -const serverThenClientFnAbstracted = abstractedServerFn -const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx deleted file mode 100644 index c1ec1e79f5..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnFactory.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' -// Isomorphic function factory - returns a createIsomorphicFn with .client() and .server() calls -export function createPlatformFn(platform: string) { - return () => `server-${platform}` -} -// Arrow function factory with only server implementation -export const createServerImplFn = (name: string) => { - return () => { - console.log(`Server: ${name}`) - return `server-${name}` - } -} -// Arrow function factory with only client implementation -export const createClientImplFn = (name: string) => { - return () => {} -} -// Factory returning no-implementation isomorphic fn -export function createNoImplFn() { - return createIsomorphicFn() -} -// Top-level isomorphic fn for comparison -export const topLevelIsomorphicFn = () => 'server' diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx deleted file mode 100644 index c2b0d07284..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnInline.tsx +++ /dev/null @@ -1,33 +0,0 @@ -// Create and immediately invoke isomorphic fn inside a function -export function getPlatformValue() { - const fn = () => 'server-value' - return fn() -} -// Arrow function that creates and invokes isomorphic fn -export const getEnvironment = () => { - const envFn = () => 'running on server' - return envFn() -} -// Create isomorphic fn inline without assigning to variable -export function getDirectValue() { - return (() => 'direct-server')() -} -// Multiple isomorphic fns created and used in same function -export function getMultipleValues() { - const first = () => 'first-server' - const second = () => 'second-server' - return { first: first(), second: second() } -} -// Isomorphic fn with server-only implementation used inline -export function getServerOnlyValue() { - const fn = () => { - console.log('server side effect') - return 'server-only-value' - } - return fn() -} -// Isomorphic fn with client-only implementation used inline -export function getClientOnlyValue() { - const fn = () => {} - return fn() -} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx deleted file mode 100644 index 6a1c429167..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/snapshots/server/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' -const noImpl = TanStackStart.createIsomorphicFn() -const serverOnlyFn = () => 'server' -const clientOnlyFn = () => {} -const serverThenClientFn = () => 'server' -const clientThenServerFn = () => 'server' -function abstractedServerFn() { - return 'server' -} -const serverOnlyFnAbstracted = abstractedServerFn -const clientOnlyFnAbstracted = () => {} -const serverThenClientFnAbstracted = abstractedServerFn -const clientThenServerFnAbstracted = abstractedServerFn diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/call-at-module-level.ts b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/call-at-module-level.ts deleted file mode 100644 index ee017d7f59..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/call-at-module-level.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' - -const getEnvironment = createIsomorphicFn() - .server(() => { - console.log('[SERVER] getEnvironment called') - return 'server' - }) - .client(() => { - console.log('[CLIENT] getEnvironment called') - return 'client' - }) - -const moduleLevel = getEnvironment() diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx deleted file mode 100644 index e3102bcb71..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructured.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' - -const noImpl = createIsomorphicFn() - -const serverOnlyFn = createIsomorphicFn().server(() => 'server') - -const clientOnlyFn = createIsomorphicFn().client(() => 'client') - -const serverThenClientFn = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = createIsomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = createIsomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = createIsomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = createIsomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = createIsomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx deleted file mode 100644 index b33515ffc5..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnDestructuredRename.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createIsomorphicFn as isomorphicFn } from '@tanstack/react-start' - -const noImpl = isomorphicFn() - -const serverOnlyFn = isomorphicFn().server(() => 'server') - -const clientOnlyFn = isomorphicFn().client(() => 'client') - -const serverThenClientFn = isomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = isomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = isomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = isomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = isomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = isomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnFactory.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnFactory.tsx deleted file mode 100644 index 3974ce77f0..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnFactory.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' - -// Isomorphic function factory - returns a createIsomorphicFn with .client() and .server() calls -export function createPlatformFn(platform: string) { - return createIsomorphicFn() - .client(() => `client-${platform}`) - .server(() => `server-${platform}`) -} - -// Arrow function factory with only server implementation -export const createServerImplFn = (name: string) => { - return createIsomorphicFn().server(() => { - console.log(`Server: ${name}`) - return `server-${name}` - }) -} - -// Arrow function factory with only client implementation -export const createClientImplFn = (name: string) => { - return createIsomorphicFn().client(() => { - console.log(`Client: ${name}`) - return `client-${name}` - }) -} - -// Factory returning no-implementation isomorphic fn -export function createNoImplFn() { - return createIsomorphicFn() -} - -// Top-level isomorphic fn for comparison -export const topLevelIsomorphicFn = createIsomorphicFn() - .client(() => 'client') - .server(() => 'server') diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnInline.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnInline.tsx deleted file mode 100644 index 1b4145bf9c..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnInline.tsx +++ /dev/null @@ -1,55 +0,0 @@ -import { createIsomorphicFn } from '@tanstack/react-start' - -// Create and immediately invoke isomorphic fn inside a function -export function getPlatformValue() { - const fn = createIsomorphicFn() - .client(() => 'client-value') - .server(() => 'server-value') - return fn() -} - -// Arrow function that creates and invokes isomorphic fn -export const getEnvironment = () => { - const envFn = createIsomorphicFn() - .server(() => 'running on server') - .client(() => 'running on client') - return envFn() -} - -// Create isomorphic fn inline without assigning to variable -export function getDirectValue() { - return createIsomorphicFn() - .client(() => 'direct-client') - .server(() => 'direct-server')() -} - -// Multiple isomorphic fns created and used in same function -export function getMultipleValues() { - const first = createIsomorphicFn() - .client(() => 'first-client') - .server(() => 'first-server') - - const second = createIsomorphicFn() - .client(() => 'second-client') - .server(() => 'second-server') - - return { first: first(), second: second() } -} - -// Isomorphic fn with server-only implementation used inline -export function getServerOnlyValue() { - const fn = createIsomorphicFn().server(() => { - console.log('server side effect') - return 'server-only-value' - }) - return fn() -} - -// Isomorphic fn with client-only implementation used inline -export function getClientOnlyValue() { - const fn = createIsomorphicFn().client(() => { - console.log('client side effect') - return 'client-only-value' - }) - return fn() -} diff --git a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx b/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx deleted file mode 100644 index 60ef4f6652..0000000000 --- a/packages/start-plugin-core/tests/createIsomorphicFn/test-files/createIsomorphicFnStarImport.tsx +++ /dev/null @@ -1,37 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' - -const noImpl = TanStackStart.createIsomorphicFn() - -const serverOnlyFn = TanStackStart.createIsomorphicFn().server(() => 'server') - -const clientOnlyFn = TanStackStart.createIsomorphicFn().client(() => 'client') - -const serverThenClientFn = TanStackStart.createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const clientThenServerFn = TanStackStart.createIsomorphicFn() - .client(() => 'client') - .server(() => 'server') - -function abstractedServerFn() { - return 'server' -} - -const serverOnlyFnAbstracted = - TanStackStart.createIsomorphicFn().server(abstractedServerFn) - -function abstractedClientFn() { - return 'client' -} - -const clientOnlyFnAbstracted = - TanStackStart.createIsomorphicFn().client(abstractedClientFn) - -const serverThenClientFnAbstracted = TanStackStart.createIsomorphicFn() - .server(abstractedServerFn) - .client(abstractedClientFn) - -const clientThenServerFnAbstracted = TanStackStart.createIsomorphicFn() - .client(abstractedClientFn) - .server(abstractedServerFn) diff --git a/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts index 94af6ed65e..789baa4d47 100644 --- a/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts +++ b/packages/start-plugin-core/tests/createMiddleware/createMiddleware.test.ts @@ -1,295 +1,284 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' -import { describe, expect, test, vi } from 'vitest' -import { StartCompiler } from '../../src/start-compiler/compiler' -import { formatSnapshot } from '../format-snapshot' +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + callFromClient, + callOnServer, + compileError, + expectCompileError, + inPage, + serveCase, + useStartHost, +} from '../regression-helpers' +import { clientMiddleware, clientMiddlewareOf } from '../page-values' -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - } +/** A third-party library the middlewares below import (a real package). */ +const someLib = { + 'node_modules/@some/lib/package.json': JSON.stringify({ + name: '@some/lib', + type: 'module', + main: './index.js', + }), + 'node_modules/@some/lib/index.js': `export const foo = () => 'foo'\n`, } -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} +const host = useStartHost({ files: someLib }) -async function compile(opts: { - env: 'client' | 'server' - code: string - id: string -}) { - const compiler = new StartCompiler({ - ...opts, - ...getDefaultTestOptions(opts.env), - loadModule: async () => { - // do nothing in test - }, - lookupKinds: new Set(['Middleware']), - lookupConfigurations: [ - { - libName: `@tanstack/react-start`, - rootExport: 'createMiddleware', - kind: 'Root', - }, - { - libName: `@tanstack/react-start`, - rootExport: 'createStart', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (id) => { - return id - }, - }) - const result = await compiler.compile({ - code: opts.code, - id: opts.id, - }) - return result -} - -describe('createMiddleware compiles correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - // Note: Middleware compilation only happens on the client - test(`should compile for ${filename} client`, async () => { - const result = await compile({ env: 'client', code, id: filename }) - - await expect( - await formatSnapshot(result!.code, filename), - ).toMatchFileSnapshot(`./snapshots/client/${filename}`) - }) +describe('createMiddleware compiles correctly', () => { + // Malformed-input diagnostic control (SPEC §8, G5): `.validator()` + // without a validator is a type error (tsc against the real declarations: + // TS2554 "Expected 1 arguments, but got 0"). It only has to fail. + test('requires an argument for validator()', async () => { + const source = `import { createMiddleware } from '@tanstack/react-start' +const myMiddleware = createMiddleware({ type: 'function' }) + .validator() + .server(async ({ next }) => next())` + const startCase = await (await host()).case({ 'module.tsx': source }) + const error = await compileError(startCase) + expectCompileError(error, { source, at: undefined }) }) - test('should compile validator method', async () => { - const code = ` - import { createMiddleware } from '@tanstack/react-start' - const myMiddleware = createMiddleware({ type: 'function' }) - .validator((input: string) => input) - .server(async ({ next }) => { - return next() - })` - - const result = await compile({ - env: 'client', - code, - id: 'test.ts', - }) - - expect(await formatSnapshot(result!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createMiddleware } from '@tanstack/react-start' - const myMiddleware = createMiddleware({ type: 'function' }) - " - `) - }) - - test('should use fast path for direct imports from known library (no extra resolveId calls)', async () => { - const code = ` - import { createMiddleware } from '@tanstack/react-start' - const myMiddleware = createMiddleware().server(async ({ next }) => { - return next() - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async () => {}, - lookupKinds: new Set(['Middleware']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createMiddleware', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - }) - - await compiler.compile({ - code, - id: 'test.ts', - }) - - // Direct known-library imports use the knownRootImports fast path, so they - // do not need resolveId. - expect(resolveIdMock).not.toHaveBeenCalled() - }) - - test('should use slow path for factory pattern (resolveId called for import resolution)', async () => { - // This simulates a factory pattern where createMiddleware is re-exported from a local file - const factoryCode = ` - import { createFooMiddleware } from './factory' - const myMiddleware = createFooMiddleware().server(async ({ next }) => { - return next() - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - // Simulate the factory module being loaded - if (id === './factory') { - compiler.ingestModule({ - code: ` - import { createMiddleware } from '@tanstack/react-start' - export const createFooMiddleware = createMiddleware - `, - id: './factory', - }) - } - }, - lookupKinds: new Set(['Middleware']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createMiddleware', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - }) - - await compiler.compile({ - code: factoryCode, - id: 'test.ts', - }) - - // resolveId should only be called for './factory'. Direct known-library - // imports use the knownRootImports fast path. - // - // Note: The factory module's import from '@tanstack/react-start' ALSO uses - // the fast path (knownRootImports), so no additional resolveId call is needed there. - expect(resolveIdMock).toHaveBeenCalledTimes(1) - expect(resolveIdMock).toHaveBeenNthCalledWith(1, './factory', 'test.ts') - }) - - test('should resolve createMiddleware from start-client-core implementation file', async () => { - const virtualModules: Record<string, string> = { - '@tanstack/start-client-core': ` - export { createMiddleware } from './createMiddleware' - export { createIsomorphicFn } from '@tanstack/start-fn-stubs' - `, - '/virtual/compiler-known/middleware-factory.ts': ` - export const createMiddleware = () => ({ - server: () => createMiddleware(), - }) - `, - } - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - lookupKinds: new Set(['Middleware', 'IsomorphicFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - resolveId: async (source) => { - if (source === '@tanstack/start-client-core') { - return '@tanstack/start-client-core' - } - - if (source === './createMiddleware') { - return '/virtual/compiler-known/middleware-factory.ts' - } - - return null - }, - }) - - const result = await compiler.compile({ - id: '/repo/packages/start-client-core/src/createCsrfMiddleware.ts', - code: ` - import { createIsomorphicFn } from '@tanstack/start-fn-stubs' - import { createMiddleware } from './createMiddleware' - - const innerCreateCsrfMiddleware = () => { - return createMiddleware().server(() => 'server-only-middleware') - } - - export const createCsrfMiddleware = createIsomorphicFn() - .server(innerCreateCsrfMiddleware) - `, - }) - - expect(result).not.toBeNull() - expect(result!.code).not.toContain('server-only-middleware') - expect(result!.code).not.toContain('createIsomorphicFn') - }) - - test('should resolve namespace createMiddleware from start-client-core implementation file', async () => { - const virtualModules: Record<string, string> = { - '@tanstack/start-client-core': ` - export { createMiddleware } from './createMiddleware' - `, - '/virtual/compiler-known/middleware-factory.ts': ` - export const createMiddleware = () => ({ - server: () => createMiddleware(), - }) - `, - } - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - lookupKinds: new Set(['Middleware']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - resolveId: async (source) => { - if (source === '@tanstack/start-client-core') { - return '@tanstack/start-client-core' - } - - if (source === './createMiddleware') { - return '/virtual/compiler-known/middleware-factory.ts' - } - - return null - }, - }) - - const result = await compiler.compile({ - id: '/repo/packages/start-client-core/src/internal.ts', - code: ` - import * as middlewareModule from './createMiddleware' - - export const middleware = middlewareModule.createMiddleware().server(() => { - return 'server-only-middleware' - }) - `, - }) - - expect(result).not.toBeNull() - expect(result!.code).not.toContain('server-only-middleware') + test('keeps a middleware without a server function on the client', async () => { + const code = `import { createMiddleware } from '@tanstack/react-start' +export const logger = createMiddleware({ type: 'function' }).client( + async ({ next }) => next(), +)` + const served = await serveCase(await host(), { 'module.tsx': code }) + expect( + await inPage(served, 'return typeof module.logger.options.client'), + ).toBe('function') }) }) + +// The client keeps what a middleware runs in the browser (`.client()`, the +// chain itself) and drops its server part: `.server()`, `.validator()` (the +// validator only runs on the server) and the code and imports only they +// read. +// Replaces the former snapshot fixtures of this directory. +describe('the client keeps the browser part of a middleware', () => { + /** A case of `code` (and `files`), which every environment serves. */ + async function evaluateClient( + code: string, + files: Record<string, string> = {}, + ) { + return serveCase(await host(), { 'module.tsx': code, ...files }) + } + + // Source: snapshot fixture create-function-middleware.ts + test('a function middleware keeps .client() and drops .server() and its imports', async () => { + const served = + await evaluateClient(`import { createMiddleware } from '@tanstack/react-start' +import { foo } from '@some/lib' +export const fnMw = createMiddleware({ type: 'function' }) + .client(() => 'client') + .server(({ next }) => { + foo() + return next() + })`) + expectNotLoaded(await served.loads(), ['@some/lib']) + expect( + await inPage( + served, + `return [module.fnMw.options.type, module.fnMw.options.client(), module.fnMw.options.server === undefined]`, + ), + ).toEqual(['function', 'client', true]) + }) + + // Source: snapshot fixtures createMiddlewareDestructured.tsx, + // createMiddlewareDestructuredRename.tsx, createMiddlewareStarImport.tsx + test('.server() given a function expression, an arrow, an identifier or a wrapper call leaves no server code or import in the client', async () => { + const served = + await evaluateClient(`import { createMiddleware } from '@tanstack/react-start' +import { z } from 'zod' +export const withFunction = createMiddleware({ type: 'function' }) + .client(() => 'function') + .server(async function () { + return z.number() + }) +export const withArrow = createMiddleware({ type: 'function' }) + .client(() => 'arrow') + .server(async () => z.number()) +export const withVariable = createMiddleware({ type: 'function' }) + .client(() => 'variable') + .server(abstractedFunction) +async function abstractedFunction() { + return z.number() +} +function zodValidator(schema: unknown, fn: (input: unknown) => unknown) { + return async (input: unknown) => fn([schema, input]) +} +export const withWrapper = createMiddleware({ type: 'function' }) + .client(() => 'wrapper') + .server(zodValidator(z.number(), (input) => ({ 'you gave': input })))`) + // What the dead helpers are called is free (SPEC §5.9): the client + // loading no server-only module is the check. + expectNotLoaded(await served.loads(), ['zod']) + expect( + await inPage( + served, + `return ['withFunction', 'withArrow', 'withVariable', 'withWrapper'].map((name) => [ + module[name].options.client(), + module[name].options.server === undefined, +])`, + ), + ).toEqual([ + ['function', true], + ['arrow', true], + ['variable', true], + ['wrapper', true], + ]) + }) + + // Source: snapshot fixture createMiddlewareValidator.tsx, inline snapshot + // "should compile validator method" + test('the validator and its module leave the client', async () => { + const served = + await evaluateClient(`import { createMiddleware } from '@tanstack/react-start' +import { z } from 'zod' +export const withValidator = createMiddleware({ type: 'function' }) + .validator(z.number()) + .client(() => 'client') + .server(({ data, next }) => next({ context: { value: data + 1 } }))`) + expectNotLoaded(await served.loads(), ['zod']) + expect( + await inPage( + served, + `const { options } = module.withValidator +return [options.validator === undefined, options.server === undefined, options.client()]`, + ), + ).toEqual([true, true, 'client']) + }) + + // Source: snapshot fixture middleware-factory.ts + test('a middleware built inside a function drops .server() and what it reads', async () => { + const served = await evaluateClient( + `import { createMiddleware } from '@tanstack/react-start' +import { rateLimit, getUser } from './auth.server' +export function createPublicRateLimitMiddleware(keySuffix) { + return createMiddleware({ type: 'function' }).server(async ({ next }) => { + await rateLimit({ key: keySuffix }) + return next() + }) +} +export const createAuthMiddleware = (requiredRole) => { + return createMiddleware({ type: 'function' }).server(async ({ next }) => { + const user = await getUser() + if (user.role !== requiredRole) { + throw new Error('Forbidden') + } + return next() + }) +} +export const topLevelMiddleware = createMiddleware({ type: 'function' }) + .client(() => 'topLevel') + .server(async ({ next }) => next())`, + { + 'auth.server.ts': `export const rateLimit = async (options: unknown) => options +export const getUser = async () => ({ role: 'admin' }) +`, + }, + ) + expectNotLoaded(await served.loads(), ['./auth.server']) + expect( + await inPage( + served, + `return [ + ${clientMiddlewareOf(`module.createPublicRateLimitMiddleware('ip')`)}, + ${clientMiddlewareOf(`module.createAuthMiddleware('admin')`)}, + module.topLevelMiddleware.options.client(), + module.topLevelMiddleware.options.server === undefined, +]`, + ), + ).toEqual([ + clientMiddleware('function'), + clientMiddleware('function'), + 'topLevel', + true, + ]) + }) + + // Source: snapshot fixture createStart.tsx + test('middleware of a createStart instance keeps .client() and drops .server()', async () => { + const served = await evaluateClient( + `import { createStart } from '@tanstack/react-start' +import { audit } from './audit.server' +export const startInstance = createStart(() => ({})) +export const serverFnMw = startInstance + .createMiddleware({ type: 'function' }) + .client(({ next }) => next()) + .server(({ next }) => { + audit('function') + return next({ context: { admin: 'admin' } }) + }) +export const requestMw = startInstance + .createMiddleware({ type: 'request' }) + .server(({ next }) => { + audit('request') + return next({ context: { requestMw: 'yes' } }) + })`, + { 'audit.server.ts': `export const audit = (kind: string) => kind\n` }, + ) + expectNotLoaded(await served.loads(), ['./audit.server']) + expect( + await inPage( + served, + `return [ + typeof module.serverFnMw.options.client, + module.serverFnMw.options.server === undefined, + ${clientMiddlewareOf('module.requestMw')}, +]`, + ), + ).toEqual(['function', true, clientMiddleware('request')]) + }) +}) + +// Start's own CSRF middleware factory is an isomorphic fn whose server +// implementation builds a middleware (`createMiddleware().server()` in +// Start's built package): an app's client gets the no-op of an isomorphic +// fn without a client implementation, its server a request middleware. +test("Start's createCsrfMiddleware is a no-op in the client and a request middleware on the server", async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createCsrfMiddleware } from '@tanstack/react-start' +export const csrf = createCsrfMiddleware()`, + }) + expect(await inPage(served, 'return module.csrf === undefined')).toBe(true) + const { csrf } = await served.ssr() + expect([csrf.options.type, typeof csrf.options.server]).toEqual([ + 'request', + 'function', + ]) +}) + +// A valid full chain (`.middleware().validator().client().server()`) of a +// middleware a server fn uses, run through Start's runtime: the client runs +// `.client()` (its send context reaches the server) and ships no server +// code; on the server, a call from server code and a client call by id run +// the validator, `.server()` and the handler, with the context `.server()` +// adds. +test('a full middleware chain runs its client part on the client and its server part on the server', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +import { check } from './check.server' +const base = createMiddleware({ type: 'function' }).client(({ next }) => + next({ sendContext: { base: 'base' } }), +) +export const auth = createMiddleware({ type: 'function' }) + .middleware([base]) + .validator((data: string) => check(data)) + .client(({ next }) => next({ sendContext: { from: 'client' } })) + .server(async ({ next, context }) => + next({ context: { user: db.user(context.from) } }), + ) +export const fn = createServerFn({ method: 'POST' }) + .middleware([auth]) + .handler(async ({ data, context }) => [data, context.user, context.base])`, + 'db.server.ts': `export const db = { user: (from: string) => \`user(\${from})\` }\n`, + 'check.server.ts': `export const check = (data: string) => \`checked(\${data})\`\n`, + }) + expectNotLoaded(await served.loads(), ['./db.server', './check.server']) + expect(served.code.client).not.toMatch(/db\.user|check\(/) + const expected = ['checked(input)', 'user(client)', 'base'] + expect(await callFromClient(served, 'module.fn', 'input')).toEqual(expected) + // Server code calling the server fn gets the same result. + expect(await callOnServer(served, 'module.fn', 'input')).toEqual(expected) +}) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts deleted file mode 100644 index 73d5910eef..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/create-function-middleware.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -export const fnMw = createMiddleware({ type: 'function' }).client(() => { - console.log('client') -}) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx deleted file mode 100644 index c3497f072b..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructured.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -export const withUseServer = createMiddleware({ id: 'test' }) -export const withoutUseServer = createMiddleware({ id: 'test' }) -export const withVariable = createMiddleware({ id: 'test' }) -export const withZodValidator = createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx deleted file mode 100644 index 70d3921bda..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareDestructuredRename.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createMiddleware as middlewareFn } from '@tanstack/react-start' -export const withUseServer = middlewareFn({ id: 'test' }) -export const withoutUseServer = middlewareFn({ id: 'test' }) -export const withVariable = middlewareFn({ id: 'test' }) -export const withZodValidator = middlewareFn({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx deleted file mode 100644 index f997f40fe0..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareStarImport.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' -export const withUseServer = TanStackStart.createMiddleware({ id: 'test' }) -export const withoutUseServer = TanStackStart.createMiddleware({ id: 'test' }) -export const withVariable = TanStackStart.createMiddleware({ id: 'test' }) -export const withZodValidator = TanStackStart.createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx deleted file mode 100644 index 773e990702..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createMiddlewareValidator.tsx +++ /dev/null @@ -1,2 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -export const withUseServer = createMiddleware({ id: 'test' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx deleted file mode 100644 index b2bde33436..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/createStart.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { createStart } from '@tanstack/react-start' -export const startInstance = createStart(() => {}) -export const serverFnMw = startInstance - .createMiddleware({ type: 'function' }) - .client(({ next }) => { - console.log('client mw') - return next() - }) -export const requestMw = startInstance.createMiddleware({ type: 'request' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts b/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts deleted file mode 100644 index 0e51f2f369..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/snapshots/client/middleware-factory.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -// Middleware factory function - returns a middleware with .server() call -export function createPublicRateLimitMiddleware(keySuffix) { - return createMiddleware({ type: 'function' }) -} -// Arrow function factory -export const createAuthMiddleware = (requiredRole) => { - return createMiddleware({ type: 'function' }) -} -// Top-level middleware for comparison -export const topLevelMiddleware = createMiddleware({ id: 'topLevel' }) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/create-function-middleware.ts b/packages/start-plugin-core/tests/createMiddleware/test-files/create-function-middleware.ts deleted file mode 100644 index c52e0d4cef..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/create-function-middleware.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' - -import { foo } from '@some/lib' - -export const fnMw = createMiddleware({ - type: 'function', -}) - .server(({ next }) => { - console.log('server') - foo() - return next() - }) - .client(() => { - console.log('client') - }) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx deleted file mode 100644 index 7e98897ecf..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructured.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = createMiddleware({ - id: 'test', -}).server(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = createMiddleware({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = createMiddleware({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = createMiddleware({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx deleted file mode 100644 index 79c59b8eb9..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareDestructuredRename.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createMiddleware as middlewareFn } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = middlewareFn({ - id: 'test', -}).server(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = middlewareFn({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = middlewareFn({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = middlewareFn({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx deleted file mode 100644 index c1cd35f42d..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareStarImport.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = TanStackStart.createMiddleware({ - id: 'test', -}).server(async function () { - 'use server' - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = TanStackStart.createMiddleware({ - id: 'test', -}).server(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = TanStackStart.createMiddleware({ - id: 'test', -}).server(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = TanStackStart.createMiddleware({ - id: 'test', -}).server( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareValidator.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareValidator.tsx deleted file mode 100644 index 894bf4608f..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/createMiddlewareValidator.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = createMiddleware({ - id: 'test', -}) - .validator(z.number()) - .server(({ input }) => input + 1) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/createStart.tsx b/packages/start-plugin-core/tests/createMiddleware/test-files/createStart.tsx deleted file mode 100644 index 0c0e456071..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/createStart.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { createStart } from '@tanstack/react-start' - -export const startInstance = createStart(() => {}) - -export const serverFnMw = startInstance - .createMiddleware({ type: 'function' }) - .server(({ next }) => { - console.log('server mw') - return next({ - context: { admin: 'admin' }, - }) - }) - .client(({ next }) => { - console.log('client mw') - return next() - }) - -export const requestMw = startInstance - .createMiddleware({ type: 'request' }) - .server(({ next }) => { - return next({ - context: { requestMw: 'yes' }, - }) - }) diff --git a/packages/start-plugin-core/tests/createMiddleware/test-files/middleware-factory.ts b/packages/start-plugin-core/tests/createMiddleware/test-files/middleware-factory.ts deleted file mode 100644 index a306dbf371..0000000000 --- a/packages/start-plugin-core/tests/createMiddleware/test-files/middleware-factory.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { createMiddleware } from '@tanstack/react-start' - -// Middleware factory function - returns a middleware with .server() call -export function createPublicRateLimitMiddleware(keySuffix) { - return createMiddleware({ type: 'function' }).server( - async ({ next, data }) => { - const key = keySuffix ? `ip:${keySuffix}` : 'ip:default' - const finalKey = typeof data === 'string' ? `ip:${data}` : key - - const { success } = await rateLimit({ key: finalKey }) - - if (!success) { - throw new Error('Too many requests') - } - - return next() - }, - ) -} - -// Arrow function factory -export const createAuthMiddleware = (requiredRole) => { - return createMiddleware({ type: 'function' }).server(async ({ next }) => { - const user = await getUser() - if (!user) { - throw new Error('Unauthorized') - } - if (requiredRole && user.role !== requiredRole) { - throw new Error('Forbidden') - } - return next() - }) -} - -// Top-level middleware for comparison -export const topLevelMiddleware = createMiddleware({ - id: 'topLevel', -}).server(async ({ next }) => { - console.log('top level') - return next() -}) diff --git a/packages/start-plugin-core/tests/createServerFn/caller-dead-code.test.ts b/packages/start-plugin-core/tests/createServerFn/caller-dead-code.test.ts index 07c7a2f2cf..25746a4b85 100644 --- a/packages/start-plugin-core/tests/createServerFn/caller-dead-code.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/caller-dead-code.test.ts @@ -1,24 +1,45 @@ -import { describe, expect, test } from 'vitest' +import { describe, expect, test, vi } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' import { - callProvider, - compileAll, - compileCode, - evaluateModule, - importSources, + callFromClient, + callOnServer, + callServerFnThroughCallers, + inPage, + serveCase, + useStartHost, } from '../regression-helpers' -import { declarationOf, getModuleErrors } from '../validate-module' -import type { ModuleStub } from '../regression-helpers' -// Client and SSR callers replace a server fn handler with an RPC, then drop -// the module code only the handler read, so server-only imports never reach -// them. Code the callers still read must survive with its values. +// The client replaces a server fn handler with an RPC, then drops the module +// code only the handler read, so server-only imports never reach it. Code the +// client still reads must survive with its values. Server code may do the +// same or keep the handler in place: calling the server fn from it runs the +// handler either way. "Drops" is observed as loading: the modules a page +// importing the module loads (`loads`: what the browser requests and Vite's +// client module graph holds), never as an inventory of its import +// declarations. Every module the fixtures import is a real +// file of the case. + +const host = useStartHost() const head = `import { createServerFn } from '@tanstack/react-start'\n` -const dbServer = `export const db = { x: () => 'x' }` +const dbServer = `export const db = { x: () => 'x' }\n` + +/** A page check: a script and what it must return. */ +interface PageCheck { + script: string + expected: unknown +} describe('callers drop a server import only the handler reads', () => { // Source: Next.js server-actions fixtures server-graph/6 (shadowed bindings) - test.each([ + test.each<{ + name: string + code: string + files: Record<string, string> + forbidden: Array<string> + check: PageCheck + expected: unknown + }>([ { name: 'a handler local shadows an import the client uses', code: `import { db } from './db.server' @@ -28,31 +49,37 @@ export const fn = createServerFn().handler(async () => { const format = (value: unknown) => \`local:\${value}\` return format(db.x()) })`, - client: ['./format'], - provider: ['./db.server'], + files: { + 'format.ts': + 'export const format = (value: string) => `format:${value}`\n', + }, + forbidden: ['./db.server'], + check: { script: 'return module.label', expected: 'format:x' }, expected: 'local:x', }, { + // The client reads the server module itself (`clientDb`): it stays. name: 'a handler parameter shadows an import the client uses', code: `import { db } from './db.server' export const fn = createServerFn().handler(async ({ data: db }: { data: string }) => db) export const clientDb = db`, - client: ['./db.server'], - provider: [], + files: {}, + forbidden: [], + check: { + script: `return module.clientDb === (await load('db.server.ts')).db`, + expected: true, + }, expected: 'param', }, - ])('when $name', async ({ code, client, provider, expected }) => { - const compiled = await compileAll(`${head}${code}`) - expect(importSources(compiled.client)).toEqual(client) - expect(importSources(compiled.provider)).toEqual(provider) - expect( - await callProvider( - compiled.provider, - 'fn', - { './db.server': dbServer }, - 'param', - ), - ).toBe(expected) + ])('when $name', async ({ code, files, forbidden, check, expected }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}${code}`, + 'db.server.ts': dbServer, + ...files, + }) + expectNotLoaded(await served.loads(), forbidden) + expect(await inPage(served, check.script)).toEqual(check.expected) + expect(await callFromClient(served, 'module.fn', 'param')).toBe(expected) }) // Each snippet uses the name `db` in a position that is not a reference to @@ -60,8 +87,8 @@ export const clientDb = db`, test.each<{ name: string code: string - stubs?: Record<string, ModuleStub> - check?: (client: Record<string, any>) => void + files?: Record<string, string> + check?: PageCheck }>([ { // Source: @vitejs/plugin-rsc scope/label.js @@ -74,20 +101,26 @@ export const clientDb = db`, } return 'loop' }`, - check: (client) => expect(client.loop()).toBe('loop'), + check: { script: 'return module.loop()', expected: 'loop' }, }, { // Source: @vitejs/plugin-rsc scope/object-expr-vs-pattern.js name: 'an object key and a pattern key', code: `export const options = { db: 'key' } export const pick = ({ db: local }) => local`, - check: (client) => expect(client.pick(client.options)).toBe('key'), + check: { + script: 'return module.pick(module.options)', + expected: 'key', + }, }, { // Source: @vitejs/plugin-rsc scope/member-expr.js name: 'a member property', code: `export const read = (object) => object.db`, - check: (client) => expect(client.read({ db: 'member' })).toBe('member'), + check: { + script: `return module.read({ db: 'member' })`, + expected: 'member', + }, }, { // Source: @vitejs/plugin-rsc scope/method-definition.js, @@ -104,10 +137,9 @@ export class Store { return [this.db, this.#db] } }`, - check: (client) => { - expect(client.api.db()).toBe('method') - expect(client.Store.db()).toBe('static') - expect(new client.Store().read()).toEqual(['field', 'private']) + check: { + script: `return [module.api.db(), module.Store.db(), new module.Store().read()]`, + expected: ['method', 'static', ['field', 'private']], }, }, { @@ -115,7 +147,7 @@ export class Store { name: 'an export alias', code: `const local = 'alias' export { local as db }`, - check: (client) => expect(client.db).toBe('alias'), + check: { script: 'return module.db', expected: 'alias' }, }, { // Source: @vitejs/plugin-rsc scope/destructuring-assignment.js @@ -123,7 +155,7 @@ export { local as db }`, code: `let bound ;({ db: bound } = { db: 'assigned' }) export { bound }`, - check: (client) => expect(client.bound).toBe('assigned'), + check: { script: 'return module.bound', expected: 'assigned' }, }, { // Source: @vitejs/plugin-rsc scope/catch-param.js @@ -135,7 +167,7 @@ export { bound }`, return db } }`, - check: (client) => expect(client.safe()).toBe('caught'), + check: { script: 'return module.safe()', expected: 'caught' }, }, { // Source: @vitejs/plugin-rsc scope/fn-expr-name.js, scope/class-expr-self.js @@ -148,9 +180,9 @@ export const Self = class db { return db } }`, - check: (client) => { - expect(client.self()).toBe(client.self) - expect(client.Self.self()).toBe(client.Self) + check: { + script: `return [module.self() === module.self, module.Self.self() === module.Self]`, + expected: [true, true], }, }, { @@ -168,9 +200,9 @@ export function hoistedFunction() { return 'function' } }`, - check: (client) => { - expect(client.hoistedVar()).toBe('var') - expect(client.hoistedFunction()).toBe('function') + check: { + script: 'return [module.hoistedVar(), module.hoistedFunction()]', + expected: ['var', 'function'], }, }, { @@ -200,10 +232,9 @@ export class Block { Block.value = db } }`, - check: (client) => { - expect(client.loops()).toEqual([0, 'of', 'in']) - expect(client.choose(2)).toBe('switch') - expect(client.Block.value).toBe('static') + check: { + script: 'return [module.loops(), module.choose(2), module.Block.value]', + expected: [[0, 'of', 'in'], 'switch', 'static'], }, }, { @@ -220,25 +251,24 @@ export const accessors = { export function rest(...db) { return db }`, - check: (client) => { - expect(client.params('param')).toBe('param') - client.accessors.value = 'set' - expect(client.accessors.stored).toBe('set') - expect(client.rest(1, 2)).toEqual([1, 2]) + check: { + script: `module.accessors.value = 'set' +return [module.params('param'), module.accessors.stored, module.rest(1, 2)]`, + expected: ['param', 'set', [1, 2]], }, }, { // Source: @vitejs/plugin-rsc scope/import-meta.js name: 'an import.meta property', code: `export const meta = typeof import.meta.db`, - check: (client) => expect(client.meta).toBe('undefined'), + check: { script: 'return module.meta', expected: 'undefined' }, }, { // Source: @vitejs/plugin-rsc hoist/reexport-import-not-bound.js name: 'a re-export', code: `export { db } from './other'`, - stubs: { './other': `export const db = 'other'` }, - check: (client) => expect(client.db).toBe('other'), + files: { 'other.ts': `export const db = 'other'\n` }, + check: { script: 'return module.db', expected: 'other' }, }, { // Source: typescript-eslint ts-module/namespace.js, ts-module/scope.js @@ -247,7 +277,7 @@ export function rest(...db) { export const db = 'namespace' export const read = () => db }`, - check: (client) => expect(client.Repo.read()).toBe('namespace'), + check: { script: 'return module.Repo.read()', expected: 'namespace' }, }, { // Source: typescript-eslint type-declaration/interface1.js, type1.js, @@ -260,7 +290,7 @@ export type Shape = { db: number } export function identity<db>(value: db): db { return value }`, - check: (client) => expect(client.identity('id')).toBe('id'), + check: { script: `return module.identity('id')`, expected: 'id' }, }, { // Source: typescript-eslint jsx/attribute.js, jsx/namespaced-attribute.js, @@ -278,19 +308,80 @@ export class View { }, ])( 'when client code uses its name in $name', - async ({ code, stubs = {}, check }) => { - const client = await compileCode( - 'client', - `${head}import { db } from './db.server' + async ({ code, files = {}, check }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { db } from './db.server' export const fn = createServerFn().handler(async () => db.x()) ${code}`, - ) - expect(await getModuleErrors(client!)).toEqual([]) - expect(importSources(client!)).toEqual(Object.keys(stubs)) - check?.(await evaluateModule(client!, stubs)) + 'db.server.ts': dbServer, + ...files, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + if (check) { + expect(await inPage(served, check.script)).toEqual(check.expected) + } }, ) + // Bug: these TypeScript positions named like the import (an enum member, + // an overload signature parameter, a constructor parameter property) count + // as references to it, so the callers keep the server-only import after + // the handler that read it is gone. + // Impact: the client loads the server-only module (its top-level code + // runs in the browser). + // Source: #8504 caller-dead-code.test.ts (typescript-eslint scope fixtures; + // red on main) + test.fails.each<{ + name: string + code: string + check: PageCheck + }>([ + { + // Source: typescript-eslint ts-enum/member-ref.js; #8504 + // caller-dead-code.test.ts + name: 'an enum member', + code: `export enum Flags { + db = 1, + other = db + 1, +}`, + check: { script: 'return module.Flags.other', expected: 2 }, + }, + { + // Source: typescript-eslint functions/function-declaration/overload.js; + // #8504 caller-dead-code.test.ts + name: 'an overload signature parameter', + code: `export function call(db: string): string +export function call(value: string) { + return value +}`, + check: { script: `return module.call('call')`, expected: 'call' }, + }, + { + // Source: typescript-eslint class/declaration/parameter-properties.js; + // #8504 caller-dead-code.test.ts + name: 'a parameter property', + code: `export class Service { + constructor(private db: string) {} + read() { + return this.db + } +}`, + check: { + script: `return new module.Service('param').read()`, + expected: 'param', + }, + }, + ])('when client code uses its name in $name', async ({ code, check }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { db } from './db.server' +export const fn = createServerFn().handler(async () => db.x()) +${code}`, + 'db.server.ts': dbServer, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await inPage(served, check.script)).toEqual(check.expected) + }) + // Source: SolidStart compile.spec.ts "removes an import when only type // specifiers remain", "preserves live value specifiers from a mixed // import"; babel-dead-code-elimination "import" > "mixed default and named" @@ -298,57 +389,143 @@ ${code}`, { name: 'only type specifiers remain', code: `import { type Session, verify } from './server-module'`, - callers: [], + client: [], + value: undefined, }, { name: 'a named client specifier remains', code: `import verify, { type Session, clientValue } from './server-module' export const value = clientValue`, - callers: ['./server-module'], + client: ['./server-module'], + value: 'client', }, { name: 'a default client specifier remains', code: `import clientDefault, { type Session, verify } from './server-module' export const value = clientDefault`, - callers: ['./server-module'], + client: ['./server-module'], + value: 'default', }, ])( 'when it shares a mixed import in which $name', - async ({ code, callers }) => { - const compiled = await compileAll(`${head}${code} -export const fn = createServerFn().handler(async (): Promise<Session | null> => verify())`) - for (const caller of [compiled.client, compiled.ssr]) { - expect(importSources(caller)).toEqual(callers) - expect(caller).not.toMatch(/\bverify\b/) + async ({ code, client, value }) => { + // `verify` is the default export where the module imports it as such. + const verify = `() => 'verified'` + const served = await serveCase(await host(), { + 'module.tsx': `${head}${code} +export const fn = createServerFn().handler(async (): Promise<Session | null> => verify())`, + 'server-module.ts': `export type Session = { id: string } +export const clientValue = 'client' +export const verify = ${verify} +export default ${code.startsWith('import verify') ? verify : `'default'`} +`, + }) + // The server module loads only for a value the client reads. + const loads = await served.loads() + if (client.length === 0) { + expectNotLoaded(loads, ['./server-module']) } - expect(compiled.provider).not.toMatch(/\bclient(?:Value|Default)\b/) - expect( - await callProvider(compiled.provider, 'fn', { - './server-module': `export const clientValue = 'client'; export const verify = () => 'verified'; export default verify`, - }), - ).toBe('verified') + expect(await inPage(served, 'return module.value')).toBe(value) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe( + 'verified', + ) }, ) + // The client keeps the middleware's `.client()` (its send context reaches + // the server) and drops the imports only its `.server()` and the server + // fn's validator read; the server runs both before the handler. // Source: Next.js server-actions fixtures server-graph/47, /58 test('when the handler only reads it through a validator or a middleware', async () => { - const compiled = - await compileAll(`import { createMiddleware, createServerFn } from '@tanstack/react-start' + // The server modules record their calls in this process (the dev + // server's SSR environment runs here). + const calls = ((globalThis as Record<string, unknown>).__b2DeadCodeCalls = + []) as Array<string> + const served = await serveCase(await host(), { + 'module.tsx': `import { createMiddleware, createServerFn } from '@tanstack/react-start' import { db } from './db.server' import { schema } from './schema.server' const auth = createMiddleware({ type: 'function' }) - .client(async ({ next }) => next()) + .client(async ({ next }) => next({ sendContext: { from: 'client' } })) .server(async ({ next }) => next({ context: { user: await db.user() } })) -export const fn = createServerFn() +export const fn = createServerFn({ method: 'POST' }) .middleware([auth]) .validator((data: unknown) => schema.parse(data)) - .handler(async () => 'ok')`) - expect(importSources(compiled.client)).toEqual([]) - expect(importSources(compiled.provider)).toEqual([ - './db.server', - './schema.server', + .handler(async ({ data, context }) => [data, context.user, context.from])`, + 'db.server.ts': `export const db = { + user: () => ((globalThis as any).__b2DeadCodeCalls.push('db.user'), 'user'), +} +`, + 'schema.server.ts': `export const schema = { + parse: (data: unknown) => ((globalThis as any).__b2DeadCodeCalls.push('schema.parse'), \`\${data}!\`), +} +`, + }) + expectNotLoaded(await served.loads(), ['./db.server', './schema.server']) + expect(await callFromClient(served, 'module.fn', 'data')).toEqual([ + 'data!', + 'user', + 'client', ]) + expect(calls).toEqual(['db.user', 'schema.parse']) }) + + // The validator only runs on the server, so the client drops it and the + // imports only it reads, also when a cast wraps the chain link. + // Bug: a `.validator()` link wrapped in `satisfies` / `as` is not stripped + // from the callers. + // Impact: the validator and its imports ship to the client, code the + // client never runs. + // Source: #8504 caller-dead-code.test.ts (differential fuzzing; red on + // main) + test.fails.each([ + { name: 'satisfies', wrap: (link: string) => `(${link} satisfies any)` }, + { name: 'cast', wrap: (link: string) => `(${link} as any)` }, + ])( + 'when the validator link is wrapped in a $name expression', + async ({ wrap }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { schema } from './schema' +export const fn = ${wrap(`createServerFn().validator(schema)`)}.handler(async ({ data }) => data)`, + 'schema.ts': 'export const schema = (data: string) => `${data}!`\n', + }) + expectNotLoaded(await served.loads(), ['./schema']) + expect(await callFromClient(served, 'module.fn', 'data')).toBe('data!') + }, + ) + + // Bug: a `.validator()` link on a builder stored in a variable is not + // stripped from the callers: the client follows the handler's chain only + // up to the identifier (`withPost.handler(...)`), so the variable's + // declaration keeps its validator. An inline chain is stripped ("when the + // handler only reads it through a validator or a middleware", above). + // Source: start-compiler/compiler.ts:1296-1330 (the chain walk stops at an + // identifier), start-compiler/handleCreateServerFn.ts:277-290; fuzzing. + // Impact: the validator and its imports (schemas, server-only modules) + // ship to the client, which never runs them. + test.fails.each([ + { + name: 'one handler', + handlers: `export const fn = withPost.handler(async ({ data }) => data)`, + }, + { + name: 'two handlers', + handlers: `export const fn = withPost.handler(async ({ data }) => data) +export const other = withPost.handler(async ({ data }) => data)`, + }, + ])( + 'when the validator link is on a builder stored in a variable ($name)', + async ({ handlers }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { schema } from './schema' +const withPost = createServerFn({ method: 'POST' }).validator(schema) +${handlers}`, + 'schema.ts': 'export const schema = (data: string) => `${data}!`\n', + }) + expectNotLoaded(await served.loads(), ['./schema']) + expect(await callFromClient(served, 'module.fn', 'data')).toBe('data!') + }, + ) }) // Source: @vitejs/plugin-rsc hoist/function-hoist-block.js, @@ -392,18 +569,16 @@ test.each([ }`, }, ])('client code that reads an import $name keeps it', async ({ code }) => { - const client = await compileCode( - 'client', - `${head}import { store } from './store' + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { store } from './store' import { db } from './db.server' export const fn = createServerFn().handler(async () => db.x()) ${code}`, - ) - expect(importSources(client!)).toEqual(['./store']) - const module = await evaluateModule(client!, { - './store': `export const store = { value: 'store' }`, + 'store.ts': `export const store = { value: 'store' }\n`, + 'db.server.ts': dbServer, }) - expect(module.read()).toBe('store') + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await inPage(served, 'return module.read()')).toBe('store') }) describe('destructurings shared by the handler and client code', () => { @@ -411,7 +586,7 @@ describe('destructurings shared by the handler and client code', () => { test.each<{ name: string code: string - stubs: Record<string, ModuleStub> + files: Record<string, string> clientValue: unknown handlerValue: unknown }>([ @@ -421,7 +596,7 @@ describe('destructurings shared by the handler and client code', () => { const [serverOnly, shared] = values export const clientValue = shared export const fn = createServerFn().handler(async () => serverOnly)`, - stubs: { './values': `export const values = ['server', 'shared']` }, + files: { 'values.ts': `export const values = ['server', 'shared']\n` }, clientValue: 'shared', handlerValue: 'server', }, @@ -432,21 +607,23 @@ export const fn = createServerFn().handler(async () => serverOnly)`, const { secretKey, ...publicConfig } = config export const clientValue = publicConfig export const fn = createServerFn().handler(async () => secretKey)`, - stubs: { - './config': `export const config = { secretKey: 'key', theme: 'dark' }`, + files: { + 'config.ts': `export const config = { secretKey: 'key', theme: 'dark' }\n`, }, clientValue: { theme: 'dark' }, handlerValue: 'key', }, ])( 'keep their values in every output for $name', - async ({ code, stubs, clientValue, handlerValue }) => { - const compiled = await compileAll(`${head}${code}`) - const client = await evaluateModule(compiled.client, stubs) - expect(client.clientValue).toEqual(clientValue) - expect(await callProvider(compiled.provider, 'fn', stubs)).toEqual( - handlerValue, + async ({ code, files, clientValue, handlerValue }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}${code}`, + ...files, + }) + expect(await inPage(served, 'return module.clientValue')).toEqual( + clientValue, ) + expect(await callFromClient(served, 'module.fn')).toEqual(handlerValue) }, ) @@ -478,114 +655,159 @@ const { db: { apiKey = readSecret() } = {}, theme } = config`, ])( 'drop a server import read by $name of a handler-only binding', async ({ code }) => { - const compiled = - await compileAll(`${head}import { config } from './config' + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { config } from './config' ${code} export const fn = createServerFn().handler(async () => apiKey) -export const currentTheme = theme`) - expect(importSources(compiled.client)).toEqual(['./config']) - const client = await evaluateModule(compiled.client, { - './config': `export const config = { theme: 'dark', list: [undefined, 'dark'] }`, +export const currentTheme = theme`, + 'config.ts': `export const config = { theme: 'dark', list: [undefined, 'dark'] }\n`, + 'secrets.server.ts': `export const readSecret = () => 'secret' +export const secretKeyName = 'apiKey' +`, }) - expect(client.currentTheme).toBe('dark') + expectNotLoaded(await served.loads(), ['./secrets.server']) + expect(await inPage(served, 'return module.currentTheme')).toBe('dark') }, ) }) describe('declarations only the handler needs', () => { + // Bug: a function whose body declares a local of the function's own name + // (`function session() { const session = ... }`) counts as used by that + // local, so the callers keep it, and the server-only import it reads, + // after the handler that called it is gone. + // Impact: the client loads the server-only module. + // Source: React Compiler fixture context-variable-as-jsx-element-tag.js; + // #8504 caller-dead-code.test.ts (red on main) + test.fails( + 'callers drop a handler-only function that declares a local of its own name', + async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { readSecret } from './server-only' +function session() { + const session = readSecret() + return session.id +} +export const getReport = createServerFn().handler(async () => session())`, + 'server-only.ts': `export const readSecret = () => ({ id: 'report' })\n`, + }) + expectNotLoaded(await served.loads(), ['./server-only']) + expect(await callServerFnThroughCallers(served, 'module.getReport')).toBe( + 'report', + ) + }, + ) + + // Whether the client keeps code that reads no server code (`loop`, + // `unusedA`, `unusedB`) is left open. // Source: babel-dead-code-elimination "SCC dead code elimination" (mutual // recursion, self-recursive functions, unexported circular references) - test('callers drop handler-only cycles and default parameters but keep cycles nothing used', async () => { - const compiled = - await compileAll(`${head}import { secret, defaultId } from './secret.server' + test('the client drops handler-only cycles and default parameters', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { secret, defaultId } from './secret.server' function walk(n: number): number { return n > 0 ? walkBack(n - 1) : secret.length } function walkBack(n: number): number { return n > 0 ? walk(n - 1) : 0 } const loop = (n: number): number => (n > 0 ? loop(n - 1) : 0) function load(id = defaultId()) { return id } function unusedA(): number { return unusedB() } function unusedB(): number { return unusedA() } -export const fn = createServerFn().handler(async () => [walk(3), loop(2), load()])`) - for (const caller of [compiled.client, compiled.ssr]) { - expect(importSources(caller)).toEqual([]) - for (const name of ['walk', 'walkBack', 'loop', 'load']) { - expect(caller).not.toMatch(declarationOf(name)) - } - } - for (const name of ['walk', 'walkBack', 'loop', 'load']) { - expect(compiled.provider).toMatch(declarationOf(name)) - } - for (const output of [compiled.client, compiled.ssr, compiled.provider]) { - expect(output).toMatch(declarationOf('unusedA')) - expect(output).toMatch(declarationOf('unusedB')) - } +export const fn = createServerFn().handler(async () => [walk(3), loop(2), load()])`, + 'secret.server.ts': `export const secret = 'secret'; export const defaultId = () => 'id'\n`, + }) + expectNotLoaded(await served.loads(), ['./secret.server']) + expect(await callServerFnThroughCallers(served, 'module.fn')).toEqual([ + 0, + 0, + 'id', + ]) }) // Source: babel-dead-code-elimination "assignment" test('callers keep handler-read bindings that top-level statements assign', async () => { - const compiled = await compileAll(`${head}let x: string + // An assignment left without its declaration throws in a module: + // `serveCase` evaluates the module on the client and the server. + const served = await serveCase(await host(), { + 'module.tsx': `${head}let x: string x = 'x-assigned' y = 'y-assigned' var y: string -export const fn = createServerFn().handler(async () => [x, y])`) - // An assignment left without its declaration throws in a module. - await evaluateModule(compiled.client) - await evaluateModule(compiled.ssr) - expect(await callProvider(compiled.provider, 'fn')).toEqual([ +export const fn = createServerFn().handler(async () => [x, y])`, + }) + expect(await callFromClient(served, 'module.fn')).toEqual([ 'x-assigned', 'y-assigned', ]) }) // Source: babel-dead-code-elimination "repeated elimination" - test('callers drop a binding only the handler writes and keep a declarator a kept sibling reads', async () => { - const compiled = - await compileAll(`${head}import { serverValue } from './db.server' + test('a binding only the handler writes and a declarator a kept sibling reads keep working', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { serverValue } from './db.server' let hits = 0 let a = serverValue(), clientCopy = a export const fn = createServerFn().handler(async () => { hits++ - return a + return [a, hits] }) -export const clientB = clientCopy`) - for (const caller of [compiled.client, compiled.ssr]) { - expect(caller).not.toMatch(declarationOf('hits')) - expect(caller).toMatch(declarationOf('a')) - expect(importSources(caller)).toEqual(['./db.server']) - } - expect(compiled.provider).toMatch(declarationOf('hits')) - expect(compiled.provider).not.toContain('clientCopy') +export const clientB = clientCopy`, + 'db.server.ts': `export const serverValue = () => 'value'\n`, + }) + // The client reads `clientCopy = a`, so it keeps `serverValue()`. + expect(await inPage(served, 'return module.clientB')).toBe('value') + // Two calls reach one server instance: the handler updates its own + // `hits`. + expect([ + await callFromClient(served, 'module.fn'), + await callFromClient(served, 'module.fn'), + ]).toEqual([ + ['value', 1], + ['value', 2], + ]) + // Server code runs the handler too, in that instance or its own + // (where the handler lives on the server is free, §5.4). + const fromServer = (await callOnServer(served, 'module.fn')) as [ + string, + number, + ] + expect(fromServer[0]).toBe('value') + expect([1, 3]).toContain(fromServer[1]) }) // Source: babel-dead-code-elimination "variable" > "within for...in", // "within for...of" (var bindings declared inside nested statements) - test('callers drop handler-only vars declared inside top-level statements', async () => { - const calls = ['openFlag', 'connect', 'readMode', 'readLabel', 'createPool'] - const compiled = - await compileAll(`${head}import { ${calls.join(', ')} } from './db.server' + test('the client drops handler-only vars declared inside top-level statements', async () => { + const calls = ['openFlag', 'connect', 'readMode'] + // The page has no `process`: the module reads the server's environment + // through `globalThis`. + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { ${calls.join(', ')} } from './db.server' if (typeof window === 'undefined') { var flag = openFlag() } try { var conn = connect() } catch {} -switch (process.env.MODE) { +switch (globalThis.process?.env.MODE) { case 'x': var mode = readMode() } -outer: { - var labeled = readLabel() - break outer -} -for (var i = 0, pool = createPool(); i < 1; i++) {} -export const fn = createServerFn().handler(async () => [flag, conn, mode, labeled, pool])`) - for (const caller of [compiled.client, compiled.ssr]) { - expect(importSources(caller)).toEqual([]) - for (const call of calls) { - expect(caller).not.toContain(call) - } - } - for (const call of calls) { - expect(compiled.provider).toContain(`${call}()`) +export const fn = createServerFn().handler(async () => [flag, conn, mode])`, + 'db.server.ts': calls + .map((call) => `export const ${call} = () => '${call}'\n`) + .join(''), + }) + expectNotLoaded(await served.loads(), ['./db.server']) + // On the server (no `window`, MODE unset), the handler reads what the + // statements it depends on assigned. + vi.stubEnv('MODE', '') + try { + expect(await callServerFnThroughCallers(served, 'module.fn')).toEqual([ + 'openFlag', + 'connect', + undefined, + ]) + } finally { + vi.unstubAllEnvs() } }) }) diff --git a/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts index e80f292891..49d74d7cf3 100644 --- a/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/createServerFn.test.ts @@ -1,901 +1,427 @@ -import { readFile, readdir } from 'node:fs/promises' +import { mkdtemp, rm, writeFile } from 'node:fs/promises' import path from 'node:path' -import { stripVTControlCharacters } from 'node:util' -import { describe, expect, test, vi } from 'vitest' -import { StartCompiler } from '../../src/start-compiler/compiler' -import { formatSnapshot } from '../format-snapshot' +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { linkWorkspacePackages } from '@tanstack/compiler-test-utils/workspace-packages' +import { + callFromClient, + callOnServer, + callServerFnThroughCallers, + compileError, + expectCompileError, + inPage, + serveCase, + serverFnUrls, + useStartHost, +} from '../regression-helpers' +import { + factoryBuilderModule, + queryDistinctModule, + virtualFactories, +} from '../compiler-inputs' +import type { Plugin } from 'vite' -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' +// Moved: the custom-id build test (formerly :223) is in +// integration/start-compiler-build-ids.test.ts. + +/** + * A user plugin serving one virtual module by its exact id, as Vite's + * documentation writes one (`if (id === resolvedVirtualModuleId)`): it + * re-exports Start's factory. + */ +function exactVirtualFactory(): Plugin { + const id = 'virtual:exact-server-fn-factory' return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', + name: 'test:exact-virtual-server-fn-factory', + resolveId: (source) => (source === id ? `\0${id}` : null), + load: (loaded) => + loaded === `\0${id}` + ? `export { createServerFn as createAppServerFn } from '@tanstack/react-start'` + : null, } } -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} +const host = useStartHost({ + plugins: [virtualFactories(), exactVirtualFactory()], +}) -const TSS_SERVERFN_SPLIT_PARAM = 'tss-serverfn-split' - -async function compile(opts: { - env: 'client' | 'server' - code: string - parserFilename?: string - isProviderFile: boolean - mode: 'dev' | 'build' -}) { - // Use an absolute path inside the test root to ensure consistent filename output - let id = '/test/src/test.ts' - - if (opts.isProviderFile) { - id += `?${TSS_SERVERFN_SPLIT_PARAM}` - } - - const compiler = new StartCompiler({ - ...opts, - ...getDefaultTestOptions(opts.env), - loadModule: async (id) => { - // do nothing in test - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: `@tanstack/react-start`, - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (id) => { - return id - }, - }) - const result = await compiler.compile({ - code: opts.code, - id, - parserFilename: opts.parserFilename, - }) - return result -} - -describe('createServerFn compiles correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each([ - { type: 'client', isProviderFile: false }, - { type: 'server', isProviderFile: false }, - { type: 'server', isProviderFile: true }, - ] as const)(`should compile for ${filename} %s`, async (env) => { - const result = await compile({ - env: env.type, - isProviderFile: env.isProviderFile, - code, - parserFilename: `/test/src/${filename}`, - mode: 'build', - }) - - const folder = - env.type === 'client' - ? 'client' - : env.isProviderFile - ? 'server-provider' - : 'server-caller' - await expect( - await formatSnapshot(result!.code, filename), - ).toMatchFileSnapshot(`./snapshots/${folder}/${filename}`) - }) - }) - - test('should compile validator method', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - const myServerFn = createServerFn() - .validator((input: string) => input) - .handler(({ input }) => input)` - - const compiledResultClient = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', - }) - - expect(await formatSnapshot(compiledResultClient!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc' - import { createServerFn } from '@tanstack/react-start' - const myServerFn = createServerFn().handler( - createClientRpc( - '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', - ), - ) - " - `) - }) - - // Editors count \n, \r\n, a lone \r, U+2028 and U+2029 as line - // terminators, so diagnostic locations must count every one. +describe('createServerFn compiles correctly', () => { + // A server fn without its handler (`.handler()` type-checks against the + // real declarations, so this is input a user can write) is a compile + // error at the server fn's line (SPEC G5). Editors count \n, \r\n, a + // lone \r, U+2028 and U+2029 as line terminators, so the reported line + // must count every one. Prose, frame layout and context length are free + // (§5.7). test.each([ ['\\n', '\n'], ['\\r\\n', '\r\n'], ['a lone \\r', '\r'], - ['U+2028', '\u2028'], - ['U+2029', '\u2029'], + ['U+2028', '
'], + ['U+2029', '
'], ])( 'reports the location of a diagnostic with %s line endings', async (_name, eol) => { - const error = await compile({ - code: [ - `import { createServerFn } from '@tanstack/react-start'`, - `export const { fn } = createServerFn().handler(async () => 1)`, - ].join(eol), - env: 'client', - isProviderFile: false, - mode: 'build', - }).catch((caught: unknown) => caught) - - expect(error).toBeInstanceOf(Error) - expect(stripVTControlCharacters((error as Error).message)).toMatch( - /> 2 \| export const \{ fn \} = createServerFn\(\)/, - ) + const source = [ + `import { createServerFn } from '@tanstack/react-start'`, + `export const fn = createServerFn().handler()`, + ].join(eol) + const startCase = await (await host()).case({ 'module.tsx': source }) + expectCompileError(await compileError(startCase), { + source, + at: 'createServerFn()', + }) }, ) - test('should work with identifiers of functions', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - const myFunc = () => { - return 'hello from the server' - } - const myServerFn = createServerFn().handler(myFunc)` - - const compiledResultClient = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', + test('reports the location of a diagnostic deep in the module', async () => { + const source = [ + `import { createServerFn } from '@tanstack/react-start'`, + ...Array.from({ length: 10 }, (_, i) => `export const v${i} = ${i}`), + `export const fn = createServerFn().handler()`, + ].join('\n') + const startCase = await (await host()).case({ 'module.tsx': source }) + expectCompileError(await compileError(startCase), { + source, + at: 'createServerFn()', }) - - // Server caller (route file - no split param) - // Should NOT have the second argument since implementation comes from extracted chunk - const compiledResultServerCaller = await compile({ - code, - env: 'server', - isProviderFile: false, - mode: 'build', - }) - - // Server provider (extracted file - has split param) - // Should HAVE the second argument since this is the implementation file - const compiledResultServerProvider = await compile({ - code, - env: 'server', - isProviderFile: true, - mode: 'build', - }) - - expect(await formatSnapshot(compiledResultClient!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc' - import { createServerFn } from '@tanstack/react-start' - const myServerFn = createServerFn().handler( - createClientRpc( - '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', - ), - ) - " - `) - - // Server caller: no second argument (implementation from extracted chunk) - expect(await formatSnapshot(compiledResultServerCaller!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' - import { createServerFn } from '@tanstack/react-start' - const myServerFn = createServerFn().handler( - createSsrRpc( - '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', - ), - ) - " - `) - - // Server provider: has second argument (this is the implementation file) - expect(await formatSnapshot(compiledResultServerProvider!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createServerRpc } from '@tanstack/react-start/server-rpc' - import { createServerFn } from '@tanstack/react-start' - const myFunc = () => { - return 'hello from the server' - } - const myServerFn_createServerFn_handler = createServerRpc( - { - id: '2c205add8e6755de551521133ddff3d48859b1631add5f1bbe5c48a5664f319b', - name: 'myServerFn', - filename: 'src/test.ts', - }, - (opts) => myServerFn.__executeServer(opts), - ) - const myServerFn = createServerFn().handler( - myServerFn_createServerFn_handler, - myFunc, - ) - export { myServerFn_createServerFn_handler } - " - `) }) - test('should remove imports used only as caller handler identifiers', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - import { getUsers } from './server' - - export const getUsersFn = createServerFn().handler(getUsers) - ` - - const compiledResult = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', + // Malformed-input diagnostic control (SPEC §8, G5): destructuring a server + // fn is a type error (tsc against the real declarations: TS2339 "Property + // 'fn' does not exist on type 'OptionalFetcher<...>'"). It only has to + // fail, at the declaration. + test('rejects a destructured server fn', async () => { + const source = `import { createServerFn } from '@tanstack/react-start' +export const { fn } = createServerFn().handler(async () => 1)` + const startCase = await (await host()).case({ 'module.tsx': source }) + expectCompileError(await compileError(startCase), { + source, + at: '{ fn }', }) - - expect(await formatSnapshot(compiledResult!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc' - import { createServerFn } from '@tanstack/react-start' - export const getUsersFn = createServerFn().handler( - createClientRpc( - 'a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100', - ), - ) - " - `) }) test('should not remove handler identifier bindings that are still referenced', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - import { getUsers } from './server' + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +import { getUsers } from './server' - export const getUsersFn = createServerFn().handler(getUsers) - console.log(getUsers) - ` - - const compiledResult = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', +export const getUsersFn = createServerFn().handler(getUsers) +export const ref = getUsers`, + 'server.ts': `export const getUsers = async () => 'users'\n`, }) - - expect(await formatSnapshot(compiledResult!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc' - import { createServerFn } from '@tanstack/react-start' - import { getUsers } from './server' - export const getUsersFn = createServerFn().handler( - createClientRpc( - 'a78c63d4bb3c0b10a8b70902c73611fbf0b9229e0807b065c03c939f9c0ce100', - ), - ) - console.log(getUsers) - " - `) - }) - - test('should compile server functions wrapped in TypeScript as expressions', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - - export const getUsersFn = createServerFn().handler(() => 'server') as any - ` - - const compiledResult = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', - }) - - expect(compiledResult).not.toBeNull() - expect(compiledResult!.code).toContain('createClientRpc') - expect(compiledResult!.code).not.toContain('server') - }) - - test('should compile server functions wrapped in TypeScript satisfies expressions', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - - export const getUsersFn = createServerFn().handler(() => 'server') satisfies unknown - ` - - const compiledResult = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', - }) - - expect(compiledResult).not.toBeNull() - expect(compiledResult!.code).toContain('createClientRpc') - expect(compiledResult!.code).not.toContain('server') - }) - - test('should use dce by default', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - const exportedVar = 'exported' - export const exportedFn = createServerFn().handler(async () => { - return exportedVar - }) - const nonExportedVar = 'non-exported' - const nonExportedFn = createServerFn().handler(async () => { - return nonExportedVar - })` - - // Client - const compiledResult = await compile({ - code, - env: 'client', - isProviderFile: false, - mode: 'build', - }) - - expect(await formatSnapshot(compiledResult!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createClientRpc } from '@tanstack/react-start/client-rpc' - import { createServerFn } from '@tanstack/react-start' - export const exportedFn = createServerFn().handler( - createClientRpc( - 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', - ), - ) - const nonExportedFn = createServerFn().handler( - createClientRpc( - 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', - ), - ) - " - `) - - // Server caller (route file) - no second argument - const compiledResultServerCaller = await compile({ - code, - env: 'server', - isProviderFile: false, - mode: 'build', - }) - - expect(await formatSnapshot(compiledResultServerCaller!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' - import { createServerFn } from '@tanstack/react-start' - export const exportedFn = createServerFn().handler( - createSsrRpc( - 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', - ), - ) - const nonExportedFn = createServerFn().handler( - createSsrRpc( - 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', - ), - ) - " - `) - - // Server provider (extracted file) - has second argument - const compiledResultServerProvider = await compile({ - code, - env: 'server', - isProviderFile: true, - mode: 'build', - }) - - expect(await formatSnapshot(compiledResultServerProvider!.code, 'test.ts')) - .toMatchInlineSnapshot(` - "import { createServerRpc } from '@tanstack/react-start/server-rpc' - import { createServerFn } from '@tanstack/react-start' - const exportedVar = 'exported' - const exportedFn_createServerFn_handler = createServerRpc( - { - id: 'c306c96e9256c7604f2a6022c4c94eb89f863274c022bc45b03970f067ea9864', - name: 'exportedFn', - filename: 'src/test.ts', - }, - (opts) => exportedFn.__executeServer(opts), - ) - const exportedFn = createServerFn().handler( - exportedFn_createServerFn_handler, - async () => { - return exportedVar - }, - ) - const nonExportedVar = 'non-exported' - const nonExportedFn_createServerFn_handler = createServerRpc( - { - id: 'f4403dc0b18e216dfe0a9711cab028bc1b9768175daa9236d7115e29c99d76c2', - name: 'nonExportedFn', - filename: 'src/test.ts', - }, - (opts) => nonExportedFn.__executeServer(opts), - ) - const nonExportedFn = createServerFn().handler( - nonExportedFn_createServerFn_handler, - async () => { - return nonExportedVar - }, - ) - export { - exportedFn_createServerFn_handler, - nonExportedFn_createServerFn_handler, - } - " - `) - }) - - test('should use fast path for direct imports from known library (no extra resolveId calls)', async () => { - const code = ` - import { createServerFn } from '@tanstack/react-start' - const myServerFn = createServerFn().handler(async () => { - return 'hello' - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async () => {}, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - mode: 'build', - }) - - await compiler.compile({ - code, - id: '/test/src/test.ts', - }) - - // Direct known-library imports use the knownRootImports fast path, so they - // do not need resolveId. - expect(resolveIdMock).not.toHaveBeenCalled() - }) - - test('should use slow path for factory pattern (resolveId called for import resolution)', async () => { - // This simulates a factory pattern where createServerFn is re-exported from a local file - const factoryCode = ` - import { createFooServerFn } from './factory' - const myServerFn = createFooServerFn().handler(async () => { - return 'hello' - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - // Simulate the factory module being loaded - if (id === './factory') { - compiler.ingestModule({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const createFooServerFn = createServerFn - `, - id: './factory', - }) - } - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - mode: 'build', - }) - - await compiler.compile({ - code: factoryCode, - id: '/test/src/test.ts', - }) - - // resolveId should only be called for './factory'. Direct known-library - // imports use the knownRootImports fast path. - // - // Note: The factory module's import from '@tanstack/react-start' ALSO uses - // the fast path (knownRootImports), so no additional resolveId call is needed there. - expect(resolveIdMock).toHaveBeenCalledTimes(1) - expect(resolveIdMock).toHaveBeenNthCalledWith( - 1, - './factory', - '/test/src/test.ts', + expect( + await inPage( + served, + `return [module.ref === (await load('server.ts')).getUsers, typeof module.getUsersFn.url]`, + ), + ).toEqual([true, 'string']) + expect(await callServerFnThroughCallers(served, 'module.getUsersFn')).toBe( + 'users', ) }) test('keeps query-bearing virtual module identities distinct', async () => { - const publicFactoryId = '\0virtual:server-fn-factory?variant=public' - const implementationFactoryId = - '\0virtual:server-fn-factory?variant=implementation' - const virtualModules: Record<string, string> = { - [publicFactoryId]: ` - import { createIssueServerFn } from 'virtual:server-fn-factory?variant=implementation' - export { createIssueServerFn } - `, - [implementationFactoryId]: ` - import { createServerFn } from '@tanstack/react-start' - export const createIssueServerFn = createServerFn - `, - } - const loadedIds: Array<string> = [] - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - mode: 'build', - loadModule: async (id) => { - loadedIds.push(id) - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (source) => { - if (source.startsWith('virtual:server-fn-factory?')) { - return `\0${source}` - } - - return null - }, - }) - - const result = await compiler.compile({ - id: '/test/src/test.ts', - code: ` - import { createIssueServerFn } from 'virtual:server-fn-factory?variant=public' - const issueServerFn = createIssueServerFn().handler(async () => 'ok') - `, - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('createClientRpc') - expect(loadedIds).toEqual([publicFactoryId, implementationFactoryId]) - }) - - test('should resolve local named re-exports of createServerFn', async () => { - const code = ` - import { createFooServerFn } from './factory' - const myServerFn = createFooServerFn().handler(async () => { - return 'hello' - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - if (id === './factory') { - compiler.ingestModule({ - code: ` - export { createServerFn as createFooServerFn } from '@tanstack/react-start' - `, - id: './factory', - }) - } - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - mode: 'build', - }) - - const result = await compiler.compile({ - code, - id: '/test/src/test.ts', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('createClientRpc') - expect(resolveIdMock).toHaveBeenCalledTimes(1) - expect(resolveIdMock).toHaveBeenNthCalledWith( - 1, - './factory', - '/test/src/test.ts', + // Two virtual modules that differ only by their query (a user plugin + // serves them): the public one re-exports the factory the + // implementation one defines. + const served = await serveCase( + await host(), + { 'test.ts': queryDistinctModule }, + { file: 'test.ts' }, ) - }) - - test('should resolve export-star re-export chains of createServerFn', async () => { - const code = ` - import { createFooServerFn } from './factory' - const myServerFn = createFooServerFn().handler(async () => { - return 'hello' - })` - - const resolveIdMock = vi.fn(async (id: string) => id) - - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - loadModule: async (id) => { - if (id === './factory') { - compiler.ingestModule({ - code: ` - export * from './factory-inner' - `, - id: './factory', - }) - } - - if (id === './factory-inner') { - compiler.ingestModule({ - code: ` - export { createServerFn as createFooServerFn } from '@tanstack/react-start' - `, - id: './factory-inner', - }) - } - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - getKnownServerFns: () => ({}), - resolveId: resolveIdMock, - mode: 'build', - }) - - const result = await compiler.compile({ - code, - id: '/test/src/test.ts', - }) - - expect(result).not.toBeNull() - expect(result!.code).toContain('createClientRpc') - expect(resolveIdMock).toHaveBeenCalledTimes(2) - expect(resolveIdMock).toHaveBeenNthCalledWith( - 1, - './factory', - '/test/src/test.ts', - ) - expect(resolveIdMock).toHaveBeenNthCalledWith( - 2, - './factory-inner', - './factory', - ) - }) - - test('reuses deduped custom IDs across compiler instances', async () => { - const serverFnsById: Record< - string, - { - functionName: string - functionId: string - extractedFilename: string - filename: string - isClientReferenced?: boolean - } - > = {} - - function createCompiler() { - return new StartCompiler({ - env: 'server', - ...getDefaultTestOptions('server'), - mode: 'build', - loadModule: async () => {}, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - resolveId: async (id) => id, - generateFunctionId: ({ functionName }) => - functionName === 'greetUser_createServerFn_handler' - ? 'constant_id' - : undefined, - getKnownServerFns: () => serverFnsById, - onServerFnsById: (discovered) => { - Object.assign(serverFnsById, discovered) - }, - }) - } - - const firstCompiler = createCompiler() - await firstCompiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const greetUser = createServerFn().handler(async () => 'first') - `, - id: '/test/src/submit-post-formdata.tsx', - }) - - await firstCompiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const greetUser = createServerFn().handler(async () => 'second') - `, - id: '/test/src/formdata-redirect/index.tsx', - }) - + expect(served.code.client).not.toContain('issue-handler') + // The client calls the server fn through an RPC, and that RPC runs the + // handler on the server. expect( - Object.values(serverFnsById) - .map((serverFn) => serverFn.functionId) - .sort(), - ).toEqual(['constant_id', 'constant_id_1']) + await serverFnUrls(served, 'module', { file: 'test.ts' }), + ).toHaveLength(1) + expect( + await callServerFnThroughCallers( + served, + 'module.issueServerFn', + undefined, + { file: 'test.ts' }, + ), + ).toBe('issue-handler') + }) +}) - const secondCompiler = createCompiler() - const firstResult = await secondCompiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const greetUser = createServerFn().handler(async () => 'first') - `, - id: '/test/src/submit-post-formdata.tsx', +// Bug: in dev, the compiler looks up a module a server fn's factory comes +// from under a derived id (the module's id with a query flag of its own +// added), which the environment then loads: a user plugin serving a +// virtual module by its exact id, as Vite documents it, does not know that +// id, so the module that defines the server fn fails to compile ("Failed to +// load url virtual:...?server-fn-module-lookup"). A build loads the +// module under its own id. +// Impact: `vite dev` cannot serve a server fn whose factory a virtual +// module of the app (or of a plugin) provides. +// Fix-agnostic: however the compiler learns the factory's provenance, the +// module compiles and its server fn works. +// Source: the former test "keeps query-bearing virtual module identities +// distinct", rerouted through the public plugin. +test.fails( + 'a server fn whose factory a virtual module serves by its exact id compiles in dev', + async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createAppServerFn } from 'virtual:exact-server-fn-factory' +export const fn = createAppServerFn().handler(async () => 'virtual-factory-handler')`, }) + expect(served.code.client).not.toContain('virtual-factory-handler') + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe( + 'virtual-factory-handler', + ) + }, +) + +describe('server fns need a handler', () => { + // `.handler()` type-checks (tsc against the real declarations), so this + // is a user error the compiler reports at the server fn (SPEC G5), in + // every environment that serves the module. + test('require a handler function', async () => { + const source = `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler()` + const startCase = await (await host()).case({ 'module.tsx': source }) + for (const environment of ['client', 'ssr'] as const) { + expectCompileError(await compileError(startCase, environment), { + source, + at: 'createServerFn()', + }) + } + }) +}) - const secondResult = await secondCompiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const greetUser = createServerFn().handler(async () => 'second') - `, - id: '/test/src/formdata-redirect/index.tsx', +// Builders, route files and formatting: replaces the factory and +// isomorphic-fns snapshot fixtures and the `.handler(` formatting +// detection unit tests. +describe('server fns of builders, route files and reformatted code', () => { + // Source: snapshot fixture factory.tsx + test('a server fn builder with middleware is callable as a factory', async () => { + const served = await serveCase(await host(), { + 'module.tsx': factoryBuilderModule, }) + expect(served.code.client).not.toContain('MARK_AUTHED_HANDLER_BODY') + expect(served.code.client).not.toContain('MARK_DELETE_HANDLER_BODY') + expect(await serverFnUrls(served)).toHaveLength(2) + expect(await inPage(served, 'return module.x')).toBe('fakeFn') + // Each server fn runs the middleware of its factory chain, called from + // the client and from server code. + const auth = { auth: 'auth' } + const admin = { auth: 'auth', admin: 'admin' } + expect([ + await callFromClient(served, 'module.myAuthedFn'), + await callFromClient(served, 'module.deleteUserFn'), + ]).toEqual([ + ['myAuthedFn', auth], + ['deleteUserFn', admin], + ]) + expect([ + await callOnServer(served, 'module.myAuthedFn'), + await callOnServer(served, 'module.deleteUserFn'), + ]).toEqual([ + ['myAuthedFn', auth], + ['deleteUserFn', admin], + ]) + }) - expect(firstResult!.code).toContain('createSsrRpc("constant_id"') - expect(secondResult!.code).toContain('createSsrRpc("constant_id_1"') - }) + // Source: snapshot fixture isomorphic-fns.tsx (#8504 + // start-compiler-factories.test.ts "provider compiles env fns") + test('a route file: the provider runs the server fns, each output runs its isomorphic branch', async () => { + const code = `import { createFileRoute } from '@tanstack/react-router' +import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' +import { useState } from 'react' + +const getEnv = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') - // The client puts the id in the URL unencoded and the server reads that - // path segment back: a `/`, `#` or `?` cut it short (the call ran another - // server function of the file or none), a client percent-encodes `"`, - // `\`, whitespace, control and non-ASCII characters, URL parsing removes - // dot segments, and the server decodes a percent-encoding to another id or - // rejects it. - test.each([ - 'users/get', - 'users#get', - 'users?get', - 'users"get', - 'users\\get', - 'users get', - 'users\u0007get', - 'utilisateurs-é', - '..', - 'users%41get', - 'x%c3%a9', - '%2E', - 'users%zz', - ])( - 'a custom id the URL never carries whole fails the build: %j', - async (id) => { - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - mode: 'build', - loadModule: async () => {}, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [ - { - libName: '@tanstack/react-start', - rootExport: 'createServerFn', - kind: 'Root', - }, - ], - resolveId: async (id) => id, - generateFunctionId: () => id, - getKnownServerFns: () => ({}), - }) - await expect( - compiler.compile({ - code: ` - import { createServerFn } from '@tanstack/react-start' - export const getUser = createServerFn().handler(async () => 'user') - `, - id: '/test/src/users.ts', - }), - ).rejects.toThrow( - `[tanstack-start] serverFns.generateFunctionId returned ${JSON.stringify(id)} for the server function getUser (functionName "getUser_createServerFn_handler") of src/users.ts.`, - ) - }, - ) +const getServerEnv = createServerFn().handler(() => getEnv()) - test('should resolve createServerFn from the same binding as a known root export', async () => { - const virtualModules: Record<string, string> = { - '@tanstack/start-client-core': ` - export { createServerFn } from './createServerFn' - `, - '/virtual/compiler-known/server-fn-factory.ts': ` - export const createServerFn = () => ({ - handler: () => createServerFn(), - }) - `, - } +const getEcho = createIsomorphicFn() + .server((input: string) => 'server received ' + input) + .client((input) => 'client received ' + input) - const compiler = new StartCompiler({ - env: 'client', - ...getDefaultTestOptions('client'), - root: '/test', - mode: 'build', - loadModule: async (id) => { - const code = virtualModules[id] - if (code) { - compiler.ingestModule({ code, id }) - } - }, - lookupKinds: new Set(['ServerFn']), - lookupConfigurations: [], - getKnownServerFns: () => ({}), - resolveId: async (source) => { - if (source === '@tanstack/start-client-core') { - return '@tanstack/start-client-core' - } +const getServerEcho = createServerFn() + .validator((input: string) => input) + .handler(({ data }) => getEcho(data)) - if (source === './createServerFn') { - return '/virtual/compiler-known/server-fn-factory.ts' - } +export const Route = createFileRoute('/isomorphic-fns')({ + component: RouteComponent, + loader() { + return { envOnLoad: getEnv() } + }, +}) - return null - }, +function RouteComponent() { + const [results, setResults] = useState<Partial<Record<string, string>>>() + async function handleClick() { + const [serverEnv, serverEcho] = await Promise.all([ + getServerEnv(), + getServerEcho({ data: 'hello' }), + ]) + setResults({ envOnClick: getEnv(), echo: getEcho('hello'), serverEnv, serverEcho }) + } + return <button onClick={handleClick}>{JSON.stringify(results)}</button> +}` + const served = await serveCase(await host(), { + 'module.tsx': code, + // The app's code rendering the route's component in the page. + 'mount.tsx': `import { createRoot } from 'react-dom/client' +import { Route } from './module' +export function mount(element: HTMLElement) { + const Component = Route.options.component! + createRoot(element).render(<Component />) +} +`, + }) + // The page's click calls both server fns through their RPCs: the + // server runs them. + expect( + await inPage( + served, + `const element = document.createElement('div') +document.body.append(element) +const { mount } = await load('mount.tsx') +mount(element) +const button = async () => { + for (let tries = 0; tries < 200; tries++) { + const found = element.querySelector('button') + if (found) return found + await new Promise((resolve) => setTimeout(resolve, 10)) + } + throw new Error('the route component did not render') +} +;(await button()).click() +for (let tries = 0; tries < 500; tries++) { + if (element.textContent) { + const results = JSON.parse(element.textContent) + element.remove() + return results + } + await new Promise((resolve) => setTimeout(resolve, 10)) +} +throw new Error('the click gave no results: ' + element.innerHTML)`, + ), + ).toEqual({ + envOnClick: 'client', + echo: 'client received hello', + serverEnv: 'server', + serverEcho: 'server received hello', + }) + expect( + await inPage(served, 'return module.Route.options.loader()'), + ).toEqual({ envOnLoad: 'client' }) + expect((await served.ssr()).Route.options.loader()).toEqual({ + envOnLoad: 'server', }) + }) - const result = await compiler.compile({ - id: '/test/src/internal-server-fn.ts', - code: ` - import { createServerFn } from './createServerFn' - - export const getMessage = createServerFn().handler(() => { - return 'server-only-value' + // Reformatted code (Vite/Babel may move the dot to its own line) and a + // builder from another module (TanStack/router#7280 class). + // Replaces compiler.test.ts "handles .handler with whitespace variations" + // and "handles whitespace between . and handler". + describe.each<{ + where: string + files: Record<string, string> + head: string + }>([ + { + where: 'the module', + files: {}, + head: `import { createServerFn } from '@tanstack/react-start' +const base = createServerFn()`, + }, + { + where: 'another module', + files: { + 'builder.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn()`, + }, + head: `import { base } from './builder'`, + }, + ])('with the builder of $where', ({ where, files, head }) => { + const calls = [ + { name: 'spaces before the call', call: '.handler (' }, + { name: 'a newline before the call', call: '.handler\n(' }, + { name: 'a newline after the dot', call: '.\n handler(' }, + { name: 'a tab before the call', call: '.handler\t(' }, + { name: 'a comment after the dot', call: './* c */handler(' }, + ] + for (const { name, call } of calls) { + // Bug: a module is only compiled when its text matches + // `createServerFn` or `.handler(` (whitespace allowed), so with the + // builder imported from another module, a comment between the dot and + // `handler` hides the server fn. + // Impact: the handler and its server-only imports ship to the client. + // Source: TanStack/router#7280 class. + const run = + where === 'another module' && name === 'a comment after the dot' + ? test.fails + : test + run(`a handler called with ${name} is extracted`, async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head} +import { db } from './db.server' +export const fn = base${call}async () => db.x())`, + 'db.server.ts': `export const db = { x: () => 'x' }\n`, + ...files, }) - `, - }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await serverFnUrls(served)).toHaveLength(1) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('x') + }) + } + }) +}) - expect(result).not.toBeNull() - expect(result!.code).toContain('createClientRpc') - expect(result!.code).not.toContain('server-only-value') +describe('server fns outside the app root', () => { + // A server fn in a module outside the Vite root (a workspace package + // whose source the app imports, which the dev server serves from + // `/@fs/`): the client calls it by id through Start's server entry, + // server code calls it directly, and the client loads none of the + // server-only modules its handler reads. + // Source: main's tests/vite/start-compiler-utils.test.ts "preserves + // POSIX absolute /@fs paths outside the app root" (the dev + // server fn id encoding, an internal helper), rerouted to its outcome. + test('dev: a server fn in a module outside the app root runs by id', async () => { + const started = await host() + const shared = await mkdtemp( + path.join(path.dirname(started.root), '.start-shared-'), + ) + try { + // The shared package resolves Start from its own node_modules, as a + // workspace package does + await linkWorkspacePackages(shared, ['@tanstack/react-start']) + await writeFile( + path.join(shared, 'fn.ts'), + `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +export const sharedFn = createServerFn().handler(async () => db.x()) +`, + ) + await writeFile( + path.join(shared, 'db.server.ts'), + `export const db = { x: () => 'from outside the root' }\n`, + ) + // Every case directory is `src/cases/c<n>`, one level deep + const specifier = path + .relative( + path.join(started.root, 'src/cases/c'), + path.join(shared, 'fn'), + ) + .split(path.sep) + .join('/') + const served = await serveCase(started, { + 'module.tsx': `export { sharedFn as fn } from '${specifier}'\n`, + }) + expect(await serverFnUrls(served)).toHaveLength(1) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe( + 'from outside the root', + ) + expect( + (await served.loads()).filter((loaded) => loaded.includes('db.server')), + ).toEqual([]) + } finally { + await rm(shared, { recursive: true, force: true }) + } }) }) diff --git a/packages/start-plugin-core/tests/createServerFn/declaration-sites.test.ts b/packages/start-plugin-core/tests/createServerFn/declaration-sites.test.ts index f42a13cdba..1ae065bf6f 100644 --- a/packages/start-plugin-core/tests/createServerFn/declaration-sites.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/declaration-sites.test.ts @@ -1,6 +1,31 @@ -import { expect, test } from 'vitest' -import { compileFor, outputs } from '../regression-helpers' -import { getModuleErrors } from '../validate-module' +/** + * Where a `createServerFn` can be written (SPEC J4.6): + * top-level server fns work everywhere; a server fn nested in a function + * whose handler reads no local of the function works too (goal pins); any + * other position works or is rejected with a clear error at the call, and + * never ships its handler to the client. Observed through the public Start + * host: what each environment serves or rejects, what a page loads, and + * calls of the server fns from the client (by id, through Start's server + * entry) and from server code. + */ +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + callFromClient, + callOnServer, + callServerFnThroughCallers, + compileError, + expectCompileError, + expectNoClientHandler, + inPage, + serveCase, + serverFnUrls, + useStartHost, +} from '../regression-helpers' +import { placementModule, placements } from './placements' +import type { PlacementHead } from './placements' + +const host = useStartHost() const head = `import { createServerFn } from '@tanstack/react-start'\n` const top = `export const top = createServerFn().handler(async () => 'top')\n` @@ -16,107 +41,335 @@ const inSwitchCase = `export function pick(kind: string) { } }` -// A `createServerFn` declared below the module top level must not produce an -// invalid module, and top-level server fns next to it are still extracted. -// Rejecting it with a compile error is valid too, but not crashing on it. -// Known limitation on main: only module-level declarations are extracted; the -// nested one is left untransformed, so its handler ships to the client. Which -// nested server fns are extracted is left open here. -test.each([ - { name: 'a function', code: inFunction, topLevel: [] }, +/** The server-only module the placement handlers read, as a real file. */ +const dbFiles = { + 'db.server.ts': `export const db = { inner: () => 'inner', top: () => 'top' }\n`, +} + +const literalPlacements = [ + { + name: 'a function', + code: inFunction, + hasTop: false, + read: 'module.make()', + }, { name: 'a switch case inside a function', code: inSwitchCase, - topLevel: [], - }, - { - name: 'a switch case at the module top level', - code: `switch (import.meta.env.MODE) { - case 'a': - const fn = createServerFn().handler(async () => 'nested') - console.log(fn) -}`, - topLevel: [], + hasTop: false, + read: "module.pick('a')", }, { name: 'a function next to a top-level one', code: `${top}${inFunction}`, - topLevel: ['top'], + hasTop: true, + read: 'module.make()', }, { name: 'a switch case next to a top-level one', code: `${top}${inSwitchCase}`, - topLevel: ['top'], + hasTop: true, + read: "module.pick('a')", }, -])( +] + +// Regression control: an environment either rejects the module clearly or +// serves a working module, and an adjacent top-level server function still +// executes. The paired goal below checks nested RPCs. +test.each(literalPlacements)( 'a server fn declared in $name compiles to valid modules or is rejected', - async ({ code, topLevel }) => { - const errors: Record<string, Array<string>> = {} - for (const output of outputs) { - let result: Awaited<ReturnType<typeof compileFor>> - try { - result = await compileFor(output, `${head}${code}`) - } catch (error) { - expect((error as Error).message, output).not.toMatch( - /Expected createServerFn declaration in a statement list/, - ) + async ({ code, hasTop }) => { + const source = `${head}${code}` + const startCase = await (await host()).case({ 'module.tsx': source }) + for (const environment of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, environment) + if (failure !== undefined) { + expectCompileError(failure, { + source, + at: undefined, + }) continue } - errors[output] = - result.code === null ? [] : await getModuleErrors(result.code) - if (output === 'client') { - const extractedNames = Object.values(result.serverFns).map( - (fn) => fn.functionName, - ) - expect(extractedNames).toEqual( - expect.arrayContaining( - topLevel.map((name) => `${name}_createServerFn_handler`), - ), - ) + if (environment === 'client') { + const run = await startCase.client('return true') + expect(run.errors, 'client page errors').toEqual([]) + if (hasTop) { + expect(await callFromClient(startCase, 'module.top')).toBe('top') + } + } else { + await startCase.ssr() + if (hasTop) { + expect(await callOnServer(startCase, 'module.top')).toBe('top') + } } } - for (const [output, moduleErrors] of Object.entries(errors)) { - expect(moduleErrors, output).toEqual([]) - } }, ) -// A server fn must be a variable initializer; anywhere else it is rejected -// in every output instead of being shipped untransformed. -// Known limitation on main: with createServerFn as the only factory import -// these modules are returned untransformed, so the extra import is needed. -const rejectionHead = `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start'\n` -test.each([ - { - name: 'an object property', - code: `export const api = { read: createServerFn().handler(async () => 1) }`, - error: 'createServerFn must be assigned to a variable!', +// Bug: dependency-free nested handlers remain in successful client output. +// The rows: the four public make/pick usages below. +// Impact: client calls execute the server handler locally instead of using RPC. +test.fails.each(literalPlacements)( + 'a server fn declared in $name never ships its nested handler to the client', + async ({ code, hasTop, read }) => { + // Keep the original literal-returning input, as well as a distinct + // executable canary. Required nested support has no rejection branch. + for (const body of [ + code, + code.replaceAll( + "async () => 'nested'", + "async () => ['MARK_LITERAL_NESTED_HANDLER', 'nested'][1]", + ), + ]) { + const served = await serveCase(await host(), { + 'module.tsx': `${head}${body}`, + }) + expect(served.code.client).not.toContain('MARK_LITERAL_NESTED_HANDLER') + // The client gets an RPC: a server fn with its public url. + expect(await inPage(served, `return typeof (${read}).url`)).toBe('string') + // RPC absence cannot skip server execution or excuse a local handler. + expect(await callFromClient(served, read)).toBe('nested') + expect(await callOnServer(served, read)).toBe('nested') + if (hasTop) { + expect(await callFromClient(served, 'module.top')).toBe('top') + } + } }, - { - name: 'a class field', - code: `export class Api { read = createServerFn().handler(async () => 1) }`, - error: 'createServerFn must be assigned to a variable!', +) + +// Loosened regression, paired with the pins "with another Start factory +// imported, a server fn in $name works or is rejected at the call" of +// known-bugs-start-compiler.test.ts (main's rejection has no position). +// Next to another Start factory, these placements never ship the handler +// to the client: each environment rejects the code with a compile error +// or serves a working module without the handler, and calling the server +// fn from the client and from server code runs it. With createServerFn +// alone, and for declarators below the top level (in a function, a switch +// case or a top-level block), they are pinned in +// known-bugs-start-compiler.test.ts. +test.each(placements.filter((placement) => !placement.declarator))( + 'next to another Start factory, a server fn in $name does not ship its handler to the client', + async ({ code, read }) => { + await expectNoClientHandler( + await host(), + placementModule('another Start factory', code), + { rejection: 'unpositioned', read }, + ) }, - { - name: 'an anonymous default export', - code: `export default createServerFn().handler(async () => 1)`, - error: 'createServerFn must be assigned to a variable!', +) + +/** + * A top-level server fn wrapped in two calls of a user helper. Its handler + * holds the marker `MARK_INNER_HANDLER` (a fallback it never returns). + */ +const wrappedTwice = `const wrap = <T,>(fn: T) => fn +export const fn = wrap(wrap(createServerFn().handler(async () => db.inner() ?? 'MARK_INNER_HANDLER')))` + +// Loosened regression of the goal below: wrapped in user helper calls, +// a top-level server fn never ships its handler to the client, whatever +// factories the module imports. +test.each<PlacementHead>(['createServerFn alone', 'another Start factory'])( + 'with %s imported, a server fn wrapped in two calls does not ship its handler to the client', + async (importHead) => { + await expectNoClientHandler( + await host(), + placementModule(importHead, wrappedTwice), + { rejection: 'unpositioned', read: 'module.fn' }, + ) }, - { - name: 'an assignment', - code: `export let fn\nfn = createServerFn().handler(async () => 1)`, - error: 'createServerFn must be assigned to a variable!', +) + +// Bug: a server fn passed through calls of a user helper (`wrap(wrap(...))`, +// e.g. helpers registering or typing it) is not extracted: the compiler +// rejects it ("must be assigned to a variable"), although the server fn +// itself initializes a top-level variable. Transparent wrappers are a +// supported recognition form (SPEC J4.5), so rejecting is no fix here. +// Impact: the build fails for a module whose server fn the user can only +// write unwrapped. +// Source: declaration-sites "wrapped in two calls". +test.fails.each<PlacementHead>([ + 'createServerFn alone', + 'another Start factory', +])( + 'with %s imported, a server fn wrapped in two calls works like an unwrapped one', + async (importHead) => { + const served = await serveCase(await host(), { + 'module.tsx': placementModule(importHead, wrappedTwice), + ...dbFiles, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(served.code.client).not.toContain('MARK_INNER_HANDLER') + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('inner') }, - { - name: 'a validator call without a validator', - code: `export const fn = createServerFn().validator().handler(async () => 1)`, - error: 'createServerFn().validator() must be called with a validator!', - }, -])('rejects $name', async ({ code, error }) => { - for (const output of outputs) { - await expect( - compileFor(output, `${rejectionHead}${code}`), - output, - ).rejects.toThrow(error) +) + +// Malformed-input diagnostic control (SPEC §8, G5): `.validator()` without +// a validator is a type error (tsc against the real declarations: TS2554 +// "Expected 1 arguments, but got 0"). It only has to fail; a position is +// not required of input the types reject. +test('rejects a validator call without a validator', async () => { + const source = `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' +export const fn = createServerFn().validator().handler(async () => 1)` + const startCase = await (await host()).case({ 'module.tsx': source }) + for (const environment of ['client', 'ssr'] as const) { + expectCompileError(await compileError(startCase, environment), { + source, + at: undefined, + }) } }) + +// Goal (SPEC J4.6): a server fn nested in a function is supported +// like a top-level one when its handler reads no local of the function: the +// client gets an RPC, and the server runs its handler under the id the +// client uses. (One whose handler reads a local may also be rejected: +// pinned in known-bugs-start-compiler.test.ts.) Today these are left +// untransformed, rejected or extracted into an invalid server module (pins +// in known-bugs-start-compiler.test.ts). +describe.each<PlacementHead>(['createServerFn alone', 'another Start factory'])( + 'with %s imported', + (importHead) => { + test.fails.each( + placements.filter( + (placement) => + placement.nested && + placement.name !== 'the handler of another server fn', + ), + )('supports a server fn in $name', async ({ code, read }) => { + const served = await serveCase(await host(), { + 'module.tsx': placementModule(importHead, code), + ...dbFiles, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await callServerFnThroughCallers(served, read!)).toBe('inner') + }) + }, +) + +// Goal (SPEC J4.6): a server fn created in the handler of another +// one is supported. The client gets an RPC of the outer server fn, its +// handler runs on the server under the id the client uses and calls the +// inner one there; how the inner one is compiled is left open. Today it is +// left untransformed or extracted into an invalid server module (pins in +// known-bugs-start-compiler.test.ts). +// Source: SolidStart compile.spec.ts "keeps client and server ids aligned +// around nested server functions"; #8504 declaration-sites.test.ts +test.fails.each<PlacementHead>([ + 'createServerFn alone', + 'another Start factory', +])( + 'with %s imported, supports a server fn in the handler of another server fn', + async (importHead) => { + const placement = placements.find( + ({ name }) => name === 'the handler of another server fn', + )! + const served = await serveCase(await host(), { + 'module.tsx': placementModule(importHead, placement.code), + ...dbFiles, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(served.code.client, 'client').not.toContain('MARK_INNER_HANDLER') + // The outer handler returns what the inner server fn returns. + expect(await callServerFnThroughCallers(served, placement.read!)).toBe( + 'inner', + ) + }, +) + +// Goal (SPEC J4.6): two functions of a module each declare a +// server fn under the same local name; each runs its own handler. +// Today they are left untransformed, rejected or extracted into an invalid +// server module (pins in known-bugs-start-compiler.test.ts, placement "a +// function body"). +test.fails.each<PlacementHead>([ + 'createServerFn alone', + 'another Start factory', +])( + 'with %s imported, supports server fns of the same name in two functions', + async (importHead) => { + const served = await serveCase(await host(), { + 'module.tsx': placementModule( + importHead, + `export function makeInner() { + const fn = createServerFn().handler(async () => db.inner()) + return fn +} +export function makeTop() { + const fn = createServerFn().handler(async () => db.top()) + return fn +}`, + ), + ...dbFiles, + }) + expect([ + await callServerFnThroughCallers(served, 'module.makeInner()'), + await callServerFnThroughCallers(served, 'module.makeTop()'), + ]).toEqual(['inner', 'top']) + }, +) + +// Sources: TanStack/router#5496 and #5892, where `.handler<T>(...)` was not +// recognized as a server fn and its body reached the client. +test.each([ + { + name: 'a type argument', + handler: `.handler<string>(() => 'SERVER_SECRET')`, + }, + { + name: 'a Promise type argument', + handler: `.handler<Promise<{ secret: string }>>(async () => ({ secret: 'SERVER_SECRET' }))`, + }, +])('extracts a server fn whose handler has $name', async ({ handler }) => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn({ method: 'GET' })${handler}`, + }) + expect(await serverFnUrls(served)).toHaveLength(1) + expect(served.code.client).not.toContain('SERVER_SECRET') + expect(await callFromClient(served, 'module.fn')).toEqual( + handler.includes('secret:') ? { secret: 'SERVER_SECRET' } : 'SERVER_SECRET', + ) +}) + +// Bug: `.handler()` called through an optional chain +// (`createServerFn()?.handler(...)`) is not recognised: the module is left +// untransformed. +// Impact: the handler and its imports ship to the client, which calls it +// in the browser instead of through an RPC. +// Fix-agnostic: compiling it like a plain chain (an RPC on the client, the +// handler on the server) or rejecting it with a clear error at the call, +// naming createServerFn, both pass. +// Source: #8504 declaration-sites.test.ts (red on main) +test.fails( + 'a server fn created through an optional call chain compiles like a plain chain or is rejected', + async () => { + const code = `${head}import { db } from './db.server' +export const fn = createServerFn()?.handler(async () => db.inner() ?? 'MARK_INNER_HANDLER')` + const startCase = await ( + await host() + ).case({ + 'module.tsx': code, + ...dbFiles, + }) + const failure = await compileError(startCase) + if (failure !== undefined) { + expectCompileError(failure, { + source: code, + at: 'createServerFn()?.', + }) + return + } + const served = await serveCase(await host(), { + 'module.tsx': code, + ...dbFiles, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(served.code.client).not.toContain('MARK_INNER_HANDLER') + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('inner') + }, +) + +// Moved: "a .ts module in a directory whose name contains # compiles as +// TypeScript" is in integration/start-compiler-build-ids.test.ts: Vite's dev +// server serves no module under a `#` directory (a plain Vite app fails the +// same way), so a production build is where the input is reachable. diff --git a/packages/start-plugin-core/tests/createServerFn/exports-and-directives.test.ts b/packages/start-plugin-core/tests/createServerFn/exports-and-directives.test.ts index 7f16dd2cc7..3fc2fefd8d 100644 --- a/packages/start-plugin-core/tests/createServerFn/exports-and-directives.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/exports-and-directives.test.ts @@ -1,70 +1,64 @@ -import { describe, expect, test } from 'vitest' +import { describe, expect, test, vi } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { expectDeterministic } from '@tanstack/compiler-test-utils/determinism' import { - callProvider, - compileAll, - compileCode, - compileFor, - evaluateModule, - importSources, + callFromClient, + callOnServer, + callServerFnThroughCallers, + directivePrologue, + inPage, + serveCase, + serverFnUrls, + useStartHost, } from '../regression-helpers' -// Callers keep the module's exports, with each server fn replaced by an RPC; -// the provider module only exports the extracted handlers. Module directives, -// ids and module formats must survive both rewrites. +// Callers keep the module's exports: the client gets each server fn as an +// RPC, and calling one from server code runs its handler; a client call +// reaches the handler by id through Start's server entry, wherever the +// handler lives on the server (SPEC J4.2, §5.4). Module directives, ids and +// module formats must survive these rewrites. +// +// Moved to integration/start-compiler-build-ids.test.ts (production builds): +// "build providers have no dev HMR code", the build row of "ids are +// repeatable for unchanged input ...", "build ids do not ship source names" +// and the two build rows of "a provider for a module ending in a line +// comment without a newline". + +const host = useStartHost() const head = `import { createServerFn } from '@tanstack/react-start'\n` -/** `functionName -> functionId` of the server fns a compilation reported. */ -function idsByName(serverFns: Record<string, { functionName: string }>) { - return Object.fromEntries( - Object.entries(serverFns).map(([id, fn]) => [fn.functionName, id]), - ) -} - describe('export forms', () => { // Source: Next.js server-actions fixtures server-graph/9, /12, /13, /29, // /66, /69, client-graph/4, /15 - test('callers keep every export form and the provider exports only the handlers', async () => { - const compiled = - await compileAll(`${head}const a = createServerFn().handler(async () => 'a') + test('callers keep every export form, each server fn running its own handler', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}const a = createServerFn().handler(async () => 'a') const b = createServerFn().handler(async () => 'b') const c = createServerFn().handler(async () => 'c') export const d = createServerFn().handler(async () => 'd'), notAServerFn = 1 export let e = createServerFn().handler(async () => 'e') export var f = createServerFn().handler(async () => 'f') -export { a as default, b as '📙', c as as }`) - const ids = idsByName(compiled.serverFns) +export { a as default, b as named, c as as }`, + }) const exported = { default: 'a', - '📙': 'b', + named: 'b', as: 'c', d: 'd', e: 'e', f: 'f', } - for (const [output, rpc] of [ - ['client', 'client'], - ['ssr', 'ssr'], - ] as const) { - const module = await evaluateModule(compiled[output]) - expect({ ...module }).toEqual({ - notAServerFn: 1, - ...Object.fromEntries( - Object.entries(exported).map(([name, local]) => [ - name, - { rpc: { [rpc]: ids[`${local}_createServerFn_handler`] } }, - ]), - ), - }) + expect(await inPage(served, 'return module.notAServerFn')).toBe(1) + // Six server fns, each its own RPC. + expect(await serverFnUrls(served)).toHaveLength(6) + for (const [name, local] of Object.entries(exported)) { + expect(await callFromClient(served, `module.${name}`), name).toBe(local) } - const provider = await evaluateModule(compiled.provider) - const locals = ['a', 'b', 'c', 'd', 'e', 'f'] - expect(Object.keys(provider).sort()).toEqual( - locals.map((local) => `${local}_createServerFn_handler`), - ) - for (const local of locals) { - expect(await callProvider(provider, local)).toBe(local) + expect((await served.ssr()).notAServerFn).toBe(1) + for (const [name, local] of Object.entries(exported)) { + expect(await callOnServer(served, `module.${name}`), name).toBe(local) } }) @@ -73,93 +67,104 @@ export { a as default, b as '📙', c as as }`) `export default async function () {\n return fn()\n}`, `export default class {\n call() {\n return fn()\n }\n}`, ])('an anonymous default export next to a server fn: %s', async (code) => { - const { client, provider } = await compileAll( - `${head}export const fn = createServerFn().handler(async () => 1)\n${code}`, + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const fn = createServerFn().handler(async () => 1)\n${code}`, + }) + expect(await inPage(served, 'return typeof module.default')).toBe( + 'function', ) - expect((await evaluateModule(client)).default).toBeTypeOf('function') - expect(await callProvider(provider, 'fn')).toBe(1) + expect(await callFromClient(served, 'module.fn')).toBe(1) }) + // E.g. a Vue options-API component or a config object. + test.each([ + { code: 'export default { a: 1, b: 2 }', value: { a: 1, b: 2 } }, + { code: 'export default 42', value: 42 }, + ])( + 'a default-exported expression next to a server fn: $code', + async ({ code, value }) => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const fn = createServerFn().handler(async () => 1)\n${code}`, + }) + expect(await inPage(served, 'return module.default')).toEqual(value) + expect(await callFromClient(served, 'module.fn')).toBe(1) + }, + ) + // Source: @vitejs/plugin-rsc source-map/wrap-export/local-export-before-declaration.js test('an export list before the server fn declaration', async () => { - const compiled = await compileAll(`${head}export { fn, fn as alias } -const fn = createServerFn().handler(async () => 'fn')`) - const client = await evaluateModule(compiled.client) - expect(client.alias).toBe(client.fn) - expect(client.fn.rpc).toHaveProperty('client') - expect(await callProvider(compiled.provider, 'fn')).toBe('fn') + const served = await serveCase(await host(), { + 'module.tsx': `${head}export { fn, fn as alias } +const fn = createServerFn().handler(async () => 'fn')`, + }) + expect( + await inPage( + served, + 'return [module.alias === module.fn, typeof module.fn.url]', + ), + ).toEqual([true, 'string']) + expect(await callFromClient(served, 'module.fn')).toBe('fn') }) // Source: @vitejs/plugin-rsc source-map/wrap-export/dependent-declarators.js test('a server fn built from a sibling declarator', async () => { - const compiled = await compileAll(`${head}import { db } from './db.server' -export const base = createServerFn(), fn = base.handler(async () => db.x())`) - expect(importSources(compiled.client)).toEqual([]) - expect( - await callProvider(compiled.provider, 'fn', { - './db.server': `export const db = { x: () => 'x' }`, - }), - ).toBe('x') + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { db } from './db.server' +export const base = createServerFn(), fn = base.handler(async () => db.x())`, + 'db.server.ts': `export const db = { x: () => 'x' }\n`, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await callFromClient(served, 'module.fn')).toBe('x') }) // Source: @vitejs/plugin-rsc wrap-export.test.ts "re-export simple", // "re-export rename", "re-export all simple", "re-export all rename" test('re-exports stay in the callers', async () => { - const compiled = await compileAll(`${head}export { x } from './dep' + const served = await serveCase(await host(), { + 'module.tsx': `${head}export { x } from './dep' export { x as y } from './dep' export * from './star' export * as ns from './dep' -export const fn = createServerFn().handler(async () => 'fn')`) - const stubs = { - './dep': `export const x = 'x'`, - './star': `export const starred = 'starred'`, - } - for (const caller of [compiled.client, compiled.ssr]) { - const module = await evaluateModule(caller, stubs) - expect(Object.keys(module).sort()).toEqual([ - 'fn', - 'ns', - 'starred', - 'x', - 'y', - ]) - expect([module.x, module.y, module.starred, module.ns.x]).toEqual([ - 'x', - 'x', - 'starred', - 'x', - ]) - } - expect(await callProvider(compiled.provider, 'fn', stubs)).toBe('fn') +export const fn = createServerFn().handler(async () => 'fn')`, + 'dep.ts': `export const x = 'x'\n`, + 'star.ts': `export const starred = 'starred'\n`, + }) + const read = '[module.x, module.y, module.starred, module.ns.x]' + const expected = ['x', 'x', 'starred', 'x'] + expect(await inPage(served, `return ${read}`)).toEqual(expected) + const ssr = await served.ssr() + expect([ssr.x, ssr.y, ssr.starred, ssr.ns.x]).toEqual(expected) + expect(await callFromClient(served, 'module.fn')).toBe('fn') }) // JSON modules only load with their `type: 'json'` attribute. // Source: @vitejs/plugin-rsc source-map/wrap-export/reexport-attributes.js; // Turbopack tree-shaker analyzer/import-with-clause test('import attributes are kept on the imports and re-exports each output keeps', async () => { - const compiled = - await compileAll(`${head}import config from './config.json' with { type: 'json' } + const served = await serveCase(await host(), { + 'module.tsx': `${head}import config from './config.json' with { type: 'json' } import secrets from './secrets.json' with { type: 'json' } export { default as data } from './data.json' with { type: 'json' } export const theme = config.theme -export const fn = createServerFn().handler(async () => secrets.key)`) - const stubs = { - './config.json': `{ "theme": "dark" }`, - './data.json': `{ "data": true }`, - './secrets.json': `{ "key": "s3cret" }`, - } - for (const caller of [compiled.client, compiled.ssr]) { - expect(importSources(caller)).toEqual(['./config.json', './data.json']) - const module = await evaluateModule(caller, stubs) - expect([module.theme, module.data]).toEqual(['dark', { data: true }]) - } - expect(await callProvider(compiled.provider, 'fn', stubs)).toBe('s3cret') +export const fn = createServerFn().handler(async () => secrets.key)`, + 'config.json': `{ "theme": "dark" }\n`, + 'data.json': `{ "data": true }\n`, + 'secrets.json': `{ "key": "s3cret" }\n`, + }) + expectNotLoaded(await served.loads(), ['./secrets.json']) + expect(await inPage(served, 'return [module.theme, module.data]')).toEqual([ + 'dark', + { data: true }, + ]) + const ssr = await served.ssr() + expect([ssr.theme, ssr.data]).toEqual(['dark', { data: true }]) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('s3cret') }) // Source: Next.js server-actions fixtures server-graph/60, /62, /68, /72 test('TypeScript-only exports and an enum next to a server fn', async () => { - const { provider } = - await compileAll(`${head}import type { Stuff } from './stuff' + const served = await serveCase(await host(), { + 'module.tsx': `${head}import type { Stuff } from './stuff' export type X = string export { type A } from './a' export type { B } from './b' @@ -172,46 +177,89 @@ export enum E { } export declare const declared: number export default interface D {} -export const fn = createServerFn().handler(async (): Promise<Stuff | string> => E.A)`) - expect(await callProvider(provider, 'fn')).toBe('a') +export const fn = createServerFn().handler(async (): Promise<Stuff | string> => E.A)`, + 'stuff.ts': 'export type Stuff = number\n', + 'a.ts': 'export type A = string\n', + 'b.ts': 'export type B = string\n', + 'c.ts': 'export type C = string\n', + }) + expect(await callFromClient(served, 'module.fn')).toBe('a') }) + // Source: TanStack/router#6480 (an exported type that reads a schema built + // from an imported enum kept the enum's server module in the client); + // replaces router-utils stripTypeExports "handles the issue #6480 + // scenario", which never checked the symptom. The real `zod`. + test('an exported type reading a schema the handler uses keeps its imports out of the client', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { z } from 'zod' +import { PostCategory } from './PostService' +const postSchema = z.object({ category: z.nativeEnum(PostCategory) }) +export type CreatePostInput = z.infer<typeof postSchema> +export const createPost = createServerFn().handler(async () => + postSchema.parse({ category: 'news' }), +)`, + 'PostService.ts': `export const PostCategory = { News: 'news' } as const\n`, + }) + expectNotLoaded(await served.loads(), ['./PostService']) + expect(await callFromClient(served, 'module.createPost')).toEqual({ + category: 'news', + }) + }) + + // The server may repeat the module's top-level code or run the handler in + // the module itself; it runs once is the goal pinned in + // known-bugs-start-compiler.test.ts ("SSR: a server fn module is + // initialised once ..."). // Source: Next.js server-actions fixtures client-graph/2 - test('side-effect imports and top-level statements stay in every output', async () => { - const compiled = await compileAll(`${head}import './polyfill' + test('side-effect imports and top-level statements stay in the callers, and the handler runs next to them', async () => { + const startCase = await ( + await host() + ).case({ + 'module.tsx': `${head}import './polyfill' console.log('side-effect-marker') -export const fn = createServerFn().handler(async () => 'fn')`) - for (const output of [compiled.client, compiled.ssr, compiled.provider]) { - expect(importSources(output)).toEqual(['./polyfill']) - expect(output).toContain('side-effect-marker') +export const fn = createServerFn().handler(async () => 'fn')`, + 'polyfill.ts': `console.log('polyfill')\nexport {}\n`, + }) + const ran: Array<string> = [] + vi.spyOn(console, 'log').mockImplementation((marker: string) => { + ran.push(marker) + }) + try { + // The SSR environment evaluates the module (its first evaluation). + await startCase.ssr() + expect(ran, 'ssr').toEqual(['polyfill', 'side-effect-marker']) + // A page importing the module runs the same code. + const run = await startCase.client('return true') + expect( + run.console.filter((message) => message.startsWith('log: ')), + 'client', + ).toEqual(['log: polyfill', 'log: side-effect-marker']) + // The handler runs on a server that ran the module's imports. + expect(await callFromClient(startCase, 'module.fn')).toBe('fn') + expect(ran).toContain('polyfill') + } finally { + vi.restoreAllMocks() } }) - - test('redeclared var server fns get distinct versioned handler names', async () => { - const code = `${head}var fn = createServerFn().handler(async () => 1) -var fn = createServerFn().handler(async () => 2) -export { fn }` - const { serverFns } = await compileFor('client', code) - const names = ['fn_createServerFn_handler', 'fn_createServerFn_handler_1'] - expect(Object.keys(idsByName(serverFns)).sort()).toEqual(names) - const provider = await evaluateModule( - (await compileCode('provider', code))!, - ) - expect(Object.keys(provider).sort()).toEqual(names) - }) }) describe('directives', () => { + // A handler with a directive prologue is a working server fn. Where its + // directives end up on the server (they have no effect in a module, which + // is always strict, and outside RSC) is not observable, so the former + // check of the provider's printed function prologues is dropped (SPEC + // §5.4, §5.5). // Source: Next.js server-actions fixtures server-graph/8 test('handler directives stay in the provider', async () => { - const { provider } = - await compileAll(`${head}export const fn = createServerFn().handler(async function () { + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const fn = createServerFn().handler(async function () { 'use strict' 'use server' return 1 -})`) - expect(provider).toMatch(/(["'])use strict\1;?\s*(["'])use server\2/) - expect(await callProvider(provider, 'fn')).toBe(1) +})`, + }) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe(1) }) // Source: Next.js server-actions fixtures server-graph/3, /4; @@ -227,117 +275,65 @@ describe('directives', () => { 'module directives stay first in the callers: $directives', async ({ prologue, directives }) => { const code = `${prologue}${head}export const fn = createServerFn().handler(async () => 1)` - const prologuePattern = new RegExp( - String.raw`^(?:\s*//[^\n]*\n)*` + - directives - .map((directive) => String.raw`\s*['"]${directive}['"];?`) - .join(''), + const startCase = await (await host()).case({ 'module.tsx': code }) + // Each directive still leads the module the client environment + // serves, read from the parsed module (their order within the + // prologue is free, SPEC §5.5; G12 keeps each user directive, it does + // not forbid another). + expect(directivePrologue(await startCase.served())).toEqual( + expect.arrayContaining(directives), ) - for (const output of ['client', 'ssr'] as const) { - expect(await compileCode(output, code)).toMatch(prologuePattern) - } - }, - ) - - // `serverFnProviderModuleDirectives` start the provider's prologue once, - // ahead of the generated imports. - // Source: @vitejs/plugin-rsc utils.test.ts "recognizes directive prologues" - test.each([`'use server'\n`, `'use strict'\n'use server'\n`])( - 'a provider whose prologue already has the configured directive keeps one: %j', - async (prologue) => { - const provider = await compileCode( - 'provider', - `${prologue}${head}export const fn = createServerFn().handler(async () => 1)`, - { directives: ['use server', '', 'use server'] }, - ) - expect(provider).toMatch( - /^(?:\s*(["'])use strict\1;?)?\s*(["'])use server\2/, - ) - expect(provider!.match(/["']use server["']/g)).toHaveLength(1) - }, - ) - - test.each([`import './setup'\n'use server'\n`, `('use server')\n`])( - 'a "use server" string outside the prologue is not the configured directive: %j', - async (prologue) => { - const provider = await compileCode( - 'provider', - `${prologue}${head}export const fn = createServerFn().handler(async () => 1)`, - { directives: ['use server'] }, - ) - expect(provider).toMatch(/^\s*(["'])use server\1/) + expect(await callFromClient(startCase, 'module.fn')).toBe(1) }, ) }) describe('server function ids', () => { - const decodeDevId = (id: string) => - JSON.parse(Buffer.from(id, 'base64url').toString('utf8')) - - test('dev ids encode the provider module and the handler export', async () => { - const { serverFns } = await compileFor( - 'client', - `${head}export const getPosts = createServerFn().handler(async () => [])`, - { mode: 'dev' }, + test('dev providers export the handler', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const getPosts = createServerFn().handler(async () => 'posts')`, + }) + expect(await callServerFnThroughCallers(served, 'module.getPosts')).toBe( + 'posts', ) - expect(Object.keys(serverFns).map(decodeDevId)).toEqual([ - { - file: '/@id/src/module.tsx?tss-serverfn-split', - export: 'getPosts_createServerFn_handler', - }, - ]) }) - test('dev providers export the handler and accept HMR updates', async () => { - const provider = await compileCode( - 'provider', - `${head}export const getPosts = createServerFn().handler(async () => 'posts')`, - { mode: 'dev' }, - ) - expect(provider).toContain('import.meta.hot.accept(') - expect(provider).toContain('import.meta.webpackHot.accept(') - expect(await callProvider(provider!, 'getPosts')).toBe('posts') - }) - - /** `functionName -> functionId` of the server fns in `code`. */ - async function idsOf( - code: string, - options: Parameters<typeof compileFor>[2] = {}, - ) { - return idsByName( - (await compileFor('client', `${head}${code}`, options)).serverFns, - ) - } - + // Ids are repeatable for unchanged input, and within each version of a + // module the client and the server agree on them (SPEC J4.4, G4). Editing + // the module (here: adding a server fn above the others) changes the + // effective input, so ids need not survive the edit. Ids are observed as + // the public `url` of the server fns the client and server code get. // Source: SolidStart compile.spec.ts "keeps ids of existing functions when a // function is added above them", "keeps production ids stable ..." - test.each(['build', 'dev'] as const)( - '%s: ids of existing server fns survive adding one above them', - async (mode) => { - const existing = `export const load = createServerFn().handler(async () => 1) -export const save = createServerFn().handler(async () => 2)` - const before = await idsOf(existing, { mode }) - const after = await idsOf( - `export const added = createServerFn().handler(async () => 0)\n${existing}`, - { mode }, + // (their edit-stability is not required). + test('dev: ids are repeatable for unchanged input, and each version of a module runs its own handlers by id', async () => { + const existing = `export const load = createServerFn().handler(async () => 'load') +export const save = createServerFn().handler(async () => 'save')` + const versions = [ + existing, + `export const added = createServerFn().handler(async () => 'added')\n${existing}`, + ] + for (const version of versions) { + const served = await serveCase(await host(), { + 'module.tsx': `${head}${version}`, + }) + const names = + version === existing ? ['load', 'save'] : ['load', 'save', 'added'] + const read = `Object.fromEntries(${JSON.stringify(names)}.map((name) => [name, module[name].url]))` + const [clientUrls] = await expectDeterministic([1, 2, 3], () => + inPage(served, `return ${read}`), ) - expect(Object.keys(after)).toHaveLength(3) - expect(after).toMatchObject(before) - }, - ) - - // Source: SolidStart compile.spec.ts "does not ship source names in production ids" - test('build ids do not ship source names', async () => { - const [id] = Object.values( - await idsOf( - `export const loadSecretReport = createServerFn().handler(async () => 1)`, - ), - ) - for (const text of [ - id!, - Buffer.from(id!, 'base64url').toString('latin1'), - ]) { - expect(text).not.toMatch(/loadSecretReport|module|src/) + const ssr = await served.ssr() + expect( + Object.fromEntries(names.map((name) => [name, ssr[name].url])), + 'the ids server code gets', + ).toEqual(clientUrls) + for (const name of names) { + expect( + await callServerFnThroughCallers(served, `module.${name}`), + name, + ).toBe(name) + } } }) @@ -345,77 +341,85 @@ export const save = createServerFn().handler(async () => 2)` // name", "keeps client and server ids aligned" test('server fns that share a name in different files get distinct ids the provider uses', async () => { const code = `${head}export const load = createServerFn().handler(async () => 1)` - const ids: Array<string> = [] - for (const id of ['/test/src/a.tsx', '/test/src/b/a.tsx']) { - const [functionId] = Object.keys( - (await compileFor('client', code, { id })).serverFns, - ) - const provider = await evaluateModule( - (await compileCode('provider', code, { id }))!, - ) - expect(provider.load_createServerFn_handler.meta.id).toBe(functionId) - ids.push(functionId!) - } - expect(new Set(ids).size).toBe(2) + const served = await serveCase(await host(), { + 'a.tsx': code, + 'b/a.tsx': code, + 'module.tsx': `export { load as first } from './a' +export { load as second } from './b/a' +`, + }) + expect(await serverFnUrls(served)).toHaveLength(2) + expect([ + await callFromClient(served, 'module.first'), + await callFromClient(served, 'module.second'), + ]).toEqual([1, 1]) }) // Source: Next.js server-actions fixtures server-graph/66, client-graph/15 test('non-ASCII and symbol-like server fn names', async () => { const names = ['ñandú', '𝑓', 'ᾩ', '$', '_', '$fn'] - const compiled = await compileAll( - head + + const served = await serveCase(await host(), { + 'module.tsx': + head + names .map( (name) => `export const ${name} = createServerFn().handler(async () => '${name}')`, ) .join('\n'), - ) - expect(Object.keys(idsByName(compiled.serverFns)).sort()).toEqual( - names.map((name) => `${name}_createServerFn_handler`).sort(), - ) - const provider = await evaluateModule(compiled.provider) + }) + expect(await serverFnUrls(served)).toHaveLength(names.length) for (const name of names) { - expect(provider[`${name}_createServerFn_handler`].meta.name).toBe(name) - expect(await callProvider(provider, name)).toBe(name) + expect( + await callServerFnThroughCallers( + served, + `module[${JSON.stringify(name)}]`, + ), + ).toBe(name) } }) }) describe('module formats', () => { - // The provider appends its exports after the last statement. + // The compiler may append code after the module's last statement. // Source: Waku vite-plugin-allow-server.test.ts "transforms with trailing // comment without new lines" - test.each([ - { end: '\n// trailing', mode: 'build' }, - { end: '\r\n// trailing', mode: 'build' }, - { end: '\n// trailing', mode: 'dev' }, - ] as const)( - '$mode: a provider for a module ending in a line comment without a newline: $end', - async ({ end, mode }) => { - const provider = await compileCode( - 'provider', - `${head}export const fn = createServerFn().handler(async () => 'handler')${end}`, - { mode }, - ) - expect(await callProvider(provider!, 'fn')).toBe('handler') - }, - ) + test('dev: a provider for a module ending in a line comment without a newline: \n// trailing', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const fn = createServerFn().handler(async () => 'handler')\n// trailing`, + }) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe( + 'handler', + ) + }) - // .cts/.mts sources are TypeScript without JSX. + // .mts sources are TypeScript without JSX. + // No `.cts` row: Vite's TypeScript transform skips `.cts` by default + // (`vite:oxc` includes `.ts`, `.mts`, `.tsx`, `.jsx`), so a plain Vite app + // without Start cannot run a `.cts` module with TypeScript syntax in dev + // either (SSR: "Parse failure: Unexpected JSX expression"; the client gets + // the TypeScript as is), and its build fails the same way for any query + // import of a `.cts` module (`./fn.cts?x`). Not a compiler outcome + // (Vite's own default). // Source: @vitejs/plugin-rsc cjs.test.ts (fixtures/cjs) - test.each(['/test/src/fn.cts', '/test/src/fn.mts'])( - '%s may use angle-bracket type assertions', - async (id) => { - const { code, serverFns } = await compileFor( - 'client', - `${head}import { db } from './db.server' + for (const file of ['fn.mts']) { + test(`${file} may use angle-bracket type assertions`, async () => { + const served = await serveCase( + await host(), + { + [file]: `${head}import { db } from './db.server' const n = <number>(1 as unknown) export const fn = createServerFn().handler(async () => [n, db.x()])`, - { id }, + 'db.server.ts': `export const db = { x: () => 'x' }\n`, + }, + { file }, ) - expect(Object.keys(serverFns)).toHaveLength(1) - expect(importSources(code!)).toEqual([]) - }, - ) + expectNotLoaded(await served.loads(file), ['./db.server']) + expect( + await callServerFnThroughCallers(served, 'module.fn', undefined, { + file, + }), + ).toEqual([1, 'x']) + }) + } }) diff --git a/packages/start-plugin-core/tests/createServerFn/handler-scope.test.ts b/packages/start-plugin-core/tests/createServerFn/handler-scope.test.ts index 2f94d1b465..dd9b704b8e 100644 --- a/packages/start-plugin-core/tests/createServerFn/handler-scope.test.ts +++ b/packages/start-plugin-core/tests/createServerFn/handler-scope.test.ts @@ -1,23 +1,36 @@ import { expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' import { - callProvider, - compileAll, - compileCode, - evaluateModule, - importSources, + callFromClient, + callServerFnThroughCallers, + compileError, + expectCompileError, + inPage, + serveCase, + useStartHost, } from '../regression-helpers' +import { + handlerFiles, + handlerModule, + handlerModules, + handlerRows, +} from '../compiler-inputs' -// The provider module runs the extracted handler: it must keep every module -// binding the handler closes over, however the handler is written and -// however its scopes shadow module names. +// The server must run the handler with every module binding it closes over, +// however the handler is written and however its scopes shadow module +// names: a client call reaches it by id through Start's server entry, and a +// call from server code runs it (`callServerFnThroughCallers`). Where the +// handler lives on the server is free (SPEC J4.2, §5.4). + +const host = useStartHost() const head = `import { createServerFn } from '@tanstack/react-start'\n` -const dbServer = `export const db = { x: () => 'x', y: () => 'y' }` // Source: Next.js server-actions fixtures server-graph/5, /6, /16 test('the provider keeps every kind of module binding the handler reads', async () => { - const { client, provider } = - await compileAll(`${head}import * as ns from './ns' + const served = await serveCase(await host(), { + 'module.tsx': `${head}import * as ns from './ns' var counter = 4 class Repo { static get() { @@ -27,109 +40,130 @@ class Repo { enum Role { Admin = 'admin', } -export const fn = createServerFn().handler(async () => [ns.x, counter, Repo.get(), Role.Admin])`) - expect(importSources(client)).toEqual([]) - expect( - await callProvider(provider, 'fn', { './ns': `export const x = 'ns'` }), - ).toEqual(['ns', 4, 'repo', 'admin']) +export const fn = createServerFn().handler(async () => [ns.x, counter, Repo.get(), Role.Admin])`, + 'ns.ts': `export const x = 'ns'\n`, + }) + expectNotLoaded(await served.loads(), ['./ns']) + expect(await callServerFnThroughCallers(served, 'module.fn')).toEqual([ + 'ns', + 4, + 'repo', + 'admin', + ]) }) -test.each<{ - name: string - code: string - expected: unknown - read?: (value: any) => Promise<unknown> -}>([ - { - // Source: Next.js server-actions fixtures server-graph/7, /44 - name: 'a named function expression', - code: `export const fn = createServerFn().handler(async function deleteItem() { - return deleteItem.name + db.x() -})`, - expected: 'deleteItemx', - }, - { - // Source: Next.js server-actions fixtures server-graph/59 - name: 'a function using this, arguments and new.target', - code: `export const fn = createServerFn().handler(async function (this: unknown) { - return [typeof this, arguments.length, new.target === undefined, db.x()] -})`, - expected: ['undefined', 1, true, 'x'], - }, - { - // Source: Next.js server-actions fixtures server-graph/14 (streaming) - name: 'an async generator', - code: `export const fn = createServerFn().handler(async function* () { - yield db.x() - yield 'done' -})`, - read: async (iterator: AsyncIterable<unknown>) => { - const values: Array<unknown> = [] - for await (const value of iterator) { - values.push(value) - } - return values - }, - expected: ['x', 'done'], - }, - { - // Source: Next.js server-actions fixtures server-graph/31 - name: 'an object literal method', - code: `export const fn = createServerFn().handler({ - async f() { - return db.x() - }, -}.f)`, - expected: 'x', - }, - { - // Source: Next.js server-actions fixtures server-graph/21, /26 - name: 'a wrapper call', - code: `import { withAuth } from './auth.server' -export const fn = createServerFn().handler(withAuth(async () => db.x()))`, - expected: 'auth:x', - }, - { - // Source: Next.js server-actions fixtures server-graph/25 - name: 'a function declared after the server fn', - code: `export const fn = createServerFn().handler(impl) -async function impl() { - return inner() - async function inner() { - return db.x() +/** The server-only module most handlers below read. */ +const dbServer = handlerFiles['db.server.ts'] + +/** + * Serves a module with the server fn `fn`: the client loads none of the + * server modules the handler reads, and calling the server fn from the + * client (through its RPC) and from server code both run the handler. + * Returns what the handler returns; with `iterate`, the handler returns an + * async iterable, read on each side. + */ +async function callHandler(code: string, iterate = false) { + const served = await serveCase(await host(), { + 'module.tsx': handlerModule(code), + ...handlerFiles, + }) + expectNotLoaded(await served.loads(), handlerModules) + if (!iterate) { + return callServerFnThroughCallers(served, 'module.fn') } -}`, - expected: 'x', - }, - { - // Source: Next.js server-actions fixtures server-graph/28, /30 - name: 'a call of a server fn declared later', - code: `export const fn = createServerFn().handler(async () => (await later()) + db.x()) -export const later = createServerFn().handler(async () => 'later:')`, - expected: 'later:x', - }, - { - name: 'a parenthesized non-null initializer', - code: `export const fn = (createServerFn().handler(async () => db.x()))!`, - expected: 'x', - }, -])( - 'the handler can be $name', - async ({ code, expected, read = async (value) => value }) => { - const compiled = await compileAll( - `${head}import { db } from './db.server'\n${code}`, - ) - for (const caller of [compiled.client, compiled.ssr]) { - expect(importSources(caller)).toEqual([]) + const client = await inPage( + served, + `const values = [] +for await (const value of await module.fn()) { + values.push(value) +} +return values`, + ) + const ssr = await served.ssr() + const server = await served.inRequest(async () => { + const values: Array<unknown> = [] + for await (const value of (await ssr.fn()) as AsyncIterable<unknown>) { + values.push(value) } - const value = await callProvider(compiled.provider, 'fn', { - './db.server': dbServer, - './auth.server': `export const withAuth = (fn) => async (opts) => 'auth:' + (await fn(opts))`, - }) - expect(await read(value)).toEqual(expected) + return values + }) + expect(server, 'read by server code').toEqual(client) + return client +} + +test.each(handlerRows)( + 'the handler can be $name', + async ({ code, expected, iterate }) => { + expect(await callHandler(code, iterate)).toEqual(expected) }, ) +// Bug: when the handler passed to `.handler()` is a `createIsomorphicFn()` +// chain, the chain is compiled first and the caller is never rewritten into +// an RPC (same cause as the createServerOnlyFn handler pin in +// known-bugs-start-compiler.test.ts). +// Impact: the server fn cannot be called through an RPC (the client's `fn` +// has no `url`) and its server implementation never runs: a call from the +// client and one from server code both resolve to `undefined` (the client +// module keeps `createServerFn().handler(() => 'client')`, the isomorphic +// fn's client implementation passed as the handler; the call does not give +// its 'client' either). +// Source: TanStack/router#8446; #8504 handler-scope.test.ts +// (imaimai17468/tanstack-start-handler-call-expression-repro; red on main) +// The outcome (SPEC J4.1, J4.2, G5): the handler runs, or the module is +// reported: a compile error, or in dev a warning, naming the file. +test.fails( + 'the handler can be a createIsomorphicFn call, or the module is reported', + async () => { + const code = `${head}import { createIsomorphicFn } from '@tanstack/react-start' +import { db } from './db.server' +export const fn = createServerFn().handler( + createIsomorphicFn() + .server(async () => db.x()) + .client(() => 'client'), +)` + const startCase = await ( + await host() + ).case({ 'module.tsx': code, ...handlerFiles }) + const mark = startCase.diagnostics().length + for (const environment of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, environment) + if (failure !== undefined) { + expectCompileError(failure, { source: code, at: undefined }) + return + } + } + // What compiling the module reported (not what calling it logs) + const reported = findDiagnostics(startCase.diagnostics().slice(mark), { + file: startCase.file(), + }) + if (reported.length === 0) { + expectNotLoaded(await startCase.loads(), handlerModules) + expect(await callServerFnThroughCallers(startCase, 'module.fn')).toBe('x') + } + }, +) + +// Source: TanStack/router#7341. In a `.ts` module, `<T>value` is a type +// assertion and `<T>(value: T) => value` a generic arrow function, not JSX. +test('a handler in a .ts module can use angle-bracket type assertions', async () => { + const file = 'module.ts' + const served = await serveCase( + await host(), + { + [file]: `${head}import { db } from './db.server' +const identity = <T>(value: T) => value +export const fn = createServerFn().handler(async () => <string>identity(<unknown>db.x()))`, + 'db.server.ts': dbServer, + }, + { file }, + ) + expectNotLoaded(await served.loads(file), ['./db.server']) + expect( + await callServerFnThroughCallers(served, 'module.fn', undefined, { file }), + ).toBe('x') +}) + // Each handler reads the module binding `value` (or `key`) through a scope // that also declares, or seems to declare, the same name. test.each<{ name: string; code: string; data?: unknown; expected: unknown }>([ @@ -307,42 +341,50 @@ export const fn = createServerFn().handler(async () => ({ value }))`, ])( 'the provider keeps a module binding the handler reads $name', async ({ code, data, expected }) => { - const provider = await compileCode('provider', `${head}${code}`) - expect(await callProvider(provider!, 'fn', {}, data)).toEqual(expected) + const served = await serveCase(await host(), { + 'module.tsx': `${head}${code}`, + }) + expect(await callServerFnThroughCallers(served, 'module.fn', data)).toEqual( + expected, + ) }, ) // Source: @vitejs/plugin-rsc hoist/self-ref-nested-function.js, // hoist/direct-recursion-self-binding.js test('a handler can call its own server fn', async () => { - const provider = await compileCode( - 'provider', - `${head}export const fn = createServerFn().handler(async ({ data }) => + const served = await serveCase(await host(), { + 'module.tsx': `${head}export const fn = createServerFn().handler(async ({ data }) => data > 0 ? fn({ data: data - 1 }) : 'done')`, - ) - expect(await callProvider(provider!, 'fn', {}, 2)).toBe('done') + }) + expect(await callServerFnThroughCallers(served, 'module.fn', 2)).toBe('done') }) // Source: @vitejs/plugin-rsc hoist/captured-local-assignment.js, // wrap-export.test.ts "preserve reference" test('a handler and client code can both update an exported let', async () => { - const compiled = await compileAll(`${head}export let count = 0 + const served = await serveCase(await host(), { + 'module.tsx': `${head}export let count = 0 export function changeCount() { count += 1 return count } -export const bump = createServerFn().handler(async () => ++count)`) - const client = await evaluateModule(compiled.client) - expect(client.changeCount()).toBe(1) - expect(client.count).toBe(1) - const provider = await evaluateModule(compiled.provider) - expect(await callProvider(provider, 'bump')).toBe(1) - expect(await callProvider(provider, 'bump')).toBe(2) +export const bump = createServerFn().handler(async () => ++count)`, + }) + expect( + await inPage(served, 'return [module.changeCount(), module.count]'), + ).toEqual([1, 1]) + // Two calls reach one server instance: the handler updates its `count`. + expect([ + await callFromClient(served, 'module.bump'), + await callFromClient(served, 'module.bump'), + ]).toEqual([1, 2]) }) // Source: Next.js server-actions fixtures server-graph/27 -test('exported helpers the handler uses stay declared in the provider', async () => { - const { provider } = await compileAll(`${head}import { db } from './db.server' +test('exported helpers the handler uses are callable from the handler', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { db } from './db.server' export async function load() { return db.x() } @@ -356,8 +398,13 @@ export class Repo { } const local = () => 'w' export { local as alias } -export const fn = createServerFn().handler(async () => [await load(), helper(), Repo.z(), local()])`) - expect( - await callProvider(provider, 'fn', { './db.server': dbServer }), - ).toEqual(['x', 'y', 'z', 'w']) +export const fn = createServerFn().handler(async () => [await load(), helper(), Repo.z(), local()])`, + 'db.server.ts': dbServer, + }) + expect(await callServerFnThroughCallers(served, 'module.fn')).toEqual([ + 'x', + 'y', + 'z', + 'w', + ]) }) diff --git a/packages/start-plugin-core/tests/createServerFn/placements.ts b/packages/start-plugin-core/tests/createServerFn/placements.ts new file mode 100644 index 0000000000..b3fbc45772 --- /dev/null +++ b/packages/start-plugin-core/tests/createServerFn/placements.ts @@ -0,0 +1,196 @@ +/** + * Places a `createServerFn` can be written other than a top-level `const` + * declarator, shared by the loosened placement tests + * (declaration-sites.test.ts), their goal pins and the bug pins + * (known-bugs-start-compiler.test.ts). Each handler reads the server-only + * module (`serverOnlyModule`, `db.inner()`; where a test checks that the + * client holds no handler code, the handler also holds the marker + * `MARK_INNER_HANDLER`, a fallback it never returns); `read` is where the server fn + * the placement creates is, as a JavaScript expression with the module + * namespace as `module` (read in a page and on the server, e.g. by + * `expectNoClientHandler` and `callServerFnThroughCallers`). + */ +export interface Placement { + name: string + code: string + /** + * The server fn in the module of the placement's code: a JavaScript + * expression with the module namespace as `module`. + */ + read?: string + /** The server fn is created inside a function. */ + nested?: boolean + /** + * The server fn initializes a variable declarator below the module top + * level (in a function body, a switch case or a block). + */ + declarator?: boolean +} + +/** The import heads the placements are compiled under. */ +export const placementHeads = { + 'createServerFn alone': { + head: `import { createServerFn } from '@tanstack/react-start'\nimport { db } from './db.server'\n`, + tail: '', + }, + 'another Start factory': { + head: `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start'\nimport { db } from './db.server'\n`, + tail: `\nexport const serverOnly = createServerOnlyFn(() => db.top())`, + }, +} + +export type PlacementHead = keyof typeof placementHeads + +/** `code` of a placement under an import head. */ +export function placementModule(head: PlacementHead, code: string) { + const { head: imports, tail } = placementHeads[head] + return `${imports}${code}${tail}` +} + +export const placements: Array<Placement> = [ + { + name: 'a function body', + code: `export function make() { + const inner = createServerFn().handler(async () => db.inner()) + return inner +}`, + read: 'module.make()', + nested: true, + declarator: true, + }, + { + name: 'a function body next to a top-level server fn', + code: `export const top = createServerFn().handler(async () => db.top()) +export function make() { + const inner = createServerFn().handler(async () => db.inner()) + return inner +}`, + read: 'module.make()', + nested: true, + declarator: true, + }, + { + name: 'a switch case inside a function', + code: `export function pick(kind: string) { + switch (kind) { + case 'a': + const inner = createServerFn().handler(async () => db.inner()) + return inner + } +}`, + read: "module.pick('a')", + nested: true, + declarator: true, + }, + { + name: 'a function return value', + code: `export function make() { + return createServerFn().handler(async () => db.inner()) +}`, + read: 'module.make()', + nested: true, + }, + { + // SPEC J4.6 ("other positions (…, block) likewise work or error + // clearly"). + name: 'a block at the module top level', + code: `export const registry: Array<unknown> = [] +{ + const inner = createServerFn().handler(async () => db.inner()) + registry.push(inner) +}`, + read: 'module.registry[0]', + declarator: true, + }, + { + name: 'an object property', + code: `export const api = { read: createServerFn().handler(async () => db.inner()) }`, + read: 'module.api.read', + }, + { + name: 'a class field', + code: `export class Api { read = createServerFn().handler(async () => db.inner()) }`, + read: 'new module.Api().read', + }, + { + name: 'an anonymous default export', + code: `export default createServerFn().handler(async () => db.inner())`, + read: 'module.default', + }, + { + name: 'an assignment', + code: `export let fn: unknown +fn = createServerFn().handler(async () => db.inner())`, + read: 'module.fn', + }, + { + // Source: SolidStart compile.spec.ts "keeps client and server ids + // aligned around nested server functions"; #8504 + // declaration-sites.test.ts + name: 'the handler of another server fn', + code: `export const outer = createServerFn().handler(async () => { + const inner = createServerFn().handler(async () => db.inner() ?? 'MARK_INNER_HANDLER') + return await inner() +})`, + read: 'module.outer', + nested: true, + declarator: true, + }, + { + // Source: #8504 declaration-sites.test.ts + name: 'a call argument', + code: `export const registered: Array<unknown> = [] +function register(fn: unknown) { + registered.push(fn) +} +register(createServerFn().handler(async () => db.inner()))`, + read: 'module.registered[0]', + }, + { + // Source: Next.js server-actions fixtures server-graph/18, /19; #8504 + // declaration-sites.test.ts + name: 'a JSX attribute', + code: `export function Page() { + return <form action={createServerFn().handler(async () => db.inner()) as any} /> +}`, + // The element the page renders (React's), its `action` prop. + read: 'module.Page().props.action', + }, + { + // Source: #8504 declaration-sites.test.ts + name: 'a conditional initializer', + code: `export const fn = Math.random() < 2 ? createServerFn().handler(async () => db.inner()) : null`, + read: 'module.fn', + }, + { + // Source: Next.js server-actions fixtures server-graph/56; #8504 + // declaration-sites.test.ts + name: 'an object destructuring declarator', + code: `export const { fn } = { fn: createServerFn().handler(async () => db.inner()) }`, + read: 'module.fn', + }, + { + // Source: Next.js server-actions fixtures server-graph/20; #8504 + // declaration-sites.test.ts + name: 'an array destructuring declarator', + code: `export const [fn] = [createServerFn().handler(async () => db.inner())]`, + read: 'module.fn', + }, +] + +/** + * A server fn nested in a function whose handler reads a local of that + * function (`id`): it cannot be hoisted as it is. The compiler either keeps + * the complete RPC semantics safely (each `make(id)` instance calls a server + * handler that sees its own `id`, and nothing leaks) or rejects it with a + * clear error naming the capture (SPEC J4.6, §5.13). + */ +export const capturingPlacement: Placement = { + name: 'a function body, with a handler reading a local of the function', + code: `export function make(id: string) { + const inner = createServerFn().handler(async () => db.inner(id) ?? 'MARK_INNER_HANDLER') + return inner +}`, + nested: true, + declarator: true, +} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx deleted file mode 100644 index 88e8607da2..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructured.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import { createServerFn } from '@tanstack/react-start' -export const withUseServer = createServerFn({ method: 'GET' }).handler( - createClientRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withArrowFunction = createServerFn({ method: 'GET' }).handler( - createClientRpc( - 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', - ), -) -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET', -}).handler( - createClientRpc( - 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', - ), -) -export const withoutUseServer = createServerFn({ method: 'GET' }).handler( - createClientRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = createServerFn({ method: 'GET' }).handler( - createClientRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = createServerFn({ method: 'GET' }).handler( - createClientRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) -export const withValidatorFn = createServerFn({ method: 'GET' }).handler( - createClientRpc( - '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx deleted file mode 100644 index 34e0c452b6..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import { createServerFn as serverFn } from '@tanstack/react-start' -export const withUseServer = serverFn({ method: 'GET' }).handler( - createClientRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withoutUseServer = serverFn({ method: 'GET' }).handler( - createClientRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = serverFn({ method: 'GET' }).handler( - createClientRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = serverFn({ method: 'GET' }).handler( - createClientRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx deleted file mode 100644 index 2cea070645..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnStarImport.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import * as TanStackStart from '@tanstack/react-start' -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createClientRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createClientRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createClientRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createClientRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx deleted file mode 100644 index 97253672a6..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/createServerFnValidator.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import { createServerFn } from '@tanstack/react-start' -export const withUseServer = createServerFn({ method: 'GET' }).handler( - createClientRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx deleted file mode 100644 index 889c1fbf4e..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/factory.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import { createServerFn, createMiddleware } from '@tanstack/react-start' -const authMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { auth: 'auth' } }) - }, -) -const adminMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { admin: 'admin' } }) - }, -) -export const createAuthServerFn = createServerFn().middleware([authMiddleware]) -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) -export const myAuthedFn = createAuthServerFn().handler( - createClientRpc( - '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', - ), -) -export const deleteUserFn = createAdminServerFn().handler( - createClientRpc( - '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', - ), -) -function createFakeFn() { - return { - handler: (cb) => { - return cb() - }, - } -} -const x = createFakeFn().handler(() => { - return 'fakeFn' -}) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx deleted file mode 100644 index 8e09a57d37..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/client/isomorphic-fns.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { createClientRpc } from '@tanstack/react-start/client-rpc' -import { createFileRoute } from '@tanstack/react-router' -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' -import { useState } from 'react' -const getEnv = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') -const getServerEnv = createServerFn().handler( - createClientRpc( - '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', - ), -) -const getEcho = createIsomorphicFn() - .server((input: string) => 'server received ' + input) - .client((input) => 'client received ' + input) -const getServerEcho = createServerFn().handler( - createClientRpc( - 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', - ), -) -export const Route = createFileRoute('/isomorphic-fns')({ - component: RouteComponent, - loader() { - return { envOnLoad: getEnv() } - }, -}) -function RouteComponent() { - const { envOnLoad } = Route.useLoaderData() - const [results, setResults] = useState<Partial<Record<string, string>>>() - async function handleClick() { - const envOnClick = getEnv() - const echo = getEcho('hello') - const [serverEnv, serverEcho] = await Promise.all([ - getServerEnv(), - getServerEcho({ data: 'hello' }), - ]) - setResults({ envOnClick, echo, serverEnv, serverEcho }) - } - const { envOnClick, echo, serverEnv, serverEcho } = results || {} - return ( - <div> - <button onClick={handleClick} data-testid="test-isomorphic-results-btn"> - Run - </button> - {!!results && ( - <div> - <h1> - <code>getEnv</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-result">{JSON.stringify(serverEnv)}</pre> - When we called the function on the client it returned: - <pre data-testid="client-result">{JSON.stringify(envOnClick)}</pre> - When we called the function during SSR it returned: - <pre data-testid="ssr-result">{JSON.stringify(envOnLoad)}</pre> - <br /> - <h1> - <code>echo</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-echo-result"> - {JSON.stringify(serverEcho)} - </pre> - When we called the function on the client it returned: - <pre data-testid="client-echo-result">{JSON.stringify(echo)}</pre> - </div> - )} - </div> - ) -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx deleted file mode 100644 index efa8f395d5..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructured.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' -export const withUseServer = createServerFn({ method: 'GET' }).handler( - createSsrRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withArrowFunction = createServerFn({ method: 'GET' }).handler( - createSsrRpc( - 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', - ), -) -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET', -}).handler( - createSsrRpc( - 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', - ), -) -export const withoutUseServer = createServerFn({ method: 'GET' }).handler( - createSsrRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = createServerFn({ method: 'GET' }).handler( - createSsrRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = createServerFn({ method: 'GET' }).handler( - createSsrRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) -export const withValidatorFn = createServerFn({ method: 'GET' }) - .validator(z.number()) - .handler( - createSsrRpc( - '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', - ), - ) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx deleted file mode 100644 index 7088a4bc69..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,22 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import { createServerFn as serverFn } from '@tanstack/react-start' -export const withUseServer = serverFn({ method: 'GET' }).handler( - createSsrRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withoutUseServer = serverFn({ method: 'GET' }).handler( - createSsrRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = serverFn({ method: 'GET' }).handler( - createSsrRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = serverFn({ method: 'GET' }).handler( - createSsrRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx deleted file mode 100644 index 899aaf3d0d..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnStarImport.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import * as TanStackStart from '@tanstack/react-start' -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createSsrRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), -) -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createSsrRpc( - 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - ), -) -export const withVariable = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createSsrRpc( - '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - ), -) -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - createSsrRpc( - '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - ), -) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx deleted file mode 100644 index e1d136311b..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/createServerFnValidator.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' -export const withUseServer = createServerFn({ method: 'GET' }) - .validator(z.number()) - .handler( - createSsrRpc( - 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - ), - ) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx deleted file mode 100644 index ab19c3e1f8..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/factory.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import { createServerFn, createMiddleware } from '@tanstack/react-start' -const authMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { auth: 'auth' } }) - }, -) -const adminMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { admin: 'admin' } }) - }, -) -export const createAuthServerFn = createServerFn().middleware([authMiddleware]) -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) -export const myAuthedFn = createAuthServerFn().handler( - createSsrRpc( - '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', - ), -) -export const deleteUserFn = createAdminServerFn().handler( - createSsrRpc( - '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', - ), -) -function createFakeFn() { - return { - handler: (cb) => { - return cb() - }, - } -} -const x = createFakeFn().handler(() => { - return 'fakeFn' -}) diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx deleted file mode 100644 index cfefad2bfb..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-caller/isomorphic-fns.tsx +++ /dev/null @@ -1,72 +0,0 @@ -import { createSsrRpc } from '@tanstack/react-start/ssr-rpc' -import { createFileRoute } from '@tanstack/react-router' -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' -import { useState } from 'react' -const getEnv = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') -const getServerEnv = createServerFn().handler( - createSsrRpc( - '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', - ), -) -const getEcho = createIsomorphicFn() - .server((input: string) => 'server received ' + input) - .client((input) => 'client received ' + input) -const getServerEcho = createServerFn() - .validator((input: string) => input) - .handler( - createSsrRpc( - 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', - ), - ) -export const Route = createFileRoute('/isomorphic-fns')({ - component: RouteComponent, - loader() { - return { envOnLoad: getEnv() } - }, -}) -function RouteComponent() { - const { envOnLoad } = Route.useLoaderData() - const [results, setResults] = useState<Partial<Record<string, string>>>() - async function handleClick() { - const envOnClick = getEnv() - const echo = getEcho('hello') - const [serverEnv, serverEcho] = await Promise.all([ - getServerEnv(), - getServerEcho({ data: 'hello' }), - ]) - setResults({ envOnClick, echo, serverEnv, serverEcho }) - } - const { envOnClick, echo, serverEnv, serverEcho } = results || {} - return ( - <div> - <button onClick={handleClick} data-testid="test-isomorphic-results-btn"> - Run - </button> - {!!results && ( - <div> - <h1> - <code>getEnv</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-result">{JSON.stringify(serverEnv)}</pre> - When we called the function on the client it returned: - <pre data-testid="client-result">{JSON.stringify(envOnClick)}</pre> - When we called the function during SSR it returned: - <pre data-testid="ssr-result">{JSON.stringify(envOnLoad)}</pre> - <br /> - <h1> - <code>echo</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-echo-result"> - {JSON.stringify(serverEcho)} - </pre> - When we called the function on the client it returned: - <pre data-testid="client-echo-result">{JSON.stringify(echo)}</pre> - </div> - )} - </div> - ) -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx deleted file mode 100644 index 3bc4879c14..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructured.tsx +++ /dev/null @@ -1,126 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' -const withUseServer_createServerFn_handler = createServerRpc( - { - id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - name: 'withUseServer', - filename: 'src/test.ts', - }, - (opts) => withUseServer.__executeServer(opts), -) -const withUseServer = createServerFn({ method: 'GET' }).handler( - withUseServer_createServerFn_handler, - async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) -const withArrowFunction_createServerFn_handler = createServerRpc( - { - id: 'a311dfd9a6554bc0bb9371ef4fbc72c852d0b5532829a2613a29157b8595a793', - name: 'withArrowFunction', - filename: 'src/test.ts', - }, - (opts) => withArrowFunction.__executeServer(opts), -) -const withArrowFunction = createServerFn({ method: 'GET' }).handler( - withArrowFunction_createServerFn_handler, - async () => null, -) -const withArrowFunctionAndFunction_createServerFn_handler = createServerRpc( - { - id: 'dbe1f77c6ea7590bce3212a75b06d3cee83b425bcf493014cb47462ef725e36e', - name: 'withArrowFunctionAndFunction', - filename: 'src/test.ts', - }, - (opts) => withArrowFunctionAndFunction.__executeServer(opts), -) -const withArrowFunctionAndFunction = createServerFn({ method: 'GET' }).handler( - withArrowFunctionAndFunction_createServerFn_handler, - async () => test(), -) -const withoutUseServer_createServerFn_handler = createServerRpc( - { - id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - name: 'withoutUseServer', - filename: 'src/test.ts', - }, - (opts) => withoutUseServer.__executeServer(opts), -) -const withoutUseServer = createServerFn({ method: 'GET' }).handler( - withoutUseServer_createServerFn_handler, - async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) -const withVariable_createServerFn_handler = createServerRpc( - { - id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - name: 'withVariable', - filename: 'src/test.ts', - }, - (opts) => withVariable.__executeServer(opts), -) -const withVariable = createServerFn({ method: 'GET' }).handler( - withVariable_createServerFn_handler, - abstractedFunction, -) -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} -const withZodValidator_createServerFn_handler = createServerRpc( - { - id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - name: 'withZodValidator', - filename: 'src/test.ts', - }, - (opts) => withZodValidator.__executeServer(opts), -) -const withZodValidator = createServerFn({ method: 'GET' }).handler( - withZodValidator_createServerFn_handler, - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) -const withValidatorFn_createServerFn_handler = createServerRpc( - { - id: '5cf922ac733d835fee496964cbf0b4b4067cb43d51f2efa484d072e6bb7dae44', - name: 'withValidatorFn', - filename: 'src/test.ts', - }, - (opts) => withValidatorFn.__executeServer(opts), -) -const withValidatorFn = createServerFn({ method: 'GET' }) - .validator(z.number()) - .handler(withValidatorFn_createServerFn_handler, async ({ input }) => { - return null - }) -export { - withUseServer_createServerFn_handler, - withArrowFunction_createServerFn_handler, - withArrowFunctionAndFunction_createServerFn_handler, - withoutUseServer_createServerFn_handler, - withVariable_createServerFn_handler, - withZodValidator_createServerFn_handler, - withValidatorFn_createServerFn_handler, -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx deleted file mode 100644 index 775c32b645..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import { createServerFn as serverFn } from '@tanstack/react-start' -import { z } from 'zod' -const withUseServer_createServerFn_handler = createServerRpc( - { - id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - name: 'withUseServer', - filename: 'src/test.ts', - }, - (opts) => withUseServer.__executeServer(opts), -) -const withUseServer = serverFn({ method: 'GET' }).handler( - withUseServer_createServerFn_handler, - async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) -const withoutUseServer_createServerFn_handler = createServerRpc( - { - id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - name: 'withoutUseServer', - filename: 'src/test.ts', - }, - (opts) => withoutUseServer.__executeServer(opts), -) -const withoutUseServer = serverFn({ method: 'GET' }).handler( - withoutUseServer_createServerFn_handler, - async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) -const withVariable_createServerFn_handler = createServerRpc( - { - id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - name: 'withVariable', - filename: 'src/test.ts', - }, - (opts) => withVariable.__executeServer(opts), -) -const withVariable = serverFn({ method: 'GET' }).handler( - withVariable_createServerFn_handler, - abstractedFunction, -) -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} -const withZodValidator_createServerFn_handler = createServerRpc( - { - id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - name: 'withZodValidator', - filename: 'src/test.ts', - }, - (opts) => withZodValidator.__executeServer(opts), -) -const withZodValidator = serverFn({ method: 'GET' }).handler( - withZodValidator_createServerFn_handler, - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) -export { - withUseServer_createServerFn_handler, - withoutUseServer_createServerFn_handler, - withVariable_createServerFn_handler, - withZodValidator_createServerFn_handler, -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx deleted file mode 100644 index bc18c08855..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnStarImport.tsx +++ /dev/null @@ -1,88 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import * as TanStackStart from '@tanstack/react-start' -import { z } from 'zod' -const withUseServer_createServerFn_handler = createServerRpc( - { - id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - name: 'withUseServer', - filename: 'src/test.ts', - }, - (opts) => withUseServer.__executeServer(opts), -) -const withUseServer = TanStackStart.createServerFn({ method: 'GET' }).handler( - withUseServer_createServerFn_handler, - async function () { - 'use server' - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) - }, -) -const withoutUseServer_createServerFn_handler = createServerRpc( - { - id: 'c0d9fdeb2b01aafecc782f439416b86f666cb5334ac9a934546b177e5698bbb2', - name: 'withoutUseServer', - filename: 'src/test.ts', - }, - (opts) => withoutUseServer.__executeServer(opts), -) -const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler(withoutUseServer_createServerFn_handler, async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) -const withVariable_createServerFn_handler = createServerRpc( - { - id: '7d36cb30c30bd688b9773bd7f85a0d51d83f868255e127605e4f236615fefe70', - name: 'withVariable', - filename: 'src/test.ts', - }, - (opts) => withVariable.__executeServer(opts), -) -const withVariable = TanStackStart.createServerFn({ method: 'GET' }).handler( - withVariable_createServerFn_handler, - abstractedFunction, -) -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} -const withZodValidator_createServerFn_handler = createServerRpc( - { - id: '43606a369c85444a332f701d6399564b6a3691aabab63dfc9a0b7c341fb798f3', - name: 'withZodValidator', - filename: 'src/test.ts', - }, - (opts) => withZodValidator.__executeServer(opts), -) -const withZodValidator = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - withZodValidator_createServerFn_handler, - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) -export { - withUseServer_createServerFn_handler, - withoutUseServer_createServerFn_handler, - withVariable_createServerFn_handler, - withZodValidator_createServerFn_handler, -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx deleted file mode 100644 index f62fa718d6..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/createServerFnValidator.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' -const withUseServer_createServerFn_handler = createServerRpc( - { - id: 'b6fe31e85836ae6c65d8ab262dd1af6a68620aeef609029d50127f4cceaaf320', - name: 'withUseServer', - filename: 'src/test.ts', - }, - (opts) => withUseServer.__executeServer(opts), -) -const withUseServer = createServerFn({ method: 'GET' }) - .validator(z.number()) - .handler(withUseServer_createServerFn_handler, ({ input }) => input + 1) -export { withUseServer_createServerFn_handler } diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx deleted file mode 100644 index 26298edd56..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/factory.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import { createServerFn, createMiddleware } from '@tanstack/react-start' -const authMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { auth: 'auth' } }) - }, -) -const adminMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ context: { admin: 'admin' } }) - }, -) -const createAuthServerFn = createServerFn().middleware([authMiddleware]) -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) -const myAuthedFn_createServerFn_handler = createServerRpc( - { - id: '3bb88b23926fa224cea3dcfb877026757733d95b42e3b66cf7f06bb89dab06a3', - name: 'myAuthedFn', - filename: 'src/test.ts', - }, - (opts) => myAuthedFn.__executeServer(opts), -) -const myAuthedFn = createAuthServerFn().handler( - myAuthedFn_createServerFn_handler, - () => { - return 'myAuthedFn' - }, -) -const deleteUserFn_createServerFn_handler = createServerRpc( - { - id: '44d9483a9412daaacaa5a8aee6b02294333a0e61b5d3b17ba6bcb34fd2bdce31', - name: 'deleteUserFn', - filename: 'src/test.ts', - }, - (opts) => deleteUserFn.__executeServer(opts), -) -const deleteUserFn = createAdminServerFn().handler( - deleteUserFn_createServerFn_handler, - () => { - return 'deleteUserFn' - }, -) -function createFakeFn() { - return { - handler: (cb) => { - return cb() - }, - } -} -const x = createFakeFn().handler(() => { - return 'fakeFn' -}) -export { - myAuthedFn_createServerFn_handler, - deleteUserFn_createServerFn_handler, -} diff --git a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx deleted file mode 100644 index 3ae8622683..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/snapshots/server-provider/isomorphic-fns.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { createServerRpc } from '@tanstack/react-start/server-rpc' -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' -const getEnv = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') -const getServerEnv_createServerFn_handler = createServerRpc( - { - id: '6049dd46bc00e0980e387f3e74924b40e92f37634a3fe74a1a1facda9e9207c2', - name: 'getServerEnv', - filename: 'src/test.ts', - }, - (opts) => getServerEnv.__executeServer(opts), -) -const getServerEnv = createServerFn().handler( - getServerEnv_createServerFn_handler, - () => getEnv(), -) -const getEcho = createIsomorphicFn() - .server((input: string) => 'server received ' + input) - .client((input) => 'client received ' + input) -const getServerEcho_createServerFn_handler = createServerRpc( - { - id: 'ebb82e0293952b7b1dde3f664dec4c139471c046d06d4dc4ca172f4f45e386d1', - name: 'getServerEcho', - filename: 'src/test.ts', - }, - (opts) => getServerEcho.__executeServer(opts), -) -const getServerEcho = createServerFn() - .validator((input: string) => input) - .handler(getServerEcho_createServerFn_handler, ({ data }) => getEcho(data)) -export { - getServerEnv_createServerFn_handler, - getServerEcho_createServerFn_handler, -} diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructured.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructured.tsx deleted file mode 100644 index b1c5e9edf2..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructured.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = createServerFn({ - method: 'GET', -}).handler(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withArrowFunction = createServerFn({ - method: 'GET', -}).handler(async () => null) - -export const withArrowFunctionAndFunction = createServerFn({ - method: 'GET', -}).handler(async () => test()) - -export const withoutUseServer = createServerFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = createServerFn({ - method: 'GET', -}).handler(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = createServerFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) - -export const withValidatorFn = createServerFn({ - method: 'GET', -}) - .validator(z.number()) - .handler(async ({ input }) => { - return null - }) diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx deleted file mode 100644 index 4c4ce6dfb2..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnDestructuredRename.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { createServerFn as serverFn } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = serverFn({ - method: 'GET', -}).handler(async function () { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = serverFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = serverFn({ method: 'GET' }).handler( - abstractedFunction, -) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = serverFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnStarImport.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnStarImport.tsx deleted file mode 100644 index 30c9f6973c..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnStarImport.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import * as TanStackStart from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler(async function () { - 'use server' - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withoutUseServer = TanStackStart.createServerFn({ - method: 'GET', -}).handler(async () => { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -}) - -export const withVariable = TanStackStart.createServerFn({ - method: 'GET', -}).handler(abstractedFunction) - -async function abstractedFunction() { - console.info('Fetching posts...') - await new Promise((r) => setTimeout(r, 500)) - return axios - .get<Array<PostType>>('https://jsonplaceholder.typicode.com/posts') - .then((r) => r.data.slice(0, 10)) -} - -function zodValidator<TSchema extends z.ZodSchema, TResult>( - schema: TSchema, - fn: (input: z.output<TSchema>) => TResult, -) { - return async (input: unknown) => { - return fn(schema.parse(input)) - } -} - -export const withZodValidator = TanStackStart.createServerFn({ - method: 'GET', -}).handler( - zodValidator(z.number(), (input) => { - return { 'you gave': input } - }), -) diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnValidator.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnValidator.tsx deleted file mode 100644 index 6c0eda77f3..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/createServerFnValidator.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { createServerFn } from '@tanstack/react-start' -import { z } from 'zod' - -export const withUseServer = createServerFn({ - method: 'GET', -}) - .validator(z.number()) - .handler(({ input }) => input + 1) diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/factory.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/factory.tsx deleted file mode 100644 index 4fb0ea3ade..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/factory.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { createServerFn, createMiddleware } from '@tanstack/react-start' - -const authMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ - context: { auth: 'auth' }, - }) - }, -) - -const adminMiddleware = createMiddleware({ type: 'function' }).server( - ({ next }) => { - return next({ - context: { admin: 'admin' }, - }) - }, -) - -export const createAuthServerFn = createServerFn().middleware([authMiddleware]) -const createAdminServerFn = createAuthServerFn().middleware([adminMiddleware]) - -export const myAuthedFn = createAuthServerFn().handler(() => { - return 'myAuthedFn' -}) -export const deleteUserFn = createAdminServerFn().handler(() => { - return 'deleteUserFn' -}) - -function createFakeFn() { - return { - handler: (cb) => { - return cb() - }, - } -} - -const x = createFakeFn().handler(() => { - return 'fakeFn' -}) diff --git a/packages/start-plugin-core/tests/createServerFn/test-files/isomorphic-fns.tsx b/packages/start-plugin-core/tests/createServerFn/test-files/isomorphic-fns.tsx deleted file mode 100644 index 2c7bbc4a8f..0000000000 --- a/packages/start-plugin-core/tests/createServerFn/test-files/isomorphic-fns.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import { createFileRoute } from '@tanstack/react-router' -import { createIsomorphicFn, createServerFn } from '@tanstack/react-start' -import { useState } from 'react' - -const getEnv = createIsomorphicFn() - .server(() => 'server') - .client(() => 'client') - -const getServerEnv = createServerFn().handler(() => getEnv()) - -const getEcho = createIsomorphicFn() - .server((input: string) => 'server received ' + input) - .client((input) => 'client received ' + input) - -const getServerEcho = createServerFn() - .validator((input: string) => input) - .handler(({ data }) => getEcho(data)) - -export const Route = createFileRoute('/isomorphic-fns')({ - component: RouteComponent, - loader() { - return { - envOnLoad: getEnv(), - } - }, -}) - -function RouteComponent() { - const { envOnLoad } = Route.useLoaderData() - const [results, setResults] = useState<Partial<Record<string, string>>>() - async function handleClick() { - const envOnClick = getEnv() - const echo = getEcho('hello') - const [serverEnv, serverEcho] = await Promise.all([ - getServerEnv(), - getServerEcho({ data: 'hello' }), - ]) - setResults({ envOnClick, echo, serverEnv, serverEcho }) - } - const { envOnClick, echo, serverEnv, serverEcho } = results || {} - return ( - <div> - <button onClick={handleClick} data-testid="test-isomorphic-results-btn"> - Run - </button> - {!!results && ( - <div> - <h1> - <code>getEnv</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-result">{JSON.stringify(serverEnv)}</pre> - When we called the function on the client it returned: - <pre data-testid="client-result">{JSON.stringify(envOnClick)}</pre> - When we called the function during SSR it returned: - <pre data-testid="ssr-result">{JSON.stringify(envOnLoad)}</pre> - <br /> - <h1> - <code>echo</code> - </h1> - When we called the function on the server it returned: - <pre data-testid="server-echo-result"> - {JSON.stringify(serverEcho)} - </pre> - When we called the function on the client it returned: - <pre data-testid="client-echo-result">{JSON.stringify(echo)}</pre> - </div> - )} - </div> - ) -} diff --git a/packages/start-plugin-core/tests/dev-server.ts b/packages/start-plugin-core/tests/dev-server.ts new file mode 100644 index 0000000000..6fe412d86b --- /dev/null +++ b/packages/start-plugin-core/tests/dev-server.ts @@ -0,0 +1,227 @@ +/** + * Dev-server harness of the Start compiler: a Vite dev server with the + * plugins a Start app's `vite.config.ts` lists, `tanstackStart()` of the + * built framework package (`@tanstack/react-start/plugin/vite`, or + * `@tanstack/solid-start`'s; see `start-plugins.ts`: client and SSR + * environments, SSR as the server fn provider) and the app's other plugins + * (a React app's `@vitejs/plugin-react` unless the test gives it), on a + * temporary app, through the shared dev-server harness + * (`@tanstack/compiler-test-utils/dev-server`). The framework package's + * configuration, Start's dev server hooks, Start compiler, import + * protection, router generator, route tree client plugin and start manifest + * all run, as in an app. `@tanstack/react-start` is the real package + * (`startRuntimeLinks`), and `@tanstack/react-router` the real one too (a + * dependency of this package). The temporary apps stand in for apps in this + * directory (`@tanstack/compiler-test-utils/app-directory`). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { pluginNames } from '@tanstack/compiler-test-utils/build-harness' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import react from '@vitejs/plugin-react' +import { onTestFinished } from 'vitest' +import { startRuntimeLinks } from './build-harness' +import { inProbeRequest, requestFiles } from './request-probe' +import { startPlugins } from './start-plugins' +import type { TanStackStartViteInputConfig } from '../src/vite' +import type { PluginOption } from 'vite' +import type { + DevServer, + DevServerOptions, +} from '@tanstack/compiler-test-utils/dev-server' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +export interface StartDevServerOptions extends Omit< + DevServerOptions, + 'dir' | 'plugins' +> { + /** + * Other plugins of the app (e.g. a Solid app's JSX plugin), after Start's, + * or a function of the app root returning them. A React app gets + * `@vitejs/plugin-react` unless these include it. + */ + plugins?: + | Array<PluginOption> + | ((app: { root: string }) => Array<PluginOption>) + /** + * The app's Start plugin options (`tanstackStart(options)`; default + * `{}`). The app's client and server entries are the harness's empty + * ones (`client.entry`, `server.entry`) unless the app has its own, and + * `src/router.ts` and `src/routes/__root.tsx` are stubs unless the app has + * them (`startPluginFiles`). + */ + start?: TanStackStartViteInputConfig + /** + * The Start framework package of the app (default `react`): Start's + * plugin is that package's `tanstackStart()`, and `solid` links the built + * `@tanstack/solid-start` and `@tanstack/solid-router` (a Solid app's + * dependencies; its JSX plugin, `vite-plugin-solid`, comes from + * `plugins`). + */ + framework?: 'react' | 'solid' +} + +/** + * The server entry of an app whose server handles HTTP requests: Start's + * default one (`@tanstack/react-start/server-entry`). + */ +export const startServerEntryFiles = { + 'harness/server-entry.ts': `export { default } from '@tanstack/react-start/server-entry'\n`, +} + +/** + * The files of an app whose server code a test runs inside a real request + * (`inDevRequest`): Start's default server entry (`startServerEntryFiles`) + * and what a request needs (`requestFiles` of `request-probe.ts`): a real + * router over the generated route tree, its root route and the probe route. + * An app's own router entry must export a real router whose tree has the + * probe route. + */ +export const startRequestFiles = { + ...startServerEntryFiles, + ...requestFiles('@tanstack/react-router'), +} + +/** + * Runs `run` inside a real request of a dev server whose app has + * `startRequestFiles`: the app's server entry (Start's `fetch`, imported in + * the SSR environment, as Start's dev server middleware calls it) serves a + * request for the probe route, whose handler runs `run`; so Start's request + * context is the one its server entry opens. Gives what `run` returned, or + * throws what it threw. + */ +export async function inDevRequest<T>( + server: Pick<DevServer, 'import'>, + run: () => T | Promise<T>, +): Promise<Awaited<T>> { + // The app's server entry, by its path (`startServerEntryFiles`). + const serverEntry = (await server.import('/harness/server-entry.ts')).default + return await inProbeRequest( + (url) => serverEntry.fetch(new Request(new URL(url, 'http://localhost'))), + async () => await run(), + ) +} + +/** + * Calls the server fn `fn` (a server fn the SSR environment evaluated, or + * its URL) of a dev server whose app has `startRequestFiles` the way a page + * of the same origin does: Start's client RPC sends its GET request to the + * app's server entry (its `fetch`, which Start's dev server middleware + * calls in the SSR environment; the browser adds `Sec-Fetch-Site`, which + * Start's CSRF middleware checks). The server fn is identified by its + * public `url` (SPEC J4.1: the server fn base, then its id), never by + * Start's own metadata fields (§5.19); a value without such a URL throws + * before any request. Gives the decoded result or throws the decoded + * error, like the client's server fn. + */ +export async function callServerFn( + server: Pick<DevServer, 'import'>, + fn: { url?: unknown } | string | undefined, + data?: unknown, +): Promise<unknown> { + const { createClientRpc } = await server.import( + '@tanstack/react-start/client-rpc', + ) + // The app's server entry, by its path (`startServerEntryFiles`). + const serverEntry = (await server.import('/harness/server-entry.ts')).default + const fetch = (url: string, init: RequestInit) => { + const headers = new Headers(init.headers) + headers.set('sec-fetch-site', 'same-origin') + return serverEntry.fetch( + new Request(new URL(url, 'http://localhost'), { ...init, headers }), + ) + } + // Start's client RPC imported through the SSR environment reads Start's + // options from the request context (`getStartOptions`): the call runs + // inside a real request of the app (`inDevRequest`), as server code that + // calls a server fn does. + const reply = (await inDevRequest(server, () => { + const base = createClientRpc('').url as string + const url = typeof fn === 'string' ? fn : fn?.url + if ( + typeof url !== 'string' || + !url.startsWith(base) || + url.length === base.length + ) { + throw new Error(`not a server fn URL: ${String(url)}`) + } + return createClientRpc(url.slice(base.length))({ + data, + method: 'GET', + fetch, + }) + })) as { result: unknown } | { error: unknown } + if ('error' in reply) { + throw reply.error + } + return reply.result +} + +/** The files the harness adds to every app, unless the app has them. */ +export const startPluginFiles = { + 'harness/client-entry.ts': `export {}\n`, + 'harness/server-entry.ts': `export {}\n`, + 'src/router.ts': `export const getRouter = () => undefined\n`, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, +} + +/** + * Start's Vite plugins of an app at `root`: `tanstackStart(start)` of the + * framework package, with the harness's entries (`harness/client-entry.ts`, + * `harness/server-entry.ts`) where the app has none. + */ +export function startPlugin( + root: string, + start: TanStackStartViteInputConfig, + framework: 'react' | 'solid' = 'react', +) { + const entries = { + client: path.join(root, 'harness/client-entry.ts'), + server: path.join(root, 'harness/server-entry.ts'), + } + return startPlugins(framework, root, start, entries) +} + +/** Starts a Vite dev server with Start's plugin on an app of `files`. */ +export function startDevServer( + options: StartDevServerOptions, +): Promise<DevServer> { + const { + files, + plugins = [], + start = {}, + framework = 'react', + ...devServerOptions + } = options + return createDevServer({ + dir: harnessDir, + prefix: '.start-dev-server-', + registerCleanup: onTestFinished, + ...devServerOptions, + files: { + ...startPluginFiles, + ...files, + }, + symlinks: { + ...startRuntimeLinks(framework), + ...devServerOptions.symlinks, + }, + plugins: ({ root }) => { + const appPlugins = + typeof plugins === 'function' ? plugins({ root }) : plugins + return [ + startPlugin(root, start, framework), + // A React app's own Vite plugin, as in every React Start app, + // unless the test gives it + ...(framework === 'react' && + !pluginNames(appPlugins).some((name) => name.startsWith('vite:react')) + ? [react()] + : []), + ...appPlugins, + ] + }, + }) +} diff --git a/packages/start-plugin-core/tests/diagnostics.ts b/packages/start-plugin-core/tests/diagnostics.ts new file mode 100644 index 0000000000..d388e50baf --- /dev/null +++ b/packages/start-plugin-core/tests/diagnostics.ts @@ -0,0 +1,161 @@ +/** + * What the Start compiler reports, checked through the shared diagnostic + * oracle (`@tanstack/compiler-test-utils/diagnostics`; SPEC G5, §5.7: file + * and position only): a compile error is reported, at the line (and column) + * of the user's module it is about; never its wording, code frame or + * channel. And the check that a misplaced server fn is supported, or + * rejected that way, and kept off the client, through the public Start + * host (`./start-host`). Re-exported by `regression-helpers.ts`. + */ +import { expect } from 'vitest' +import { + diagnosticPosition, + diagnosticsOf, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + CompileFailure, + Thrown, + callFromClient, + callOnServer, + compileError, +} from './regression-helpers' +import type { StartHost } from './start-host' + +/** + * Asserts that `error` is a compile error about the user's module `source` + * (SPEC G5) that names the module's file (a `CompileFailure` of + * `compileError` knows it) and, unless `at` is `undefined`, reports the + * line of `at` (the first occurrence of that text in `source`, or a + * 1-based line), and its column with `column`, after naming the file: the + * error the environment threw or one the app reported meanwhile on any + * channel (a `CompileFailure` carries both). + */ +export function expectCompileError( + error: unknown, + expected: { + source: string + at: string | number | undefined + /** Also require the column of `at` (a string). */ + column?: boolean + }, +) { + expect(error, 'a compile error').toBeInstanceOf(Error) + const candidates = + error instanceof CompileFailure + ? [...diagnosticsOf(error.error), ...error.reported] + : diagnosticsOf(error) + const position = + expected.at === undefined + ? undefined + : typeof expected.at === 'number' + ? { line: expected.at } + : expected.column + ? diagnosticPosition(expected.source, expected.at) + : { line: diagnosticPosition(expected.source, expected.at).line } + expectDiagnostic(candidates, { + ...(error instanceof CompileFailure && { file: error.file }), + ...(position && { position }), + }) +} + +/** Server-only module the server fns of the misplacement tests read. */ +export const serverOnlyModule = './db.server' + +/** The real server-only module of the misplacement fixtures. */ +const serverOnlyFile = `export const db = { inner: () => 'inner', top: () => 'top' }\n` + +/** The handler body the misplacement fixtures give their server fn. */ +const misplacedHandlerBody = 'db.inner()' + +export interface MisplacementOptions { + /** What a rejection must report (default: the position). */ + rejection?: 'positioned' | 'unpositioned' + /** + * The misplaced server fn: a JavaScript expression with the module as + * `module` (e.g. `module.make()`), read in the page and on the server. + */ + read?: string + /** Other case files, by path relative to the case directory. */ + files?: Record<string, string> +} + +/** + * A misplaced `createServerFn` (one not assigned to a top-level variable; + * its handler reads `db.inner()` of `serverOnlyModule`, a real module of + * the case) is supported or rejected, never shipped to the client (SPEC + * J4.6, J4.12). Each environment, on its own, either rejects the module + * with a compile error pointing at the misplaced call's line + * (`expectCompileError`), or serves a working module: the client page imports it without loading + * the server-only module or receiving the handler body, and the SSR + * environment evaluates it; with `read` (where the module holds the server + * fn), calling it from the client reaches the handler through the server + * (`callFromClient`) and calling it from server code runs it + * (`callOnServer`), both giving what the misplaced handler returns. One + * environment rejecting the code does not excuse another. + * + * `rejection: 'unpositioned'` is the loosened form of the regressions + * paired with a goal pin: any compile error, at no particular position. + */ +export async function expectNoClientHandler( + host: StartHost, + code: string, + options: MisplacementOptions = {}, +) { + const startCase = await host.case({ + 'db.server.ts': serverOnlyFile, + ...options.files, + 'module.tsx': code, + }) + const served: Partial<Record<'client' | 'ssr', string>> = {} + for (const environment of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, environment) + if (failure) { + expectCompileError(failure, { + source: code, + at: + options.rejection === 'unpositioned' + ? undefined + : misplacedHandlerBody, + }) + } else { + served[environment] = await startCase.served('module.tsx', environment) + } + } + if (served.client !== undefined) { + expectNotLoaded(await startCase.loads(), [serverOnlyModule]) + expect(served.client, 'client').not.toContain(misplacedHandlerBody) + const run = await startCase.client('return true') + expect(run.errors, 'client page errors').toEqual([]) + } + if (served.ssr !== undefined) { + await startCase.ssr() + } + if (options.read !== undefined) { + if (served.client !== undefined) { + expect( + await callFromClient(startCase, options.read), + 'the handler a client call reaches', + ).toBe('inner') + } + if (served.ssr !== undefined) { + expect( + await callOnServer(startCase, options.read), + 'the handler a server call runs', + ).toBe('inner') + } + } +} + +/** + * What `settle` gives for a `createServerOnlyFn` called outside the server, + * or a `createClientOnlyFn` called outside the client (J4.10): it is a + * function (`settle` gives back what is no function), and calling it threw + * (SPEC G5, §5.7: the error's wording is not checked). An asymmetric + * matcher: compare with `toEqual`. + */ +export const throwsError = expect.toSatisfy( + (value: unknown) => value instanceof Thrown, + 'a call that throws', +) diff --git a/packages/start-plugin-core/tests/envOnly/envOnly.test.ts b/packages/start-plugin-core/tests/envOnly/envOnly.test.ts deleted file mode 100644 index 4c18f2da81..0000000000 --- a/packages/start-plugin-core/tests/envOnly/envOnly.test.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { readFile, readdir } from 'node:fs/promises' -import path from 'node:path' -import { describe, expect, test } from 'vitest' - -import { StartCompiler } from '../../src/start-compiler/compiler' -import { formatSnapshot } from '../format-snapshot' - -// Default test options for StartCompiler -function getDefaultTestOptions(env: 'client' | 'server') { - const envName = env === 'client' ? 'client' : 'ssr' - return { - envName, - root: '/test', - framework: 'react' as const, - providerEnvName: 'ssr', - } -} - -async function compile(opts: { - env: 'client' | 'server' - code: string - id: string -}) { - const compiler = new StartCompiler({ - ...opts, - ...getDefaultTestOptions(opts.env), - loadModule: async () => { - // do nothing in test - }, - lookupKinds: new Set(['ServerOnlyFn', 'ClientOnlyFn']), - lookupConfigurations: [ - { - libName: `@tanstack/react-start`, - rootExport: 'createServerOnlyFn', - kind: 'ServerOnlyFn', - }, - { - libName: `@tanstack/react-start`, - rootExport: 'createClientOnlyFn', - kind: 'ClientOnlyFn', - }, - ], - getKnownServerFns: () => ({}), - resolveId: async (id) => { - return id - }, - }) - const result = await compiler.compile({ - code: opts.code, - id: opts.id, - }) - return result -} - -async function getFilenames() { - return await readdir(path.resolve(import.meta.dirname, './test-files')) -} - -describe('envOnly functions compile correctly', async () => { - const filenames = await getFilenames() - - describe.each(filenames)('should handle "%s"', async (filename) => { - const file = await readFile( - path.resolve(import.meta.dirname, `./test-files/${filename}`), - ) - const code = file.toString() - - test.each(['client', 'server'] as const)( - `should compile for ${filename} %s`, - async (env) => { - const compiledResult = await compile({ - env, - code, - id: filename, - }) - - await expect( - await formatSnapshot(compiledResult!.code, filename), - ).toMatchFileSnapshot(`./snapshots/${env}/${filename}`) - }, - ) - }) - - test('should error if implementation not provided', async () => { - await expect( - compile({ - env: 'client', - code: ` - import { createClientOnlyFn } from '@tanstack/react-start' - const fn = createClientOnlyFn()`, - id: 'no-fn.ts', - }), - ).rejects.toThrowError() - - await expect( - compile({ - env: 'server', - code: ` - import { createServerOnlyFn } from '@tanstack/react-start' - const fn = createServerOnlyFn()`, - id: 'no-fn.ts', - }), - ).rejects.toThrowError() - }) -}) diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx deleted file mode 100644 index 8c97577305..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructured.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -} -const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx deleted file mode 100644 index 8c97577305..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -} -const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx deleted file mode 100644 index cad8d612c9..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyExportedAlias.tsx +++ /dev/null @@ -1,10 +0,0 @@ -export const fn = () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -} -export const wrappedFn = (() => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -}) as () => string diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx deleted file mode 100644 index b226e30116..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyFactory.tsx +++ /dev/null @@ -1,34 +0,0 @@ -// Server-only function factory -export function createServerFactory(name: string) { - return () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) - } -} -// Client-only function factory -export function createClientFactory(name: string) { - return () => { - console.log(`Client only: ${name}`) - return `client-${name}` - } -} -// Arrow function server factory -export const createServerArrowFactory = (prefix: string) => { - return () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) - } -} -// Arrow function client factory -export const createClientArrowFactory = (prefix: string) => { - return () => `${prefix}-client` -} -// Top-level for comparison -export const topLevelServerFn = () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -} -export const topLevelClientFn = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx deleted file mode 100644 index 8c97577305..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/client/envOnlyStarImport.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => { - throw new Error( - 'createServerOnlyFn() functions can only be called on the server!', - ) -} -const clientFunc = () => 'client' diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx deleted file mode 100644 index 924d8d2442..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructured.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => 'server' -const clientFunc = () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) -} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx deleted file mode 100644 index 924d8d2442..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => 'server' -const clientFunc = () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) -} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx deleted file mode 100644 index 078c324406..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyExportedAlias.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export const fn = () => 'server-only-value' -export const wrappedFn = (() => 'wrapped-server-only-value') as () => string diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx deleted file mode 100644 index fdb022bc0d..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyFactory.tsx +++ /dev/null @@ -1,34 +0,0 @@ -// Server-only function factory -export function createServerFactory(name: string) { - return () => { - console.log(`Server only: ${name}`) - return `server-${name}` - } -} -// Client-only function factory -export function createClientFactory(name: string) { - return () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) - } -} -// Arrow function server factory -export const createServerArrowFactory = (prefix: string) => { - return () => `${prefix}-server` -} -// Arrow function client factory -export const createClientArrowFactory = (prefix: string) => { - return () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) - } -} -// Top-level for comparison -export const topLevelServerFn = () => 'server' -export const topLevelClientFn = () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) -} diff --git a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx deleted file mode 100644 index 924d8d2442..0000000000 --- a/packages/start-plugin-core/tests/envOnly/snapshots/server/envOnlyStarImport.tsx +++ /dev/null @@ -1,6 +0,0 @@ -const serverFunc = () => 'server' -const clientFunc = () => { - throw new Error( - 'createClientOnlyFn() functions can only be called on the client!', - ) -} diff --git a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructured.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructured.tsx deleted file mode 100644 index 136a858164..0000000000 --- a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructured.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { createServerOnlyFn, createClientOnlyFn } from '@tanstack/react-start' - -const serverFunc = createServerOnlyFn(() => 'server') - -const clientFunc = createClientOnlyFn(() => 'client') diff --git a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructuredRename.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructuredRename.tsx deleted file mode 100644 index 6da1e20381..0000000000 --- a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyDestructuredRename.tsx +++ /dev/null @@ -1,8 +0,0 @@ -import { - createServerOnlyFn as serverFn, - createClientOnlyFn as clientFn, -} from '@tanstack/react-start' - -const serverFunc = serverFn(() => 'server') - -const clientFunc = clientFn(() => 'client') diff --git a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyExportedAlias.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyExportedAlias.tsx deleted file mode 100644 index 1d51d5dd4f..0000000000 --- a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyExportedAlias.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import { createServerOnlyFn as so } from '@tanstack/react-start' - -export const fn = so(() => 'server-only-value') -export const wrappedFn = so(() => 'wrapped-server-only-value') as () => string diff --git a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyFactory.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyFactory.tsx deleted file mode 100644 index a1223a6aee..0000000000 --- a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyFactory.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { createServerOnlyFn, createClientOnlyFn } from '@tanstack/react-start' - -// Server-only function factory -export function createServerFactory(name: string) { - return createServerOnlyFn(() => { - console.log(`Server only: ${name}`) - return `server-${name}` - }) -} - -// Client-only function factory -export function createClientFactory(name: string) { - return createClientOnlyFn(() => { - console.log(`Client only: ${name}`) - return `client-${name}` - }) -} - -// Arrow function server factory -export const createServerArrowFactory = (prefix: string) => { - return createServerOnlyFn(() => `${prefix}-server`) -} - -// Arrow function client factory -export const createClientArrowFactory = (prefix: string) => { - return createClientOnlyFn(() => `${prefix}-client`) -} - -// Top-level for comparison -export const topLevelServerFn = createServerOnlyFn(() => 'server') -export const topLevelClientFn = createClientOnlyFn(() => 'client') diff --git a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyStarImport.tsx b/packages/start-plugin-core/tests/envOnly/test-files/envOnlyStarImport.tsx deleted file mode 100644 index 7dc500f275..0000000000 --- a/packages/start-plugin-core/tests/envOnly/test-files/envOnlyStarImport.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import * as TanstackStart from '@tanstack/react-start' - -const serverFunc = TanstackStart.createServerOnlyFn(() => 'server') - -const clientFunc = TanstackStart.createClientOnlyFn(() => 'client') diff --git a/packages/start-plugin-core/tests/format-snapshot.ts b/packages/start-plugin-core/tests/format-snapshot.ts deleted file mode 100644 index d152094bea..0000000000 --- a/packages/start-plugin-core/tests/format-snapshot.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { format } from 'prettier' -import { parsers } from 'prettier/plugins/typescript' -import type { ParserOptions } from 'prettier' - -/** - * Formats compiler output before it is compared with a file snapshot, so that - * snapshots record the emitted program instead of the layout choices of the - * code generator (object wrapping, blank lines, parentheses around JSX, ...). - * - * Comments are kept: they are part of the output. Output that does not parse - * is returned unchanged. - */ -export async function formatSnapshot(code: string, filepath: string) { - try { - return await format(await removeBlankLines(code, filepath), { - filepath, - parser: 'typescript', - semi: false, - singleQuote: true, - trailingComma: 'all', - // Do not keep an object expanded because the generator printed it - // over several lines. - objectWrap: 'collapse', - }) - } catch { - return code - } -} - -/** - * Prettier keeps single blank lines from its input. Outside template literals, - * line breaks are not significant, so blank lines can be dropped. - */ -async function removeBlankLines(code: string, filepath: string) { - const parser = parsers.typescript - const ast = await parser.parse(code, { filepath } as ParserOptions) - const templateRanges: Array<[number, number]> = [] - const visit = (node: unknown): void => { - if (Array.isArray(node)) { - node.forEach(visit) - return - } - if (!node || typeof node !== 'object') { - return - } - if ((node as { type?: unknown }).type === 'TemplateElement') { - templateRanges.push([parser.locStart(node), parser.locEnd(node)]) - } - for (const [key, value] of Object.entries(node)) { - if (key !== 'loc' && key !== 'range') { - visit(value) - } - } - } - visit(ast) - - const lines: Array<string> = [] - let lineStart = 0 - for (const line of code.split('\n')) { - const isInTemplate = templateRanges.some( - ([start, end]) => start < lineStart && lineStart < end, - ) - if (line.trim() !== '' || isInTemplate) { - lines.push(line) - } - lineStart += line.length + 1 - } - return lines.join('\n') -} diff --git a/packages/start-plugin-core/tests/hydrate-captures.test.ts b/packages/start-plugin-core/tests/hydrate-captures.test.ts deleted file mode 100644 index c9b98c7b4e..0000000000 --- a/packages/start-plugin-core/tests/hydrate-captures.test.ts +++ /dev/null @@ -1,309 +0,0 @@ -import { expect, test } from 'vitest' -import { - compileFirstChunk, - compileHydrate, - evaluateModule, - getChunkIds, - getChunkParams, - hydrateParentStubs, - loadChunk, - renderChunk, -} from './regression-helpers' -import { declarationOf, getModuleErrors } from './validate-module' - -// `<Hydrate>` moves its children into a chunk component at module level. The -// locals of the enclosing scopes the children read become props of that -// component, under the same names; module bindings move along with the -// children; names the children declare themselves are not captured. React -// keeps the `key` and `ref` props for itself, so no captured local here is -// named like them. - -const head = `import { Hydrate } from '@tanstack/react-start'\n` - -/** Compiles for the client, checks every module and returns the single chunk. */ -async function compileChunk(code: string) { - const { parent, chunks } = await compileHydrate('client', `${head}${code}`) - expect(chunks).toHaveLength(1) - for (const module of [parent, chunks[0]!]) { - expect(await getModuleErrors(module)).toEqual([]) - } - return { parent, chunk: chunks[0]! } -} - -test.each<{ - name: string - children: string - params: Array<string> - expected: string -}>([ - { - // Source: @vitejs/plugin-rsc hoist/function-hoist-block.js - name: 'past a function declared in a nested block', - children: `{(() => { - const seen = value - { - function value() {} - } - return seen -})()}`, - params: ['value'], - expected: '<p>outer</p>', - }, - { - // Source: @vitejs/plugin-rsc scope/param-default-var-hoisting.js - name: 'from a parameter default next to a var of the same name', - children: `{((seen = value) => { - var value = 'inner' - return seen + ':' + value -})()}`, - params: ['value'], - expected: '<p>outer:inner</p>', - }, - { - // Source: @vitejs/plugin-rsc scope/label.js - name: 'next to a label of the same name', - children: `{(() => { - value: for (const item of [1]) { - if (item) { - break value - } - } - return value -})()}`, - params: ['value'], - expected: '<p>outer</p>', - }, - { - // Source: @vitejs/plugin-rsc hoist/computed-destructuring-key-captures-outer-binding.js - name: 'through a computed destructuring key', - children: `{(({ [field]: picked }) => picked)({ value })}`, - params: ['field', 'value'], - expected: '<p>outer</p>', - }, - { - // Source: @vitejs/plugin-rsc hoist/var-hoist-block.js, hoist/shadow-var-nested-block.js - name: 'unless a var in a nested block shadows them', - children: `{(() => { - if (field) { - var value = 'inner' - } - return value -})()}`, - params: ['field'], - expected: '<p>inner</p>', - }, - { - // Source: SolidStart compile.spec.ts "allows `this` and `arguments` in a - // function expression" - name: 'except the arguments of a function expression', - children: `{(function (..._args: Array<unknown>) { - return arguments.length -})(1, 2)}`, - params: [], - expected: '<p>2</p>', - }, -])( - 'client: the children capture locals $name', - async ({ children, params, expected }) => { - const { chunk } = await compileChunk(`export function Page() { - const value = 'outer' - const field = 'value' - return <Hydrate><p>${children}</p></Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual(params) - expect(await renderChunk(chunk, { value: 'outer', field: 'value' })).toBe( - expected, - ) - }, -) - -// Source: @vitejs/plugin-rsc hoist/function-hoist-block.js (module-level binding) -test('client: a module binding read past a block-level function moves into the chunk', async () => { - const { chunk } = await compileChunk(`const value = 'module' -export function Page() { - return <Hydrate><p>{(() => { - const seen = value - { - function value() {} - } - return seen -})()}</p></Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual([]) - expect(await renderChunk(chunk)).toBe('<p>module</p>') -}) - -// Source: Qwik optimizer should_not_auto_export_var_shadowed_in_catch -test('client: a catch parameter is captured', async () => { - const { chunk } = await compileChunk(`export function Page() { - try { - throw new Error('caught') - } catch (error) { - return <Hydrate><p>{error.message}</p></Hydrate> - } -}`) - expect(getChunkParams(chunk)).toEqual(['error']) - expect(await renderChunk(chunk, { error: new Error('caught') })).toBe( - '<p>caught</p>', - ) -}) - -// Source: Qwik optimizer should_transform_handler_in_for_of_loop -test('client: a destructured loop variable and a block-scoped local are captured, module helpers move', async () => { - const { parent, chunk } = await compileChunk(`function Row({ v }) { - return <li>{v}</li> -} -export function Page({ entries }) { - const out = [] - for (const [key, value] of entries) { - const label = key + '-' - out.push(<Hydrate key={key}><Row v={label + value} /></Hydrate>) - } - return <ul>{out}</ul> -}`) - expect(getChunkParams(chunk)).toEqual(['label', 'value']) - // The helper only the children use leaves the parent with them. - expect(parent).not.toMatch(declarationOf('Row')) - expect(await renderChunk(chunk, { label: 'a-', value: 1 })).toBe( - '<li>a-1</li>', - ) -}) - -// Source: Qwik optimizer jsx_tag_names_are_not_segment_uses, -// jsx_lowercase_tag_outside_segments, jsx_tag_named_like_inlined_const -test.each([ - { - scope: 'module', - code: `const div = sideEffect('div') -console.log(div) -export function Page() { - return <Hydrate><div>x</div></Hydrate> -}`, - }, - { - scope: 'component', - code: `export function Page() { - const div = sideEffect('div') - console.log(div) - return <Hydrate><div>x</div></Hydrate> -}`, - }, -])( - 'client: a $scope binding named like an intrinsic tag is not captured', - async ({ code }) => { - const { chunk } = await compileChunk(code) - expect(chunk).not.toContain('sideEffect') - expect(getChunkParams(chunk)).toEqual([]) - expect(await renderChunk(chunk)).toBe('<div>x</div>') - }, -) - -// Source: Qwik optimizer local_shadowing_destructured_prop, -// should_not_auto_export_var_shadowed_in_catch -test('client: names the children declare themselves are not captured', async () => { - const { chunk } = await compileChunk(`export function Page({ value }) { - const x = 'outer' - console.log(x) - return <Hydrate> - <input value={value} onChange={(e) => { const value = e.target.value; return value }} /> - <p>{(() => { try { throw new Error('e') } catch (err) { const x = 'catch:' + err.message; return x } })()}</p> - </Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual(['value']) - expect(await renderChunk(chunk, { value: 'v' })).toBe( - '<input></input><p>catch:e</p>', - ) -}) - -// Source: Qwik optimizer example_functional_component_capture_props, -// example_spread_jsx, should_convert_rest_props -test('client: destructured params with defaults and rests, and spread props, are captured', async () => { - const { chunk } = - await compileChunk(`function Child(props) { return <b>{props.a + props.extra}</b> } -export function Page({ a: [b = 1], ...c }) { - const extra = '!' - return <Hydrate><p>{b}</p><Child {...c} {...{ extra }} /></Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual(['b', 'c', 'extra']) - expect(await renderChunk(chunk, { b: 1, c: { a: 'A' }, extra: '!' })).toBe( - '<p>1</p><b>A!</b>', - ) -}) - -// Split children move to a module-level chunk component, so only runtime -// values may become props. -// Source: Qwik optimizer should_wrap_type_asserted_variables_in_template; -// SolidStart compile.spec.ts "does not read type annotations as captured values" -test('client: local types used by the children are not captured', async () => { - const { chunk } = await compileChunk(`import type { Shape } from './types' -function format<T>(value: T) { return String(value) } -function List<T>(props: { items: Array<T> }) { return <ul>{props.items.length}</ul> } -export function Page({ v }: { v: unknown }) { - type Local = string - interface Box { value: Local } - return <Hydrate><List<Box> items={[v] as Array<Shape>} /><p>{format<Local>(v as Local) + (v satisfies unknown as Box['value'] as Shape)}</p></Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual(['v']) - expect(await renderChunk(chunk, { v: 'x' })).toBe('<ul>1</ul><p>xx</p>') -}) - -// Source: Qwik optimizer example_qwik_conflict, import_collision_with_renaming -test('client: generated names do not collide with user bindings or imports', async () => { - const { parent, chunk } = - await compileChunk(`import { lazyRouteComponent } from '@tanstack/react-router' -const _lazyRouteComponent = 'user' -export const Lazy = lazyRouteComponent(() => import('./other')) -export function Page() { - const _H0 = 'local' - const _H0_preload = 'preload' - return <Hydrate prefetch><p>{_lazyRouteComponent + _H0 + _H0_preload}</p></Hydrate> -}`) - // The lazy chunk component must not be shadowed by the captured locals. - const module = await evaluateModule(parent, hydrateParentStubs) - expect(module.Page()).toBe('[lazy(_H0=local,_H0_preload=preload)]') - expect( - await renderChunk(chunk, { _H0: 'local', _H0_preload: 'preload' }), - ).toBe('<p>userlocalpreload</p>') -}) - -// Source: Qwik optimizer example_capture_imports, example_qwik_conflict -test('client: a captured local shadowing an import or module binding wins inside the children only', async () => { - const { chunk } = await compileChunk(`import { label } from './labels' -import { Row } from './row' -const value = 'module' -function Show() { return <b>{value + ':' + label}</b> } -export function Page() { - const label = 'local' - const value = 'local-value' - return <Hydrate><Row text={label} /><Show /><i>{value}</i></Hydrate> -}`) - expect(getChunkParams(chunk)).toEqual(['label', 'value']) - expect( - await renderChunk( - chunk, - { label: 'local', value: 'local-value' }, - { - './labels': { label: 'imported' }, - './row': { Row: ({ text }: { text: string }) => `<r>${text}</r>` }, - }, - ), - ).toBe('<r>local</r><b>module:imported</b><i>local-value</i>') -}) - -// Source: Qwik optimizer nested_segment_param_does_not_collide_with_captured_props -test('client: a nested boundary receives the captures of its enclosing boundary', async () => { - const { parent, chunks, plugin } = await compileHydrate( - 'client', - `${head}export function Page({ isOpen, fee }) { - const label = 'fee' - return <Hydrate><section><Hydrate><p>{label + ':' + (isOpen ? fee : 0)}</p></Hydrate></section></Hydrate> -}`, - ) - expect(getChunkParams(chunks[0]!)).toEqual(['fee', 'isOpen', 'label']) - const outer = await compileFirstChunk(plugin, parent) - const inner = loadChunk(plugin, 'client', getChunkIds(outer.code!)[0]!) - expect(getChunkParams(inner!)).toEqual(['fee', 'isOpen', 'label']) - expect( - await renderChunk(inner!, { label: 'fee', isOpen: true, fee: 5 }), - ).toBe('<p>fee:5</p>') -}) diff --git a/packages/start-plugin-core/tests/hydrate-helpers.ts b/packages/start-plugin-core/tests/hydrate-helpers.ts new file mode 100644 index 0000000000..9c85b626d4 --- /dev/null +++ b/packages/start-plugin-core/tests/hydrate-helpers.ts @@ -0,0 +1,50 @@ +/** + * `<Hydrate>` test helpers that are not part of the render kit + * (`render.ts`). + */ +import { bindingNames } from './binding-names' +import { lazyCode, renderClient } from './render' +import type { HydrateHost } from './render' + +/** + * The binding names the compiler introduces when it splits the `<Hydrate>` + * children of `code`: names in what the dev server serves for the module + * (client and SSR) and for the split code a page loads when it hydrates it + * (whatever modules that is), that `code` does not have. A fixture + * declaring them as user bindings or globals checks that generated names + * never collide with the user's, whatever names the compiler picks. + */ +export async function generatedNames(hosts: HydrateHost, code: string) { + const source = bindingNames(code) + // What the dev server and the framework plugin add to every JSX module + // they serve (HMR and refresh setup, interop bindings), whatever the + // compiler does: the names of a module without a boundary, digits + // ignored (their counters vary with the imports). + const control = await hosts.start.case({ + 'module.tsx': `import { useState } from 'react'\nexport const Control = () => <p>{String(useState)}</p>\n`, + }) + const shape = (name: string) => name.replace(/\d+/g, '#') + const pipeline = new Set<string>() + for (const environment of ['client', 'ssr'] as const) { + for (const name of bindingNames( + await control.served('module.tsx', environment), + )) { + pipeline.add(shape(name)) + } + } + const client = await renderClient(hosts, code) + const outputs = [ + await client.case.served('module.tsx', 'client'), + await client.case.served('module.tsx', 'ssr'), + ...Object.values(await lazyCode(hosts, client)), + ] + const names = new Set<string>() + for (const output of outputs) { + for (const name of bindingNames(output)) { + if (!source.has(name) && !pipeline.has(shape(name))) { + names.add(name) + } + } + } + return [...names].sort() +} diff --git a/packages/start-plugin-core/tests/hydrate-split-modules.test.ts b/packages/start-plugin-core/tests/hydrate-split-modules.test.ts deleted file mode 100644 index cb62a7d1bd..0000000000 --- a/packages/start-plugin-core/tests/hydrate-split-modules.test.ts +++ /dev/null @@ -1,643 +0,0 @@ -import { afterEach, describe, expect, test } from 'vitest' -import { createHydrateCompilerPlugin } from '../src/hydrate-when-transform' -import { - compileCode, - compileFirstChunk, - compileHydrate, - evaluateHydrateParent, - evaluateModule, - getBoundaryIds, - getChunkComponent, - getChunkIds, - hydrateParentStubs, - importSources, - loadChunk, - parentImportSources, - renderChunk, -} from './regression-helpers' -import { declarationOf, getModuleErrors } from './validate-module' - -// On the client `<Hydrate>` children move into a lazily loaded chunk module -// and the parent renders the chunk component in their place; on the server -// the children render inline and the client-only `fallback` is stripped. -// Both modules must stay valid and behave like the original source. - -const head = `import { Hydrate } from '@tanstack/react-start'\n` - -describe('the parent module', () => { - const widgetPage = `${head}import { visible } from '@tanstack/react-start/hydration' -import { Chart, FallbackPane } from './widgets' -import { formatValue } from './format' -const chartTitle = formatValue('Revenue') -export function Page() { - return <Hydrate when={visible()} fallback={<FallbackPane />}><Chart title={chartTitle} /></Hydrate> -}` - - test('client: bindings only the split children use leave the parent', async () => { - const { parent, chunks } = await compileHydrate('client', widgetPage) - expect(chunks[0]).toMatch(declarationOf('chartTitle')) - expect(parent).not.toMatch(declarationOf('chartTitle')) - expect(parent).not.toMatch(/\bChart\b/) - expect(importSources(parent)).toEqual(['./widgets']) - }) - - test('server: bindings only the stripped fallback uses are removed', async () => { - const { parent } = await compileHydrate('server', widgetPage) - expect(parent).not.toContain('FallbackPane') - }) - - test("client: 'use client' stays first in the parent module and the split chunk", async () => { - const { parent, chunks } = await compileHydrate( - 'client', - `'use client' -${head}import { Chart } from './chart' -export function Page() { - return <Hydrate><Chart /></Hydrate> -}`, - ) - expect(parent).toMatch(/^\s*['"]use client['"]/) - expect(chunks[0]).toMatch(/^\s*['"]use client['"]/) - }) - - test('client: a self-closing Hydrate with a children prop renders nothing next to its boundary', async () => { - const { parent } = await compileHydrate( - 'client', - `${head}import { idle } from '@tanstack/react-start/hydration' -import { Chart } from './chart' -export function Page() { - return <section><Hydrate when={idle()} children={<Chart />} /></section> -}`, - ) - expect(await getModuleErrors(parent)).toEqual([]) - const module = await evaluateModule(parent, { - ...hydrateParentStubs, - './chart': { Chart: () => 'chart' }, - }) - // Whether the children prop renders inline or from the chunk, nothing - // may render next to the boundary. - expect(module.Page()).toMatch( - /^<section>\[(?:chart|lazy\(\))\]<\/section>$/, - ) - }) - - test('client: a stale h attribute is replaced by the generated boundary id', async () => { - const { parent } = await compileHydrate( - 'client', - `${head}export function Page() { - return <Hydrate h="stale"><p>child</p></Hydrate> -}`, - ) - expect(parent).not.toContain('stale') - expect(getBoundaryIds(parent)).toHaveLength(1) - }) - - // String values of `split` are accepted too, for untyped or JS callers. - test('client: split="false" keeps function-as-children in place', async () => { - const parent = await compileCode( - 'client', - `${head}export function Page() { - return <Hydrate split="false">{() => <p>child</p>}</Hydrate> -}`, - { compilerPlugins: [createHydrateCompilerPlugin()] }, - ) - expect(parent).toBeNull() - }) - - test.each(['split', 'split="true"'])( - 'client: %s splits the children', - async (split) => { - const { chunks } = await compileHydrate( - 'client', - `${head}export function Page() { - return <Hydrate ${split}><p>child</p></Hydrate> -}`, - ) - expect(chunks).toHaveLength(1) - expect(await renderChunk(chunks[0]!)).toBe('<p>child</p>') - }, - ) - - // An object spread into one boundary only is stripped of its fallback; a - // shared or computed object may be observed elsewhere and is kept. - test.each([ - { - name: 'used once', - code: `const opts = { fallback: <p>server-fallback</p>, when: true } -export function Page() { return <Hydrate {...opts}><p>child</p></Hydrate> }`, - kept: false, - }, - { - name: 'shared by two boundaries', - code: `const opts = { fallback: <p>server-fallback</p> } -export function Page() { return <><Hydrate {...opts}><p>a</p></Hydrate><Hydrate {...opts}><p>b</p></Hydrate></> }`, - kept: true, - }, - { - name: 'returned by a call', - code: `const makeOpts = () => ({ fallback: <p>server-fallback</p> }) -const opts = makeOpts() -export function Page() { return <Hydrate {...opts}><p>child</p></Hydrate> }`, - kept: true, - }, - ])( - 'server: a fallback in a spread object $name is kept: $kept', - async ({ code, kept }) => { - const { parent } = await compileHydrate('server', `${head}${code}`) - expect(await getModuleErrors(parent)).toEqual([]) - expect(parent.includes('server-fallback')).toBe(kept) - }, - ) - - // Source: Qwik optimizer example_functional_component_capture_props - test('server: params used only by the fallback keep later params in place', async () => { - const { parent } = await compileHydrate( - 'server', - `${head}export function List({ items }) { - return <ul>{items.map((item, i) => <Hydrate key={i} fallback={<p>{item}</p>}><li>{i}</li></Hydrate>)}</ul> -} -export function Card(label, body) { - return <Hydrate fallback={<p>{label}</p>}><p>{body}</p></Hydrate> -}`, - ) - const module = await evaluateModule(parent, hydrateParentStubs) - expect(module.List({ items: ['a', 'b'] })).toBe( - '<ul>[<li>0</li>][<li>1</li>]</ul>', - ) - expect(module.Card('L', 'B')).toBe('[<p>B</p>]') - }) - - // Source: Qwik optimizer should_transform_handler_in_for_of_loop - test('server: a loop variable used only by the fallback keeps the module valid', async () => { - const { parent } = await compileHydrate( - 'server', - `${head}export function List({ xs }) { - const out = [] - for (const x of xs) out.push(<Hydrate fallback={<p>{x}</p>}><p>child</p></Hydrate>) - return out -}`, - ) - expect(await getModuleErrors(parent)).toEqual([]) - }) - - // Source: Qwik optimizer should_keep_non_migrated_binding_from_shared_destructuring_declarator - test('server: a destructuring shared by the fallback and the children keeps the children binding', async () => { - const { parent } = await compileHydrate( - 'server', - `${head}export function Page(props) { - const { a, b } = props - return <Hydrate fallback={<p>{a}</p>}><p>{b}</p></Hydrate> -}`, - ) - const module = await evaluateModule(parent, hydrateParentStubs) - expect(module.Page({ a: 'A', b: 'B' })).toBe('[<p>B</p>]') - }) - - // Source: Qwik optimizer example_mutable_children, issue_5008 - test('client: boundaries in conditionals and callbacks load the chunk the server id names', async () => { - const code = `${head}export function Page({ flag, items }) { - return <div> - {flag ? <Hydrate><p>yes</p></Hydrate> : <Hydrate><p>no</p></Hydrate>} - {flag && <Hydrate><p>and</p></Hydrate>} - {items.map(function (item, idx) { return <Hydrate key={idx}><p>{'fn' + item}</p></Hydrate> })} - {items.map((item) => <Hydrate key={item}><p>{'arrow' + item}</p></Hydrate>)} - </div> -} -export function Other({ early }) { - if (early) { return <Hydrate><p>early</p></Hydrate> } - return <Hydrate><p>late</p></Hydrate> -}` - const server = await compileHydrate('server', code) - const { parent, plugin } = await compileHydrate('client', code) - const serverIds = getBoundaryIds(server.parent) - expect(getBoundaryIds(parent)).toEqual(serverIds) - const rendered: Array<unknown> = [] - for (const id of serverIds) { - const chunkId = getChunkIds(parent).find((chunk) => - chunk.endsWith(`=${id}`), - ) - rendered.push( - await renderChunk(loadChunk(plugin, 'client', chunkId!)!, { - item: 'x', - }), - ) - } - expect(rendered).toEqual([ - '<p>yes</p>', - '<p>no</p>', - '<p>and</p>', - '<p>fnx</p>', - '<p>arrowx</p>', - '<p>early</p>', - '<p>late</p>', - ]) - }) - - // Source: Qwik optimizer example_strip_exports_used - test.each([ - { - name: 'an exported server fn also called by the parent', - code: `import { Hydrate, createServerFn } from '@tanstack/react-start' -export const greet = createServerFn().handler(async () => 'greet-handler-marker') -export function Page() { - return <><button onClick={() => greet()}>a</button><Hydrate><button onClick={() => greet()}>b</button></Hydrate></> -}`, - }, - { - name: 'a private server fn only called by the children', - code: `import { Hydrate, createServerFn } from '@tanstack/react-start' -const greet = createServerFn().handler(async () => 'greet-handler-marker') -export function Page() { - return <Hydrate><button onClick={() => greet()}>b</button></Hydrate> -}`, - }, - ])( - 'client: $name calls the provider id from the split chunk', - async ({ code }) => { - const { parent, plugin } = await compileHydrate('client', code) - const compiled = await compileFirstChunk(plugin, parent) - const chunk = - compiled.code ?? loadChunk(plugin, 'client', getChunkIds(parent)[0]!)! - expect(await getModuleErrors(chunk)).toEqual([]) - expect(chunk).not.toContain('greet-handler-marker') - const provider = await evaluateModule( - (await compileCode('provider', code))!, - ) - // The chunk compiles its own caller of the provider, or imports the - // parent's caller. - const ids = Object.keys(compiled.serverFns) - if (ids.length > 0) { - expect(ids).toEqual([provider.greet_createServerFn_handler.meta.id]) - } else { - expect(parentImportSources(chunk)).not.toEqual([]) - } - }, - ) -}) - -describe('the split chunk', () => { - test.each([ - { name: 'entities', text: '& & &', rendered: '& & &' }, - { - name: 'multi-line text with entities', - text: '\n Fish &\n Chips ©\n ', - rendered: 'Fish & Chips ©', - }, - ])( - 'client: a text-only child renders like JSX text: $name', - async ({ text, rendered }) => { - const { chunks } = await compileHydrate( - 'client', - `${head}export function Page() { - return <Hydrate>${text}</Hydrate> -}`, - ) - // Whitespace collapsing aside, the text must render like the - // server-rendered JSX text. - const output = await renderChunk(chunks[0]!) - expect(output.replace(/\s+/g, ' ').trim()).toBe(rendered) - }, - ) - - test('client: children may contain return statements', async () => { - const { chunks } = await compileHydrate( - 'client', - `${head}const letters = ['a', 'b'] -export function Page() { - return <Hydrate><ul>{letters.map((letter) => { const upper = letter.toUpperCase(); return <li>{upper}</li> })}</ul></Hydrate> -}`, - ) - expect(await getModuleErrors(chunks[0]!)).toEqual([]) - expect(await renderChunk(chunks[0]!)).toBe('<ul><li>A</li><li>B</li></ul>') - }) - - // Leaving such a boundary unsplit is valid too. - test('client: empty and comment-only boundaries load chunks that render nothing', async () => { - const { parent, chunks } = await compileHydrate( - 'client', - `${head}export function Page() { - return <div><Hydrate></Hydrate><Hydrate>{/* nothing */}</Hydrate></div> -}`, - ) - expect(await getModuleErrors(parent)).toEqual([]) - expect(chunks.length).toBeLessThanOrEqual(2) - for (const chunk of chunks) { - expect(await getModuleErrors(chunk)).toEqual([]) - expect(await renderChunk(chunk)).toBeNull() - } - }) - - test('client: chunk ids stay loadable when the same source is compiled again', async () => { - const source = `${head}export function Page() { - return <Hydrate><p>chunk-marker</p></Hydrate> -}` - const { parent, plugin } = await compileHydrate('client', source) - const [id] = getChunkIds(parent) - expect(loadChunk(plugin, 'client', id!)).toContain('chunk-marker') - await compileCode('client', source, { compilerPlugins: [plugin] }) - expect(loadChunk(plugin, 'client', id!)).toContain('chunk-marker') - // Unknown boundaries and ids without a split id are not Hydrate chunks. - expect(loadChunk(plugin, 'client', id!.replace(/=0_/, '=5_'))).toBeNull() - expect( - loadChunk(plugin, 'client', '/test/src/module.tsx?other=1'), - ).toBeNull() - }) - - // Source: Qwik optimizer example_capture_imports, - // jsx_member_tag_object_is_captured, example_jsx - test('client: default, namespace and aliased imports and namespaced names in the children', async () => { - const { chunks } = await compileHydrate( - 'client', - `${head}import Chart from './chart' -import * as UI from './ui' -import { format as fmt, default as theme } from './format' -export function Page() { - return <Hydrate><Chart /><UI.Button label={fmt(theme)} /><svg><use xlink:href="#icon" /></svg></Hydrate> -}`, - ) - expect(await getModuleErrors(chunks[0]!)).toEqual([]) - expect( - await renderChunk( - chunks[0]!, - {}, - { - './chart': { default: () => '<chart></chart>' }, - './ui': { - Button: ({ label }: { label: string }) => - `<button>${label}</button>`, - }, - './format': { - format: (value: string) => `[${value}]`, - default: 'dark', - }, - }, - ), - ).toBe('<chart></chart><button>[dark]</button><svg><use></use></svg>') - }) - - // Source: Qwik optimizer should_handle_dangerously_set_inner_html - test('client: string attributes keep their value', async () => { - const element = `<span title="Fish & Chips ©" data-q='say "hi"' data-n="a -b" dangerouslySetInnerHTML={{ __html: "<h1>I'm an h1!</h1>" }} />` - const { chunks } = await compileHydrate( - 'client', - `${head}export function Page() { - return <Hydrate>${element}</Hydrate> -}`, - ) - // Render the props instead of the element. - const propsRuntime = `const __Fragment = null -const __jsx = (type, props) => JSON.stringify(props) -` - const expected = await evaluateModule( - `export const H0 = () => ${element}`, - {}, - propsRuntime, - ) - const module = await evaluateModule(chunks[0]!, {}, propsRuntime) - expect(getChunkComponent(module)({})).toBe(expected.H0()) - }) - - // Source: Qwik optimizer example_default_export - test('client: an anonymous default-exported component splits its boundary', async () => { - const { parent, chunks } = await compileHydrate( - 'client', - `${head}const label = 'default' -export default () => <Hydrate><p>{label}</p></Hydrate>`, - ) - expect(await getModuleErrors(parent)).toEqual([]) - expect(await renderChunk(chunks[0]!)).toBe('<p>default</p>') - }) - - // Source: Qwik optimizer example_invalid_references, - // should_migrate_destructured_binding_with_imported_dependency - test('client: a module-level destructuring of an import moves into the chunk with the import', async () => { - const { chunks } = await compileHydrate( - 'client', - `${head}import { source } from './lib' -const fallback = 'd' -const [a, { b = fallback, ...rest }] = source -export function Page() { - return <Hydrate><p>{[a, b, JSON.stringify(rest)].join('|')}</p></Hydrate> -}`, - ) - expect(await getModuleErrors(chunks[0]!)).toEqual([]) - expect( - await renderChunk( - chunks[0]!, - {}, - { './lib': { source: ['A', { extra: 'x' }] } }, - ), - ).toBe('<p>A|d|{"extra":"x"}</p>') - }) - - // Source: Qwik optimizer should_preserve_let_when_migrated_into_segment - test('client: a module-level let used only by the children stays mutable', async () => { - const { chunks } = await compileHydrate( - 'client', - `${head}let renders = 0 -export function Page() { - return <Hydrate><p>{++renders}</p></Hydrate> -}`, - ) - const component = getChunkComponent(await evaluateModule(chunks[0]!)) - expect(component({})).toBe('<p>1</p>') - expect(component({})).toBe('<p>2</p>') - }) - - // Source: Qwik optimizer should_keep_non_migrated_binding_from_shared_destructuring_declarator - // (+ _array_destructuring_declarator, _with_rest) - test.each([ - { name: 'object', declaration: `const { a, b } = { a: 'A', b: 'B' }` }, - { name: 'array', declaration: `const [a, b] = ['A', 'B']` }, - { name: 'rest', declaration: `const { a, ...b } = { a: 'A', c: 'B' }` }, - ])( - 'client: an $name destructuring shared by the parent and the children keeps both bindings', - async ({ declaration }) => { - const { parent, chunks, plugin } = await compileHydrate( - 'client', - `${head}${declaration} -export const fromRoot = () => JSON.stringify(b) -export function Page() { - return <Hydrate><p>{a}</p></Hydrate> -}`, - ) - const { module, parentModuleStubs } = await evaluateHydrateParent( - plugin, - parent, - ) - expect(module.fromRoot()).toContain('B') - expect( - await renderChunk(chunks[0]!, {}, await parentModuleStubs(chunks[0]!)), - ).toBe('<p>A</p>') - }, - ) - - // Source: Qwik optimizer should_keep_root_var_used_by_export_decl_and_qrl, - // example_segment_variable_migration, - // variable_migration_transitive_dep_used_by_other_segment - test('client: helpers shared by two boundaries and an export stay available to each', async () => { - const { parent, chunks, plugin } = await compileHydrate( - 'client', - `${head}const scrollState = (el) => ({ x: el.x, y: el.y }) -const saveScroll = (s) => s.x + s.y -const bigHelper = (el) => saveScroll(scrollState(el)) -export const direct = saveScroll(scrollState({ x: 1, y: 1 })) -export function App() { - return <><Hydrate><p>{bigHelper({ x: 1, y: 2 })}</p></Hydrate><Hydrate><p>{scrollState({ x: 3, y: 4 }).y}</p></Hydrate></> -}`, - ) - expect(chunks).toHaveLength(2) - const { module, parentModuleStubs } = await evaluateHydrateParent( - plugin, - parent, - ) - expect(module.direct).toBe(2) - const render = async (chunk: string) => - renderChunk(chunk, {}, await parentModuleStubs(chunk)) - expect(await render(chunks[0]!)).toBe('<p>3</p>') - expect(await render(chunks[1]!)).toBe('<p>4</p>') - }) - - // Source: Qwik optimizer example_ts_enums (TypeScript-only declaration forms) - test('client: an overloaded function used by the children keeps its implementation', async () => { - const { chunks } = await compileHydrate( - 'client', - `${head}function label(value: string): string -function label(value: number): string -function label(value: unknown) { return 'label:' + String(value) } -export function Page() { - return <Hydrate><p>{label(1)}</p></Hydrate> -}`, - ) - expect(await getModuleErrors(chunks[0]!)).toEqual([]) - expect(await renderChunk(chunks[0]!)).toBe('<p>label:1</p>') - }) - - /** A page whose split child renders `Widget`, declared by `body`. */ - const widgetPage = (body: string) => `${head}${body} -export function Page(props) { - return <Hydrate><Widget {...props} /></Hydrate> -}` - - // A component the children render moves into the chunk with the module - // bindings it reads. - // Source: React Compiler fixtures (per row) - test.each([ - { - // try-catch-* fixtures - name: 'a catch parameter shadowing a module binding', - body: `const error = 'module' -function Widget() { - let caught - try { - throw 'thrown' - } catch (error) { - caught = error - } - return <p>{caught}-{error}</p> -}`, - expected: '<p>thrown-module</p>', - }, - { - // fn-name-no-leak-to-nested-arrow.js - name: 'a named function expression shadowing a module binding', - body: `const helper = () => 'module' -function Widget() { - const local = function helper(n) { - return n > 0 ? helper(n - 1) : 'local' - } - return <p>{local(2)}/{helper()}</p> -}`, - expected: '<p>local/module</p>', - }, - { - // destructure-*-default fixtures - name: 'parameter defaults reading module bindings', - body: `const fallback = 'fb' -function Widget({ title = fallback, items: [first = fallback.toUpperCase()] = [] }) { - return <p>{title}{first}</p> -}`, - expected: '<p>fbFB</p>', - }, - { - // hoisting-simple-function-declaration.js - name: 'a hoisted local function reading a module binding declared later', - body: `function Widget() { - const x = format() - function format() { - return prefix + 'x' - } - return <p>{x}</p> -} -const prefix = 'p-'`, - expected: '<p>p-x</p>', - }, - { - // class fixtures (static blocks, private fields) - name: 'a local class with a static block and a private field', - body: `const base = 2 -function Widget() { - class Counter { - static start - static { - Counter.start = base * 2 - } - #n = Counter.start - get n() { - return this.#n - } - } - return <p>{new Counter().n}</p> -}`, - expected: '<p>4</p>', - }, - ])( - 'client: the chunk renders like the original with $name', - async ({ body, expected }) => { - const { chunks } = await compileHydrate('client', widgetPage(body)) - expect(await getModuleErrors(chunks[0]!)).toEqual([]) - expect(await renderChunk(chunks[0]!, { props: {} })).toBe(expected) - }, - ) - - describe('side effects of the component bodies it moves', () => { - afterEach(() => { - delete (globalThis as { __hydrateCalls?: unknown }).__hydrateCalls - }) - - // An unused local initialized by a hook call or another side effect must - // still run when the chunk renders. - // Source: React Compiler fixtures react-namespace.js, - // unused-optional-method-assigned-to-variable.js, error.todo-reassign-const.js - test.each([ - { name: 'a call', initializer: `useTracked('call')` }, - { name: 'an optional call', initializer: `useTracked?.('optional')` }, - { - name: 'a member read of a call', - initializer: `useTracked('member').length`, - }, - ])( - 'client: an unused local initialized by $name still runs', - async ({ initializer }) => { - const { chunks } = await compileHydrate( - 'client', - widgetPage(`function useTracked(label) { - globalThis.__hydrateCalls.push(label) - return label -} -function Widget() { - const unused = ${initializer} - return <p>widget</p> -}`), - ) - const calls: Array<string> = [] - ;(globalThis as { __hydrateCalls?: Array<string> }).__hydrateCalls = - calls - expect(await renderChunk(chunks[0]!, { props: {} })).toBe( - '<p>widget</p>', - ) - expect(calls).toHaveLength(1) - }, - ) - }) -}) diff --git a/packages/start-plugin-core/tests/hydrate-when-transform.test.ts b/packages/start-plugin-core/tests/hydrate-when-transform.test.ts deleted file mode 100644 index 442482bd86..0000000000 --- a/packages/start-plugin-core/tests/hydrate-when-transform.test.ts +++ /dev/null @@ -1,706 +0,0 @@ -import { mkdtempSync } from 'node:fs' -import { tmpdir } from 'node:os' -import { join } from 'node:path' -import * as t from '@babel/types' -import { generateFromAst, parseAst } from '@tanstack/router-utils' -import { describe, expect, test } from 'vitest' -import { createHydrateCompilerPlugin } from '../src/hydrate-when-transform' -import type { CompileStartFrameworkOptions } from '../src/types' - -const root = '/repo' -const id = '/repo/src/routes/about.tsx' - -type HydrateBoundary = { - id: string - exportName: string - index: number -} - -function getHydrateBoundariesFromCode(code: string): Array<HydrateBoundary> { - const boundaries: Array<HydrateBoundary> = [] - const hydrateImportPattern = - /import\("([^"]*[?&]tss-hydrate=[^"]*)"\),\s*"([^"]+)"/g - let match: RegExpExecArray | null - - while ((match = hydrateImportPattern.exec(code))) { - const importId = match[1]! - const queryIndex = importId.indexOf('?') - const params = new URLSearchParams(importId.slice(queryIndex + 1)) - const boundaryId = params.get('tss-hydrate') - const separatorIndex = boundaryId?.indexOf('_') ?? -1 - const index = - boundaryId && separatorIndex > 0 - ? Number.parseInt(boundaryId.slice(0, separatorIndex), 36) - : Number.NaN - - if (boundaryId && Number.isInteger(index)) { - boundaries.push({ - id: boundaryId, - exportName: match[2]!, - index, - }) - } - } - - return boundaries.sort((a, b) => a.index - b.index) -} - -function virtualHydrateId( - file: string, - boundary: Pick<HydrateBoundary, 'id' | 'index'>, -) { - const params = new URLSearchParams() - params.set('tss-hydrate', boundary.id) - return `${file}?${params.toString()}` -} - -function withSourceHash(id: string, sourceHash: string) { - const separatorIndex = id.indexOf('_') - return `${id.slice(0, separatorIndex + 1)}${sourceHash}` -} - -function compileHydrate(options: { - code: string - id: string - root: string - env: 'client' | 'server' - envName?: string - framework?: CompileStartFrameworkOptions - plugin?: ReturnType<typeof createHydrateCompilerPlugin> -}) { - const plugin = options.plugin ?? createHydrateCompilerPlugin() - const envName = options.envName ?? options.env - const ast = parseAst({ code: options.code, sourceFilename: options.id }) - const result = plugin.transformAst?.({ - ast, - code: options.code, - id: options.id, - root: options.root, - env: options.env, - envName, - mode: 'dev', - framework: options.framework ?? 'react', - providerEnvName: 'ssr', - types: t, - parseExpression: (expressionCode) => t.identifier(expressionCode), - }) - if (!result) return null - - const generated = generateFromAst(ast, { - sourceMaps: true, - sourceFileName: options.id, - filename: options.id, - }) - - return { - code: generated.code, - map: generated.map, - boundaries: getHydrateBoundariesFromCode(generated.code), - plugin, - } -} - -function loadVirtualHydrateModule(options: { - code: string - id: string - root: string - envName?: string -}) { - const plugin = createHydrateCompilerPlugin() - return plugin.loadVirtualModule?.({ - code: options.code, - id: options.id, - root: options.root, - env: 'client', - envName: options.envName ?? 'client', - }) -} - -describe('Hydrate compiler transform', () => { - test.each(['client', 'server'] as const)( - 'resolves spread props declared after their containing function in %s output', - (env) => { - const result = compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start' -export function Page() { return <Hydrate {...props}><p>child</p></Hydrate> } -const props = { when: true, fallback: <p>server-fallback</p> }`, - id, - root, - env, - }) - expect(result).not.toBeNull() - expect(result?.code).toContain('when: true') - if (env === 'client') { - expect(result?.code).not.toContain('.preload') - expect(result?.code).toContain('server-fallback') - } else { - expect(result?.code).not.toContain('server-fallback') - } - }, - ) - - test.each(['client', 'server'] as const)( - 'respects parenthesized split={false} in %s output', - (env) => { - const result = compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start'; export function Page() { return <Hydrate split={(false)}>{() => <p>child</p>}</Hydrate> }`, - id, - root, - env, - }) - expect(result).toBeNull() - }, - ) - - test.each(['{...({ fallback: <p>server-fallback</p> })}', '{...(props)}'])( - 'strips fallback from a parenthesized spread %s', - (spread) => { - const result = compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start'; ${spread.includes('props') ? 'const props = ({ fallback: <p>server-fallback</p> });' : ''} export function Page() { return <Hydrate ${spread}><p>child</p></Hydrate> }`, - id, - root, - env: 'server', - }) - expect(result).not.toBeNull() - expect(result?.code).not.toContain('server-fallback') - }, - ) - - test('strips a statically computed fallback property from server output', () => { - const result = compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start'; export function Page() { return <Hydrate {...{ ['fallback']: <p>server-fallback</p> }}><p>child</p></Hydrate> }`, - id, - root, - env: 'server', - }) - expect(result).not.toBeNull() - expect(result?.code).not.toContain('server-fallback') - }) - - test.each(['{...({ when: true })}', '{...(props)}'])( - 'avoids generating a preload callback for known props %s', - (spread) => { - const result = compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start'; const props = ({ when: true }); export function Page() { return <Hydrate ${spread}><p>child</p></Hydrate> }`, - id, - root, - env: 'client', - }) - expect(result).not.toBeNull() - expect(result?.code).not.toContain('.preload') - }, - ) - - test.each([ - ['{(() => <p>child</p>)}', /function-as-children/], - ['{(useThing)()}', /hooks/], - ])('rejects parenthesized unsafe extraction %s', (child, message) => { - expect(() => - compileHydrate({ - code: `import { Hydrate } from '@tanstack/react-start'; export function Page() { return <Hydrate>${child}</Hydrate> }`, - id, - root, - env: 'client', - }), - ).toThrow(message) - }) - - test('splits Hydrate children behind a lazy import', () => { - const result = compileHydrate({ - code: ` - import { Hydrate } from '@tanstack/react-start' - import { visible } from '@tanstack/react-start/hydration' - - export function Page() { - return ( - <Hydrate when={visible()}> - <Widget title="Hello" /> - </Hydrate> - ) - } - - function Widget(props: { title: string }) { - return <p>{props.title}</p> - } - `, - id, - root, - env: 'client', - }) - - expect(result?.code).toContain('lazyRouteComponent') - expect(result?.code).toContain('tss-hydrate=') - expect(result?.code).not.toContain('tss-hydrate-index') - expect(result?.code).not.toContain('createElement') - expect(result?.code).toContain('h=') - expect(result?.code).not.toContain('p=') - }) - - test('uses the Solid Router import source for Solid Hydrate boundaries', () => { - const result = compileHydrate({ - code: ` - import { Hydrate } from '@tanstack/solid-start' - import { visible } from '@tanstack/solid-start/hydration' - - export function Page() { - return ( - <Hydrate when={visible()}> - <Widget title="Hello" /> - </Hydrate> - ) - } - - function Widget(props: { title: string }) { - return <p>{props.title}</p> - } - `, - id, - root, - env: 'client', - framework: 'solid', - }) - - expect(result?.code).toContain( - 'lazyRouteComponent } from "@tanstack/solid-router"', - ) - expect(result?.code).toContain('tss-hydrate=') - expect(result?.code).toContain('h=') - expect(result?.code).not.toContain('p=') - }) - - test('rejects function-as-children unless the boundary opts out of splitting', () => { - expect(() => - compileHydrate({ - code: ` - import { Hydrate } from '@tanstack/react-start' - import { idle } from '@tanstack/react-start/hydration' - - export function Page() { - return ( - <Hydrate when={idle()}> - {() => <p>child</p>} - </Hydrate> - ) - } - `, - id, - root, - env: 'client', - }), - ).toThrow(/function-as-children/) - }) - - test('rejects hook calls that would be moved into an extracted component', () => { - expect(() => - compileHydrate({ - code: ` - import { Hydrate } from '@tanstack/react-start' - import { idle } from '@tanstack/react-start/hydration' - - function useThing() { - return 'thing' - } - - export function Page() { - return ( - <Hydrate when={idle()}> - <p>{useThing()}</p> - </Hydrate> - ) - } - `, - id, - root, - env: 'client', - }), - ).toThrow(/hooks/) - }) - - test('strips Hydrate fallback from the server transform', () => { - const result = compileHydrate({ - code: ` - import { Hydrate } from '@tanstack/react-start' - import { idle, visible } from '@tanstack/react-start/hydration' - - const spreadProps = { - when: visible(), - fallback: <div data-testid="server-bound-spread">bound</div>, - } - - export function Page() { - return ( - <> - <Hydrate - when={visible()} - fallback={<div data-testid="server-fallback">fallback</div>} - > - <Widget title="split" /> - </Hydrate> - <Hydrate - when={idle()} - split={false} - fallback={<div data-testid="server-inline">inline</div>} - > - <Widget title="inline" /> - </Hydrate> - <Hydrate - {...{ - when: visible(), - fallback: <div data-testid="server-spread">spread</div>, - }} - > - <Widget title="spread" /> - </Hydrate> - <Hydrate {...spreadProps}> - <Widget title="bound-spread" /> - </Hydrate> - </> - ) - } - - function Widget(props: { title: string }) { - return <p>{props.title}</p> - } - `, - id, - root, - env: 'server', - }) - - expect(result?.code).not.toContain('fallback=') - expect(result?.code).not.toContain('fallback:') - expect(result?.code).not.toContain('server-fallback') - expect(result?.code).not.toContain('server-inline') - expect(result?.code).not.toContain('server-spread') - expect(result?.code).not.toContain('server-bound-spread') - expect(result?.code).toContain('h=') - expect(result?.code).toContain('<Widget title="split" />') - expect(result?.code).toContain('<Widget title="inline" />') - expect(result?.code).toContain('<Widget title="spread" />') - expect(result?.code).toContain('<Widget title="bound-spread" />') - }) - - test('supports nested Hydrate boundaries in extracted virtual modules', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const code = ` - import { Hydrate } from '@tanstack/react-start' - import { interaction, visible } from '@tanstack/react-start/hydration' - - const unused = 'remove me' - - export function Page() { - return ( - <Hydrate when={visible()}> - <section> - <Hydrate when={interaction()}> - <button>Nested</button> - </Hydrate> - </section> - </Hydrate> - ) - } - ` - const firstPass = compileHydrate({ - code, - id: file, - root: dir, - env: 'client', - }) - expect(firstPass?.boundaries).toHaveLength(1) - - const virtualId = virtualHydrateId(file, firstPass!.boundaries[0]!) - const virtualModule = loadVirtualHydrateModule({ - code, - id: virtualId, - root: dir, - }) - expect(virtualModule?.code).not.toContain('remove me') - - const boundaryIndex = firstPass!.boundaries[0]!.index - const nestedPass = compileHydrate({ - code: virtualModule!.code, - id: virtualId, - root: dir, - env: 'client', - }) - - expect(boundaryIndex).toBe(0) - expect(nestedPass?.code).toContain('H1') - expect(nestedPass?.code).toContain('tss-hydrate=') - }) - - test('keeps sibling boundary ids stable after nested boundaries', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const code = ` - import { Hydrate } from '@tanstack/react-start' - import { idle, interaction, visible } from '@tanstack/react-start/hydration' - - export function Page() { - return ( - <> - <Hydrate when={visible()}> - <section> - <Hydrate when={interaction()}> - <button>Nested</button> - </Hydrate> - </section> - </Hydrate> - <Hydrate when={idle()}> - <p>Sibling</p> - </Hydrate> - </> - ) - } - ` - const firstPass = compileHydrate({ - code, - id: file, - root: dir, - env: 'client', - }) - expect( - firstPass?.boundaries.map((boundary) => boundary.exportName), - ).toEqual(['H0', 'H2']) - - const siblingBoundary = firstPass!.boundaries[1]! - const virtualId = virtualHydrateId(file, siblingBoundary) - const boundaryIndex = siblingBoundary.index - const virtualModule = loadVirtualHydrateModule({ - code, - id: virtualId, - root: dir, - }) - const parentVirtualId = virtualHydrateId(file, firstPass!.boundaries[0]!) - const parentVirtualModule = loadVirtualHydrateModule({ - code, - id: parentVirtualId, - root: dir, - }) - const nestedPass = compileHydrate({ - code: parentVirtualModule!.code, - id: parentVirtualId, - root: dir, - env: 'client', - }) - const serverPass = compileHydrate({ - code, - id: file, - root: dir, - env: 'server', - }) - - expect(boundaryIndex).toBe(2) - expect(virtualModule?.code).toContain('Sibling') - expect(virtualModule?.code).not.toContain('Nested') - expect(nestedPass?.boundaries[0]?.exportName).toBe('H1') - expect(serverPass?.code).toContain(firstPass!.boundaries[0]!.id) - expect(serverPass?.code).toContain(nestedPass!.boundaries[0]!.id) - expect(serverPass?.code).toContain(siblingBoundary.id) - }) - - test('loads virtual modules from supplied bundler code instead of the filesystem', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const oldCode = ` - import { Hydrate } from '@tanstack/react-start' - import { visible } from '@tanstack/react-start/hydration' - - export function Page() { - return <Hydrate when={visible()}><p>Old</p></Hydrate> - } - ` - const nextCode = oldCode.replace('Old', 'New') - const firstPass = compileHydrate({ - code: oldCode, - id: file, - root: dir, - env: 'client', - }) - const virtualModule = loadVirtualHydrateModule({ - code: nextCode, - id: virtualHydrateId(file, firstPass!.boundaries[0]!), - root: dir, - }) - - expect(virtualModule?.code).toContain('New') - expect(virtualModule?.code).not.toContain('Old') - }) - - test('captures identifiers used by shorthand objects and computed members', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const code = ` - import { Hydrate } from '@tanstack/react-start' - import { visible } from '@tanstack/react-start/hydration' - - export function Page() { - const key = 'name' - const items = { name: 'Ada' } - return ( - <Hydrate when={visible()}> - <Widget data={{ key, value: items[key] }} /> - </Hydrate> - ) - } - - function Widget(props: { data: { key: string; value: string } }) { - return <p>{props.data.value}</p> - } - ` - const firstPass = compileHydrate({ - code, - id: file, - root: dir, - env: 'client', - }) - const virtualModule = loadVirtualHydrateModule({ - code, - id: virtualHydrateId(file, firstPass!.boundaries[0]!), - root: dir, - }) - - expect(virtualModule?.code).toContain('export function H0({') - expect(virtualModule?.code).toContain('items') - expect(virtualModule?.code).toContain('key') - expect(virtualModule?.code).toContain('items[key]') - }) - - test('unwraps exported declarations needed by extracted virtual modules', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const code = ` - import { createFileRoute } from '@tanstack/react-router' - import { Hydrate } from '@tanstack/react-start' - import { visible } from '@tanstack/react-start/hydration' - - export const Route = createFileRoute('/test')({ - component: Page, - }) - - export const label = 'Ada' - - export const Widget = () => { - return <p>{label}</p> - } - - function Page() { - return <Hydrate when={visible()}><Widget /></Hydrate> - } - ` - const firstPass = compileHydrate({ - code, - id: file, - root: dir, - env: 'client', - }) - const virtualModule = loadVirtualHydrateModule({ - code, - id: virtualHydrateId(file, firstPass!.boundaries[0]!), - root: dir, - }) - - expect(virtualModule?.code).toContain('const Widget') - expect(virtualModule?.code).toContain('const label') - expect(virtualModule?.code).toContain('<Widget />') - expect(virtualModule?.code).not.toContain('export const Widget') - expect(virtualModule?.code).not.toContain('createFileRoute') - expect(virtualModule?.code).not.toContain('const Route') - }) - - test('invalidates cached Hydrate source for virtual module loads', () => { - const dir = mkdtempSync(join(tmpdir(), 'hydrate-when-')) - const file = join(dir, 'route.tsx') - const oldCode = ` - import { Hydrate } from '@tanstack/react-start' - import { visible } from '@tanstack/react-start/hydration' - - export function Page() { - return <Hydrate when={visible()}><p>Old</p></Hydrate> - } - ` - const nextCode = oldCode.replace('Old', 'New') - const envName = 'client' - const plugin = createHydrateCompilerPlugin() - const transformed = compileHydrate({ - code: oldCode, - id: file, - root: dir, - env: 'client', - envName, - plugin, - }) - const virtualId = virtualHydrateId(file, transformed!.boundaries[0]!) - - expect( - transformed!.plugin.loadVirtualModule?.({ - id: virtualId, - root: dir, - env: 'client', - envName, - })?.code, - ).toContain('Old') - - transformed!.plugin.invalidateModule?.({ id: file, envName }) - expect(() => - transformed!.plugin.loadVirtualModule?.({ - id: virtualId, - root: dir, - env: 'client', - envName, - }), - ).toThrow(/Missing Hydrate source/) - - const updated = compileHydrate({ - code: nextCode, - id: file, - root: dir, - env: 'client', - envName, - plugin, - }) - - expect( - updated!.plugin.loadVirtualModule?.({ - id: virtualId, - root: dir, - env: 'client', - envName, - })?.code, - ).toContain('New') - }) - - test('rejects virtual module ids whose source hash does not match', () => { - const code = ` - import { Hydrate } from '@tanstack/react-start' - import { idle, visible } from '@tanstack/react-start/hydration' - - export function Page() { - return ( - <> - <Hydrate when={visible()}><p>First</p></Hydrate> - <Hydrate when={idle()}><p>Second</p></Hydrate> - </> - ) - } - ` - const firstPass = compileHydrate({ - code, - id, - root, - env: 'client', - }) - const mismatchedId = virtualHydrateId(id, { - id: withSourceHash(firstPass!.boundaries[0]!.id, 'mismatch'), - index: firstPass!.boundaries[0]!.index, - }) - - expect( - new URLSearchParams(mismatchedId.split('?')[1]).get('tss-hydrate'), - ).toMatch(/_mismatch$/) - expect( - loadVirtualHydrateModule({ code, id: mismatchedId, root }), - ).toBeNull() - }) -}) diff --git a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenFunctionChild.tsx b/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenFunctionChild.tsx deleted file mode 100644 index a2560a6197..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenFunctionChild.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -export function Page() { - return <Hydrate when={idle()}>{() => <p>child</p>}</Hydrate> -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenHookCall.tsx b/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenHookCall.tsx deleted file mode 100644 index 1e89bb7303..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenHookCall.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -function useThing() { - return 'thing' -} - -export function Page() { - return ( - <Hydrate when={idle()}> - <p>{useThing()}</p> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenSuperCapture.tsx b/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenSuperCapture.tsx deleted file mode 100644 index 63b91b0239..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenSuperCapture.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -class Base { - title = 'super' -} - -export class Page extends Base { - render() { - return ( - <Hydrate when={idle()}> - <p>{super.title}</p> - </Hydrate> - ) - } -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenThisCapture.tsx b/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenThisCapture.tsx deleted file mode 100644 index 5f7b3df606..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/error-files/hydrateWhenThisCapture.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -export class Page { - title = 'this' - - render() { - return ( - <Hydrate when={idle()}> - <p>{this.title}</p> - </Hydrate> - ) - } -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts b/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts deleted file mode 100644 index d47bc3972d..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/hydrateWhen.test.ts +++ /dev/null @@ -1,313 +0,0 @@ -import { readFile, readdir } from 'node:fs/promises' -import { traverse } from '@babel/core' -import * as t from '@babel/types' -import { generateFromAst, parseAst } from '@tanstack/router-utils' -import path from 'pathe' -import { describe, expect, test } from 'vitest' -import { createHydrateCompilerPlugin } from '../../src/hydrate-when-transform' -import { formatSnapshot } from '../format-snapshot' - -const fixtureRoot = path.resolve(import.meta.dirname, './test-files') -const errorRoot = path.resolve(import.meta.dirname, './error-files') - -function fixtureId(filename: string) { - return path.join(fixtureRoot, filename) -} - -// Replace the fixture root before formatting so that line breaks do not -// depend on where the repository is checked out. -async function normalizeSnapshotCode(code: string, filename: string) { - return await formatSnapshot( - code.split(fixtureRoot).join('<fixtureRoot>'), - filename, - ) -} - -async function readFixture(filename: string) { - return await readFile(fixtureId(filename), 'utf8') -} - -async function getFilenames(dirname: string) { - return (await readdir(dirname)) - .filter((filename) => filename.endsWith('.tsx')) - .sort() -} - -type HydrateBoundary = { - id: string - exportName: string - index: number -} - -function getHydrateBoundariesFromCode(code: string): Array<HydrateBoundary> { - const boundaries: Array<HydrateBoundary> = [] - const hydrateImportPattern = - /import\("([^"]*[?&]tss-hydrate=[^"]*)"\),\s*"([^"]+)"/g - let match: RegExpExecArray | null - - while ((match = hydrateImportPattern.exec(code))) { - const importId = match[1]! - const queryIndex = importId.indexOf('?') - const params = new URLSearchParams(importId.slice(queryIndex + 1)) - const boundaryId = params.get('tss-hydrate') - const separatorIndex = boundaryId?.indexOf('_') ?? -1 - const index = - boundaryId && separatorIndex > 0 - ? Number.parseInt(boundaryId.slice(0, separatorIndex), 36) - : Number.NaN - - if (boundaryId && Number.isInteger(index)) { - boundaries.push({ - id: boundaryId, - exportName: match[2]!, - index, - }) - } - } - - return boundaries.sort((a, b) => a.index - b.index) -} - -function compile(opts: { - env: 'client' | 'server' - code: string - id: string - root?: string -}) { - const options = { - ...opts, - root: opts.root ?? fixtureRoot, - } - const plugin = createHydrateCompilerPlugin() - const ast = parseAst({ code: options.code, sourceFilename: options.id }) - const result = plugin.transformAst?.({ - ast, - code: options.code, - id: options.id, - root: options.root, - env: options.env, - envName: options.env, - mode: 'dev', - framework: 'react', - providerEnvName: 'ssr', - types: t, - parseExpression: (expressionCode) => t.identifier(expressionCode), - }) - if (!result) return null - - const generated = generateFromAst(ast, { - sourceMaps: true, - sourceFileName: options.id, - filename: options.id, - }) - - return { - code: generated.code, - map: generated.map, - boundaries: getHydrateBoundariesFromCode(generated.code), - } -} - -function loadVirtualHydrateModule(options: { - code: string - id: string - root: string -}) { - return createHydrateCompilerPlugin().loadVirtualModule?.({ - code: options.code, - id: options.id, - root: options.root, - env: 'client', - envName: 'client', - }) -} - -function virtualHydrateId( - file: string, - boundary: Pick<HydrateBoundary, 'id' | 'index'>, -) { - const params = new URLSearchParams() - params.set('tss-hydrate', boundary.id) - return `${file}?${params.toString()}` -} - -describe('Hydrate compiler transform fixtures', async () => { - const filenames = await getFilenames(fixtureRoot) - - describe.each(filenames)('should handle "%s"', async (filename) => { - const code = await readFixture(filename) - const id = fixtureId(filename) - - test(`should compile ${filename} for client`, async () => { - const result = compile({ env: 'client', code, id }) - - await expect( - result - ? await normalizeSnapshotCode(result.code, filename) - : 'no-transform', - ).toMatchFileSnapshot(`./snapshots/client/${filename}`) - }) - - test(`should compile ${filename} for server`, async () => { - const result = compile({ env: 'server', code, id }) - - await expect( - result - ? await normalizeSnapshotCode(result.code, filename) - : 'no-transform', - ).toMatchFileSnapshot(`./snapshots/server/${filename}`) - }) - }) - - test('generated lazy names do not shadow existing global references', () => { - const code = `import { Hydrate } from '@tanstack/react-start'; export const before = _H0; export function Page() { return <Hydrate><div /></Hydrate> }` - const compiled = compile({ - env: 'client', - code, - id: fixtureId('global.tsx'), - })! - const output = parseAst({ code: compiled.code }) - const globalReferences: Array<string> = [] - traverse(output, { - ReferencedIdentifier(path) { - if (path.node.name === '_H0' && !path.scope.hasBinding('_H0', true)) { - globalReferences.push(path.node.name) - } - }, - }) - expect(globalReferences).toEqual(['_H0']) - }) - - test('retains captured local components and values across extraction', async () => { - const code = ` - import { Hydrate } from '@tanstack/react-start' - export function Page({ name }) { - const count = 1 - const Local = () => <b>{name}</b> - return <Hydrate><Local count={count}/><span>{name}</span></Hydrate> - } - ` - const id = fixtureId('captured.tsx') - const compiled = compile({ env: 'client', code, id })! - expect(compiled.code).toContain('Local={Local}') - expect(compiled.code).toContain('count={count}') - expect(compiled.code).toContain('name={name}') - expect(compiled.code).toContain('const count = 1') - expect(compiled.code).toContain('const Local') - const loaded = await loadVirtualHydrateModule({ - code, - id: virtualHydrateId(id, compiled.boundaries[0]!), - root: fixtureRoot, - }) - expect(loaded).toBeTruthy() - const output = parseAst({ code: loaded!.code }) - const capturedReferences = new Set<string>() - traverse(output, { - Program(path) { - expect(path.scope.getBinding('Page')).toBeUndefined() - }, - ReferencedIdentifier(path) { - if (['Local', 'count', 'name'].includes(path.node.name)) { - capturedReferences.add(path.node.name) - expect(path.scope.hasBinding(path.node.name, true)).toBe(true) - } - }, - }) - expect([...capturedReferences].sort()).toEqual(['Local', 'count', 'name']) - }) - - test('should extract virtual modules and keep nested ids stable', async () => { - const filename = 'hydrateWhenNested.tsx' - const code = await readFixture(filename) - const id = fixtureId(filename) - const firstPass = compile({ env: 'client', code, id }) - - expect( - firstPass?.boundaries.map((boundary) => boundary.exportName), - ).toEqual(['H0', 'H2']) - - for (const boundary of firstPass!.boundaries) { - const virtualId = virtualHydrateId(id, boundary) - const loaded = loadVirtualHydrateModule({ - code, - id: virtualId, - root: fixtureRoot, - }) - - await expect( - loaded - ? await normalizeSnapshotCode(loaded.code, filename) - : 'no-virtual-module', - ).toMatchFileSnapshot( - `./snapshots/virtual/${filename}.${boundary.exportName}.tsx`, - ) - } - - const parentBoundary = firstPass!.boundaries[0]! - const parentVirtualId = virtualHydrateId(id, parentBoundary) - const parentVirtualModule = loadVirtualHydrateModule({ - code, - id: parentVirtualId, - root: fixtureRoot, - }) - const nestedPass = compile({ - code: parentVirtualModule!.code, - id: parentVirtualId, - env: 'client', - }) - - await expect( - nestedPass - ? await normalizeSnapshotCode(nestedPass.code, filename) - : 'no-transform', - ).toMatchFileSnapshot(`./snapshots/virtual/${filename}.H0.client.tsx`) - }) -}) - -describe('Hydrate compiler extraction errors', async () => { - const errorCases = [ - { - filename: 'hydrateWhenFunctionChild.tsx', - message: /function-as-children/, - }, - { - filename: 'hydrateWhenHookCall.tsx', - message: /hooks/, - }, - { - filename: 'hydrateWhenThisCapture.tsx', - message: /captures this/, - }, - { - filename: 'hydrateWhenSuperCapture.tsx', - message: /captures super/, - }, - ] as const - - describe.each(errorCases)('$filename', async ({ filename, message }) => { - const code = await readFile(path.join(errorRoot, filename), 'utf8') - const id = path.join(errorRoot, filename) - - test('should reject unsafe client extraction', () => { - expect(() => - compile({ - code, - id, - root: errorRoot, - env: 'client', - }), - ).toThrow(message) - }) - - test('should reject unsafe server extraction', () => { - expect(() => - compile({ - code, - id, - root: errorRoot, - env: 'server', - }), - ).toThrow(message) - }) - }) -}) diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx deleted file mode 100644 index 5f057addab..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenBasic.tsx +++ /dev/null @@ -1,24 +0,0 @@ -const _H = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenBasic.tsx?tss-hydrate=0_3cf0187f82'), - 'H0', - ), - _H0_preload = _H.preload -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -import { FallbackPane } from './widgets' -export function Page() { - return ( - <section> - <Hydrate - when={visible({ rootMargin: '200px', threshold: 0.25 })} - prefetch={idle({ timeout: 100 })} - fallback={<FallbackPane label="chart" />} - h="0_3cf0187f82" - p={_H0_preload} - > - {<_H />} - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx deleted file mode 100644 index 34203df6ad..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenMultiple.tsx +++ /dev/null @@ -1,33 +0,0 @@ -const _H3 = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenMultiple.tsx?tss-hydrate=2_21aa371e0f'), - 'H2', -) -const _H2 = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenMultiple.tsx?tss-hydrate=1_21aa371e0f'), - 'H1', -) -const _H = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenMultiple.tsx?tss-hydrate=0_21aa371e0f'), - 'H0', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { load, media, visible } from '@tanstack/react-start/hydration' -export function Page() { - return ( - <> - <Hydrate when={load()} h="0_21aa371e0f"> - {<_H />} - </Hydrate> - <Hydrate when={visible()} h="1_21aa371e0f"> - {<_H2 />} - </Hydrate> - <Hydrate when={media('(min-width: 800px)')} h="2_21aa371e0f"> - {<_H3 />} - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx deleted file mode 100644 index adec83789c..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNested.tsx +++ /dev/null @@ -1,24 +0,0 @@ -const _H2 = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenNested.tsx?tss-hydrate=2_466696e41d'), - 'H2', -) -const _H = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenNested.tsx?tss-hydrate=0_466696e41d'), - 'H0', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -const unused = 'remove me from virtual modules' -export function Page() { - return ( - <> - <Hydrate when={visible()} h="0_466696e41d"> - {<_H />} - </Hydrate> - <Hydrate when={idle()} h="2_466696e41d"> - {<_H2 />} - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx deleted file mode 100644 index c2af676fa4..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNever.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const _H = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenNever.tsx?tss-hydrate=0_b752509d76'), - 'H0', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { never } from '@tanstack/react-start/hydration' -export function Page() { - return ( - <Hydrate when={never()} h="0_b752509d76"> - {<_H />} - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNoImport.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNoImport.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNoImport.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNotFromTanstack.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNotFromTanstack.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenNotFromTanstack.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx deleted file mode 100644 index a0353594f2..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenObjectFallback.tsx +++ /dev/null @@ -1,47 +0,0 @@ -const _H3 = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenObjectFallback.tsx?tss-hydrate=2_7f4dc3aa80'), - 'H2', -) -const _H2 = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenObjectFallback.tsx?tss-hydrate=1_7f4dc3aa80'), - 'H1', -) -const _H = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenObjectFallback.tsx?tss-hydrate=0_7f4dc3aa80'), - 'H0', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -const spreadProps = { - when: visible(), - fallback: <div data-testid="bound-spread-fallback">Bound</div>, -} -export function Page() { - return ( - <> - <Hydrate - when={visible()} - fallback={<div data-testid="direct-fallback">Direct</div>} - h="0_7f4dc3aa80" - > - {<_H />} - </Hydrate> - <Hydrate - {...{ - when: idle(), - fallback: <div data-testid="inline-spread-fallback">Inline</div>, - }} - h="1_7f4dc3aa80" - > - {<_H2 />} - </Hydrate> - <Hydrate {...spreadProps} h="2_7f4dc3aa80"> - {<_H3 />} - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx deleted file mode 100644 index 05028ec03b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenPrefetchState.tsx +++ /dev/null @@ -1,30 +0,0 @@ -const _H = _lazyRouteComponent( - () => - import('<fixtureRoot>/hydrateWhenPrefetchState.tsx?tss-hydrate=0_24b5f958eb'), - 'H0', - ), - _H0_preload = _H.preload -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { useState } from 'react' -import { Hydrate } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -export function Page() { - const [status, setStatus] = useState('idle') - const [, setUnusedStatus] = useState('idle') - return ( - <section> - <p>{status}</p> - <Hydrate - when={interaction()} - prefetch={async () => { - setStatus('prefetched') - setUnusedStatus('prefetched') - }} - h="0_24b5f958eb" - p={_H0_preload} - > - {<_H />} - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx deleted file mode 100644 index 509b2b988b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenRenamed.tsx +++ /dev/null @@ -1,14 +0,0 @@ -const _H = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenRenamed.tsx?tss-hydrate=0_f555ef3ac2'), - 'H0', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate as HW } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -export function Page() { - return ( - <HW when={interaction({ events: 'focusin' })} h="0_f555ef3ac2"> - {<_H />} - </HW> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalse.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalse.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalse.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalseFunctionChild.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalseFunctionChild.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenSplitFalseFunctionChild.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenWrongImportName.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenWrongImportName.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/client/hydrateWhenWrongImportName.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx deleted file mode 100644 index 71896aa304..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenBasic.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -import { Chart } from './widgets' -import { formatValue } from './format' -const chartTitle = formatValue('Revenue') -export function Page() { - return ( - <section> - <Hydrate - when={visible({ rootMargin: '200px', threshold: 0.25 })} - prefetch={idle({ timeout: 100 })} - h="0_3cf0187f82" - > - <Chart title={chartTitle} /> - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx deleted file mode 100644 index 92bb4f9a26..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenMultiple.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { load, media, visible } from '@tanstack/react-start/hydration' -function Summary() { - return <section>Summary</section> -} -function Comments() { - return <section>Comments</section> -} -function Footer() { - return <footer>Footer</footer> -} -export function Page() { - return ( - <> - <Hydrate when={load()} h="0_21aa371e0f"> - <Summary /> - </Hydrate> - <Hydrate when={visible()} h="1_21aa371e0f"> - <Comments /> - </Hydrate> - <Hydrate when={media('(min-width: 800px)')} h="2_21aa371e0f"> - <Footer /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNested.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNested.tsx deleted file mode 100644 index 95664d6ca7..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNested.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, interaction, visible } from '@tanstack/react-start/hydration' -const unused = 'remove me from virtual modules' -function Outer() { - return <section>Outer</section> -} -function NestedButton() { - return <button>Nested</button> -} -function Sibling() { - return <aside>Sibling</aside> -} -export function Page() { - return ( - <> - <Hydrate when={visible()} h="0_466696e41d"> - <Outer /> - <Hydrate when={interaction()} h="1_466696e41d"> - <NestedButton /> - </Hydrate> - </Hydrate> - <Hydrate when={idle()} h="2_466696e41d"> - <Sibling /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNever.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNever.tsx deleted file mode 100644 index a2631b5b94..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNever.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { never } from '@tanstack/react-start/hydration' -function StaticMarketingBlock() { - return <section>Static marketing</section> -} -export function Page() { - return ( - <Hydrate when={never()} h="0_b752509d76"> - <StaticMarketingBlock /> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNoImport.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNoImport.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNoImport.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNotFromTanstack.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNotFromTanstack.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenNotFromTanstack.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenObjectFallback.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenObjectFallback.tsx deleted file mode 100644 index f2c8d8a0bc..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenObjectFallback.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -const spreadProps = { when: visible() } -function Widget(props: { title: string }) { - return <p>{props.title}</p> -} -export function Page() { - return ( - <> - <Hydrate when={visible()} h="0_7f4dc3aa80"> - <Widget title="direct" /> - </Hydrate> - <Hydrate {...{ when: idle() }} h="1_7f4dc3aa80"> - <Widget title="inline spread" /> - </Hydrate> - <Hydrate {...spreadProps} h="2_7f4dc3aa80"> - <Widget title="bound spread" /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenPrefetchState.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenPrefetchState.tsx deleted file mode 100644 index c6642f24b6..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenPrefetchState.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { useState } from 'react' -import { Hydrate } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -function Widget() { - return <button>Widget</button> -} -export function Page() { - const [status, setStatus] = useState('idle') - const [, setUnusedStatus] = useState('idle') - return ( - <section> - <p>{status}</p> - <Hydrate - when={interaction()} - prefetch={async () => { - setStatus('prefetched') - setUnusedStatus('prefetched') - }} - h="0_24b5f958eb" - > - <Widget /> - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenRenamed.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenRenamed.tsx deleted file mode 100644 index 57173c550b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenRenamed.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { Hydrate as HW } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -function SearchBox() { - return <input aria-label="Search" /> -} -export function Page() { - return ( - <HW when={interaction({ events: 'focusin' })} h="0_f555ef3ac2"> - <SearchBox /> - </HW> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalse.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalse.tsx deleted file mode 100644 index 31ad5545c1..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalse.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' -function Counter() { - return <button>Count</button> -} -export function Page() { - return ( - <Hydrate when={idle()} split={false}> - <Counter /> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalseFunctionChild.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalseFunctionChild.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenSplitFalseFunctionChild.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenWrongImportName.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenWrongImportName.tsx deleted file mode 100644 index b35c36ab1b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/server/hydrateWhenWrongImportName.tsx +++ /dev/null @@ -1 +0,0 @@ -no-transform \ No newline at end of file diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.client.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.client.tsx deleted file mode 100644 index f068af9a5b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.client.tsx +++ /dev/null @@ -1,20 +0,0 @@ -const _H = _lazyRouteComponent( - () => import('<fixtureRoot>/hydrateWhenNested.tsx?tss-hydrate=1_466696e41d'), - 'H1', -) -import { lazyRouteComponent as _lazyRouteComponent } from '@tanstack/react-router' -import { Hydrate } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -function Outer() { - return <section>Outer</section> -} -export function H0() { - return ( - <> - <Outer /> - <Hydrate when={interaction()} h="1_466696e41d"> - {<_H />} - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.tsx deleted file mode 100644 index 5b9817a3e1..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H0.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' -function Outer() { - return <section>Outer</section> -} -function NestedButton() { - return <button>Nested</button> -} -export function H0() { - return ( - <> - <Outer /> - <Hydrate when={interaction()}> - <NestedButton /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H2.tsx b/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H2.tsx deleted file mode 100644 index fecef9f558..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/snapshots/virtual/hydrateWhenNested.tsx.H2.tsx +++ /dev/null @@ -1,6 +0,0 @@ -function Sibling() { - return <aside>Sibling</aside> -} -export function H2() { - return <Sibling /> -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenBasic.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenBasic.tsx deleted file mode 100644 index 29795147b6..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenBasic.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' -import { Chart, FallbackPane } from './widgets' -import { formatValue } from './format' - -const chartTitle = formatValue('Revenue') - -export function Page() { - return ( - <section> - <Hydrate - when={visible({ rootMargin: '200px', threshold: 0.25 })} - prefetch={idle({ timeout: 100 })} - fallback={<FallbackPane label="chart" />} - > - <Chart title={chartTitle} /> - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenMultiple.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenMultiple.tsx deleted file mode 100644 index 451ea3058b..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenMultiple.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { load, media, visible } from '@tanstack/react-start/hydration' - -function Summary() { - return <section>Summary</section> -} - -function Comments() { - return <section>Comments</section> -} - -function Footer() { - return <footer>Footer</footer> -} - -export function Page() { - return ( - <> - <Hydrate when={load()}> - <Summary /> - </Hydrate> - <Hydrate when={visible()}> - <Comments /> - </Hydrate> - <Hydrate when={media('(min-width: 800px)')}> - <Footer /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNested.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNested.tsx deleted file mode 100644 index b7363aa0f9..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNested.tsx +++ /dev/null @@ -1,32 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, interaction, visible } from '@tanstack/react-start/hydration' - -const unused = 'remove me from virtual modules' - -function Outer() { - return <section>Outer</section> -} - -function NestedButton() { - return <button>Nested</button> -} - -function Sibling() { - return <aside>Sibling</aside> -} - -export function Page() { - return ( - <> - <Hydrate when={visible()}> - <Outer /> - <Hydrate when={interaction()}> - <NestedButton /> - </Hydrate> - </Hydrate> - <Hydrate when={idle()}> - <Sibling /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNever.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNever.tsx deleted file mode 100644 index 97805825cf..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNever.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { never } from '@tanstack/react-start/hydration' - -function StaticMarketingBlock() { - return <section>Static marketing</section> -} - -export function Page() { - return ( - <Hydrate when={never()}> - <StaticMarketingBlock /> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNoImport.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNoImport.tsx deleted file mode 100644 index a05ae67fef..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNoImport.tsx +++ /dev/null @@ -1,7 +0,0 @@ -export function Page() { - return ( - <Hydrate when={visible()}> - <p>No transform</p> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNotFromTanstack.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNotFromTanstack.tsx deleted file mode 100644 index d69d102475..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenNotFromTanstack.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Hydrate } from 'not-tanstack-start' -import { visible } from '@tanstack/react-start/hydration' - -export function Page() { - return ( - <Hydrate when={visible()}> - <p>No transform</p> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenObjectFallback.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenObjectFallback.tsx deleted file mode 100644 index b0c2bfd498..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenObjectFallback.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle, visible } from '@tanstack/react-start/hydration' - -const spreadProps = { - when: visible(), - fallback: <div data-testid="bound-spread-fallback">Bound</div>, -} - -function Widget(props: { title: string }) { - return <p>{props.title}</p> -} - -export function Page() { - return ( - <> - <Hydrate - when={visible()} - fallback={<div data-testid="direct-fallback">Direct</div>} - > - <Widget title="direct" /> - </Hydrate> - <Hydrate - {...{ - when: idle(), - fallback: <div data-testid="inline-spread-fallback">Inline</div>, - }} - > - <Widget title="inline spread" /> - </Hydrate> - <Hydrate {...spreadProps}> - <Widget title="bound spread" /> - </Hydrate> - </> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenPrefetchState.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenPrefetchState.tsx deleted file mode 100644 index d5d41ae3b9..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenPrefetchState.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { useState } from 'react' -import { Hydrate } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' - -function Widget() { - return <button>Widget</button> -} - -export function Page() { - const [status, setStatus] = useState('idle') - const [, setUnusedStatus] = useState('idle') - - return ( - <section> - <p>{status}</p> - <Hydrate - when={interaction()} - prefetch={async () => { - setStatus('prefetched') - setUnusedStatus('prefetched') - }} - > - <Widget /> - </Hydrate> - </section> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenRenamed.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenRenamed.tsx deleted file mode 100644 index b10aafe742..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenRenamed.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { Hydrate as HW } from '@tanstack/react-start' -import { interaction } from '@tanstack/react-start/hydration' - -function SearchBox() { - return <input aria-label="Search" /> -} - -export function Page() { - return ( - <HW when={interaction({ events: 'focusin' })}> - <SearchBox /> - </HW> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalse.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalse.tsx deleted file mode 100644 index 93ea432c20..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalse.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -const fallback = <div data-testid="split-false-fallback">Loading</div> - -function Counter() { - return <button>Count</button> -} - -export function Page() { - return ( - <Hydrate when={idle()} split={false} fallback={fallback}> - <Counter /> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalseFunctionChild.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalseFunctionChild.tsx deleted file mode 100644 index 461a3b5758..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenSplitFalseFunctionChild.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { Hydrate } from '@tanstack/react-start' -import { idle } from '@tanstack/react-start/hydration' - -export function Page() { - return ( - <Hydrate when={idle()} split={false}> - {() => <p>render prop stays inline</p>} - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenWrongImportName.tsx b/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenWrongImportName.tsx deleted file mode 100644 index 4e0693db83..0000000000 --- a/packages/start-plugin-core/tests/hydrateWhen/test-files/hydrateWhenWrongImportName.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { Link as Hydrate } from '@tanstack/react-start' - -export function Page() { - return ( - <Hydrate to="/about"> - <p>No transform</p> - </Hydrate> - ) -} diff --git a/packages/start-plugin-core/tests/importProtection/analysis.exports.test.ts b/packages/start-plugin-core/tests/importProtection/analysis.exports.test.ts deleted file mode 100644 index 4cb1081e94..0000000000 --- a/packages/start-plugin-core/tests/importProtection/analysis.exports.test.ts +++ /dev/null @@ -1,278 +0,0 @@ -import { describe, expect, test } from 'vitest' - -import { - isValidExportName, - getImportSpecifierLocationFromResult, - getMockExportNamesBySource, - getNamedExports, - getImportSources, -} from '../../src/import-protection/analysis' - -describe('isValidExportName', () => { - test('rejects "default"', () => { - expect(isValidExportName('default')).toBe(false) - }) - - test('accepts valid JS identifiers', () => { - expect(isValidExportName('foo')).toBe(true) - expect(isValidExportName('_private')).toBe(true) - expect(isValidExportName('$ref')).toBe(true) - expect(isValidExportName('camelCase')).toBe(true) - expect(isValidExportName('A')).toBe(true) - }) - - test('rejects names starting with a digit', () => { - expect(isValidExportName('1foo')).toBe(false) - }) - - test('rejects names with special characters', () => { - expect(isValidExportName('foo-bar')).toBe(false) - expect(isValidExportName('foo.bar')).toBe(false) - expect(isValidExportName('foo bar')).toBe(false) - }) - - test('rejects empty string', () => { - expect(isValidExportName('')).toBe(false) - }) -}) - -describe('collectMockExportNamesBySource', () => { - test('collects named imports', () => { - const code = `import { alpha, beta } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha', 'beta']) - }) - - test('ignores default imports', () => { - const code = `import def from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.has('mod-a')).toBe(false) - }) - - test('collects namespace member usage', () => { - const code = [ - `import * as ns from 'mod-a'`, - `const a = ns.alpha`, - `const b = ns.beta`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha', 'beta']) - }) - - test('collects optional namespace member usage', () => { - const code = [ - `import * as ns from 'mod-a'`, - `const maybe = ns.gamma?.()`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['gamma']) - }) - - test('collects string-literal computed namespace member usage', () => { - const code = [ - `import * as ns from 'mod-a'`, - `const val = ns['delta']`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['delta']) - }) - - test('collects member usage from default imports', () => { - const code = [ - `import mock from 'mod-a'`, - `const a = mock.getSecret`, - `const b = mock['foo-bar']`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['foo-bar', 'getSecret']) - }) - - test('ignores non-literal computed namespace member usage', () => { - const code = [ - `import * as ns from 'mod-a'`, - `const key = 'epsilon'`, - `const val = ns[key]`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.has('mod-a')).toBe(false) - }) - - test('ignores type-only imports', () => { - const code = `import type { Foo } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.has('mod-a')).toBe(false) - }) - - test('ignores type-only specifiers in value imports', () => { - const code = `import { type Foo, bar } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['bar']) - }) - - test('ignores "import { default as x }" specifiers', () => { - const code = `import { default as myDefault } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.has('mod-a')).toBe(false) - }) - - test('collects from re-exports', () => { - const code = `export { alpha, beta } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha', 'beta']) - }) - - test('ignores type-only re-exports', () => { - const code = `export type { Foo } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.has('mod-a')).toBe(false) - }) - - test('merges specifiers from multiple imports of the same source', () => { - const code = [ - `import { alpha } from 'mod-a'`, - `import { beta } from 'mod-a'`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha', 'beta']) - }) - - test('dedupes specifiers from import and re-export of same source', () => { - const code = [ - `import { alpha } from 'mod-a'`, - `export { alpha } from 'mod-a'`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha']) - }) - - test('sorts output alphabetically', () => { - const code = `import { zeta, alpha, mu } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['alpha', 'mu', 'zeta']) - }) - - test('handles multiple sources', () => { - const code = [ - `import { a } from 'mod-a'`, - `import { b } from 'mod-b'`, - ].join('\n') - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['a']) - expect(result.get('mod-b')).toEqual(['b']) - }) - - test('returns empty map for code with no relevant imports', () => { - const code = `const x = 1` - const result = getMockExportNamesBySource(code) - expect(result.size).toBe(0) - }) - - test('collects ES2022 string-keyed import specifiers', () => { - const code = `import { "foo-bar" as x } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['foo-bar']) - }) - - test('collects string-literal re-export specifiers', () => { - const code = `export { "foo-bar" as baz } from 'mod-a'` - const result = getMockExportNamesBySource(code) - expect(result.get('mod-a')).toEqual(['foo-bar']) - }) -}) - -describe('collectNamedExports', () => { - test('collects declaration exports', () => { - const code = [ - `export function alpha() {}`, - `export const beta = 1`, - `export class Gamma {}`, - ].join('\n') - expect(getNamedExports(code)).toEqual(['Gamma', 'alpha', 'beta']) - }) - - test('collects named export specifiers and aliases', () => { - const code = [ - `const local = 1`, - `const x = 2`, - `export { local as renamed, x }`, - ].join('\n') - expect(getNamedExports(code)).toEqual(['renamed', 'x']) - }) - - test('ignores default and type-only exports', () => { - const code = [ - `export default function main() {}`, - `export type { Foo } from 'mod-a'`, - ].join('\n') - expect(getNamedExports(code)).toEqual([]) - }) - - test('collects destructured object pattern exports', () => { - const code = `export const { a, b } = obj` - expect(getNamedExports(code)).toEqual(['a', 'b']) - }) - - test('collects destructured array pattern exports', () => { - const code = `export const [x, y] = arr` - expect(getNamedExports(code)).toEqual(['x', 'y']) - }) - - test('collects renamed destructured exports', () => { - const code = `export const { a: renamed } = obj` - expect(getNamedExports(code)).toEqual(['renamed']) - }) - - test('collects nested destructured exports', () => { - const code = `export const { a: { b, c } } = obj` - expect(getNamedExports(code)).toEqual(['b', 'c']) - }) - - test('collects destructured exports with defaults', () => { - const code = `export const { a = 1, b = 2 } = obj` - expect(getNamedExports(code)).toEqual(['a', 'b']) - }) - - test('collects rest element in destructured exports', () => { - const code = `export const { a, ...rest } = obj` - expect(getNamedExports(code)).toEqual(['a', 'rest']) - }) - - test('collects re-exports with aliases', () => { - const code = `export { default as hello } from './foo'` - expect(getNamedExports(code)).toEqual(['hello']) - }) - - test('collects string-literal exported names', () => { - const code = [`const local = 1`, `export { local as "foo-bar" }`].join('\n') - expect(getNamedExports(code)).toEqual(['foo-bar']) - }) -}) - -test('discovers mock exports through parenthesized namespace access', () => { - const exports = getMockExportNamesBySource( - `import * as denied from 'denied'; (denied).read(); (denied)['write']()`, - ) - expect(exports.get('denied')).toEqual(['read', 'write']) -}) - -test('discovers parenthesized literal dynamic import sources', () => { - expect(getImportSources(`export const value = import(('denied'))`)).toEqual([ - 'denied', - ]) -}) - -test('namespace and default re-exports are import sources without named exports', () => { - const code = [ - `export * as ns from 'denied-a'`, - `export { default } from 'denied-b'`, - `export type { OnlyType } from 'denied-c'`, - ].join('\n') - expect(getImportSources(code)).toEqual(['denied-a', 'denied-b']) - expect(getNamedExports(`export { default } from 'denied-b'`)).toEqual([]) - expect(getMockExportNamesBySource(code).get('denied-b')).toBeUndefined() - const result = { code, map: undefined, originalCode: undefined } - expect(getImportSpecifierLocationFromResult(result, 'denied-a')).toBe( - code.indexOf('denied-a'), - ) - expect(getImportSpecifierLocationFromResult(result, 'denied-c')).toBe(-1) -}) diff --git a/packages/start-plugin-core/tests/importProtection/analysis.usage.test.ts b/packages/start-plugin-core/tests/importProtection/analysis.usage.test.ts deleted file mode 100644 index 4580eb4c35..0000000000 --- a/packages/start-plugin-core/tests/importProtection/analysis.usage.test.ts +++ /dev/null @@ -1,366 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - findOriginalUnsafeUsagePos, - findOriginalUnsafeUsagePosFromResult, - findPostCompileUsagePos, -} from '../../src/import-protection/analysis' - -function pos(code: string, source: string) { - return findPostCompileUsagePos(code, source) -} - -function originalPos( - code: string, - source: string, - envType: 'client' | 'server', -) { - return findOriginalUnsafeUsagePos(code, source, envType) -} - -describe('findPostCompileUsagePos', () => { - test('returns undefined when there is no import from the source', () => { - expect(pos(`const x = 1`, 'denied')).toBeUndefined() - }) - - test('reports UTF-16 columns after astral characters, tabs and CRLF line endings', () => { - const code = - "import { secret } from 'denied'\r\n" + - '// 👨‍👩‍👧 𝒳𝒴 日本語\r\n' + - "\tconst label = '🎉'; const value = secret()\r\n" - expect(pos(code, 'denied')).toEqual({ - line: 3, - column0: "\tconst label = '🎉'; const value = ".length, - }) - }) - - test('returns undefined when import is type-only', () => { - expect( - pos(`import type { Foo } from 'denied';\nconst x = 1`, 'denied'), - ).toBeUndefined() - }) - - test('finds preferred call usage for named import', () => { - const p = pos( - `import { getRequest } from 'denied';\nexport function x(){ return getRequest() }`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(2) - }) - - test('prefers call usage over earlier non-preferred identifier usage', () => { - const p = pos( - `import { getRequest } from 'denied';\nconst a = getRequest;\ngetRequest()`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(3) - }) - - test('falls back to non-binding identifier usage if no preferred usage exists', () => { - const p = pos(`import { x } from 'denied';\nconst y = x;`, 'denied') - expect(p).toBeDefined() - expect(p!.line).toBe(2) - }) - - test('ignores binding positions (variable declarator id)', () => { - const p = pos( - `import { x } from 'denied';\n{ const x = 1;\nconst y = x; }`, - 'denied', - ) - expect(p).toBeUndefined() - }) - - test('ignores object property key (non-shorthand) but still finds later usage', () => { - const p = pos( - `import { x } from 'denied';\nconst obj = { x: 1 };\nx()`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(3) - }) - - test('ignores shadowed identifiers in nested function scope', () => { - const p = pos( - `import { x } from 'denied';\nfunction inner(x: any){ return x }\nconst y = x;`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(3) - }) - - test('ignores shadowing via catch clause param', () => { - const p = pos( - `import { err } from 'denied';\ntry { throw 1 } catch (err) { console.log(err) }\nconsole.log(err)`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(3) - }) - - test('handles namespace member preferred usage (ns.foo)', () => { - const p = pos(`import * as ns from 'denied';\nns.getRequest()`, 'denied') - expect(p).toBeDefined() - expect(p!.line).toBe(2) - }) - - test('handles default import preferred usage (call)', () => { - const p = pos(`import req from 'denied';\nreq()`, 'denied') - expect(p).toBeDefined() - expect(p!.line).toBe(2) - }) - - test('counts object pattern shorthand as usage (not a binding position)', () => { - const p = pos( - `import { foo } from 'denied';\nconst obj = { foo };`, - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(2) - }) - - test('var in block scope shadows import at function level', () => { - const p = pos( - [ - `import { x } from 'denied';`, - `function f() {`, - ` if (true) {`, - ` var x = 1;`, - ` }`, - ` return x;`, - `}`, - ].join('\n'), - 'denied', - ) - expect(p).toBeUndefined() - }) - - test('var in block scope does NOT shadow import in outer scope', () => { - const p = pos( - [ - `import { x } from 'denied';`, - `function f() {`, - ` if (true) {`, - ` var x = 1;`, - ` }`, - ` return x;`, - `}`, - `console.log(x);`, - ].join('\n'), - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(8) - }) - - test('let in block scope does NOT shadow import in enclosing function', () => { - const p = pos( - [ - `import { x } from 'denied';`, - `function f() {`, - ` if (true) {`, - ` let x = 1;`, - ` }`, - ` return x;`, - `}`, - ].join('\n'), - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(6) - }) - - test('const in block scope does NOT shadow import in enclosing function', () => { - const p = pos( - [ - `import { x } from 'denied';`, - `function f() {`, - ` {`, - ` const x = 1;`, - ` }`, - ` return x;`, - `}`, - ].join('\n'), - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(6) - }) - - test('var in nested arrow function does not shadow outer scope', () => { - const p = pos( - [ - `import { x } from 'denied';`, - `const outer = () => {`, - ` const inner = () => {`, - ` var x = 1;`, - ` };`, - ` return x;`, - `};`, - ].join('\n'), - 'denied', - ) - expect(p).toBeDefined() - expect(p!.line).toBe(6) - }) -}) - -describe('findOriginalUnsafeUsagePos', () => { - test('skips createServerFn handler usage in client env and finds later unsafe usage', () => { - const p = originalPos( - [ - `import { createServerFn } from '@tanstack/react-start';`, - `import { getSecret } from './secret.server';`, - `export const safeServerFn = createServerFn().handler(async () => {`, - ` return getSecret();`, - `});`, - `export function leakyReference() {`, - ` return getSecret();`, - `}`, - ].join('\n'), - './secret.server', - 'client', - ) - - expect(p).toBeDefined() - expect(p!.line).toBe(7) - }) - - test('returns undefined when usage is only inside createServerOnlyFn in client env', () => { - const p = originalPos( - [ - `import { createServerOnlyFn } from '@tanstack/react-start';`, - `import { getSecret } from './secret.server';`, - `export const safeServerOnly = createServerOnlyFn(() => {`, - ` return getSecret();`, - `});`, - ].join('\n'), - './secret.server', - 'client', - ) - - expect(p).toBeUndefined() - }) - - test('returns undefined when usage is only inside createMiddleware.server in client env', () => { - const p = originalPos( - [ - `import { createMiddleware } from '@tanstack/react-start';`, - `import { getSecret } from './secret.server';`, - `const middleware = createMiddleware({ type: 'function' }).server(({ next }) => {`, - ` const secret = getSecret();`, - ` return next({ context: { secret } });`, - `});`, - ].join('\n'), - './secret.server', - 'client', - ) - - expect(p).toBeUndefined() - }) - - test('returns undefined when usage is only inside createIsomorphicFn.server in client env', () => { - const p = originalPos( - [ - `import { createIsomorphicFn } from '@tanstack/react-start';`, - `import { getSecret } from './secret.server';`, - `export const safeIsomorphic = createIsomorphicFn().server(() => {`, - ` return getSecret();`, - `});`, - ].join('\n'), - './secret.server', - 'client', - ) - - expect(p).toBeUndefined() - }) - - test('returns undefined when usage is only inside createClientOnlyFn in server env', () => { - const p = originalPos( - [ - `import { createClientOnlyFn } from '@tanstack/react-start';`, - `import { readWindow } from './browser.client';`, - `export const safeClientOnly = createClientOnlyFn(() => {`, - ` return readWindow();`, - `});`, - ].join('\n'), - './browser.client', - 'server', - ) - - expect(p).toBeUndefined() - }) -}) - -test.each([ - `createServerFn().handler((() => denied()))`, - `(createServerFn)().handler(() => denied())`, -])( - 'preserves safe-boundary recognition through parentheses: %s', - (expression) => { - const code = `import { denied } from 'denied';\nexport const result = ${expression}` - expect(findOriginalUnsafeUsagePos(code, 'denied', 'client')).toBeUndefined() - }, -) - -test.each([ - `createIsomorphicFn().client((() => denied()))`, - `(createClientOnlyFn)((() => denied()))`, -])('preserves server safe boundaries through parentheses: %s', (expression) => { - const code = `import { denied } from 'denied';\nexport const result = ${expression}` - expect(findOriginalUnsafeUsagePos(code, 'denied', 'server')).toBeUndefined() -}) - -test('does not treat an immediately invoked function as a safe handler argument', () => { - const code = `import { denied } from 'denied';\nexport const result = createServerFn().handler((() => denied())())` - expect(findOriginalUnsafeUsagePos(code, 'denied', 'client')).toEqual({ - line: 2, - column0: code.split('\n')[1]!.indexOf('denied'), - }) -}) - -test('prefers parenthesized call usage over an earlier value reference', () => { - const code = `import { denied } from 'denied';\nconst value = denied;\n(denied)()` - expect(findPostCompileUsagePos(code, 'denied')).toEqual({ - line: 3, - column0: 1, - }) -}) - -// On the client, `.handler()` (of createServerFn or a `*ServerFn` builder) and -// `.server()` (of createMiddleware, a `*Middleware` builder or -// createIsomorphicFn) are safe boundaries, matched by the root name of the -// call chain. On the server, the client branches are: createIsomorphicFn() -// .client() and createClientOnlyFn(). -test.each([ - [ - 'client', - `createServerFn({ method: 'GET' }).validator((d) => d).handler(() => denied())`, - true, - ], - ['client', `myServerFn.handler(() => denied())`, true], - ['client', `authMiddleware.server(() => denied())`, true], - ['client', `createIsomorphicFn().client(() => denied())`, false], - ['server', `createServerFn().handler(() => denied())`, false], -] as const)('%s: %s is a safe boundary: %s', (env, expression, safe) => { - const code = `import { denied } from 'denied';\nexport const result = ${expression}` - expect(findOriginalUnsafeUsagePos(code, 'denied', env)).toEqual( - safe - ? undefined - : { line: 2, column0: code.split('\n')[1]!.indexOf('denied()') }, - ) -}) - -test('repeated lookups on one transform result return the cached position', () => { - const code = `import { denied } from 'denied';\ndenied()` - const result = { code, map: undefined, originalCode: undefined } - const position = findOriginalUnsafeUsagePosFromResult( - result, - 'denied', - 'client', - ) - expect(position).toEqual({ line: 2, column0: 0 }) - expect( - findOriginalUnsafeUsagePosFromResult(result, 'denied', 'client'), - ).toEqual(position) -}) diff --git a/packages/start-plugin-core/tests/importProtection/defaults.test.ts b/packages/start-plugin-core/tests/importProtection/defaults.test.ts deleted file mode 100644 index 53e33ea902..0000000000 --- a/packages/start-plugin-core/tests/importProtection/defaults.test.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - getDefaultImportProtectionRules, - getMarkerSpecifiers, -} from '../../src/import-protection/defaults' - -describe('getDefaultImportProtectionRules', () => { - test('returns client rules with all framework specifiers', () => { - const rules = getDefaultImportProtectionRules() - - expect(rules.client.specifiers).toEqual( - expect.arrayContaining([ - '@tanstack/react-start/server', - '@tanstack/solid-start/server', - '@tanstack/vue-start/server', - ]), - ) - - expect(rules.client.files).toEqual( - expect.arrayContaining(['**/*.server.*']), - ) - }) - - test('returns client excludeFiles defaulting to node_modules', () => { - const rules = getDefaultImportProtectionRules() - - expect(rules.client.excludeFiles).toEqual( - expect.arrayContaining(['**/node_modules/**']), - ) - }) - - test('returns server rules', () => { - const rules = getDefaultImportProtectionRules() - - expect(rules.server.specifiers).toEqual([]) - - expect(rules.server.files).toEqual( - expect.arrayContaining(['**/*.client.*']), - ) - }) - - test('returns server excludeFiles defaulting to node_modules', () => { - const rules = getDefaultImportProtectionRules() - - expect(rules.server.excludeFiles).toEqual( - expect.arrayContaining(['**/node_modules/**']), - ) - }) -}) - -describe('getMarkerSpecifiers', () => { - test('returns server-only and client-only markers', () => { - const markers = getMarkerSpecifiers() - - expect(markers.serverOnly).toContain('@tanstack/react-start/server-only') - expect(markers.clientOnly).toContain('@tanstack/react-start/client-only') - }) - - test('includes all frameworks', () => { - const markers = getMarkerSpecifiers() - - expect(markers.serverOnly.length).toBe(3) - expect(markers.clientOnly.length).toBe(3) - - expect(markers.serverOnly).toContain('@tanstack/solid-start/server-only') - expect(markers.clientOnly).toContain('@tanstack/vue-start/client-only') - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/matchers.test.ts b/packages/start-plugin-core/tests/importProtection/matchers.test.ts deleted file mode 100644 index 2cfb0acd9f..0000000000 --- a/packages/start-plugin-core/tests/importProtection/matchers.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - compileMatcher, - compileMatchers, - isLiteralMatcherPattern, - matchesAny, -} from '../../src/import-protection/matchers' - -describe('compileMatcher', () => { - test('matches exact strings', () => { - const m = compileMatcher('@tanstack/react-start/server') - expect(m.literal).toBe('@tanstack/react-start/server') - expect(m.test('@tanstack/react-start/server')).toBe(true) - expect(m.test('@tanstack/react-start/client')).toBe(false) - }) - - test('matches glob with *', () => { - const m = compileMatcher('**/*.server.*') - expect(m.literal).toBeUndefined() - expect(m.test('src/utils/db.server.ts')).toBe(true) - expect(m.test('src/utils/db.client.ts')).toBe(false) - expect(m.test('secret.server.js')).toBe(true) - }) - - test('matches glob with ** for deep paths', () => { - const m = compileMatcher('**/.server/**') - expect(m.test('src/.server/db.ts')).toBe(true) - expect(m.test('src/.client/ui.ts')).toBe(false) - }) - - test('matches RegExp patterns', () => { - const m = compileMatcher(/^pg$/) - expect(m.test('pg')).toBe(true) - expect(m.test('pg-pool')).toBe(false) - }) - - test('RegExp with global flag is not stateful', () => { - const m = compileMatcher(/pg/g) - expect(m.test('pg')).toBe(true) - // Would fail without resetting lastIndex - expect(m.test('pg')).toBe(true) - }) -}) - -describe('isLiteralMatcherPattern', () => { - test('classifies exact strings as literals', () => { - expect(isLiteralMatcherPattern('@tanstack/react-start/server')).toBe(true) - expect(isLiteralMatcherPattern('node:fs')).toBe(true) - }) - - test('classifies glob syntax as non-literal', () => { - expect(isLiteralMatcherPattern('**/*.server.*')).toBe(false) - expect(isLiteralMatcherPattern('{pg,postgres}')).toBe(false) - }) -}) - -describe('compileMatchers', () => { - test('compiles an array of patterns', () => { - const matchers = compileMatchers([ - '@tanstack/react-start/server', - /^node:fs$/, - ]) - expect(matchers.length).toBe(2) - expect(matchers[0]!.test('@tanstack/react-start/server')).toBe(true) - expect(matchers[1]!.test('node:fs')).toBe(true) - }) -}) - -describe('matchesAny', () => { - test('returns the matching matcher', () => { - const matchers = compileMatchers([ - '@tanstack/react-start/server', - 'pg', - /^node:/, - ]) - - const result = matchesAny('node:fs', matchers) - expect(result).toBeDefined() - expect(result!.pattern).toBeInstanceOf(RegExp) - }) - - test('returns undefined when nothing matches', () => { - const matchers = compileMatchers(['pg']) - const result = matchesAny('react', matchers) - expect(result).toBeUndefined() - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/mock-helpers.ts b/packages/start-plugin-core/tests/importProtection/mock-helpers.ts new file mode 100644 index 0000000000..1df72658f5 --- /dev/null +++ b/packages/start-plugin-core/tests/importProtection/mock-helpers.ts @@ -0,0 +1,215 @@ +/** + * The mock import protection serves in place of a denied module, told by + * what it does, not by what it looks like (SPEC J6.8, §5 item 18): a safe + * mock is a value a consumer can read members of, call and construct, to any + * depth, without an exception, whose primitive conversions do not throw and + * carry no secret of the denied module. Its label, Proxy shape and where its + * runtime lives are the compiler's. + * + * `probeMock` exercises those operations on a value and reports each + * outcome; `safeMock` is the outcome of a safe mock, `isSafeMock` and + * `expectSafeMock` compare with it. A real value fails the probe: a function + * or an object has no member two levels deep, a primitive none at all. + * `probeMockPrelude` defines the same probe in the scripts the build and + * Rsbuild harnesses run in another process, a VM context or a browser page + * (a mock cannot cross that boundary). Never `await` a mock: the mock runtime is a + * thenable that resolves to itself. + * + * Pure: only the probe and the readers of the runtime diagnostics, no module + * of the implementation. + */ +import { expect } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import type { + Diagnostic, + Severity, +} from '@tanstack/compiler-test-utils/diagnostics' + +/** + * What each operation a consumer may perform on a mock did: `ok`, or the + * error it threw (`threw: ...`). + */ +export interface MockProbe { + /** `value.member` */ + read: string + /** `value.member.deeper.deepest` */ + deepRead: string + /** `value()` */ + call: string + /** `value.member()`, `value()()`, `value().member` */ + deepCall: string + /** `new value()`, `new value.member()` */ + construct: string + /** `String(value)`, `${value}`, `value + ''`, `Number(value)` */ + primitive: string + /** `JSON.stringify(value)` */ + json: string + /** The `secret` text appeared in a primitive conversion of a value. */ + leaked: boolean +} + +/** + * Exercises `value` the way a consumer of a mocked import may (member reads + * and calls to a depth of three, construction, primitive conversions) and + * reports each outcome. A primitive conversion whose text contains `secret` + * counts as a leak. Self-contained (no closure), so that scripts run in + * another process can define it too (`probeMockPrelude`). + */ +export function probeMock(value: unknown, secret?: string): MockProbe { + const attempt = (run: () => unknown): string => { + try { + run() + return 'ok' + } catch (error) { + return `threw: ${error instanceof Error ? error.message : String(error)}` + } + } + let leaked = false + const texts = (subject: unknown) => { + const results = [ + String(subject), + `${subject}`, + (subject as string) + '', + String(Number(subject)), + String(JSON.stringify(subject)), + ] + if (secret !== undefined && results.some((text) => text.includes(secret))) { + leaked = true + } + } + const any = value as any + const probe: MockProbe = { + read: attempt(() => any.member), + deepRead: attempt(() => any.member.deeper.deepest), + call: attempt(() => any()), + deepCall: attempt(() => { + any.member() + any()() + any().member + any.member.deeper() + // (Not `any.constructor.member()` or `any.__proto__.member()`: those + // are the object protocol every value has, not members a consumer + // reads of the denied binding; a mock may keep them, SPEC §5.18 + // leaves its Proxy shape free.) + }), + construct: attempt(() => { + new any() + new any.member() + }), + primitive: attempt(() => { + texts(any) + texts(any.member) + texts(any()) + texts(new any()) + }), + json: attempt(() => JSON.stringify(any)), + leaked, + } + probe.leaked = leaked + return probe +} + +/** The outcome of a safe mock: every operation `ok`, nothing leaked. */ +export const safeMock: MockProbe = { + read: 'ok', + deepRead: 'ok', + call: 'ok', + deepCall: 'ok', + construct: 'ok', + primitive: 'ok', + json: 'ok', + leaked: false, +} + +/** Whether `value` is a safe mock (`probeMock(value, secret)` is `safeMock`). */ +export function isSafeMock(value: unknown, secret?: string): boolean { + const probe = probeMock(value, secret) + return ( + !probe.leaked && + Object.keys(probe).every( + (key) => key === 'leaked' || probe[key as keyof MockProbe] === 'ok', + ) + ) +} + +/** Fails, listing the operations that threw or leaked, unless `value` is a safe mock. */ +export function expectSafeMock(value: unknown, secret?: string): void { + expect(probeMock(value, secret)).toEqual(safeMock) +} + +/** + * Defines `probeMock` and `isSafeMock` in a script run elsewhere (the body + * of a build's `run()` script, an Rsbuild client script): the same probe, + * serialised. A script reports `isSafeMock(value, 'MARK_SECRET')` or the + * probe itself; it cannot return the mock. + */ +export const probeMockPrelude = `const probeMock = ${probeMock.toString()} +const isSafeMock = ${isSafeMock.toString()} +` + +/** + * A value's description for a script's result: `a safe mock` for a safe + * mock, else its text (`describeValue` in `probeMockPrelude` scripts does the + * same). + */ +export function describeValue(value: unknown, secret?: string): string { + return isSafeMock(value, secret) ? 'a safe mock' : String(value) +} + +/** `describeValue` for `probeMockPrelude` scripts. */ +export const describeValuePrelude = `${probeMockPrelude}const describeValue = ${describeValue.toString()} +` + +/** + * What identifies the runtime diagnostic of a use of a mock: its severity + * and, for a denied file, the file (SPEC G5, §5.7: diagnostics are + * checked by file and position only; a use of the mock of a denied + * specifier names no file of the app). Which importer used the mock is not + * required: the violation names it, SPEC J6.5. + */ +export interface MockAccessExpectation { + /** The console severity (`mockAccess: 'error'` or `'warn'`). */ + severity: Severity + /** The denied import as the importer wrote it (for the failure message). */ + specifier: string + /** The file the denied import resolves to, when it is a file. */ + file?: string + /** The project root `file` is relative to. */ + root?: string +} + +/** + * The runtime diagnostics of a use of a mock (SPEC J6.3, `mockAccess`) + * among `diagnostics` (what the console received while the app ran): those + * of the expected severity, naming `file` when one is expected. + */ +export function mockAccessDiagnostics( + diagnostics: Array<Diagnostic>, + expected: MockAccessExpectation, +): Array<Diagnostic> { + const { severity, file, root } = expected + return findDiagnostics(diagnostics, { severity, file, root }) +} + +/** + * Fails, listing what the console received, unless a runtime diagnostic of + * a use of a mock meets `expected` (`mockAccessDiagnostics`). + */ +export function expectMockAccess( + diagnostics: Array<Diagnostic>, + expected: MockAccessExpectation, +): void { + expect( + mockAccessDiagnostics(diagnostics, expected).length, + `a ${expected.severity} naming ${expected.file ?? expected.specifier}, among:\n${diagnostics + .map(({ severity, text }) => `[${severity}] ${text}`) + .join('\n')}`, + ).toBeGreaterThan(0) +} + +/** + * The console diagnostics of warning or error severity: what `mockAccess` + * may log (`off` logs none of them). + */ +export const warningsAndErrors = (diagnostics: Array<Diagnostic>) => + diagnostics.filter(({ severity }) => severity !== 'info') diff --git a/packages/start-plugin-core/tests/importProtection/original-location.ts b/packages/start-plugin-core/tests/importProtection/original-location.ts new file mode 100644 index 0000000000..4161708f7f --- /dev/null +++ b/packages/start-plugin-core/tests/importProtection/original-location.ts @@ -0,0 +1,59 @@ +/** + * The J6.5 location check in the `client|server file:line:column` form the + * import-protection tests compare violations in: the genuine surviving use, + * any line of the original import, or the places the test writes out + * (`others`); no coordinates only where the location is unavailable + * (`unavailable`, §5.14: an import a tool rewrote), never as a blanket + * escape. + */ +import { expect } from 'vitest' +import { isAt, locationParts } from './start-apps' + +/** `[environment, location]` of `client file:line:column`. */ +function splitEnvironment(value: string) { + const match = /^(?:(client|server) )?(.*)$/.exec(value)! + return [match[1], match[2]!] as const +} + +/** + * An asymmetric matcher of `use` (`[environment ]file:line:column`), any + * column of the lines `importLines` of the same file, or one of `others` + * (`file:line`, `file:line:column`, or `file` for no location; `isAt`). + */ +export function originalLocation( + use: string, + importLines: number | Array<number>, + options: { + /** + * Also no coordinates: where the location is unavailable (§5.14: an + * import a tool rewrote), or where a pin checks that it is there. + */ + unavailable?: boolean + /** Other accepted places (e.g. a marker's origin, SPEC J6.5). */ + others?: Array<string> + } = {}, +) { + const [environment, location] = splitEnvironment(use) + const { file } = locationParts(location) + const places = [ + location, + ...([] as Array<number>) + .concat(importLines) + .map((line) => `${file}:${line}`), + ...(options.unavailable ? [file] : []), + ...(options.others ?? []), + ] + return expect.toSatisfy( + (value: unknown) => { + if (typeof value !== 'string') { + return false + } + const [actualEnvironment, actual] = splitEnvironment(value) + return ( + actualEnvironment === environment && + places.some((place) => isAt(actual, place)) + ) + }, + `${environment ?? ''} ${places.join(' or ')}`, + ) +} diff --git a/packages/start-plugin-core/tests/importProtection/public-types.ts b/packages/start-plugin-core/tests/importProtection/public-types.ts new file mode 100644 index 0000000000..3f68a90f99 --- /dev/null +++ b/packages/start-plugin-core/tests/importProtection/public-types.ts @@ -0,0 +1,55 @@ +/** + * The public types of Start's import protection, as a user writes them: the + * `importProtection` option of `tanstackStart()` and what its `onViolation` + * callback receives. No package entry exports `ViolationInfo` (the option's + * `onViolation` takes `unknown`), so it is declared here from the guide + * (`docs/start/framework/react/guide/import-protection.md`, "The + * `onViolation` Callback") and SPEC J6.5/J6.6, not imported from the + * implementation. + */ +import type { TanStackStartInputConfig } from '../../src' + +/** Start's `importProtection` option (`tanstackStart({ importProtection })`). */ +export type ImportProtectionOptions = NonNullable< + TanStackStartInputConfig['importProtection'] +> + +/** A location in a file: 1-based line and column. */ +export interface ViolationLocation { + file?: string + line: number + column: number +} + +/** A step of a violation's import chain, from an entry to the importer. */ +export interface ViolationTraceStep { + file: string + line?: number + column?: number + /** The specifier this step imports the next one with. */ + specifier?: string +} + +/** What `onViolation` receives (the guide's list; SPEC J6.5, J6.6). */ +export interface ViolationInfo { + /** The environment's name (e.g. `client`, `ssr`). */ + env: string + envType: 'client' | 'server' + type: 'specifier' | 'file' | 'marker' + /** The rule that matched (specifier and file rules). */ + pattern?: string | RegExp + /** The raw import string. */ + specifier: string + /** Absolute path of the importing file. */ + importer: string + /** + * Where in the importer's original source the violation is (SPEC J6.5: + * optional, `trace.ts:163-174`). + */ + importerLoc?: ViolationLocation + /** Absolute path of the resolved target, when available. */ + resolved?: string + trace: Array<ViolationTraceStep> + /** The code frame of the violation, when available. */ + snippet?: { lines: Array<string>; highlightLine: number; location: string } +} diff --git a/packages/start-plugin-core/tests/importProtection/rewrite.test.ts b/packages/start-plugin-core/tests/importProtection/rewrite.test.ts deleted file mode 100644 index 1a2ea2c6e5..0000000000 --- a/packages/start-plugin-core/tests/importProtection/rewrite.test.ts +++ /dev/null @@ -1,215 +0,0 @@ -import { transformWithOxc } from 'vite' -import { describe, expect, test } from 'vitest' -import { rewriteDeniedImports } from '../../src/import-protection/rewrite' - -const MOCK_SUBSTR = 'tanstack-start-import-protection:mock' - -function rewrite(code: string, denied: Array<string>): string { - const result = rewriteDeniedImports(code, '/test.ts', new Set(denied)) - expect(result).toBeDefined() - return result!.code.trim() -} - -function expectMockImport(out: string, varName: string): void { - expect(out).toContain(MOCK_SUBSTR) - expect(out).toMatch(new RegExp(`import ${varName} from`)) -} - -describe('rewriteDeniedImports', () => { - test('rewrites named imports', () => { - const out = rewrite(`import { foo, bar } from './secret.server';`, [ - './secret.server', - ]) - expectMockImport(out, '__tss_deny_0') - expect(out).toContain('const foo = __tss_deny_0.foo') - expect(out).toContain('const bar = __tss_deny_0.bar') - expect(out).not.toContain('./secret.server') - }) - - test('rewrites default import', () => { - const out = rewrite(`import secret from './secret.server';`, [ - './secret.server', - ]) - expectMockImport(out, '__tss_deny_0') - expect(out).toContain('const secret = __tss_deny_0') - expect(out).not.toContain('./secret.server') - }) - - test('rewrites namespace import', () => { - const out = rewrite(`import * as ns from './secret.server';`, [ - './secret.server', - ]) - expectMockImport(out, '__tss_deny_0') - expect(out).toContain('const ns = __tss_deny_0') - expect(out).not.toContain('./secret.server') - }) - - test('rewrites aliased named import', () => { - const out = rewrite(`import { foo as myFoo } from './secret.server';`, [ - './secret.server', - ]) - expect(out).toContain('const myFoo = __tss_deny_0.foo') - }) - - test('rewrites mixed default + named imports', () => { - const out = rewrite(`import def, { a, b } from './secret.server';`, [ - './secret.server', - ]) - expect(out).toContain('const def = __tss_deny_0') - expect(out).toContain('const a = __tss_deny_0.a') - expect(out).toContain('const b = __tss_deny_0.b') - }) - - test('skips type-only import declaration', () => { - const result = rewriteDeniedImports( - `import type { Foo } from './secret.server';`, - '/test.ts', - new Set(['./secret.server']), - ) - expect(result).toBeUndefined() - }) - - test('skips type-only specifiers but rewrites value specifiers', () => { - const out = rewrite(`import { type Foo, bar } from './secret.server';`, [ - './secret.server', - ]) - expect(out).toContain('const bar = __tss_deny_0.bar') - expect(out).not.toContain('const Foo') - }) - - test('rewrites export { x } from "denied"', () => { - const out = rewrite(`export { foo, bar } from './secret.server';`, [ - './secret.server', - ]) - expectMockImport(out, '__tss_deny_0') - expect(out).toContain('const __tss_reexport_foo = __tss_deny_0.foo') - expect(out).toContain('const __tss_reexport_bar = __tss_deny_0.bar') - expect(out).toMatch(/export\s*\{/) - expect(out).toContain('__tss_reexport_foo as foo') - expect(out).toContain('__tss_reexport_bar as bar') - expect(out).not.toContain('./secret.server') - }) - - test('rewrites aliased re-export', () => { - const out = rewrite(`export { foo as myFoo } from './secret.server';`, [ - './secret.server', - ]) - expect(out).toContain('const __tss_reexport_foo = __tss_deny_0.foo') - expect(out).toContain('__tss_reexport_foo as myFoo') - }) - - test('rewrites string-literal import names with computed access', () => { - const out = rewrite( - `import { "foo-bar" as fooBar } from './secret.server';`, - ['./secret.server'], - ) - expect(out).toContain('const fooBar = __tss_deny_0["foo-bar"]') - }) - - test('rewrites string-literal re-export names with computed access', () => { - const out = rewrite( - `export { "foo-bar" as exposed } from './secret.server';`, - ['./secret.server'], - ) - expect(out).toContain('const __tss_reexport_0 = __tss_deny_0["foo-bar"]') - expect(out).toContain('__tss_reexport_0 as exposed') - }) - - test('removes export * from "denied"', () => { - const out = rewrite( - `export * from './secret.server';\nexport const x = 1;`, - ['./secret.server'], - ) - expect(out).not.toContain('export *') - expect(out).not.toContain('./secret.server') - expect(out).toContain('export const x = 1') - }) - - test('returns undefined when no denied imports are found', () => { - const result = rewriteDeniedImports( - `import { ok } from './safe';\nimport { also } from './fine';`, - '/test.ts', - new Set(['./secret.server']), - ) - expect(result).toBeUndefined() - }) - - test('preserves non-denied imports alongside denied ones', () => { - const out = rewrite( - `import { safe } from './ok';\nimport { secret } from './secret.server';`, - ['./secret.server'], - ) - expect(out).toContain("from './ok'") - expect(out).toContain('const secret = __tss_deny_0.secret') - }) - - test('handles multiple denied sources with separate counters', () => { - const out = rewrite( - `import { a } from './server-a';\nimport { b } from './server-b';`, - ['./server-a', './server-b'], - ) - expect(out).toContain('__tss_deny_0') - expect(out).toContain('__tss_deny_1') - expect(out).toContain('const a =') - expect(out).toContain('const b =') - expect(out).not.toContain('./server-a') - expect(out).not.toContain('./server-b') - }) - - test('returns a source map', () => { - const result = rewriteDeniedImports( - `import { foo } from './secret.server';`, - '/test.ts', - new Set(['./secret.server']), - ) - expect(result).toBeDefined() - expect(result!.map).toBeDefined() - }) - - test('skips type-only export declaration', () => { - const result = rewriteDeniedImports( - `export type { Foo } from './secret.server';`, - '/test.ts', - new Set(['./secret.server']), - ) - expect(result).toBeUndefined() - }) - - test('skips type-only export * from denied', () => { - const result = rewriteDeniedImports( - `export type * from './secret.server';`, - '/test.ts', - new Set(['./secret.server']), - ) - expect(result).toBeUndefined() - }) - - test('rewritten modules evaluate with mock values for every specifier form', async () => { - const mockModule = `data:text/javascript,${encodeURIComponent( - `export default new Proxy({}, { get: (_, key) => typeof key === 'string' ? 'mock:' + key : undefined })`, - )}` - const rewritten = rewriteDeniedImports( - `import 'denied' -import def, { type T, value, "kebab-name" as kebab } from 'denied' with { type: 'json' } -import * as ns from 'denied' -export { type U, reexported, reexported as "string export", "a-b" as ab } from 'denied' -export { default as renamedDefault } from 'denied' -export const seen: T = [def === ns, value, kebab] as unknown as T -`, - '/test/module.ts', - new Set(['denied']), - () => mockModule, - ) - const { code } = await transformWithOxc(rewritten!.code, 'module.ts') - const module = await import( - /* @vite-ignore */ `data:text/javascript,${encodeURIComponent(code)}` - ) - expect({ ...module }).toEqual({ - seen: [true, 'mock:value', 'mock:kebab-name'], - reexported: 'mock:reexported', - 'string export': 'mock:reexported', - ab: 'mock:a-b', - renamedDefault: 'mock:default', - }) - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/sourceLocation.test.ts b/packages/start-plugin-core/tests/importProtection/sourceLocation.test.ts deleted file mode 100644 index 569aa231b4..0000000000 --- a/packages/start-plugin-core/tests/importProtection/sourceLocation.test.ts +++ /dev/null @@ -1,595 +0,0 @@ -import { transformWithOxc } from 'vite' -import { describe, expect, test } from 'vitest' -import { - createImportSpecifierLocationIndex, - ImportLocCache, - addTraceImportLocations, - buildCodeSnippet, - buildLineIndex, - findImportStatementLocationFromTransformed, - findOriginalUsageLocation, - findPostCompileUsageLocation, - getOrCreateOriginalTransformResult, - normalizeSourceMap, - pickOriginalCodeFromSourcesContent, -} from '../../src/import-protection/sourceLocation' -import type { - SourceMapLike, - TransformResult, - TransformResultProvider, -} from '../../src/import-protection/sourceLocation' - -describe('pickOriginalCodeFromSourcesContent', () => { - test('picks exact matching source by path', () => { - const map = { - version: 3, - sources: ['src/a.ts', 'src/b.ts'], - names: [], - mappings: '', - sourcesContent: ['A', 'B'], - } satisfies SourceMapLike - - const picked = pickOriginalCodeFromSourcesContent( - map, - '/project/src/b.ts', - '/project', - ) - - expect(picked).toBe('B') - }) - - test('falls back to sourcesContent[0] when no match exists', () => { - const map = { - version: 3, - sources: ['src/a.ts'], - names: [], - mappings: '', - sourcesContent: ['A'], - } satisfies SourceMapLike - - const picked = pickOriginalCodeFromSourcesContent( - map, - '/project/src/does-not-exist.ts', - '/project', - ) - - expect(picked).toBe('A') - }) - - test('returns undefined when map is undefined', () => { - expect( - pickOriginalCodeFromSourcesContent(undefined, '/a.ts', '/'), - ).toBeUndefined() - }) - - test('returns undefined when sourcesContent is missing', () => { - const map = { - version: 3, - sources: ['a.ts'], - names: [], - mappings: '', - } satisfies SourceMapLike - - expect( - pickOriginalCodeFromSourcesContent(map, '/a.ts', '/'), - ).toBeUndefined() - }) - - test('returns undefined when sources array is empty', () => { - const map = { - version: 3, - sources: [], - names: [], - mappings: '', - sourcesContent: [], - } satisfies SourceMapLike - - expect( - pickOriginalCodeFromSourcesContent(map, '/a.ts', '/'), - ).toBeUndefined() - }) - - test('picks best suffix-matching source when no exact match', () => { - const map = { - version: 3, - sources: ['../lib/util.ts', '../routes/page.tsx'], - names: [], - mappings: '', - sourcesContent: ['UTIL', 'PAGE'], - } satisfies SourceMapLike - - const picked = pickOriginalCodeFromSourcesContent( - map, - '/project/src/routes/page.tsx', - '/project', - ) - - expect(picked).toBe('PAGE') - }) - - test('skips null entries in sourcesContent', () => { - const map = { - version: 3, - sources: ['src/a.ts', 'src/b.ts'], - names: [], - mappings: '', - sourcesContent: [null, 'B'], - } satisfies SourceMapLike - - const picked = pickOriginalCodeFromSourcesContent( - map, - '/project/src/a.ts', - '/project', - ) - - expect(picked).toBeUndefined() - }) -}) - -describe('buildLineIndex', () => { - test('single line — one offset at 0', () => { - const idx = buildLineIndex('hello') - expect(idx.offsets).toEqual([0]) - }) - - test('multiple lines', () => { - const idx = buildLineIndex('a\nb\nc') - // Lines start at offsets 0, 2, 4 - expect(idx.offsets).toEqual([0, 2, 4]) - }) - - test('empty string', () => { - const idx = buildLineIndex('') - expect(idx.offsets).toEqual([0]) - }) - - test('trailing newline', () => { - const idx = buildLineIndex('a\n') - expect(idx.offsets).toEqual([0, 2]) - }) -}) - -function makeTransformResult(code: string): TransformResult { - return { - code, - map: undefined, - originalCode: undefined, - } -} - -describe('createImportSpecifierLocationIndex', () => { - test('finds first matching import location across static and dynamic forms', () => { - const finder = createImportSpecifierLocationIndex() - const code = [ - `const later = import('./secret.server')`, - `import { getSecret } from './secret.server'`, - ].join('\n') - - expect( - finder.find(makeTransformResult(code), './secret.server'), - ).toBeGreaterThanOrEqual(0) - }) - - test('reuses cached per-result index without changing results', () => { - const finder = createImportSpecifierLocationIndex() - const result = makeTransformResult( - `import { getSecret } from './secret.server'`, - ) - - const first = finder.find(result, './secret.server') - const second = finder.find(result, './secret.server') - - expect(second).toBe(first) - expect(result.analysis?.importSpecifierLocationIndex).toBeDefined() - }) - - test('returns -1 when source is absent', () => { - const finder = createImportSpecifierLocationIndex() - expect( - finder.find(makeTransformResult('const x = 1'), './secret.server'), - ).toBe(-1) - }) - - test('finds dynamic imports with options', () => { - const finder = createImportSpecifierLocationIndex() - const code = - "const data = import('./secret.server', { with: { type: 'json' } })" - - expect( - finder.find(makeTransformResult(code), './secret.server'), - ).toBeGreaterThanOrEqual(0) - }) - - test('finds specifier locations in decorated modules', () => { - const finder = createImportSpecifierLocationIndex() - const code = [ - `@sealed class Example {}`, - `import { value } from './secret.server'`, - ].join('\n') - - expect(finder.find(makeTransformResult(code), './secret.server')).toBe( - code.indexOf('./secret.server'), - ) - }) - - test('finds import attributes syntax', () => { - const finder = createImportSpecifierLocationIndex() - const code = "import data from './secret.server' with { type: 'json' }" - - expect( - finder.find(makeTransformResult(code), './secret.server'), - ).toBeGreaterThanOrEqual(0) - }) - - test('finds export-all declarations', () => { - const finder = createImportSpecifierLocationIndex() - const code = "export * from './secret.server'" - - expect( - finder.find(makeTransformResult(code), './secret.server'), - ).toBeGreaterThanOrEqual(0) - }) - - test('returns earliest occurrence when the same specifier appears multiple times', () => { - const finder = createImportSpecifierLocationIndex() - const code = [ - `export * from './secret.server'`, - `import { getSecret } from './secret.server'`, - `const later = import('./secret.server')`, - ].join('\n') - - const idx = finder.find(makeTransformResult(code), './secret.server') - expect(idx).toBe(code.indexOf('./secret.server')) - }) - - test('reuses a lazily created original transform result', () => { - const result = makeTransformResult(`import { x } from './safe'`) - result.originalCode = `import { y } from './secret.server'` - - const first = getOrCreateOriginalTransformResult(result) - const second = getOrCreateOriginalTransformResult(result) - - expect(first).toBe(second) - expect(first?.code).toBe(result.originalCode) - }) -}) - -describe('normalizeSourceMap', () => { - test('normalizes sourcemap version, file, names, and sourcesContent', () => { - const normalized = normalizeSourceMap({ - version: '3', - sources: ['src/a.ts'], - names: undefined as unknown as Array<string>, - sourcesContent: [null, 'A'], - mappings: '', - }) - - expect(normalized).toEqual({ - version: 3, - file: '', - sources: ['src/a.ts'], - names: [], - sourcesContent: ['', 'A'], - mappings: '', - }) - }) - - test('returns undefined for missing map', () => { - expect(normalizeSourceMap(undefined)).toBeUndefined() - expect(normalizeSourceMap(null)).toBeUndefined() - }) -}) - -describe('buildCodeSnippet', () => { - function makeProvider( - code: string, - originalCode?: string, - ): TransformResultProvider { - return { - getTransformResult: () => ({ - code, - map: undefined, - originalCode, - }), - } - } - - test('builds snippet with context lines around target', () => { - const code = ['line1', 'line2', 'line3', 'line4', 'line5'].join('\n') - const provider = makeProvider(code) - const snippet = buildCodeSnippet(provider, '/test.ts', { - line: 3, - column: 1, - }) - - expect(snippet).toBeDefined() - expect(snippet!.highlightLine).toBe(3) - expect(snippet!.lines.length).toBeGreaterThanOrEqual(5) - const markerLine = snippet!.lines.find((l) => l.startsWith(' >')) - expect(markerLine).toContain('line3') - }) - - test('uses originalCode over transformed code when available', () => { - const provider = makeProvider('transformed', 'original line 1') - const snippet = buildCodeSnippet(provider, '/test.ts', { - line: 1, - column: 1, - }) - - expect(snippet).toBeDefined() - const content = snippet!.lines.join('\n') - expect(content).toContain('original line 1') - expect(content).not.toContain('transformed') - }) - - test('returns undefined when no transform result', () => { - const provider: TransformResultProvider = { - getTransformResult: () => undefined, - } - expect( - buildCodeSnippet(provider, '/test.ts', { line: 1, column: 1 }), - ).toBeUndefined() - }) - - test('returns undefined when target line is out of range', () => { - const provider = makeProvider('one line') - expect( - buildCodeSnippet(provider, '/test.ts', { line: 999, column: 1 }), - ).toBeUndefined() - }) - - test('includes column pointer on target line', () => { - const provider = makeProvider('const x = 1') - const snippet = buildCodeSnippet(provider, '/test.ts', { - line: 1, - column: 7, - }) - - expect(snippet).toBeDefined() - const pointerLine = snippet!.lines.find((l) => l.includes('^')) - expect(pointerLine).toBeDefined() - }) - - test('location string includes file:line:col', () => { - const provider = makeProvider('code') - const snippet = buildCodeSnippet(provider, '/test.ts', { - line: 1, - column: 5, - }) - - expect(snippet!.location).toBe('/test.ts:1:5') - }) - - test('respects custom contextLines parameter', () => { - const code = Array.from({ length: 20 }, (_, i) => `line${i + 1}`).join('\n') - const provider = makeProvider(code) - const snippet = buildCodeSnippet( - provider, - '/test.ts', - { line: 10, column: 1 }, - 1, - ) - - expect(snippet).toBeDefined() - expect(snippet!.lines.length).toBe(4) - }) -}) - -describe('findOriginalUsageLocation', () => { - function makeProvider( - code: string, - originalCode?: string, - ): TransformResultProvider { - return { - getTransformResult: () => ({ - code, - map: undefined, - originalCode, - }), - } - } - - test('prefers original usage site over import site when original code is available', () => { - const provider = makeProvider( - 'const secretServerFn = createServerFn().handler(rpc())\n', - [ - "import { createServerFn } from '@tanstack/react-start'", - "import { getSecret } from './secret.server'", - '', - 'export const secretServerFn = createServerFn().handler(async () => {', - ' return getSecret()', - '})', - '', - 'export function leakyReference() {', - ' return getSecret()', - '}', - ].join('\n'), - ) - - expect( - findOriginalUsageLocation( - provider, - '/test/compiler-leak.ts', - './secret.server', - 'client', - ), - ).toEqual({ - file: '/test/compiler-leak.ts', - line: 9, - column: 10, - }) - }) - - test('returns undefined when original usage only exists inside compiler-safe boundary', () => { - const provider = makeProvider( - 'export const safe = noop\n', - [ - "import { createServerOnlyFn } from '@tanstack/react-start'", - "import { getSecret } from './secret.server'", - '', - 'export const safe = createServerOnlyFn(() => {', - ' return getSecret()', - '})', - ].join('\n'), - ) - - expect( - findOriginalUsageLocation( - provider, - '/test/boundary-safe.ts', - './secret.server', - 'client', - ), - ).toBeUndefined() - }) -}) - -describe('ImportLocCache', () => { - test('stores and retrieves values', () => { - const cache = new ImportLocCache() - const entry = { line: 1, column: 1 } - cache.set('/a.ts::./b', entry) - expect(cache.get('/a.ts::./b')).toBe(entry) - expect(cache.has('/a.ts::./b')).toBe(true) - }) - - test('returns undefined for missing keys', () => { - const cache = new ImportLocCache() - expect(cache.get('/missing::./b')).toBeUndefined() - expect(cache.has('/missing::./b')).toBe(false) - }) - - test('stores null values (negative cache)', () => { - const cache = new ImportLocCache() - cache.set('/a.ts::./b', null) - expect(cache.has('/a.ts::./b')).toBe(true) - expect(cache.get('/a.ts::./b')).toBeNull() - }) - - test('deleteByFile removes all entries for a file', () => { - const cache = new ImportLocCache() - cache.set('/a.ts::./x', { line: 1, column: 1 }) - cache.set('/a.ts::./y', { line: 2, column: 1 }) - cache.set('/b.ts::./x', { line: 3, column: 1 }) - - cache.deleteByFile('/a.ts') - - expect(cache.has('/a.ts::./x')).toBe(false) - expect(cache.has('/a.ts::./y')).toBe(false) - expect(cache.has('/b.ts::./x')).toBe(true) - }) - - test('deleteByFile is a no-op for unknown files', () => { - const cache = new ImportLocCache() - cache.set('/a.ts::./x', { line: 1, column: 1 }) - cache.deleteByFile('/unknown.ts') - expect(cache.has('/a.ts::./x')).toBe(true) - }) - - test('clear removes all entries', () => { - const cache = new ImportLocCache() - cache.set('/a.ts::./x', { line: 1, column: 1 }) - cache.set('/b.ts::./y', { line: 2, column: 1 }) - cache.clear() - expect(cache.has('/a.ts::./x')).toBe(false) - expect(cache.has('/b.ts::./y')).toBe(false) - }) -}) - -describe('locations through a real source map', () => { - const file = '/root/src/page.tsx' - // Multi-byte characters before the import shift every generated column. - const original = `// ünïcödé 👨‍👩‍👧 comment -import type { Shape } from './types' -import { getSecret } from './secret.server' -interface Props { shape: Shape } -export const Page = ({ shape }: Props) => <div title="é">{getSecret(shape)}</div> -` - - const importLocation = { - file, - line: 3, - column: original.split('\n')[2]!.indexOf("'./secret.server'") + 1, - } - - async function createProvider(): Promise<TransformResultProvider> { - const output = await transformWithOxc(original, file, { - jsx: 'preserve', - sourcemap: true, - }) - const result: TransformResult = { - code: output.code, - map: { - ...output.map!, - file: undefined, - sourceRoot: '/root/', - sources: ['src/page.tsx'], - sourcesContent: [original], - }, - originalCode: undefined, - filename: file, - } - return { getTransformResult: () => result } - } - - function findSpecifier() { - const index = createImportSpecifierLocationIndex() - return (result: TransformResult, source: string) => - index.find(result, source) - } - - test('import and usage locations map back to the original source', async () => { - const provider = await createProvider() - expect( - await findImportStatementLocationFromTransformed( - provider, - file, - './secret.server', - new ImportLocCache(), - findSpecifier(), - ), - ).toEqual(importLocation) - const usageLine = original.split('\n')[4]! - const usage = { file, line: 5, column: usageLine.indexOf('getSecret(') + 1 } - expect( - await findPostCompileUsageLocation(provider, file, './secret.server'), - ).toEqual(usage) - expect( - findOriginalUsageLocation( - provider, - file, - './secret.server', - 'client', - '/root', - ), - ).toEqual(usage) - }) - - test('trace steps that import a specifier get the original import line', async () => { - const provider = await createProvider() - const trace: Array<{ - file: string - specifier?: string - line?: number - column?: number - }> = [ - { file: '/root/src/entry.tsx' }, - { file, specifier: './secret.server' }, - // A second lookup of the same specifier exercises the cache-hit path. - { file, specifier: './secret.server' }, - { file, specifier: './types', line: 1, column: 1 }, - ] - await addTraceImportLocations( - provider, - trace, - new ImportLocCache(), - findSpecifier(), - ) - expect(trace).toEqual([ - { file: '/root/src/entry.tsx' }, - { specifier: './secret.server', ...importLocation }, - { specifier: './secret.server', ...importLocation }, - { file, specifier: './types', line: 1, column: 1 }, - ]) - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/start-apps.ts b/packages/start-plugin-core/tests/importProtection/start-apps.ts new file mode 100644 index 0000000000..a331bfa222 --- /dev/null +++ b/packages/start-plugin-core/tests/importProtection/start-apps.ts @@ -0,0 +1,617 @@ +/** + * Helpers of the import-protection tests that run Start's import protection + * on a real app. + * + * `startProtectedDevServer` is a Vite dev server with Start's whole public + * Vite plugin (`startDevServer`: `tanstackStart()` of the built framework + * package), configured through Start's public options only: + * `importProtection`, and + * the app's router entry (`router.entry`, default `src/entry.ts` for these + * fixtures), the module every client module of a Start app is reached from. + * The start entry `src/start.ts` is Start's default. + * + * The violations a run reports are read as Start's public `onViolation` + * callback receives them (`server.violations`, `build.violations`; SPEC + * J6.5, J6.6), never parsed from the printed report. That each is printed + * (a warning or an error the user sees) is checked by `expectViolationsAt` + * and `expectPrinted`, only for the file and position it names (SPEC G5, + * §5.7). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import { expect, onTestFinished } from 'vitest' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { startDevServer } from '../dev-server' +import { + rscDependency, + rscPluginFactory, + startPluginFactory, +} from '../start-plugins' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import type { ImportProtectionOptions, ViolationInfo } from './public-types' +import type { StartDevServerOptions } from '../dev-server' +import type { StartBuild, StartBuildError } from '../build-harness' +import type { PluginOption } from 'vite' + +export type { ImportProtectionOptions, ViolationInfo } from './public-types' + +/** + * What recorded the violations of a run: a dev server, a build or a failed + * build (`violations`: what `onViolation` received; `root`: the app root). + */ +export interface Recorded { + violations: Array<ViolationInfo> + root: string + /** What the run printed, on every channel (a dev server's or a build's). */ + diagnostics?: Array<Diagnostic> +} + +/** A violation `onViolation` received, with paths relative to the app root. */ +export interface Violation { + environment: 'client' | 'server' + /** The importer, with `:line:column` when the violation has a location. */ + importer: string + specifier: string + resolved?: string + /** + * The import chain, from an entry to the importer (`file[:line:column]`), + * whichever direction `onViolation` listed it in (`traceFromEntry`). + */ + trace: Array<{ at: string; imports?: string }> +} + +/** `file` relative to `root` when it is an absolute path under it. */ +function relative(root: string, file: string) { + const name = path.relative(root, file) + return !path.isAbsolute(file) || name.startsWith('..') + ? file + : name.split(path.sep).join('/') +} + +/** `file:line:column`, or the file alone without a line. */ +const located = (root: string, file: string, line?: number, column?: number) => + `${relative(root, file)}${line === undefined ? '' : `:${line}${column === undefined ? '' : `:${column}`}`}` + +/** + * An `onViolation` for Start's public `importProtection` option that records + * every violation Start reports (`violations`), and `importProtection` with + * it. The app's own `onViolation` (of `importProtection`) still decides: a + * violation it allows (`false`) is not reported, so not recorded. + */ +export function violationRecorder( + importProtection: ImportProtectionOptions = {}, +) { + const violations: Array<ViolationInfo> = [] + const own = importProtection.onViolation + const onViolation = async (info: unknown) => { + const verdict = await own?.(info) + if (verdict !== false) { + violations.push(info as ViolationInfo) + } + return verdict + } + return { + violations, + onViolation, + importProtection: { ...importProtection, onViolation }, + } +} + +/** + * The steps of `info.trace` from the entry to the importer. A trace may be + * listed entry first or entry last (SPEC J6.5, §5.19): one whose first step is the importer, and whose last + * step is not, is listed entry last. + */ +export function traceFromEntry(info: ViolationInfo): ViolationInfo['trace'] { + const isImporter = (step: ViolationInfo['trace'][number] | undefined) => + step !== undefined && + step.file.split('?')[0] === info.importer.split('?')[0] + return isImporter(info.trace[0]) && !isImporter(info.trace.at(-1)) + ? [...info.trace].reverse() + : info.trace +} + +/** + * The violations of `recorded`, in order (each trace from the entry to the + * importer, `traceFromEntry`). + */ +export function violationsOf(recorded: Recorded): Array<Violation> { + return recorded.violations.map((info) => ({ + environment: info.envType, + // (the file of the location when it names one: an original source) + importer: located( + recorded.root, + info.importerLoc?.file ?? info.importer, + info.importerLoc?.line, + info.importerLoc?.column, + ), + specifier: info.specifier, + ...(info.resolved !== undefined && { + resolved: relative(recorded.root, info.resolved), + }), + trace: traceFromEntry(info).map((step) => ({ + at: located(recorded.root, step.file, step.line, step.column), + ...(step.specifier !== undefined && { imports: step.specifier }), + })), + })) +} + +/** `environment` and `importer` of each violation of `recorded`, in order. */ +export function reportedViolations( + recorded: Recorded, +): Array<{ environment: string; importer: string }> { + return violationsOf(recorded).map(({ environment, importer }) => ({ + environment, + importer, + })) +} + +/** `recorded` with only the violations of the environment type `environment`. */ +export function inEnvironment( + recorded: Recorded, + environment: 'client' | 'server', +): Recorded { + return { + root: recorded.root, + violations: recorded.violations.filter( + (info) => info.envType === environment, + ), + } +} + +/** + * A violation a test expects: its environment type, the importer's use of + * the denied import (`use`: `file:line:column`) and the other places it + * may be reported at instead (SPEC J6.5: any line of the + * import, another genuine use, a marker's origin), written out: `file:line` + * (any column), `file:line:column`, or `file` (no location). + */ +export interface ExpectedViolation { + environment: 'client' | 'server' + use: string + also?: Array<string> +} + +/** `environment use`: how `expectViolationsAt` names an expected violation. */ +export const violationLabel = (expected: ExpectedViolation) => + `${expected.environment} ${expected.use}` + +/** + * The file, line and column of a location (`file`, `file:line` or + * `file:line:column`): only a trailing `:line` or `:line:column` is the + * position, so a file named with a colon (Rspack's `webpack:/src/a.tsx`, + * pinned in reported-location.test.ts) keeps its whole name. + */ +export function locationParts(location: string): { + file: string + line?: string + column?: string +} { + const [, file, line, column] = /^(.*?)(?::(\d+))?(?::(\d+))?$/.exec(location)! + return { + file: file!, + ...(line !== undefined && { line }), + ...(column !== undefined && { column }), + } +} + +/** + * The file of the app a location names: its file (`locationParts`) without + * a URL scheme such as Rspack's `webpack:/` (how the report names the file + * is pinned in reported-location.test.ts, "the reported importer is a file + * of the app"). + */ +export const appFileOf = (location: string) => + locationParts(location).file.replace(/^[a-z]+:\/+/, '') + +/** + * Whether `reported` (`file`, `file:line` or `file:line:column`) is the + * place `accepted` names: the same file, line and column, as far as + * `accepted` gives them, with no location for a bare file. + */ +export function isAt(reported: string, accepted: string) { + const { file, line, column } = locationParts(accepted) + const { + file: reportedFile, + line: reportedLine, + column: reportedColumn, + } = locationParts(reported) + return ( + reportedFile === file && + (line === undefined + ? reportedLine === undefined + : reportedLine === line && + (column === undefined || reportedColumn === column)) + ) +} + +/** + * Each distinct violation of `recorded` (environment type and importer), + * named `violationLabel` of the expected violation it is at one of the + * places of, else `environment importer` as received. + */ +export function relevantViolations( + recorded: Recorded, + expected: Array<ExpectedViolation>, +): Array<string> { + return distinct( + reportedViolations(recorded).map(({ environment, importer }) => { + const match = expected.find( + (violation) => + violation.environment === environment && + [violation.use, ...(violation.also ?? [])].some((place) => + isAt(importer, place), + ), + ) + return match ? violationLabel(match) : `${environment} ${importer}` + }), + ) +} + +/** + * Asserts that the distinct violations of `recorded` are exactly the + * `expected` ones, each at one of its places, in any order; and, when + * `recorded` has what the run printed, that each is printed as a warning or + * an error naming its importer and position (SPEC J6.3: every violation is + * reported). + */ +export function expectViolationsAt( + recorded: Recorded, + expected: Array<ExpectedViolation>, +) { + expect(relevantViolations(recorded, expected).sort()).toEqual( + expected.map(violationLabel).sort(), + ) + if (recorded.diagnostics) { + for (const violation of violationsOf(recorded)) { + expectPrinted(recorded.diagnostics, recorded.root, violation, [ + 'warning', + 'error', + ]) + } + } +} + +/** + * `environment file` of each violation of `recorded` (the importer's file, + * without its location), in order: which importers are reported. Where + * they are is checked by `expectViolationsAt`. + */ +export function reportedImporters(recorded: Recorded): Array<string> { + return reportedViolations(recorded).map( + ({ environment, importer }) => + `${environment} ${locationParts(importer).file}`, + ) +} + +export interface ProtectedDevServerOptions { + /** Serve actual dependencies and an HTTP origin for client consumers. */ + browser?: boolean + /** + * The app's router entry (relative to the app root, in `src`): Start's + * public `router.entry` option, the module every client module of a Start + * app is reached from. Default `src/entry.ts`. + */ + router?: string + /** Other plugins of the app, after Start's. */ + plugins?: Array<PluginOption> + /** Vite configuration of the app (e.g. `server.warmup`). */ + config?: StartDevServerOptions['config'] + /** + * Vite's full-bundle dev (`experimental.bundledDev`): Rolldown bundles the + * client from Start's own client entry (the bundle input Start's plugin + * configures), which imports the app's client entry: `src/client.ts` + * when the app has one, else one that imports `entry` (as a real client + * entry reaches the router entry through `StartClient`). + * `server.clientBundle()` gives the bundle. + */ + bundledDev?: StartDevServerOptions['bundledDev'] +} + +export interface ProtectedDevServer extends DevServer { + /** + * Every violation Start reported through `onViolation`, in order (the + * app's own `onViolation`, when it has one, still decides: one it allows + * is not listed). + */ + violations: Array<ViolationInfo> +} + +/** + * Starts a Vite dev server with Start's plugin (`startDevServer`) on an app + * of `files`, with Start's `importProtection` option `importProtection` + * (source directory `src`) and the app's router entry `options.router`. + */ +export async function startProtectedDevServer( + files: Record<string, string>, + importProtection: ImportProtectionOptions = {}, + options: ProtectedDevServerOptions = {}, +): Promise<ProtectedDevServer> { + const { + router = 'src/entry.ts', + plugins = [], + config = {}, + bundledDev, + } = options + const recorder = violationRecorder(importProtection) + const hasClientEntry = Object.keys(files).some((file) => + /^src\/client\.[cm]?[jt]sx?$/.test(file), + ) + const server = await startDevServer({ + files: { + ...(bundledDev && + !hasClientEntry && { + 'harness/client-entry.ts': `import ${JSON.stringify( + `../${bundledDev.entry.replace(/\.[cm]?[jt]sx?$/, '')}`, + )}\n`, + }), + ...files, + }, + browser: options.browser, + bundledDev, + config, + start: { + importProtection: recorder.importProtection, + router: { entry: path.posix.relative('src', router) }, + }, + // A React app's plugin: full-bundle dev needs its Refresh runtime. + plugins: bundledDev ? [react(), ...plugins] : plugins, + }) + return Object.assign(server, { violations: recorder.violations }) +} + +/** + * Starts a Vite dev server on a React Start app with RSC enabled, the way + * its `vite.config.ts` configures it: `tanstackStart({ rsc: { enabled: + * true }, importProtection, router })` (Start's import protection with its + * defaults, recorded; router entry `src/entry.ts`) of the built + * `@tanstack/react-start/plugin/vite`, Vite's RSC plugin + * (`@vitejs/plugin-rsc`, as `@tanstack/react-start-rsc` installs it) and + * `@vitejs/plugin-react`. Its server fn provider environment is `rsc`, a + * third environment beside `client` and `ssr`. `@tanstack/react-start`, + * `@tanstack/react-start-rsc` and `@vitejs/plugin-rsc` are linked into the + * app (it imports them, as an installed app does). + */ +export async function startRscProtectedDevServer( + files: Record<string, string>, +): Promise<ProtectedDevServer> { + const recorder = violationRecorder({}) + const tanstackStart = await startPluginFactory('react') + const rsc = await rscPluginFactory() + const server = await createDevServer({ + dir: path.dirname(path.dirname(fileURLToPath(import.meta.url))), + prefix: '.start-rsc-dev-server-', + registerCleanup: onTestFinished, + files: { + 'src/router.tsx': `export const getRouter = () => undefined\n`, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + ...files, + }, + symlinks: { + ...workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + 'node_modules/@vitejs/plugin-rsc': rscDependency('@vitejs/plugin-rsc'), + }, + config: { appType: 'custom' }, + plugins: [ + tanstackStart({ + rsc: { enabled: true }, + importProtection: recorder.importProtection, + router: { entry: 'entry.ts' }, + }), + rsc(), + react(), + ], + }) + return Object.assign(server, { violations: recorder.violations }) +} + +/** + * An app whose server fn factory module `src/factory.ts` uses its denied + * imports (the denied file `src/secret.server.ts` and the denied specifier + * `@tanstack/react-start/server`) only inside `createMiddleware().server()`, + * which the client never runs, and whose `src/leak.ts` uses the denied file + * in a function the client may call; the router entry `src/entry.ts` + * re-exports a server fn of the factory and the leak. `factoryTail` is + * appended to the factory module (from line 9). + */ +export const serverFnFactoryApp = (factoryTail = '') => ({ + 'src/secret.server.ts': `export const getSecret = () => 'MARK_SECRET'\n`, + 'src/factory.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { getRequest } from '@tanstack/react-start/server' +import { getSecret } from './secret.server' +const mw = createMiddleware({ type: 'function' }).server(({ next }) => { + const req = getRequest() + return next({ context: { req, secret: getSecret() } }) +}) +export const createSecretFn = createServerFn().middleware([mw]) +${factoryTail}`, + 'src/usage.ts': `import { createSecretFn } from './factory' +export const fn = createSecretFn().handler(async ({ context }) => context) +`, + 'src/leak.ts': `import { getSecret } from './secret.server' +export const leak = () => getSecret() +`, + 'src/entry.ts': `export { fn } from './usage' +export { leak } from './leak' +`, +}) + +/** + * A `factoryTail` of `serverFnFactoryApp` calling the denied + * `getRequest()` at the top level of the factory module, which the client + * runs (located at `src/factory.ts:9:24`). + */ +export const factoryTopLevelCall = `export const request = getRequest()\n` + +/** + * A client module re-exporting everything of a denied module (`src/b.ts`: + * `export * from`, line 1) and a module importing one of its names + * (`src/c.ts`, as `v`), with the import-protection options that deny it: + * a denied file, and a package denied by a specifier rule. The denied + * module's value carries `MARK_SECRET`. For the rows of SPEC J6.8 on + * `export *` of a denied module. + */ +export const starReexportApps: Array<{ + name: string + files: Record<string, string> + importProtection: ImportProtectionOptions +}> = [ + { + name: 'a denied file', + files: { + 'src/secret.server.ts': `export const getRequest = () => 'MARK_SECRET'\n`, + 'src/b.ts': `export * from './secret.server'\n`, + 'src/c.ts': `import { getRequest } from './b'\nexport const v = getRequest\n`, + }, + importProtection: {}, + }, + { + name: 'a denied specifier', + files: { + 'node_modules/denied-sdk/package.json': JSON.stringify({ + name: 'denied-sdk', + type: 'module', + exports: './index.js', + }), + 'node_modules/denied-sdk/index.js': `export const getRequest = () => 'MARK_SECRET'\n`, + 'src/b.ts': `export * from 'denied-sdk'\n`, + 'src/c.ts': `import { getRequest } from './b'\nexport const v = getRequest\n`, + }, + importProtection: { client: { specifiers: ['denied-sdk'] } }, + }, +] + +/** + * Checks a marker violation (a module marked server-only imported by the + * client, or client-only imported by the server): it is reported either at + * the marker import (`marker`, `file:line` of the marked module's import of the + * marker; any column of it, or the file without a location), at the + * importer's use of the import (`use`, `file:line:column`) or at a line of + * the importer's import of the marked module (`imports`, `file:line`). + * Each location is fine (SPEC J6.5). + */ +export function expectMarkerViolation( + violation: Violation, + locations: { marker: string; use: string; imports: Array<string> }, +) { + const markerFile = locationParts(locations.marker).file + expect( + [locations.use, ...locations.imports, locations.marker, markerFile].some( + (place) => isAt(violation.importer, place), + ), + `${violation.importer} is at ${locations.use}, ${locations.imports.join(', ')} or ${locations.marker}`, + ).toBe(true) +} + +/** + * Asserts that a `severity` diagnostic the user sees (`diagnostics`: every + * channel) names the importer of `violation` and its position (SPEC G5, §5.7: + * file and position only). + */ +export function expectPrinted( + diagnostics: Array<Diagnostic>, + root: string, + violation: { importer: string }, + severity: 'warning' | 'error' | Array<'warning' | 'error'>, +) { + const { file, line, column } = locationParts(violation.importer) + expectDiagnostic(diagnostics, { + severity, + file, + root, + ...(line !== undefined && { + position: { line: Number(line), column: Number(column) }, + }), + }) +} + +/** + * What a dev server reported, on any channel (`server.diagnostics`: the + * console, the process streams, Vite's logger), as a warning or an error + * naming one of `files` (relative to the app root, or absolute), from + * `since` (a `server.diagnostics.length` mark) on: for checks that nothing + * is reported about a module, whatever the report's wording or layout + * (SPEC §5.7, J6.12), next to the `onViolation` check. + */ +export function problemsNaming( + server: Pick<DevServer, 'diagnostics' | 'root'>, + files: Array<string>, + since = 0, +): Array<string> { + const reported = server.diagnostics + .slice(since) + .filter(({ severity }) => severity !== 'info') as Array<Diagnostic> + return [ + ...new Set( + files.flatMap((file) => + findDiagnostics(reported, { file, root: server.root }).map( + ({ text }) => text, + ), + ), + ), + ] +} + +/** Each distinct value of `values`, in order. */ +export function distinct<T>(values: Array<T>): Array<T> { + return [...new Set(values)] +} + +/** `file:line:column` of the first `needle` on 1-based line `line` of `code`. */ +export function locationIn( + file: string, + code: string, + line: number, + needle: string, +): string { + const column = code.split('\n')[line - 1]!.indexOf(needle) + if (column === -1) { + throw new Error(`${needle} is not on line ${line}`) + } + return `${file}:${line}:${column + 1}` +} + +/** + * The error a promise rejects with (fails when it resolves): a build's + * `StartBuildError`, with what the build reported. + */ +export async function rejection( + promise: Promise<StartBuild>, +): Promise<StartBuildError> +export async function rejection(promise: Promise<unknown>): Promise<Error> +export async function rejection(promise: Promise<unknown>): Promise<Error> { + try { + await promise + } catch (error) { + return error as Error + } + throw new Error('expected the promise to reject') +} + +/** + * The import-protection violations `onViolation` received, as + * `<environment type> <importer>` relative to `root` (with `:line:column` + * when located), each distinct value once, in order. + */ +export function receivedViolations( + violations: Array<ViolationInfo>, + root: string, +): Array<string> { + return distinct( + reportedViolations({ violations, root }).map( + ({ environment, importer }) => `${environment} ${importer}`, + ), + ) +} diff --git a/packages/start-plugin-core/tests/importProtection/trace.test.ts b/packages/start-plugin-core/tests/importProtection/trace.test.ts deleted file mode 100644 index 874adc0fab..0000000000 --- a/packages/start-plugin-core/tests/importProtection/trace.test.ts +++ /dev/null @@ -1,429 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - ImportGraph, - buildTrace, - formatViolation, -} from '../../src/import-protection/trace' -import type { ViolationInfo } from '../../src/import-protection/trace' - -describe('ImportGraph', () => { - test('addEdge and reverse lookup', () => { - const graph = new ImportGraph() - graph.addEdge('/src/secret.server.ts', '/src/edge-a.ts', './secret.server') - graph.addEdge( - '/src/edge-a.ts', - '/src/routes/index.tsx', - './violations/edge-a', - ) - - const edges = graph.getEdges('/src/secret.server.ts') - expect(edges).toBeDefined() - expect(edges!.size).toBe(1) - - const firstEdge = [...edges!][0]! - expect(firstEdge.importer).toBe('/src/edge-a.ts') - expect(firstEdge.specifier).toBe('./secret.server') - }) - - test('addEntry marks entries', () => { - const graph = new ImportGraph() - graph.addEntry('/src/main.tsx') - expect(graph.entries.has('/src/main.tsx')).toBe(true) - }) - - test('clear resets everything', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a') - graph.addEntry('/b') - graph.clear() - expect(graph.reverseEdges.size).toBe(0) - expect(graph.entries.size).toBe(0) - }) - - test('invalidate removes edges involving a module', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a') - graph.addEdge('/c', '/b', './c') - graph.addEdge('/d', '/a', './d') - - graph.invalidate('/b') - - // Edges where /b is importer should be removed - const edgesForA = graph.getEdges('/a') - expect(edgesForA).toBeDefined() - expect(edgesForA!.size).toBe(0) - - const edgesForC = graph.getEdges('/c') - expect(edgesForC).toBeDefined() - expect(edgesForC!.size).toBe(0) - - const edgesForD = graph.getEdges('/d') - expect(edgesForD).toBeDefined() - expect(edgesForD!.size).toBe(1) - }) - - test('getEdges returns undefined for unknown ID', () => { - const graph = new ImportGraph() - expect(graph.getEdges('/nonexistent')).toBeUndefined() - }) - - test('invalidate also removes reverseEdges entry for the invalidated module', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a') - graph.invalidate('/a') - // /a's own reverse-edge map should be gone - expect(graph.reverseEdges.has('/a')).toBe(false) - }) - - test('invalidate is safe on unknown ID', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a') - graph.invalidate('/unknown') - expect(graph.getEdges('/a')!.size).toBe(1) - }) - - test('addEdge overwrites specifier for same importer→resolved pair', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a-old') - graph.addEdge('/a', '/b', './a-new') - const edges = graph.getEdges('/a') - expect(edges!.size).toBe(1) - expect([...edges!][0]!.specifier).toBe('./a-new') - }) -}) - -describe('buildTrace', () => { - test('builds a trace from entry to denied module', () => { - const graph = new ImportGraph() - graph.addEntry('/src/main.tsx') - - // main.tsx -> routes/index.tsx -> violations/edge-a.ts -> violations/secret.server.ts - graph.addEdge('/src/routes/index.tsx', '/src/main.tsx', './routes/index') - graph.addEdge( - '/src/violations/edge-a.ts', - '/src/routes/index.tsx', - './violations/edge-a', - ) - graph.addEdge( - '/src/violations/secret.server.ts', - '/src/violations/edge-a.ts', - './secret.server', - ) - - // Build trace starting from edge-a (the importer of the denied module) - const trace = buildTrace(graph, '/src/violations/edge-a.ts') - - expect(trace.length).toBeGreaterThanOrEqual(2) - expect(trace[0]!.file).toBe('/src/main.tsx') - expect(trace[trace.length - 1]!.file).toBe('/src/violations/edge-a.ts') - }) - - test('respects maxDepth', () => { - const graph = new ImportGraph() - graph.addEntry('/entry') - - // Chain: /entry -> /a -> /b -> /c -> /d -> /e - graph.addEdge('/a', '/entry', './a') - graph.addEdge('/b', '/a', './b') - graph.addEdge('/c', '/b', './c') - graph.addEdge('/d', '/c', './d') - graph.addEdge('/e', '/d', './e') - - const trace = buildTrace(graph, '/e', 2) - expect(trace.length).toBeLessThanOrEqual(4) - }) - - test('handles single node with no importers', () => { - const graph = new ImportGraph() - const trace = buildTrace(graph, '/orphan') - expect(trace.length).toBe(1) - expect(trace[0]!.file).toBe('/orphan') - }) - - test('treats node with no reverse-edge map entry as entry', () => { - const graph = new ImportGraph() - graph.addEdge('/b', '/a', './b') - - const trace = buildTrace(graph, '/b') - expect(trace[0]!.file).toBe('/a') - expect(trace[trace.length - 1]!.file).toBe('/b') - }) - - test('treats node with empty importers map as entry', () => { - const graph = new ImportGraph() - graph.addEdge('/a', '/b', './a') - graph.addEdge('/b', '/a', './b') - graph.invalidate('/a') - - graph.addEdge('/b', '/a', './b') - - const trace = buildTrace(graph, '/b') - expect(trace[0]!.file).toBe('/a') - expect(trace[trace.length - 1]!.file).toBe('/b') - }) - - test('prefers explicit entry over implicit no-importers entry', () => { - const graph = new ImportGraph() - graph.addEntry('/entry') // /entry -> /mid -> /leaf - graph.addEdge('/mid', '/entry', './mid') - graph.addEdge('/leaf', '/mid', './leaf') - - const trace = buildTrace(graph, '/leaf') - expect(trace[0]!.file).toBe('/entry') - expect(trace[trace.length - 1]!.file).toBe('/leaf') - }) - - test('handles cycles without infinite loop', () => { - const graph = new ImportGraph() - graph.addEntry('/entry') - graph.addEdge('/a', '/entry', './a') - graph.addEdge('/b', '/a', './b') - graph.addEdge('/a', '/b', './a') // cycle: /a -> /b -> /a - - const trace = buildTrace(graph, '/b') - // Should terminate and produce a trace ending at /b - expect(trace[trace.length - 1]!.file).toBe('/b') - expect(trace.length).toBeGreaterThanOrEqual(2) - }) - - test('handles fully disconnected node (no edges at all)', () => { - const graph = new ImportGraph() - const trace = buildTrace(graph, '/island') - expect(trace).toEqual([{ file: '/island', specifier: undefined }]) - }) -}) - -describe('formatViolation', () => { - test('formats specifier violation correctly', () => { - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'specifier', - behavior: 'error', - pattern: '@tanstack/react-start/server', - specifier: '@tanstack/react-start/server', - importer: '/project/src/routes/index.tsx', - trace: [ - { file: '/project/src/main.tsx' }, - { file: '/project/src/routes/index.tsx', specifier: './routes/index' }, - ], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Import denied in client environment') - expect(formatted).toContain('specifier pattern') - expect(formatted).toContain('@tanstack/react-start/server') - expect(formatted).toContain('src/routes/index.tsx') - expect(formatted).toContain('Trace:') - expect(formatted).toContain('(entry)') - }) - - test('formats file violation correctly', () => { - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'file', - behavior: 'mock', - pattern: '**/*.server.*', - specifier: './secret.server', - importer: '/project/src/edge-a.ts', - resolved: '/project/src/secret.server.ts', - trace: [], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('file pattern') - expect(formatted).toContain('**/*.server.*') - expect(formatted).toContain('src/secret.server.ts') - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain('createServerFn().handler') - expect(formatted).toContain('createServerOnlyFn') - expect(formatted).toContain('createIsomorphicFn') - expect(formatted).toContain('Move the server-only import') - }) - - test('formats marker violation correctly', () => { - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'marker', - behavior: 'error', - specifier: '@tanstack/react-start/server-only', - importer: '/project/src/routes/index.tsx', - trace: [], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('marker') - expect(formatted).toContain('restricted to the opposite environment') - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain('createServerFn') - }) - - test('client-in-server violation includes client-only suggestions', () => { - const info: ViolationInfo = { - env: 'ssr', - envType: 'server', - type: 'file', - behavior: 'mock', - pattern: '**/*.client.*', - specifier: './browser-api.client', - importer: '/project/src/routes/page.tsx', - resolved: '/project/src/browser-api.client.ts', - trace: [], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain('createClientOnlyFn') - expect(formatted).toContain('createIsomorphicFn') - expect(formatted).toContain('Move the client-only import') - expect(formatted).not.toContain('<ClientOnly') - }) - - test('env is printed with env type suffix', () => { - const info: ViolationInfo = { - env: 'ssr', - envType: 'server', - type: 'specifier', - behavior: 'error', - pattern: /^node:/, - specifier: 'node:fs', - importer: '/project/src/routes/page.tsx', - trace: [], - } - - const formatted = formatViolation(info, '/project') - expect(formatted).toContain('Import denied in server environment') - }) - - test('client-in-server violation with JSX suggests ClientOnly', () => { - const info: ViolationInfo = { - env: 'ssr', - envType: 'server', - type: 'file', - behavior: 'mock', - pattern: '**/*.client.*', - specifier: './browser-api.client', - importer: '/project/src/routes/page.tsx', - resolved: '/project/src/browser-api.client.ts', - trace: [], - snippet: { - lines: [ - ' 15 | <div>', - ' 16 | <h1>Page</h1>', - ' > 17 | <p>{getBrowserTitle()}</p>', - ' | ^', - ' 18 | </div>', - ], - highlightLine: 17, - location: '/project/src/routes/page.tsx:17:11', - }, - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain( - '<ClientOnly fallback={<Loading />}>...</ClientOnly>', - ) - expect(formatted).toContain('createClientOnlyFn') - expect(formatted).toContain('createIsomorphicFn') - }) - - test('specifier violation in client env gets server-in-client suggestions', () => { - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'specifier', - behavior: 'error', - pattern: '@tanstack/react-start/server', - specifier: '@tanstack/react-start/server', - importer: '/project/src/routes/index.tsx', - trace: [], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain('createServerFn') - expect(formatted).toContain('createServerOnlyFn') - expect(formatted).toContain('createIsomorphicFn') - }) - - test('marker violation in server env gets client-in-server suggestions', () => { - const info: ViolationInfo = { - env: 'ssr', - envType: 'server', - type: 'marker', - behavior: 'error', - specifier: '@tanstack/react-start/client-only', - importer: '/project/src/routes/page.tsx', - trace: [], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Suggestions:') - expect(formatted).toContain('createClientOnlyFn') - expect(formatted).toContain('createIsomorphicFn') - }) - - test('relativizes absolute-path specifiers in Import line and trace steps', () => { - // When an alias (e.g. ~/) is resolved by a transform plugin before - // resolveId, the specifier stored in the graph can be an absolute path. - // formatViolation should display it as a root-relative path. - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'file', - behavior: 'error', - pattern: '**/client/**', - specifier: '/project/src/utils/prisma', - importer: '/project/src/routes/signup.tsx', - resolved: '/project/src/utils/prisma.ts', - trace: [ - { file: '/project/src/routes/signup.tsx' }, - { - file: '/project/src/routes/signup.tsx', - specifier: '/project/src/utils/prisma', - }, - ], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Import: "src/utils/prisma"') - expect(formatted).not.toContain('Import: "/project/src/utils/prisma"') - - expect(formatted).toContain('(import "src/utils/prisma")') - expect(formatted).not.toContain('(import "/project/src/utils/prisma")') - }) - - test('leaves non-absolute specifiers unchanged', () => { - const info: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'specifier', - behavior: 'error', - pattern: '@tanstack/react-start/server', - specifier: '@tanstack/react-start/server', - importer: '/project/src/routes/index.tsx', - trace: [ - { - file: '/project/src/routes/index.tsx', - specifier: './secret.server', - }, - ], - } - - const formatted = formatViolation(info, '/project') - - expect(formatted).toContain('Import: "@tanstack/react-start/server"') - expect(formatted).toContain('(import "./secret.server")') - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/utils.test.ts b/packages/start-plugin-core/tests/importProtection/utils.test.ts deleted file mode 100644 index dfef591aca..0000000000 --- a/packages/start-plugin-core/tests/importProtection/utils.test.ts +++ /dev/null @@ -1,413 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { getImportSources } from '../../src/import-protection/analysis' -import { escapeRegExp } from '../../src/utils' - -import { - buildResolutionCandidates, - buildSourceCandidates, - canonicalizeResolvedId, - checkFileDenial, - dedupeViolationKey, - dedupePatterns, - getOrCreate, - isInsideDirectory, - isFileExcluded, - normalizeFilePath, - relativizePath, - shouldDeferViolation, - stripQuery, - stripQueryAndHash, - withoutKnownExtension, -} from '../../src/import-protection/utils' -import { compileMatchers } from '../../src/import-protection/matchers' -import { formatViolation } from '../../src/import-protection/trace' - -describe('dedupePatterns', () => { - test('dedupes strings and preserves first occurrence order', () => { - expect(dedupePatterns(['a', 'b', 'a', 'c', 'b'])).toEqual(['a', 'b', 'c']) - }) - - test('dedupes regexes by toString() and preserves first occurrence order', () => { - const a1 = /foo/i - const a2 = /foo/i - const b = /bar/ - - const out = dedupePatterns([a1, b, a2, b]) - expect(out).toEqual([a1, b]) - }) - - test('treats strings and regexes as distinct keys', () => { - const out = dedupePatterns(['/foo/i', /foo/i, '/foo/i', /foo/i]) - expect(out).toEqual(['/foo/i', /foo/i]) - }) - - test('returns empty array for empty input', () => { - expect(dedupePatterns([])).toEqual([]) - }) -}) - -describe('stripQueryAndHash', () => { - test('strips ?query params', () => { - expect(stripQueryAndHash('/a/b.ts?x=1')).toBe('/a/b.ts') - }) - - test('strips #fragments', () => { - expect(stripQueryAndHash('/a/b.ts#hash')).toBe('/a/b.ts') - }) - - test('strips whichever comes first of ? and #', () => { - expect(stripQueryAndHash('/a/b.ts?x=1#hash')).toBe('/a/b.ts') - expect(stripQueryAndHash('/a/b.ts#hash?x=1')).toBe('/a/b.ts') - }) - - test('returns path unchanged when no query or fragment', () => { - expect(stripQueryAndHash('/a/b.ts')).toBe('/a/b.ts') - }) -}) - -describe('stripQuery', () => { - test('strips query params only', () => { - expect(stripQuery('/a/b.ts?x=1')).toBe('/a/b.ts') - expect(stripQuery('/a/b.ts#hash')).toBe('/a/b.ts#hash') - }) -}) - -describe('withoutKnownExtension', () => { - test('removes known source extension', () => { - expect(withoutKnownExtension('/a/b.ts')).toBe('/a/b') - expect(withoutKnownExtension('/a/b.tsx')).toBe('/a/b') - }) - - test('keeps unknown extension', () => { - expect(withoutKnownExtension('/a/b.css')).toBe('/a/b.css') - }) -}) - -describe('buildSourceCandidates', () => { - test('includes source and resolved variants', () => { - const out = buildSourceCandidates('src/mod.ts', '/app/src/mod.ts', '/app') - expect(out.has('src/mod.ts')).toBe(true) - expect(out.has('src/mod')).toBe(true) - expect(out.has('/app/src/mod.ts')).toBe(true) - expect(out.has('/app/src/mod')).toBe(true) - expect(out.has('./src/mod.ts')).toBe(true) - expect(out.has('/src/mod.ts')).toBe(true) - }) -}) - -describe('checkFileDenial', () => { - test('returns matching file matcher when file is denied', () => { - const matchers = { - files: compileMatchers(['**/*.server.*']), - excludeFiles: compileMatchers([]), - } - - const result = checkFileDenial('src/secret.server.ts', matchers) - - expect(result?.pattern).toBe('**/*.server.*') - }) - - test('returns undefined when file is excluded', () => { - const matchers = { - files: compileMatchers(['**/*.server.*']), - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - expect( - checkFileDenial('node_modules/pkg/index.server.js', matchers), - ).toBeUndefined() - }) -}) - -describe('isFileExcluded', () => { - test('returns true when exclude matcher matches', () => { - const matchers = { - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - expect(isFileExcluded('node_modules/pkg/index.server.js', matchers)).toBe( - true, - ) - }) - - test('returns false when exclude matcher does not match', () => { - const matchers = { - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - expect(isFileExcluded('src/secret.server.ts', matchers)).toBe(false) - }) -}) - -describe('buildResolutionCandidates', () => { - test('returns deduped id variants', () => { - expect(buildResolutionCandidates('/a/b.ts?x=1')).toEqual([ - '/a/b.ts?x=1', - '/a/b.ts', - ]) - }) -}) - -describe('canonicalizeResolvedId', () => { - test('normalizes and resolves non-absolute ids against root', () => { - const root = process.cwd().replaceAll('\\', '/') - expect(canonicalizeResolvedId('src/a.ts?x=1', root, (id) => id)).toBe( - `${root}/src/a.ts`, - ) - }) - - test('keeps absolute ids as absolute', () => { - expect( - canonicalizeResolvedId('/app/src/a.ts?x=1', '/app', (id) => id), - ).toBe('/app/src/a.ts') - }) -}) - -describe('shouldDeferViolation', () => { - test('defers in build mode', () => { - expect(shouldDeferViolation({ isBuild: true, isDevMock: false })).toBe(true) - }) - - test('defers in dev mock mode', () => { - expect(shouldDeferViolation({ isBuild: false, isDevMock: true })).toBe(true) - }) - - test('defers in build + dev mock', () => { - expect(shouldDeferViolation({ isBuild: true, isDevMock: true })).toBe(true) - }) - - test('does not defer in dev error mode', () => { - expect(shouldDeferViolation({ isBuild: false, isDevMock: false })).toBe( - false, - ) - }) -}) - -describe('dedupeViolationKey', () => { - test('includes resolved path when present', () => { - expect( - dedupeViolationKey({ - type: 'file', - importer: '/app/src/a.ts', - specifier: './secret.server', - resolved: '/app/src/secret.server.ts', - }), - ).toBe('file:/app/src/a.ts:./secret.server:/app/src/secret.server.ts') - }) - - test('uses empty resolved segment when resolved is absent', () => { - expect( - dedupeViolationKey({ - type: 'specifier', - importer: '/app/src/a.ts', - specifier: '@tanstack/react-start/server', - }), - ).toBe('specifier:/app/src/a.ts:@tanstack/react-start/server:') - }) -}) - -describe('isInsideDirectory', () => { - test('returns true for file inside directory', () => { - expect(isInsideDirectory('/app/src/foo.ts', '/app/src')).toBe(true) - }) - - test('returns true for file in nested subdirectory', () => { - expect(isInsideDirectory('/app/src/deep/nested/foo.ts', '/app/src')).toBe( - true, - ) - }) - - test('returns false for sibling directory with same prefix', () => { - expect(isInsideDirectory('/app/src2/foo.ts', '/app/src')).toBe(false) - }) - - test('returns false for parent directory', () => { - expect(isInsideDirectory('/app/foo.ts', '/app/src')).toBe(false) - }) - - test('returns false for exact directory match (no file inside)', () => { - expect(isInsideDirectory('/app/src', '/app/src')).toBe(false) - }) -}) - -describe('normalizeFilePath', () => { - test('strips query params', () => { - expect(normalizeFilePath('/a/b.ts?v=123')).toBe('/a/b.ts') - }) - - test('returns plain path unchanged', () => { - expect(normalizeFilePath('/a/b.ts')).toBe('/a/b.ts') - }) - - test('returns cached result on second call', () => { - const input = '/unique/cache-test/file.ts?q=1' - const first = normalizeFilePath(input) - const second = normalizeFilePath(input) - expect(first).toBe(second) - expect(first).toBe('/unique/cache-test/file.ts') - }) - - test('handles path with both query and hash', () => { - expect(normalizeFilePath('/a/b.ts?x=1#hash')).toBe('/a/b.ts') - }) -}) - -describe('getImportSources', () => { - test('extracts static import sources', () => { - const code = `import { foo } from 'bar'\nimport baz from "qux"` - expect(getImportSources(code)).toEqual(['bar', 'qux']) - }) - - test('skips type-only static import sources', () => { - const code = [ - `import type { Foo } from './foo.server'`, - `import { type Bar } from './bar.server'`, - ].join('\n') - expect(getImportSources(code)).toEqual([]) - }) - - test('keeps mixed type and value static import sources', () => { - const code = `import { type Foo, bar } from './mixed.server'` - expect(getImportSources(code)).toEqual(['./mixed.server']) - }) - - test('keeps side-effect import sources', () => { - const code = `import './setup.server'` - expect(getImportSources(code)).toEqual(['./setup.server']) - }) - - test('extracts re-export sources', () => { - const code = `export { a } from './mod'\nexport * from "./other"` - expect(getImportSources(code)).toEqual(['./mod', './other']) - }) - - test('skips type-only re-export sources', () => { - const code = [ - `export type { Foo } from './foo.server'`, - `export { type Bar } from './bar.server'`, - `export type * from './baz.server'`, - ].join('\n') - expect(getImportSources(code)).toEqual([]) - }) - - test('keeps mixed type and value re-export sources', () => { - const code = `export { type Foo, bar } from './mixed.server'` - expect(getImportSources(code)).toEqual(['./mixed.server']) - }) - - test('extracts dynamic import sources', () => { - const code = `const m = import('./lazy')\nconst n = import("./lazy2")` - expect(getImportSources(code)).toEqual(['./lazy', './lazy2']) - }) - - test('handles mixed import styles', () => { - const code = [ - `import { a } from 'static'`, - `export { b } from './reexport'`, - `const c = import('./dynamic')`, - ].join('\n') - expect(getImportSources(code)).toEqual([ - 'static', - './reexport', - './dynamic', - ]) - }) - - test('extracts imports from decorated modules', () => { - const code = [ - `@sealed class Example {}`, - `import { value } from 'broken'`, - ].join('\n') - expect(getImportSources(code)).toEqual(['broken']) - }) - - test('returns empty array for code with no imports', () => { - expect(getImportSources('const x = 1')).toEqual([]) - }) - - test('handles empty string', () => { - expect(getImportSources('')).toEqual([]) - }) - - test('does not match import in comments or strings', () => { - const code = `// import { x } from 'commented'` - expect(getImportSources(code)).toEqual([]) - }) - - test('extracts import attributes syntax', () => { - const code = `import data from './data.json' with { type: 'json' }` - expect(getImportSources(code)).toEqual(['./data.json']) - }) -}) - -describe('escapeRegExp', () => { - test('escapes special regex characters', () => { - expect(escapeRegExp('a.b*c?d')).toBe('a\\.b\\*c\\?d') - }) - - test('escapes all special characters', () => { - const specials = '.*+?^${}()|[]\\' - const escaped = escapeRegExp(specials) - expect(new RegExp(escaped).test(specials)).toBe(true) - }) - - test('returns plain strings unchanged', () => { - expect(escapeRegExp('foobar')).toBe('foobar') - }) - - test('handles empty string', () => { - expect(escapeRegExp('')).toBe('') - }) -}) - -describe('getOrCreate', () => { - test('creates value when key is absent', () => { - const map = new Map<string, Array<number>>() - const result = getOrCreate(map, 'a', () => [1, 2]) - expect(result).toEqual([1, 2]) - expect(map.get('a')).toBe(result) - }) - - test('returns existing value without calling factory', () => { - const map = new Map<string, Array<number>>([['a', [1]]]) - let factoryCalled = false - const result = getOrCreate(map, 'a', () => { - factoryCalled = true - return [99] - }) - expect(result).toEqual([1]) - expect(factoryCalled).toBe(false) - }) - - test('works with Set values', () => { - const map = new Map<string, Set<string>>() - const set = getOrCreate(map, 'k', () => new Set()) - set.add('v') - expect(map.get('k')?.has('v')).toBe(true) - }) -}) - -describe('relativizePath', () => { - test('strips root prefix and leading slash', () => { - expect( - relativizePath('/Users/foo/project/src/bar.ts', '/Users/foo/project'), - ).toBe('src/bar.ts') - }) - - test('returns path as-is when it does not start with root', () => { - expect(relativizePath('some-module', '/Users/foo/project')).toBe( - 'some-module', - ) - }) - - test('handles root with trailing content that is not a separator', () => { - // /Users/foo/project-extra should NOT match root /Users/foo/project - expect( - relativizePath('/Users/foo/project-extra/bar.ts', '/Users/foo/project'), - ).toBe('/Users/foo/project-extra/bar.ts') - }) - - test('returns empty string when path equals root + slash', () => { - expect(relativizePath('/Users/foo/project/', '/Users/foo/project')).toBe('') - }) -}) diff --git a/packages/start-plugin-core/tests/importProtection/virtualModules.test.ts b/packages/start-plugin-core/tests/importProtection/virtualModules.test.ts deleted file mode 100644 index 70f174650c..0000000000 --- a/packages/start-plugin-core/tests/importProtection/virtualModules.test.ts +++ /dev/null @@ -1,350 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - MOCK_EDGE_PREFIX, - MOCK_MODULE_ID, - MOCK_RUNTIME_PREFIX, - generateDevSelfDenialModule, - generateSelfContainedMockModule, - loadMarkerModule, - loadMockEdgeModule, - loadMockRuntimeModule, - loadSilentMockModule, - makeMockEdgeModuleId, - mockRuntimeModuleIdFromViolation, -} from '../../src/vite/import-protection-plugin/virtualModules' -import type { ViolationInfo } from '../../src/import-protection/trace' - -type MockValue = { - toString: () => string - valueOf: () => string - toJSON: () => string -} - -type MockFunction = { - (): MockValue -} - -function evaluateGeneratedModule<T>(code: string): T { - const exports: Record<string, unknown> = {} - const runnableCode = code - .replace(/export default mock;?/g, 'exports.default = mock;') - .replace(/export const ([A-Za-z_$][\w$]*) = ([^;]+);/g, 'exports.$1 = $2;') - - new Function('exports', runnableCode)(exports) - return exports as T -} - -describe('loadSilentMockModule', () => { - test('returns mock code', () => { - const result = loadSilentMockModule() - expect(result.code).toContain('export default mock') - expect(result.code).toContain('createMock') - expect(result.code).toContain('Proxy') - expect(result.code).toContain('@__NO_SIDE_EFFECTS__') - expect(result.code).toContain('@__PURE__') - }) - - test('supports primitive conversion for called mocks', () => { - const result = loadSilentMockModule() - const mod = evaluateGeneratedModule<{ default: MockFunction }>(result.code) - const value = mod.default() - - expect(String(value)).toBe('[import-protection mock]') - expect(value.toString()).toBe('[import-protection mock]') - expect(value.valueOf()).toBe('[import-protection mock]') - expect(JSON.stringify(value)).toBe('"[import-protection mock]"') - }) -}) - -describe('loadMarkerModule', () => { - test('returns empty module', () => { - const result = loadMarkerModule() - expect(result.code).toBe('export {}') - }) -}) - -describe('loadMockEdgeModule', () => { - test('generates named exports from payload', () => { - const payload = JSON.stringify({ - exports: ['getSecret', 'initDb'], - runtimeId: MOCK_MODULE_ID, - }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockEdgeModule(encoded) - - expect(result.code).toContain('export const getSecret') - expect(result.code).toContain('export const initDb') - expect(result.code).toContain('export default mock') - }) - - test('handles empty exports array', () => { - const payload = JSON.stringify({ - exports: [], - runtimeId: MOCK_MODULE_ID, - }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockEdgeModule(encoded) - - expect(result.code).toContain('export default mock') - expect(result.code).not.toContain('export const') - }) - - test('handles string-keyed (non-identifier) export names via re-export', () => { - const payload = JSON.stringify({ - exports: ['valid', 'default', '123invalid', 'also-invalid'], - runtimeId: MOCK_MODULE_ID, - }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockEdgeModule(encoded) - - // Valid identifier: direct const export - expect(result.code).toContain('export const valid') - // 'default' is filtered out - expect(result.code).not.toContain('export const default') - // Non-identifiers get string-keyed re-exports - expect(result.code).toContain('__tss_str_') - expect(result.code).toContain('"123invalid"') - expect(result.code).toContain('"also-invalid"') - }) - - test('handles malformed base64', () => { - const result = loadMockEdgeModule('not-valid-base64!!!') - expect(result.code).toContain('export default mock') - }) - - test('falls back to MOCK_MODULE_ID when runtimeId missing', () => { - const payload = JSON.stringify({ - exports: ['a'], - }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockEdgeModule(encoded) - - expect(result.code).toContain(MOCK_MODULE_ID) - }) -}) - -describe('loadMockRuntimeModule', () => { - test('generates runtime diagnostic module with error mode', () => { - const payload = JSON.stringify({ - mode: 'error', - env: 'client', - importer: '/src/routes/index.tsx', - specifier: './secret.server', - trace: ['src/main.tsx', 'src/routes/index.tsx'], - }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockRuntimeModule(encoded) - - expect(result.code).toContain('__report') - expect(result.code).toContain('console.error') - expect(result.code).toContain('"error"') - expect(result.code).toContain('export default mock') - }) - - test('generates warn mode module', () => { - const payload = JSON.stringify({ mode: 'warn' }) - const encoded = Buffer.from(payload, 'utf8').toString('base64url') - const result = loadMockRuntimeModule(encoded) - - expect(result.code).toContain('"warn"') - expect(result.code).toContain('console.warn') - }) - - test('handles malformed payload gracefully', () => { - const result = loadMockRuntimeModule('bad-data') - expect(result.code).toContain('export default mock') - }) -}) - -describe('mockRuntimeModuleIdFromViolation', () => { - const baseViolation: ViolationInfo = { - env: 'client', - envType: 'client', - type: 'file', - behavior: 'mock', - specifier: './secret.server', - importer: '/project/src/routes/index.tsx', - trace: [ - { file: '/project/src/main.tsx' }, - { file: '/project/src/routes/index.tsx', specifier: './secret.server' }, - ], - } - - test('returns MOCK_MODULE_ID when mode is off', () => { - const id = mockRuntimeModuleIdFromViolation( - baseViolation, - 'off', - '/project', - ) - expect(id).toBe(MOCK_MODULE_ID) - }) - - test('returns MOCK_MODULE_ID for non-client env', () => { - const ssrViolation = { ...baseViolation, env: 'ssr' } - const id = mockRuntimeModuleIdFromViolation( - ssrViolation, - 'error', - '/project', - ) - expect(id).toBe(MOCK_MODULE_ID) - }) - - test('returns runtime module ID for client env with error mode', () => { - const id = mockRuntimeModuleIdFromViolation( - baseViolation, - 'error', - '/project', - ) - expect(id.startsWith(MOCK_RUNTIME_PREFIX)).toBe(true) - const encoded = id.slice(MOCK_RUNTIME_PREFIX.length) - const payload = JSON.parse( - Buffer.from(encoded, 'base64url').toString('utf8'), - ) - expect(payload.env).toBe('client') - expect(payload.mode).toBe('error') - expect(payload.specifier).toBe('./secret.server') - }) - - test('includes relative trace paths', () => { - const id = mockRuntimeModuleIdFromViolation( - baseViolation, - 'warn', - '/project', - ) - const encoded = id.slice(MOCK_RUNTIME_PREFIX.length) - const payload = JSON.parse( - Buffer.from(encoded, 'base64url').toString('utf8'), - ) - expect(payload.trace[0]).toBe('src/main.tsx') - }) - - test('includes line numbers in trace when present', () => { - const violation: ViolationInfo = { - ...baseViolation, - trace: [ - { file: '/project/src/main.tsx' }, - { - file: '/project/src/routes/index.tsx', - specifier: './secret.server', - line: 5, - column: 10, - }, - ], - } - const id = mockRuntimeModuleIdFromViolation(violation, 'error', '/project') - const encoded = id.slice(MOCK_RUNTIME_PREFIX.length) - const payload = JSON.parse( - Buffer.from(encoded, 'base64url').toString('utf8'), - ) - expect(payload.trace[1]).toBe('src/routes/index.tsx:5:10') - }) -}) - -describe('makeMockEdgeModuleId', () => { - test('encodes exports into module ID payload', () => { - const id = makeMockEdgeModuleId(['foo', 'bar'], MOCK_MODULE_ID) - expect(id.startsWith(MOCK_EDGE_PREFIX)).toBe(true) - const encoded = id.slice(MOCK_EDGE_PREFIX.length) - const payload = JSON.parse( - Buffer.from(encoded, 'base64url').toString('utf8'), - ) - expect(payload.exports).toEqual(['foo', 'bar']) - expect(payload.runtimeId).toBe(MOCK_MODULE_ID) - }) - - test('handles empty exports', () => { - const id = makeMockEdgeModuleId([], MOCK_MODULE_ID) - const encoded = id.slice(MOCK_EDGE_PREFIX.length) - const payload = JSON.parse( - Buffer.from(encoded, 'base64url').toString('utf8'), - ) - expect(payload.exports).toEqual([]) - }) -}) - -describe('generateSelfContainedMockModule', () => { - test('generates module with named exports', () => { - const result = generateSelfContainedMockModule(['getSecret', 'initDb']) - expect(result.code).toContain('export const getSecret = mock.getSecret;') - expect(result.code).toContain('export const initDb = mock.initDb;') - expect(result.code).toContain('export default mock') - expect(result.code).toContain('createMock') - expect(result.code).toContain('Proxy') - }) - - test('handles empty exports', () => { - const result = generateSelfContainedMockModule([]) - expect(result.code).toContain('export default mock') - expect(result.code).not.toContain('export const') - }) - - test('filters out default export', () => { - const result = generateSelfContainedMockModule(['default', 'foo']) - expect(result.code).toContain('export const foo = mock.foo;') - expect(result.code).not.toContain('export const default') - }) - - test('handles string-keyed (non-identifier) export names via re-export', () => { - const result = generateSelfContainedMockModule([ - 'valid', - '123invalid', - 'also-invalid', - ]) - expect(result.code).toContain('export const valid = mock.valid;') - expect(result.code).toContain('__tss_str_') - expect(result.code).toContain('"123invalid"') - expect(result.code).toContain('"also-invalid"') - }) - - test('is self-contained (no imports)', () => { - const result = generateSelfContainedMockModule(['foo']) - // Should not import from any other module - expect(result.code).not.toMatch(/^\s*import\s/m) - }) - - test('supports primitive conversion for named export calls', () => { - const result = generateSelfContainedMockModule(['getSecret']) - const mod = evaluateGeneratedModule<{ getSecret: MockFunction }>( - result.code, - ) - - expect(String(mod.getSecret())).toBe('[import-protection mock]') - }) -}) - -describe('generateDevSelfDenialModule', () => { - test('generates module with named exports and mock-runtime import', () => { - const runtimeId = 'tanstack-start-import-protection:mock-runtime:abc' - const result = generateDevSelfDenialModule( - ['getSecret', 'initDb'], - runtimeId, - ) - expect(result.code).toContain(`import mock from "${runtimeId}"`) - expect(result.code).toContain('export const getSecret = mock.getSecret;') - expect(result.code).toContain('export const initDb = mock.initDb;') - expect(result.code).toContain('export default mock;') - }) - - test('handles empty exports', () => { - const runtimeId = MOCK_MODULE_ID - const result = generateDevSelfDenialModule([], runtimeId) - expect(result.code).toContain(`import mock from "${runtimeId}"`) - expect(result.code).toContain('export default mock;') - expect(result.code).not.toContain('export const') - }) - - test('filters out default export', () => { - const result = generateDevSelfDenialModule(['default', 'foo'], 'mock-rt:x') - expect(result.code).toContain('export const foo = mock.foo;') - expect(result.code).not.toContain('export const default') - expect(result.code).toContain('export default mock;') - }) - - test('imports mock-runtime (not self-contained)', () => { - const result = generateDevSelfDenialModule(['foo'], 'mock-rt:xyz') - expect(result.code).toMatch(/\bimport\b/) - // Should NOT contain inline createMock/Proxy (that's the build-mode mock) - expect(result.code).not.toContain('createMock') - expect(result.code).not.toContain('Proxy') - }) -}) diff --git a/packages/start-plugin-core/tests/integration/clientOnlyJSX.test.ts b/packages/start-plugin-core/tests/integration/clientOnlyJSX.test.ts new file mode 100644 index 0000000000..9695d230a1 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/clientOnlyJSX.test.ts @@ -0,0 +1,209 @@ +/** + * `<ClientOnly>` in a real page: the server renders the fallback, the page + * hydrates that HTML without a mismatch and then renders the children, which + * the client output keeps (the server half, with the children's libraries + * throwing on the server, is clientOnlyJSX/clientOnlyJSX.test.ts). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { reportedViolations } from '../importProtection/start-apps' +import { buildHydrationApp } from './hydrate-pages' +import type { HydrationApp } from './hydrate-pages' + +/** An installed library exporting components that render `<tag>`. */ +const library = (name: string, components: Record<string, string>) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: `import { createElement } from 'react' +${Object.entries(components) + .map( + ([component, tag]) => + `export const ${component} = () => createElement(${JSON.stringify(tag)})`, + ) + .join('\n')} +`, +}) + +const fixtures = { + basic: `import { ClientOnly } from '@tanstack/react-router' +import { Chart } from 'heavy-chart-library' +import { formatData } from '../utils' +export function Page() { + return ( + <div> + <ClientOnly fallback={<div>Loading...</div>}> + <Chart data={formatData()} /> + </ClientOnly> + </div> + ) +}`, + multiple: `import { ClientOnly } from '@tanstack/react-router' +import { VideoPlayer } from 'video-player-lib' +import { AudioVisualizer } from 'audio-viz-lib' +export function Page() { + return ( + <div> + <ClientOnly fallback={<span>Loading video...</span>}> + <VideoPlayer src="/video.mp4" /> + </ClientOnly> + <p>Some server content</p> + <ClientOnly fallback={<span>Loading audio...</span>}> + <AudioVisualizer frequency={440} /> + </ClientOnly> + </div> + ) +}`, + nested: `import { ClientOnly } from '@tanstack/react-router' +import { OuterWidget } from 'outer-lib' +import { InnerWidget } from 'inner-lib' +export function Page() { + return ( + <div> + <ClientOnly fallback={<div>Outer loading</div>}> + <div> + Outer content + <OuterWidget /> + <ClientOnly fallback={<span>Inner loading</span>}> + <InnerWidget /> + </ClientOnly> + </div> + </ClientOnly> + </div> + ) +}`, + noFallback: `import { ClientOnly } from '@tanstack/react-router' +import { HeavyAnimation } from 'animation-library' +export function Page() { + return ( + <div> + <ClientOnly> + <HeavyAnimation type="fade" /> + </ClientOnly> + </div> + ) +}`, + clientFile: `import { ClientOnly } from '@tanstack/react-router' +import { Chart } from '../chart.client' +export function Page() { + return ( + <div> + <ClientOnly fallback={<div>Loading...</div>}> + <Chart /> + </ClientOnly> + </div> + ) +}`, + renamed: `import { ClientOnly as CO } from '@tanstack/react-router' +import { WindowSize } from '../WindowSize' +export function Page() { + return ( + <div> + <CO fallback={<div>Loading...</div>}> + <WindowSize /> + </CO> + </div> + ) +}`, +} + +let app: HydrationApp +const cleanups: Array<() => Promise<void>> = [] + +beforeAll(async () => { + app = await buildHydrationApp({ + fixtures, + files: { + ...library('heavy-chart-library', { Chart: 'chart-el' }), + ...library('video-player-lib', { VideoPlayer: 'video-el' }), + ...library('audio-viz-lib', { AudioVisualizer: 'audio-el' }), + ...library('animation-library', { HeavyAnimation: 'animation-el' }), + ...library('outer-lib', { OuterWidget: 'outer-el' }), + ...library('inner-lib', { InnerWidget: 'inner-el' }), + 'src/utils.ts': `export const formatData = () => 'data'\n`, + // (a top-level effect, which a bundler keeps in any module it bundles) + 'src/WindowSize.tsx': `;(globalThis as Record<string, unknown>).MARK_WINDOW_SIZE_LOADED = true +export const WindowSize = () => <size-el /> +`, + 'src/chart.client.tsx': `export const Chart = () => <client-chart-el data-mark="MARK_CLIENT_CHART" />\n`, + }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) +}, 60_000) + +afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) +}) + +describe('<ClientOnly> in a hydrated page', () => { + // Source: snapshot fixtures clientOnlyBasic/Multiple/Nested/NoFallback/Renamed.tsx + test.each([ + { + name: 'basic', + server: '<div><div>Loading...</div></div>', + client: '<div><chart-el></chart-el></div>', + }, + { + name: 'multiple', + server: + '<div><span>Loading video...</span><p>Some server content</p><span>Loading audio...</span></div>', + client: + '<div><video-el></video-el><p>Some server content</p><audio-el></audio-el></div>', + }, + { + name: 'nested', + server: '<div><div>Outer loading</div></div>', + client: + '<div><div>Outer content<outer-el></outer-el><inner-el></inner-el></div></div>', + }, + { + name: 'noFallback', + server: '<div></div>', + client: '<div><animation-el></animation-el></div>', + }, + { + name: 'renamed', + server: '<div><div>Loading...</div></div>', + client: '<div><size-el></size-el></div>', + }, + { + name: 'clientFile', + server: '<div><div>Loading...</div></div>', + client: + '<div><client-chart-el data-mark="MARK_CLIENT_CHART"></client-chart-el></div>', + }, + ])( + '$name: the server renders the fallback and the hydrated page the children', + async ({ name, server, client }) => { + const page = await app.hydrate(name) + expect(page.serverHtml).toBe(server) + expect({ + html: page.html, + recoverableErrors: page.recoverableErrors, + consoleErrors: page.consoleErrors, + }).toEqual({ html: client, recoverableErrors: [], consoleErrors: [] }) + }, + ) +}) + +// A module import protection denies on the server (`*.client.*`) that only +// the children of a `<ClientOnly>` use is eliminated from the server build +// (the build above reports no import-protection violation: by default a +// violation fails a build) and its code is not in the server bundle. +// Source: SPEC J4.11. +test('a *.client.* module only ClientOnly children use is not in the server build', () => { + expect( + // (everything the build reported, on every channel) + reportedViolations(app.build), + ).toEqual([]) + expect(app.build.ssr.where('MARK_CLIENT_CHART')).toBe('nowhere') + expect(app.build.client.where('MARK_CLIENT_CHART')).not.toBe('nowhere') +}) + +// So is a neutral module (`src/WindowSize.tsx`, the `renamed` fixture): +// the server build neither bundles nor runs it (SPEC J4.11, G16). +test('a neutral module only ClientOnly children use is not in the server build', () => { + expect(app.build.ssr.where('MARK_WINDOW_SIZE_LOADED')).toBe('nowhere') + expect(app.build.client.where('MARK_WINDOW_SIZE_LOADED')).not.toBe('nowhere') +}) diff --git a/packages/start-plugin-core/tests/integration/hydrate-build-cases.ts b/packages/start-plugin-core/tests/integration/hydrate-build-cases.ts new file mode 100644 index 0000000000..ad8b8cedc7 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-build-cases.ts @@ -0,0 +1,772 @@ +/** + * `<Hydrate>` in real builds (Start's Vite and Rsbuild plugins) and on Vite + * and Rsbuild dev servers, with the real `@tanstack/react-start`, React and + * router. Where the children's code ends up is the bundler's decision (with + * the side-effect hints of the app), so it is asserted on build output. + * That the children hydrate is asserted like a browser sees it: the server + * build renders a page to HTML with `react-dom/server`, a page of headless + * Chromium loads the client build, hydrates that HTML with `hydrateRoot` + * (recoverable errors and `console.error` recorded) and clicks each child, + * whose button then shows that it was clicked: the child hydrated, with its + * own code, in the boundary the server rendered it in. + */ +import { afterAll, describe, expect, test } from 'vitest' +import { originalFrameOf } from '@tanstack/compiler-test-utils/build-harness' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { + diagnosticPosition, + expectDiagnostic, +} from '@tanstack/compiler-test-utils/diagnostics' +import { StartBuildError, buildStart } from '../build-harness' +import type { StartBuild, StartBundler } from '../build-harness' + +const timeout = 60_000 + +/** A clickable child: `<button>` showing `label`, then `label clicked`. */ +const toggleSource = `import { useState } from 'react' +export function Toggle(props: { label: string }) { + const [clicked, setClicked] = useState(false) + return <button onClick={() => setClicked(true)}>{props.label}{clicked ? ' clicked' : ''}</button> +} +` + +/** The entries of an app whose pages `src/pages.ts` exports (`pages`). */ +const pageEntries = { + 'entry-server.ts': `export * as pages from './src/pages' +export { createElement } from 'react' +export { renderToReadableStream } from 'react-dom/server' +`, + 'entry-client.ts': `export * as pages from './src/pages' +export { createElement } from 'react' +export { createRoot, hydrateRoot } from 'react-dom/client' +`, +} +const entry = { client: 'entry-client.ts', ssr: 'entry-server.ts' } + +/** + * Server-renders every export of `pages` (a component) to HTML, like Start's + * SSR: `renderToReadableStream`, all Suspense boundaries ready. A page whose + * render fails gives its error. + */ +async function renderPages(build: StartBuild) { + const { result } = await build.ssr.run(`const html = {} +for (const [name, Page] of Object.entries(entry.pages)) { + try { + const stream = await entry.renderToReadableStream(entry.createElement(Page)) + await stream.allReady + html[name] = await new Response(stream).text() + } catch (error) { + html[name] = { error: String(error) } + } +} +return html`) + return result as Record<string, string | { error: string }> +} + +/** What hydrating a page showed (`hydratePage`). */ +interface Hydrated { + /** The value of the `read` expression after the clicks, if any. */ + read?: unknown + /** The page's text after the clicks. */ + text: string + /** Errors given to `onRecoverableError` (e.g. a hydration mismatch). */ + recoverableErrors: Array<string> + /** What the page logged with `console.error`. */ + consoleErrors: Array<string> +} + +/** + * Hydrates the server HTML of the page `name` (`html`) in a page of the + * client build, then clicks each button whose text contains a label of + * `click` (again every 20 ms, while it hydrates) until it shows `<label> + * clicked`. + * `read` is an expression the page evaluates last. + */ +async function hydratePage( + build: StartBuild, + html: string, + name: string, + click: Array<string>, + read?: string, +): Promise<Hydrated> { + const { result } = await build.client.run(`const recoverableErrors = [] +const consoleErrors = [] +const logError = console.error +console.error = (...args) => { + consoleErrors.push(args.map(String).join(' ')) + logError(...args) +} +const root = document.getElementById('root') +root.innerHTML = ${JSON.stringify(html)} +entry.hydrateRoot(root, entry.createElement(entry.pages[${JSON.stringify(name)}]), { + onRecoverableError: (error) => recoverableErrors.push(String(error)), +}) +const button = (label) => + [...root.querySelectorAll('button')].find((candidate) => candidate.textContent.includes(label)) +const requestsAt = [] +const deadline = Date.now() + 10_000 +for (const label of ${JSON.stringify(click)}) { + while (!button(label)?.textContent.includes(label + ' clicked')) { + if (Date.now() > deadline) { + throw new Error('child did not respond to clicks: ' + label + ': ' + root.innerHTML) + } + button(label)?.click() + await new Promise((resolve) => setTimeout(resolve, 20)) + } + requestsAt.push(performance.getEntriesByType('resource').map((entry) => new URL(entry.name).pathname)) +} +return { + text: root.textContent, + recoverableErrors, + consoleErrors,${read ? `\n read: ${read},` : ''} +}`) + return result as Hydrated +} + +export function hydrateBuildSuite(bundler: StartBundler) { + describe(`${bundler} build`, () => { + // One production build (minified, with source maps) of every page below; + // each test reads its own page (its own markers and modules). + let shared: Promise<StartBuild> | undefined + let sharedHtml: ReturnType<typeof renderPages> | undefined + let disposeShared: (() => Promise<void>) | undefined + const sharedApp = () => + (shared ??= buildStart({ + bundler, + entry, + sourcemap: true, + registerCleanup: (cleanup) => { + disposeShared = cleanup + }, + files: { ...pageEntries, ...sharedFiles }, + })) + afterAll(() => disposeShared?.()) + + /** The page `name` of the shared build, hydrated (`hydratePage`). */ + async function hydrateShared( + name: string, + click: Array<string>, + read?: string, + ) { + const build = await sharedApp() + const html = (await (sharedHtml ??= renderPages(build)))[name] + expect(typeof html, `server render of ${name}`).toBe('string') + return hydratePage(build, html as string, name, click, read) + } + + // When the parent's own module-level code (`formatValue('Revenue')`) + // runs is left open: in the eager code or in the lazy chunk, not both. + // So is where the chart's code goes when the page also imports the + // package's barrel eagerly and the package has no side-effect hints: the + // barrel evaluates the chart module, and whether its code may wait for the + // chunk is the bundler's call (both keep it eager with the real React). + // Source: hydrate-split-modules.test.ts "bindings only the split children + // use leave the parent", "server: bindings only the stripped fallback uses + // are removed"; hydrate-captures.test.ts "a destructured loop variable…, + // module helpers move" (placement). + test.each([ + { + name: 'a project module', + page: 'chartProject', + key: 'project', + chart: ['lazy'], + }, + { + // The barrel is eager (the page logs `Other`). + name: 'a package without side-effect hints', + page: 'chartPlainWidgets', + key: 'plain-widgets', + chart: ['lazy', 'eager'], + }, + { + name: 'a package marked "sideEffects": false', + page: 'chartPureWidgets', + key: 'pure-widgets', + chart: ['lazy'], + }, + ])( + 'with the chart from $name, the server drops the fallback and the chart hydrates', + async ({ page, key, chart }) => { + const build = await sharedApp() + expect(chart).toContain(build.client.where(`${key}-chart-marker`)) + expect({ + fallback: build.client.where(`${key}-fallback-marker`), + serverFallback: build.ssr.where(`${key}-fallback-marker`), + }).toEqual({ + fallback: 'eager', + serverFallback: 'nowhere', + }) + expect(['lazy', 'eager']).toContain( + build.client.where(`${key}-format-marker`), + ) + expect(await hydrateShared(page, [`${key}-chart-marker`])).toEqual({ + text: `Revenue ${key}-format-marker ${key}-chart-marker clicked`, + recoverableErrors: [], + consoleErrors: [], + }) + }, + timeout, + ) + + // Each boundary loads only its own children's code, and each child + // hydrates in its own boundary: an `interaction()` boundary hydrates when + // its server-rendered marker is clicked, which finds the boundary by the + // identity the server rendered. + test( + 'two boundaries each load their own children lazily and hydrate on their own interaction', + async () => { + const build = await sharedApp() + const chart = build.client.locate('two-chart-marker') + const table = build.client.locate('two-table-marker') + expect({ chart: chart.eager, table: table.eager }).toEqual({ + chart: [], + table: [], + }) + for (const [first, second, unopened] of [ + ['two-table-marker', 'two-chart-marker', chart.lazy], + ['two-chart-marker', 'two-table-marker', table.lazy], + ] as const) { + const hydrated = await hydrateShared( + 'twoBoundaries', + [first, second], + 'requestsAt', + ) + expect(hydrated).toMatchObject({ + text: 'two-chart-marker clicked two-table-marker clicked', + recoverableErrors: [], + consoleErrors: [], + }) + const [afterFirst, afterSecond] = hydrated.read as Array< + Array<string> + > + const requested = (urls: Array<string>) => + unopened.some((file) => + urls.some((url) => url.endsWith('/' + file)), + ) + expect(requested(afterFirst!)).toBe(false) + expect(requested(afterSecond!)).toBe(true) + } + }, + timeout, + ) + + // Module-level code only the children use is in the client once: a + // helper declaration in the lazy chunk; a destructuring of an import (an + // initializer, whose timing is left open) in the lazy chunk or the eager + // code. Either way the children hydrate with its values. + // Source: hydrate-split-modules.test.ts "the children read a + // module-level destructuring of an import" (placement), "helpers shared + // by two boundaries"; Qwik optimizer example_invalid_references + test( + 'module-level code only the children use is not duplicated', + async () => { + const build = await sharedApp() + expect(build.client.where('helper-marker')).toBe('lazy') + expect(['lazy', 'eager']).toContain(build.client.where('lib-marker')) + expect( + await hydrateShared('moduleLevel', ['lib-markerB helper-marker']), + ).toEqual({ + text: 'lib-markerB helper-marker clicked', + recoverableErrors: [], + consoleErrors: [], + }) + }, + timeout, + ) + + // A route whose split options (`component` and `pendingComponent`) + // contain boundaries: each boundary hydrates in the boundary the server + // rendered (`interaction()`, see above) and loads its own children. The + // route's groupings are its own (`codeSplitGroupings`); the default ones + // split `component` only, so `pendingComponent` stays in the route module + // and only its boundary's children are lazy. One page renders the three + // routes (their boundaries render at the same time, so their identities + // must not collide either). + let routes: Promise<Hydrated> | undefined + test.each([ + { name: 'in their own groupings', route: 'separateGroups' }, + { name: 'in one grouping', route: 'oneGroup' }, + { name: 'split and unsplit (default groupings)', route: 'defaultGroups' }, + ])( + 'boundaries in route options $name hydrate in the boundaries the server renders', + async ({ route }) => { + const build = await sharedApp() + expect(build.client.where(`${route}-page-marker`)).toBe('lazy') + expect(build.client.where(`${route}-pending-marker`)).toBe('lazy') + const hydrated = await (routes ??= hydrateShared( + 'routes', + sharedRoutes.flatMap((name) => [ + `${name}-page-marker`, + `${name}-pending-marker`, + ]), + )) + expect(hydrated.text).toContain( + `${route}-pending-marker clicked${route}-page-marker clicked`, + ) + expect(hydrated).toMatchObject({ + recoverableErrors: [], + consoleErrors: [], + }) + }, + timeout, + ) + + // Bug: a split component with a boundary that another route option + // reads (`head` reads `Page.name`) goes to a module the route module and + // the chunk share, without the lazy component of its boundary, which + // stays in the chunk: the shared module reads an undeclared name (the + // build harness rejects the client output). Root cause: the code + // splitter takes a JSX tag whose name starts with `_` for an intrinsic + // element and does not count it as a read of the binding, here a name + // the `<Hydrate>` transform generates (router-utils/src/ + // compiler-helpers.ts:268; same root cause as the `_Widget` row in + // router-plugin/tests/code-splitter-jsx.test.ts). + // Control: the "in their own groupings" row above (same route shape, + // without `head`). + // Source: fuzzing (real Start builds, Vite and Rsbuild). + // Impact: the route's component throws a ReferenceError when it + // renders, so the page never renders. + test.fails( + 'boundaries in split route options that another option reads hydrate in the boundaries the server renders', + async () => { + const build = await buildStart({ + bundler, + entry, + files: { + ...pageEntries, + 'src/toggle.tsx': toggleSource, + ...splitRouteFiles( + 'read', + `[['component'], ['pendingComponent']]`, + `\n head: () => ({ meta: [{ title: Page.name }] }),`, + ), + 'src/pages.ts': routesPageModule(['read']), + }, + }) + const html = (await renderPages(build)).routes + expect(typeof html).toBe('string') + expect( + await hydratePage(build, html as string, 'routes', [ + 'read-page-marker', + 'read-pending-marker', + ]), + ).toEqual({ + text: 'read-pending-marker clickedread-page-marker clicked', + recoverableErrors: [], + consoleErrors: [], + }) + }, + timeout, + ) + + // Control for the pin below (same build): an unused export without a + // boundary is not in the client. + test( + 'an unused exported component without a boundary is not in the client', + async () => { + const build = await sharedApp() + expect(build.client.where('unused-plain-marker')).toBe('nowhere') + }, + timeout, + ) + + // Bug: the client parent declares the lazy component of each boundary + // with a module-level call (`lazyRouteComponent(() => import(...))`) + // that bundlers must keep (it is not marked pure), so the children of an + // unused exported component still ship: the call stays in the eager + // code, and its chunk is emitted. + // Source: hydrate-when-transform.ts:653-690 (the call at :676); fuzzing. + // Impact: the code of components nothing renders loads in the client. + test.fails( + 'an unused exported component with a boundary is not in the client', + async () => { + const build = await sharedApp() + expect(build.client.where('unused-hydrated-marker')).toBe('nowhere') + }, + timeout, + ) + + // An export only the children use, which no other module imports, ends + // up in the lazy chunk when the bundler may drop its initializer from the + // parent (a function, or a call marked pure). + // Source: hydrate-when-transform.test.ts "unwraps exported declarations + // needed by extracted virtual modules". + test.each([ + { name: 'a function', page: 'widgetFunction' }, + { name: 'a pure call', page: 'widgetPureCall' }, + ])( + 'an export only the children use, initialized by $name, loads lazily and hydrates', + async ({ page }) => { + const build = await sharedApp() + expect(build.client.where(`${page}-marker`)).toBe('lazy') + expect(await hydrateShared(page, [`${page}-marker`])).toEqual({ + text: `${page}-marker clicked`, + recoverableErrors: [], + consoleErrors: [], + }) + }, + timeout, + ) + + // Bug: an initializer with side effects may keep the export in the eager + // code (no warning is required), but it must run once, and the children + // must render the one `Widget` it made, while the boundary's own children + // still load lazily. Today the client chunk gets its own copy of the + // declaration (hydrate-when-transform.ts:850-851, the module-level + // declarations the children read are kept in the chunk), and the parent + // keeps the export (its initializer has a side effect), so the + // initializer runs twice: once in the parent, again when the chunk loads + // (both bundlers). Same root cause as known-bugs-hydrate.test.ts "client: + // an exported declaration the children use has one instance, initialized + // once" (compiler level); this is its production-build row. + // Source: hydrate-when-transform.test.ts "unwraps exported declarations + // needed by extracted virtual modules". + // Impact: the initializer's side effects run twice, and the children use + // another instance than the module exports (e.g. another store). + test.fails( + 'an export only the children use, initialized by a call, is initialized once and hydrates', + async () => { + const build = await sharedApp() + expect(build.client.where('widgetCall-boundary-marker')).toBe('lazy') + expect( + await hydrateShared( + 'widgetCall', + ['widgetCall-marker'], + 'globalThis.__initialized?.widgetCall', + ), + ).toEqual({ + text: 'widgetCall-marker clicked widgetCall-boundary-marker', + recoverableErrors: [], + consoleErrors: [], + read: 1, + }) + }, + timeout, + ) + + // Source maps point at the user's code: a throw in the children, which + // run from their lazy chunk on the client, maps through the chunk's + // emitted source map to its line in the page. The column is left out: + // minifiers map the throw to different tokens of the expression. + test.each([ + { name: 'minified', minify: true }, + { name: 'unminified', minify: false }, + ])( + 'client: a throw in the children maps to its line in the page ($name)', + async ({ minify }) => { + const build = minify + ? await sharedApp() + : await buildStart({ + bundler, + entry, + minify, + sourcemap: true, + files: { + ...pageEntries, + 'src/pages/throwing.tsx': throwingPage, + 'src/chart.ts': `export const chart: any = {}\n`, + 'src/pages.ts': `export { Page as throwing } from './pages/throwing'\n`, + }, + }) + expect(build.client.where('MARK_HYDRATE_THROW')).toBe('lazy') + const { result: stack } = await build.client + .run(`return await new Promise((resolve) => { + const root = entry.createRoot(document.getElementById('root'), { + onUncaughtError: (error) => resolve(error.stack), + }) + root.render(entry.createElement(entry.pages.throwing)) +})`) + expect(stack).toMatch(/MARK_HYDRATE_THROW/) + const { file, line } = + originalFrameOf(build.client, stack as string) ?? {} + expect({ file, line }).toEqual({ + file: 'src/pages/throwing.tsx', + line: throwingPage + .slice(0, throwingPage.indexOf('chart.missing')) + .split('\n').length, + }) + }, + timeout, + ) + + // Children the compiler cannot extract fail the build with an error that + // names the user's file and the line of the boundary (SPEC J5.5, G5, + // §5.7: no wording is required). Every channel of the failed build is + // read (a compiler may print the details and fail with a short error). + test.each([ + { name: 'a function child', children: '{() => <p>child</p>}' }, + { name: 'a hook call', children: '<p>{useThing()}</p>' }, + ])( + 'client: $name in a boundary fails the build, naming the file and line', + async ({ children }) => { + const page = `import { Hydrate } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +import { useThing } from '../hooks' +export function Page() { + return ( + <main> + <Hydrate when={idle()}>${children}</Hydrate> + </main> + ) +} +` + const failure = await buildStart({ + bundler, + entry, + files: { + ...pageEntries, + 'src/hooks.ts': `import { useId } from 'react'\nexport const useThing = () => useId()\n`, + 'src/pages/unsafe.tsx': page, + 'src/pages.ts': `export { Page as unsafe } from './pages/unsafe'\n`, + }, + }).then( + () => undefined, + (error: unknown) => error, + ) + expect(failure, 'the build fails').toBeInstanceOf(StartBuildError) + expectDiagnostic(problems((failure as StartBuildError).diagnostics), { + severity: 'error', + file: 'src/pages/unsafe.tsx', + position: { line: diagnosticPosition(page, '<Hydrate').line }, + }) + }, + timeout, + ) + }) +} + +/** A page whose boundary's children throw (`chart.missing` is undefined). */ +const throwingPage = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { chart } from '../chart' +const title = 'title' +export function Page() { + return ( + <Hydrate when={load()}> + <b>{title}{chart.missing.MARK_HYDRATE_THROW}</b> + </Hydrate> + ) +} +` + +/** + * The route `/<name>` (`src/routes/<name>.tsx`): its `pendingComponent` and + * `component` each render an `interaction()` boundary with a `Toggle`, with + * the route's `codeSplitGroupings` (none: the default ones) and `more` as + * more route options. + */ +const splitRouteFiles = (name: string, groupings?: string, more = '') => ({ + [`src/routes/${name}.tsx`]: `import { createFileRoute } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { Toggle } from '../toggle' +export const Route = createFileRoute('/${name}')({${groupings ? `\n codeSplitGroupings: ${groupings},` : ''} + pendingComponent: Pending, + component: Page,${more} +}) +function Pending() { + return <Hydrate when={interaction()}><Toggle label="${name}-pending-marker" /></Hydrate> +} +function Page() { + return <section><Hydrate when={interaction()}><Toggle label="${name}-page-marker" /></Hydrate></section> +} +`, +}) + +/** + * A module exporting `routes`, a page that renders the `pendingComponent` + * and `component` of each route `/<name>` of `names` (the route tree's own, + * split or not). + */ +const routesPageModule = ( + names: Array<string>, +) => `import { createElement, Fragment } from 'react' +import { routeTree } from './routeTree.gen' +const options = (path: string) => + (Object.values((routeTree as any).children) as Array<any>).find( + (route) => route.options.path === path, + ).options +const routeOptions = ${JSON.stringify(names.map((name) => `/${name}`))}.map(options) +export function routes() { + return createElement( + Fragment, + null, + ...routeOptions.flatMap((route) => [ + createElement(route.pendingComponent), + createElement(route.component), + ]), + ) +} +` + +/** The routes of the shared build (`splitRouteFiles`). */ +const sharedRoutes = ['separateGroups', 'oneGroup', 'defaultGroups'] + +/** `src/pages/chart-<key>.tsx`: a `visible()` boundary around a `Chart`. */ +const chartPage = (key: string, chartImport: string) => ({ + [`src/pages/chart-${key}.tsx`]: `import { Hydrate } from '@tanstack/react-start' +import { visible } from '@tanstack/react-start/hydration' +${chartImport} +import { FallbackPane } from './chart-${key}-fallback' +import { formatValue } from './chart-${key}-format' +const chartTitle = formatValue('Revenue') +export function Page() { + return <Hydrate when={visible()} fallback={<FallbackPane />}><Chart title={chartTitle} /></Hydrate> +} +`, + [`src/pages/chart-${key}-fallback.tsx`]: `export const FallbackPane = () => <p>${key}-fallback-marker</p>\n`, + [`src/pages/chart-${key}-format.ts`]: `export const formatValue = (value: string) => value + ' ${key}-format-marker'\n`, +}) + +/** The package `name` of `node_modules`, with a `Chart` and an `Other`. */ +const widgetsPackage = (name: string, manifest: Record<string, unknown>) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + ...manifest, + }), + [`node_modules/${name}/chart.js`]: `import { useState } from 'react' +import { jsxs } from 'react/jsx-runtime' +export const Chart = (props) => { + const [clicked, setClicked] = useState(false) + return jsxs('button', { onClick: () => setClicked(true), children: [props.title, ' ${name}-chart-marker', clicked ? ' clicked' : ''] }) +} +`, + [`node_modules/${name}/other.js`]: `export const Other = () => 'other'\n`, + [`node_modules/${name}/index.js`]: `export { Chart } from './chart.js' +export { Other } from './other.js' +`, +}) + +/** + * `src/pages/<name>.tsx`: a boundary whose children render `Widget`, an + * export no other module imports, declared as `export const Widget = + * <widget>`. `initialize(key, component)` counts its calls by key + * (`globalThis.__initialized`), so only a purity hint lets the bundler drop + * a call of it. + */ +const widgetPage = (name: string, widget: string, more = '') => ({ + [`src/pages/${name}.tsx`]: `import { useState } from 'react' +import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { initialize } from '../initialize' +export const Widget = ${widget} +export function Page() { + return <Hydrate when={load()}><Widget />${more}</Hydrate> +} +`, +}) +const widgetComponent = (name: string) => `function Widget() { + const [clicked, setClicked] = useState(false) + return <button onClick={() => setClicked(true)}>${name}-marker{clicked ? ' clicked' : ''}</button> +}` + +/** The pages of the shared build of each bundler. */ +const sharedFiles: Record<string, string> = { + 'src/toggle.tsx': toggleSource, + 'src/initialize.ts': `export const initialize = <T,>(key: string, component: T) => { + const counts = ((globalThis as any).__initialized ??= {}) + counts[key] = (counts[key] ?? 0) + 1 + return component +} +`, + 'src/chart.ts': `export const chart: any = {}\n`, + 'src/pages/throwing.tsx': throwingPage, + ...chartPage('project', `import { Chart } from './chart-project-chart'`), + 'src/pages/chart-project-chart.tsx': `import { useState } from 'react' +export const Chart = (props: { title: string }) => { + const [clicked, setClicked] = useState(false) + return <button onClick={() => setClicked(true)}>{props.title} project-chart-marker{clicked ? ' clicked' : ''}</button> +} +`, + ...chartPage( + 'plain-widgets', + `import { Chart, Other } from 'plain-widgets' +console.log(Other)`, + ), + ...widgetsPackage('plain-widgets', {}), + ...chartPage( + 'pure-widgets', + `import { Chart, Other } from 'pure-widgets' +console.log(Other)`, + ), + ...widgetsPackage('pure-widgets', { sideEffects: false }), + 'src/pages/two-chart.tsx': `import { useState } from 'react' +export const Chart = () => { + const [clicked, setClicked] = useState(false) + return <button onClick={() => setClicked(true)}>two-chart-marker{clicked ? ' clicked' : ''}</button> +} +`, + 'src/pages/two-table.tsx': `import { useState } from 'react' +export const Table = () => { + const [clicked, setClicked] = useState(false) + return <button onClick={() => setClicked(true)}>{' '}two-table-marker{clicked ? ' clicked' : ''}</button> +} +`, + 'src/pages/two-boundaries.tsx': `import { Hydrate } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { Chart } from './two-chart' +import { Table } from './two-table' +export function Page() { + return <><Hydrate when={interaction()}><Chart /></Hydrate><Hydrate when={interaction()}><Table /></Hydrate></> +} +`, + 'src/lib.ts': `export const source = ['lib-marker', { b: 'B' }] as const\n`, + 'src/pages/module-level.tsx': `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { source } from '../lib' +import { Toggle } from '../toggle' +const [a, { b }] = source +function helper(value: string) { + return value + ' helper-marker' +} +export function Page() { + return <Hydrate when={load()}><Toggle label={helper(a + b)} /></Hydrate> +} +`, + ...splitRouteFiles('separateGroups', `[['component'], ['pendingComponent']]`), + ...splitRouteFiles('oneGroup', `[['component', 'pendingComponent']]`), + ...splitRouteFiles('defaultGroups'), + // Modules with unused exported components, one with a boundary and one + // without; the app imports only their used neighbours. + 'src/hydrated-widgets.tsx': `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +export function UnusedHydratedWidget() { + return <div><Hydrate when={load()}><section>unused-hydrated-marker</section></Hydrate></div> +} +export function UsedHydratedWidget() { + return <p>used</p> +} +`, + 'src/plain-widgets.tsx': `export function UnusedPlainWidget() { + return <div><section>unused-plain-marker</section></div> +} +export function UsedPlainWidget() { + return <p>used</p> +} +`, + ...widgetPage('widgetFunction', widgetComponent('widgetFunction')), + ...widgetPage( + 'widgetPureCall', + `/* @__PURE__ */ initialize('widgetPureCall', ${widgetComponent('widgetPureCall')})`, + ), + ...widgetPage( + 'widgetCall', + `initialize('widgetCall', ${widgetComponent('widgetCall')})`, + `<i> widgetCall-boundary-marker</i>`, + ), + 'src/pages.ts': `export { Page as chartProject } from './pages/chart-project' +export { Page as chartPlainWidgets } from './pages/chart-plain-widgets' +export { Page as chartPureWidgets } from './pages/chart-pure-widgets' +export { Page as twoBoundaries } from './pages/two-boundaries' +export { Page as moduleLevel } from './pages/module-level' +export { Page as widgetFunction } from './pages/widgetFunction' +export { Page as widgetPureCall } from './pages/widgetPureCall' +export { Page as widgetCall } from './pages/widgetCall' +export { routes } from './route-pages' +export { UsedHydratedWidget } from './hydrated-widgets' +export { UsedPlainWidget } from './plain-widgets' +export { Page as throwing } from './pages/throwing' +`, + 'src/route-pages.ts': routesPageModule(sharedRoutes), +} diff --git a/packages/start-plugin-core/tests/integration/hydrate-build-dev.test.ts b/packages/start-plugin-core/tests/integration/hydrate-build-dev.test.ts new file mode 100644 index 0000000000..572a971b24 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-build-dev.test.ts @@ -0,0 +1,194 @@ +import { writeFile } from 'node:fs/promises' +import react from '@vitejs/plugin-react' +import { createServer } from 'vite' +import { describe, expect, onTestFinished, test } from 'vitest' +import { servedDirectories } from '@tanstack/compiler-test-utils/app-directory' +import { closeViteServer } from '@tanstack/compiler-test-utils/dev-server' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { + clientEntryFiles, + reportedErrors, + startRsbuildDevServer, +} from '../rsbuild-dev-server' +import { startPlugin } from '../dev-server' +import { + clientFixturePlugin, + startBrowserStartDevServer, +} from './importProtection/client-pages' + +const timeout = 60_000 + +describe('Vite dev server', () => { + const page = ( + text: string, + ) => `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +export function Page() { + return <Hydrate when={load()}><p>${text}</p></Hydrate> +} +` + + /** `src/main.tsx`: renders `Page` into the page, after `before`. */ + const main = (before = '') => `import { createRoot } from 'react-dom/client' +${before}const { Page } = await import('./page') +createRoot(document.getElementById('root')!).render(<Page />) +` + + // A browser may request a chunk before its parent module was compiled in + // this dev session (a reload after a server restart), and an edit of the + // file must reach its chunks. A real page with Vite's HMR client and React + // Refresh renders the page module on the client (Start's whole Vite + // plugin; the page is Vite's own HTML pipeline, `runViteClient`'s fixture + // page). Which request carries the children is learned from the page + // itself (the requests whose code holds them), and the dev server restarts + // at the same root (a new Vite dev server with the same plugins on the same + // app directory). + // Source: hydrate-when-transform.test.ts "invalidates cached Hydrate + // source for virtual module loads" (the compiler half is in + // hydrate-boundary-forms.test.ts) + test( + 'client: a chunk requested before its parent module renders the children, and an edit reaches it', + async () => { + const optimizeDeps = { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + } + const server = await startBrowserStartDevServer({ + config: { optimizeDeps }, + plugins: [react()], + files: { 'src/page.tsx': page('MARK_OLD'), 'src/main.tsx': main() }, + }) + const pageUrl = new URL('/__ip-fixture.html', server.url) + pageUrl.searchParams.set('entry', '/src/main.tsx') + + // The requests of a page that renders the children + const first = await openPage(pageUrl.href) + let childRequests: Array<string> + try { + await first.waitForText('MARK_OLD', { selector: '#root' }) + childRequests = await first.page.evaluate<Array<string>>(`(async () => { + const urls = [...new Set(performance.getEntriesByType('resource') + .map((entry) => entry.name) + .filter((url) => url.startsWith(location.origin + '/')))] + const holding = [] + for (const url of urls) { + const code = await (await fetch(url)).text() + if (code.includes('MARK_OLD')) { + holding.push(url.slice(location.origin.length)) + } + } + return holding +})()`) + } finally { + await first.close() + } + expect(childRequests).not.toEqual([]) + + // The dev server restarts at the same root (the app's files and + // dependency cache stay): the new one has compiled nothing of the app. + // A page then requests what carries the children before the page + // module. + await writeFile( + server.file('src/main.tsx'), + main( + childRequests + .map( + (url) => + `await import(/* @vite-ignore */ ${JSON.stringify(url)})\n`, + ) + .join(''), + ), + ) + await server.stop() + const restarted = await createServer({ + root: server.root, + configFile: false, + logLevel: 'error', + server: { + host: '127.0.0.1', + port: 0, + fs: { allow: await servedDirectories(server.root) }, + }, + optimizeDeps, + plugins: [startPlugin(server.root, {}), clientFixturePlugin, react()], + }) + onTestFinished(() => closeViteServer(restarted)) + await restarted.listen() + const restartedUrl = new URL( + '/__ip-fixture.html', + restarted.resolvedUrls!.local[0], + ) + restartedUrl.searchParams.set('entry', '/src/main.tsx') + const browser = await openPage(restartedUrl.href, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('MARK_OLD', { selector: '#root' }) + + await writeFile(server.file('src/page.tsx'), page('MARK_NEW')) + + await browser.waitForText('MARK_NEW', { selector: '#root' }) + expect(browser.errors).toEqual([]) + }, + timeout, + ) +}) + +describe('Rsbuild dev server', () => { + // Rsbuild serves bundles: a chunk is only built through its parent's + // import, so only the edit half of the Vite test applies. The page loads + // the client entry's initial files first (Rspack's stats entrypoints, + // `clientEntryFiles`); the children are in another file. + test( + 'client: an edit of the file reaches the chunk of its boundary', + async () => { + const page = ( + marker: string, + ) => `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +export function Page() { + return <Hydrate when={load()}><p>${marker}</p></Hydrate> +} +` + const server = await startRsbuildDevServer({ + files: { + 'src/page.tsx': page('OLD_MARKER'), + 'src/entry.ts': `import { Page } from './page'\nconsole.log(Page)\n`, + }, + }) + /** The output files containing each marker, and the entry's files. */ + const locate = async () => { + const outputs = Object.entries(await server.outputs('client')) + const files = (marker: string) => + outputs + .filter(([, code]) => code.includes(marker)) + .map(([file]) => file) + return { + entry: clientEntryFiles(server), + old: files('OLD_MARKER'), + new: files('NEW_MARKER'), + } + } + const before = await locate() + expect(before.entry).not.toEqual([]) + expect(before.old.length).toBeGreaterThan(0) + // The children are in a chunk of their own. + expect(before.old.filter((file) => before.entry.includes(file))).toEqual( + [], + ) + + await server.edit({ 'src/page.tsx': page('NEW_MARKER') }) + + expect(reportedErrors(server)).toEqual([]) + const after = await locate() + expect(after.old).toEqual([]) + expect(after.new.length).toBeGreaterThan(0) + expect(after.new.filter((file) => after.entry.includes(file))).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/hydrate-build-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/hydrate-build-rsbuild.test.ts new file mode 100644 index 0000000000..690e6348c8 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-build-rsbuild.test.ts @@ -0,0 +1,4 @@ +/** Real Rsbuild production builds and Chromium hydration; shared app rows. */ +import { hydrateBuildSuite } from './hydrate-build-cases' + +hydrateBuildSuite('rsbuild') diff --git a/packages/start-plugin-core/tests/integration/hydrate-build.test.ts b/packages/start-plugin-core/tests/integration/hydrate-build.test.ts new file mode 100644 index 0000000000..3c18d8ec6a --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-build.test.ts @@ -0,0 +1,4 @@ +/** Real Vite production builds and Chromium hydration; shared app rows. */ +import { hydrateBuildSuite } from './hydrate-build-cases' + +hydrateBuildSuite('vite') diff --git a/packages/start-plugin-core/tests/integration/hydrate-dev-edits.ts b/packages/start-plugin-core/tests/integration/hydrate-dev-edits.ts new file mode 100644 index 0000000000..255825800c --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-dev-edits.ts @@ -0,0 +1,420 @@ +/** + * The apps and the edit scenario of the `<Hydrate>` dev-server tests, + * shared by their Vite (`hydrate-dev.test.ts`) and Rsbuild + * (`hydrate-dev-rsbuild.test.ts`) files: React and Solid Start apps whose + * root renders the document, two boundaries hydrating on interaction + * (`src/widgets.tsx`), and the edits of their children on an opened page + * (`editLoadedChild`, `expectEditsReached`). + */ +import { expect } from 'vitest' +import { startServerEntryFiles } from '../dev-server' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' + +/** + * Modules only the children of one boundary import, each with a marker in + * its code: which of them the page downloaded (not when their top-level + * code runs, which is free: SPEC J5.6, G3). + */ +const childModules = Object.fromEntries( + ['a', 'b'].map((name) => [ + `src/child-${name}.ts`, + `export const probe = 'child-${name}-exclusive-marker'\n`, + ]), +) + +/** The files of a React Start app whose root renders the document. */ +export const reactApp = { + ...childModules, + ...startServerEntryFiles, + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient), { + onRecoverableError: (error) => { + ;((globalThis as any).__recoverable ??= []).push(String(error)) + }, +}) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/counter.tsx': `import { useState } from 'react' +export function Counter(props: { label: string }) { + const [clicks, setClicks] = useState(0) + return <button data-label={props.label} onClick={() => setClicks(clicks + 1)}>{props.label + ':' + clicks}</button> +} +`, +} +/** + * `src/widgets.tsx` of the edit rows: two boundaries hydrating on + * interaction, each rendering a child (`<button data-child=name>` showing + * `name label clicks`, counting its mounted instances in `__effects`) and + * `children` after it; `label` is a local the children capture. + */ +export const reactWidgets = ( + children: string, + label: string, +) => `import { Hydrate } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { probe as probeA } from './child-a' +import { probe as probeB } from './child-b' +import { useEffect, useState } from 'react' +function Child(props: { name: string; label: string; probe: string }) { + const [clicks, setClicks] = useState(0) + useEffect(() => { + const page = globalThis as any + page.__effects = (page.__effects ?? 0) + 1 + return () => { + page.__effects -= 1 + } + }, []) + return <button data-child={props.name} onClick={() => setClicks(clicks + 1)}>{props.name + ' ' + props.label + ' ' + clicks}</button> +} +export function Widgets() { + const label = '${label}' + return ( + <div> + <section><Hydrate when={interaction()}><Child name="a" label={label} probe={probeA} />${children}</Hydrate></section> + <section><Hydrate when={interaction()}><Child name="b" label={label} probe={probeB} />${children}</Hydrate></section> + </div> + ) +} +` + +/** + * The files of a Solid Start app whose root renders the document (with + * Solid's hydration script), hydrated by Start's Solid client entry. + */ +export const solidApp = { + ...childModules, + 'harness/client-entry.ts': `import { createComponent, hydrate } from 'solid-js/web' +import { StartClient, hydrateStart } from '@tanstack/solid-start/client' +hydrateStart().then((router) => { + hydrate(() => createComponent(StartClient, { router }), document) +}) +`, + 'harness/server-entry.ts': `export { default } from '@tanstack/solid-start/server-entry'\n`, + 'src/router.ts': `import { createRouter } from '@tanstack/solid-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/solid-router' +import { HydrationScript } from 'solid-js/web' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HydrationScript /> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated() ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/solid-router' +import { Widgets } from '../widgets' +export const Route = createFileRoute('/')({ component: Widgets }) +`, +} + +/** + * Files over `solidApp` whose index route component (split by Start's + * router plugin) holds a boundary itself, so the route's split chunk is + * split again for the boundary's children: a counter hydrating on + * interaction (SPEC J2.20, J5.2). + */ +export const solidRouteWithBoundary = { + 'src/counter.tsx': `import { createSignal } from 'solid-js' +export function Counter(props: { label: string }) { + const [clicks, setClicks] = createSignal(0) + return <button data-label={props.label} onClick={() => setClicks(clicks() + 1)}>{props.label + ':' + clicks()}</button> +} +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/solid-router' +import { Hydrate } from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +export const Route = createFileRoute('/')({ component: Home }) +function Home() { + return <section><Hydrate when={interaction()}><Counter label="child" /></Hydrate></section> +} +`, +} + +/** + * The page of `solidRouteWithBoundary` hydrates, and a click on the + * counter loads its boundary's code (scripts the page had not requested), + * hydrates it and counts. + */ +export async function expectRouteBoundaryCounts(browser: BrowserPage) { + const scripts = () => + browser.page.evaluate( + () => + performance + .getEntriesByType('resource') + .filter( + (entry) => + (entry as PerformanceResourceTiming).initiatorType === 'script', + ).length, + ) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + expect(await browser.text('[data-label=child]')).toBe('child:0') + const beforeClick = await scripts() + await browser.page.locator('[data-label=child]').click() + await browser.waitForText('child:1', { selector: '[data-label=child]' }) + expect({ + loadedByClick: (await scripts()) > beforeClick, + errors: browser.errors, + }).toEqual({ loadedByClick: true, errors: [] }) +} + +/** `reactWidgets` in Solid (a signal; mounted instances in `__effects`). */ +export const solidWidgets = ( + children: string, + label: string, +) => `import { Hydrate } from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { probe as probeA } from './child-a' +import { probe as probeB } from './child-b' +import { createSignal, onCleanup, onMount } from 'solid-js' +function Child(props: { name: string; label: string; probe: string }) { + const [clicks, setClicks] = createSignal(0) + onMount(() => { + const page = globalThis as any + page.__effects = (page.__effects ?? 0) + 1 + onCleanup(() => { + page.__effects -= 1 + }) + }) + return <button data-child={props.name} onClick={() => setClicks(clicks() + 1)}>{props.name + ' ' + props.label + ' ' + clicks()}</button> +} +export function Widgets() { + const label = '${label}' + return ( + <div> + <section><Hydrate when={interaction()}><Child name="a" label={label} probe={probeA} />${children}</Hydrate></section> + <section><Hydrate when={interaction()}><Child name="b" label={label} probe={probeB} />${children}</Hydrate></section> + </div> + ) +} +` + +/** + * The edit scenario on an opened page: opens `a`, edits the children's JSX + * (`v1` -> `v2`) then the captured `label`, opens `b`. `widgets(children, + * label)` is the source of `src/widgets.tsx`. Returns what the sections of + * `a` and `b` showed at each step, the mounted children (`effects`) and + * React's recoverable errors. + */ +export async function editLoadedChild( + server: { edit: (files: Record<string, string>) => Promise<unknown> }, + browser: BrowserPage, + widgets: (children: string, label: string) => string, +) { + const { page } = browser + /** The child-only modules the page requested by their own URL. */ + const childRequests = async () => + page.evaluate(() => + performance + .getEntriesByType('resource') + .map((entry) => entry.name) + .filter((url) => /child-[ab]\.ts(?:\?|$)/.test(url)), + ) + // Inspect the scripts the browser actually requested, including opaque + // Rsbuild chunk URLs. The test-side HTTP client reads their real response + // bodies; it neither evaluates them nor requests them from the page. + const inspected = new Map<string, string>() + /** Whether the page downloaded the code of `src/child-<name>.ts`. */ + const downloaded = async (name: 'a' | 'b') => { + const urls = await page.evaluate(() => + performance + .getEntriesByType('resource') + .filter((entry) => + ['script', 'link'].includes( + (entry as PerformanceResourceTiming).initiatorType, + ), + ) + .map((entry) => entry.name), + ) + await Promise.all( + urls + .filter((url) => !inspected.has(url)) + .map(async (url) => { + const response = await page.request.get(url) + inspected.set(url, await response.text()) + }), + ) + return [...inspected.values()].some((body) => + body.includes(`child-${name}-exclusive-marker`), + ) + } + expect(await downloaded('a')).toBe(false) + expect(await downloaded('b')).toBe(false) + expect(await childRequests()).toEqual([]) + /** The text of the section of child `name` (`''` while it has none). */ + const section = (name: string) => + page.evaluate( + (selector) => + document.querySelector(selector)?.closest('section')?.textContent ?? '', + `[data-child=${name}]`, + ) + /** + * What the page shows once both sections are rendered and unchanged for + * 100 ms (a hot update that remounts the module's components, as Solid's + * does, re-renders them one after the other). + */ + const step = async () => { + const read = async () => ({ + a: await section('a'), + b: await section('b'), + ...(await page.evaluate(() => ({ + effects: (globalThis as any).__effects ?? 0, + recoverable: (globalThis as any).__recoverable ?? [], + }))), + }) + const deadline = Date.now() + 10_000 + let last = await read() + for (;;) { + await new Promise((resolve) => setTimeout(resolve, 100)) + const next = await read() + if (next.a && next.b && JSON.stringify(next) === JSON.stringify(last)) { + return next as { + a: string + b: string + effects: number + recoverable: Array<string> + } + } + if (Date.now() > deadline) { + throw new Error(`the page did not settle: ${JSON.stringify(next)}`) + } + last = next + } + } + /** Clicks child `name` until its section shows `expected`. */ + const clickUntil = async (name: string, expected: string) => { + const deadline = Date.now() + 10_000 + while (!(await section(name)).includes(expected)) { + if (Date.now() > deadline) { + throw new Error( + `${name} never showed ${expected}: ${await section(name)}`, + ) + } + await page.locator(`[data-child=${name}]`).click() + await new Promise((resolve) => setTimeout(resolve, 100)) + } + } + /** Waits until the section of `name` shows `expected`. */ + const shows = async (name: string, expected: string) => { + const deadline = Date.now() + 10_000 + while (!(await section(name)).includes(expected)) { + if (Date.now() > deadline) { + throw new Error( + `${name} never showed ${expected}: ${await section(name)}`, + ) + } + await new Promise((resolve) => setTimeout(resolve, 50)) + } + } + await clickUntil('a', 'a capture-v1 1') + const opened = await step() + expect(await downloaded('b')).toBe(false) + + await server.edit({ 'src/widgets.tsx': widgets('<i>v2</i>', 'capture-v1') }) + await shows('a', 'v2') + const childrenEdited = await step() + if (childrenEdited.b === 'b capture-v1 0v1') { + expect(await downloaded('b')).toBe(false) + expect( + (await childRequests()).filter((url) => /child-b\.ts(?:\?|$)/.test(url)), + ).toEqual([]) + } + + await server.edit({ 'src/widgets.tsx': widgets('<i>v2</i>', 'capture-v2') }) + await shows('a', 'capture-v2') + const captureEdited = await step() + if (captureEdited.b === 'b capture-v1 0v1') { + expect(await downloaded('b')).toBe(false) + expect( + (await childRequests()).filter((url) => /child-b\.ts(?:\?|$)/.test(url)), + ).toEqual([]) + } + + await clickUntil('b', 'b capture-v2 1') + const siblingOpened = await step() + expect(await downloaded('b')).toBe(true) + return { opened, childrenEdited, captureEdited, siblingOpened } +} + +/** + * What `editLoadedChild` must see: the loaded child `a` shows each edit (its + * state may reset: a remount is allowed), and `b`, whose code had not + * loaded, either still shows the server's HTML or (when the framework's hot + * update remounts the edited module's components: Solid) the edited + * version, never a mix of versions; once opened it shows the edited + * version. The gauge counts currently mounted children (`effects`: `a`, and `b` + * once it is mounted); it does not count cumulative mounts, and React reported no recoverable error. + */ +export function expectEditsReached( + steps: Awaited<ReturnType<typeof editLoadedChild>>, +) { + const serverB = 'b capture-v1 0v1' + /** `b`'s text, as one of `accepted`; the children mounted then. */ + const mounted = (b: string, edited: string) => { + expect([serverB, edited]).toContain(b) + return b === serverB ? 1 : 2 + } + const { opened, childrenEdited, captureEdited, siblingOpened } = steps + expect(opened).toEqual({ + a: 'a capture-v1 1v1', + b: serverB, + effects: 1, + recoverable: [], + }) + expect(childrenEdited).toEqual({ + a: expect.stringMatching(/^a capture-v1 \dv2$/), + b: childrenEdited.b, + effects: mounted(childrenEdited.b, 'b capture-v1 0v2'), + recoverable: [], + }) + expect(captureEdited).toEqual({ + a: expect.stringMatching(/^a capture-v2 \dv2$/), + b: captureEdited.b, + effects: mounted(captureEdited.b, 'b capture-v2 0v2'), + recoverable: [], + }) + expect(siblingOpened).toEqual({ + a: expect.stringMatching(/^a capture-v2 \dv2$/), + b: 'b capture-v2 1v2', + effects: 2, + recoverable: [], + }) +} diff --git a/packages/start-plugin-core/tests/integration/hydrate-dev-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/hydrate-dev-rsbuild.test.ts new file mode 100644 index 0000000000..9d96b7d005 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-dev-rsbuild.test.ts @@ -0,0 +1,120 @@ +/** + * The edit rows of hydrate-dev.test.ts (SPEC J5.2, G10) on + * Start's Rsbuild dev server, seen from a real browser page: React Refresh + * from `@rsbuild/plugin-react`, Solid's hot updates from + * `@rsbuild/plugin-solid` (with `@rsbuild/plugin-babel`, configured like a + * Solid Start app, `solidAppConfig`). Its own file so that each bundler's + * dev servers run in a worker of their own. + */ +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { pluginReact } from '@rsbuild/plugin-react' +import { + reportedErrors, + startRsbuildStartDevServer, +} from '../rsbuild-dev-server' +import { + editLoadedChild, + expectEditsReached, + expectRouteBoundaryCounts, + reactApp, + reactWidgets, + solidApp, + solidRouteWithBoundary, + solidWidgets, +} from './hydrate-dev-edits' +import { solidAppConfig } from './hydrate-pages' + +const timeout = 60_000 + +describe('Rsbuild dev', () => { + test( + 'React: a loaded child hot-updates in place, and a sibling opened later shows the edited version', + async () => { + const server = await startRsbuildStartDevServer({ + hmr: true, + browser: true, + // Start serves the pages, not an HTML template. + config: { tools: { htmlPlugin: false }, plugins: [pluginReact()] }, + files: { + ...reactApp, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { Widgets } from '../widgets' +export const Route = createFileRoute('/')({ component: Widgets }) +`, + 'src/widgets.tsx': reactWidgets('<i>v1</i>', 'capture-v1'), + }, + }) + expect(reportedErrors(server)).toEqual([]) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + expectEditsReached(await editLoadedChild(server, browser, reactWidgets)) + expect(reportedErrors(server)).toEqual([]) + expect(browser.loads()).toBe(1) + expect(browser.errors).toEqual([]) + }, + timeout, + ) + + test( + 'Solid: a loaded child hot-updates in place, and a sibling opened later shows the edited version', + async () => { + const server = await startRsbuildStartDevServer({ + framework: 'solid', + hmr: true, + browser: true, + config: { + ...solidAppConfig.rsbuildConfig, + // Start serves the pages, not an HTML template. + tools: { htmlPlugin: false }, + }, + files: { + ...solidApp, + 'src/widgets.tsx': solidWidgets('<i>v1</i>', 'capture-v1'), + }, + }) + expect(reportedErrors(server)).toEqual([]) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + expectEditsReached(await editLoadedChild(server, browser, solidWidgets)) + expect(reportedErrors(server)).toEqual([]) + expect(browser.loads()).toBe(1) + expect(browser.errors).toEqual([]) + }, + timeout, + ) + + // A boundary in the split route component itself: the route's chunk is + // split again, and each module still gets Solid's JSX transform. + test( + 'Solid: a boundary written in a split route component loads on a click, hydrates and counts', + async () => { + const server = await startRsbuildStartDevServer({ + framework: 'solid', + hmr: true, + browser: true, + config: { + ...solidAppConfig.rsbuildConfig, + // Start serves the pages, not an HTML template. + tools: { htmlPlugin: false }, + }, + files: { ...solidApp, ...solidRouteWithBoundary }, + }) + expect(reportedErrors(server)).toEqual([]) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await expectRouteBoundaryCounts(browser) + expect(reportedErrors(server)).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/hydrate-dev-solid.test.ts b/packages/start-plugin-core/tests/integration/hydrate-dev-solid.test.ts new file mode 100644 index 0000000000..e288259714 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-dev-solid.test.ts @@ -0,0 +1,66 @@ +import solid from 'vite-plugin-solid' +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { startDevServer } from '../dev-server' +import { + editLoadedChild, + expectEditsReached, + expectRouteBoundaryCounts, + solidApp, + solidRouteWithBoundary, + solidWidgets, +} from './hydrate-dev-edits' + +const timeout = 60_000 + +describe('Vite dev, Solid', () => { + // A Solid boundary is served with the Solid packages, its chunk renders, + // and an edit reaches it (replaces a former row that used stand-in + // packages: here the real packages, with Solid's hot updates). + test( + 'a loaded child hot-updates in place, and a sibling opened later shows the edited version', + async () => { + const server = await startDevServer({ + start: {}, + framework: 'solid', + browser: true, + plugins: [solid({ ssr: true })], + files: { + ...solidApp, + 'src/widgets.tsx': solidWidgets('<i>v1</i>', 'capture-v1'), + }, + }) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + await server.idle() + expectEditsReached(await editLoadedChild(server, browser, solidWidgets)) + expect(browser.loads()).toBe(1) + expect(browser.errors).toEqual([]) + }, + timeout, + ) + + // A boundary in the split route component itself: the route's chunk is + // split again, and each module still gets Solid's JSX transform. + test( + 'a boundary written in a split route component loads on a click, hydrates and counts', + async () => { + const server = await startDevServer({ + start: {}, + framework: 'solid', + browser: true, + plugins: [solid({ ssr: true })], + files: { ...solidApp, ...solidRouteWithBoundary }, + }) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await expectRouteBoundaryCounts(browser) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/hydrate-dev.test.ts b/packages/start-plugin-core/tests/integration/hydrate-dev.test.ts new file mode 100644 index 0000000000..bed0c1d141 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-dev.test.ts @@ -0,0 +1,158 @@ +/** + * `<Hydrate>` on Start's Vite dev server, seen from a real browser page: the + * app is a Start app (Start's whole Vite plugin, its dev middleware + * rendering the page with the app's server entry, `StartClient` hydrating + * it), the page is headless Chromium with Vite's HMR client and React + * Refresh (`@vitejs/plugin-react`) or Solid's (`vite-plugin-solid`), and + * the edits are files written to disk, which Vite's watcher reports. + * + * - A loaded child hot-updates in place, and a sibling whose code had not + * loaded yet shows the edited version when it opens (SPEC J5.2, G10), + * React and Solid. + * - Route code splitting and `<Hydrate>` in one route module: the split + * route component's boundaries hydrate the server's HTML (splitter + * composition). + * + * The Rsbuild counterparts of the edit rows: hydrate-dev-rsbuild.test.ts. + */ +import react from '@vitejs/plugin-react' +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { describeHmr } from '@tanstack/compiler-test-utils/dev-server' +import { startDevServer } from '../dev-server' +import { + editLoadedChild, + expectEditsReached, + reactApp, + reactWidgets, +} from './hydrate-dev-edits' + +const timeout = 60_000 + +/** Pre-bundled up front, as Vite does for an app that installed them. */ +const reactOptimizeDeps = { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + ], +} + +describe('Vite dev, React', () => { + test( + 'a loaded child hot-updates in place, and a sibling opened later shows the edited version', + async () => { + const server = await startDevServer({ + start: {}, + browser: true, + config: { optimizeDeps: reactOptimizeDeps }, + plugins: [react()], + files: { + ...reactApp, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { Widgets } from '../widgets' +export const Route = createFileRoute('/')({ component: Widgets }) +`, + 'src/widgets.tsx': reactWidgets('<i>v1</i>', 'capture-v1'), + }, + }) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + await server.idle() + expectEditsReached(await editLoadedChild(server, browser, reactWidgets)) + expect(browser.loads()).toBe(1) + expect( + describeHmr( + server.hmr.filter( + (message) => + message.environment === 'client' && + message.type === 'full-reload', + ), + ), + ).toEqual([]) + expect(browser.errors).toEqual([]) + }, + timeout, + ) + + // The router splits the route component into its own module, which the + // Hydrate plugin splits again: the page hydrates the server's HTML with + // both, the deferred child loading its code on its interaction. + test( + 'boundaries of a split route component hydrate the server HTML', + async () => { + const server = await startDevServer({ + start: {}, + browser: true, + config: { optimizeDeps: reactOptimizeDeps }, + plugins: [react()], + files: { + ...reactApp, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { Hydrate } from '@tanstack/react-start' +import { idle, interaction } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +export const Route = createFileRoute('/')({ component: Page }) +function Page() { + return ( + <main> + <Counter label="route" /> + <Hydrate when={interaction()}><Counter label="deferred" /></Hydrate> + <Hydrate when={idle()}><Counter label="idle" /></Hydrate> + </main> + ) +} +`, + }, + }) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + expect(await browser.text('#app')).toBe('route:0deferred:0idle:0') + /** How many resources the page requested so far. */ + const requested = () => + browser.page.evaluate( + () => performance.getEntriesByType('resource').length, + ) + /** Clicks the counter `label` until it counts. */ + const count = async (label: string) => { + const deadline = Date.now() + 10_000 + while (!(await browser.text('#app')).includes(`${label}:1`)) { + if (Date.now() > deadline) { + throw new Error( + `${label} never counted: ${await browser.text('#app')}`, + ) + } + await browser.page.locator(`[data-label=${label}]`).click() + await new Promise((resolve) => setTimeout(resolve, 100)) + } + } + await count('route') + await count('idle') + await server.idle() + // The deferred child's code loads when it hydrates. + const beforeDeferred = await requested() + await count('deferred') + expect(await requested()).toBeGreaterThan(beforeDeferred) + expect(await browser.text('#app')).toBe('route:1deferred:1idle:1') + expect( + await browser.page.evaluate( + () => (globalThis as any).__recoverable ?? [], + ), + ).toEqual([]) + expect(browser.errors).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages-react.ts b/packages/start-plugin-core/tests/integration/hydrate-pages-react.ts new file mode 100644 index 0000000000..c1f908df30 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages-react.ts @@ -0,0 +1,983 @@ +/** + * `<Hydrate>` pages of a React Start app in a real browser, run for each + * bundler by its own test file (`hydrate-pages.test.ts`: Vite, + * `hydrate-pages-rsbuild.test.ts`: Rsbuild): the SSR build renders the + * page, a page of headless Chromium hydrates that HTML with the client + * build (`hydrate-pages.ts`), and each child is exercised (a click must + * update it). React's recoverable errors and hydration warnings + * (development build) must stay empty. This is where the identities of the + * boundaries are checked (SPEC J5.4): whatever ids the compiler assigns, + * every boundary hydrates the HTML the server rendered and reaches the + * children the server rendered in it. Also: `prefetch` (J5.2, J5.6), a + * function `when` evaluated on the client only (J5.8), the fallback of a + * boundary mounted after startup (J5.3), a server fn called from split + * children (J4.13), which `Hydrate` elements are boundaries (J5.1), and + * the children under parent updates (J5.8). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + buildHydrationApp, + loadedOnInteraction, + updatesExpected, + updatesScript, +} from './hydrate-pages' +import type { HydrateOptions, HydrationApp } from './hydrate-pages' +import type { StartBundler } from '../build-harness' +/** A counter: `<label>:<clicks>`; clicking it counts. */ +const counterFile = `import { useState } from 'react' +export function Counter({ label }: { label: string }) { + const [clicks, setClicks] = useState(0) + return <button data-label={label} onClick={() => setClicks(clicks + 1)}>{label + ':' + clicks}</button> +} +` + +const head = `import { Hydrate } from '@tanstack/react-start' +import { idle, interaction, load, visible } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +` + +/** A context of the app, declared in its own module. */ +const themeFile = `import { createContext } from 'react' +export const Theme = createContext('no-provider') +` + +/** + * A page whose two keyed boundaries render the same child, reading the + * page's state through captures (`count`, a local named `ref`), a context + * and a callback; the page changes them, and reverses the boundaries. The + * `when` and `prefetch` props are new objects on every render. `split` is + * added to each boundary (`split={false}`: the reference, which the + * compiler leaves in place). + */ +function updatesPage(split: string) { + return `import { Hydrate } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { useContext, useState } from 'react' +import { Theme } from '../theme' +function Item(props: { name: string; count: number; tag: string; onPick: () => void }) { + const theme = useContext(Theme) + return <button data-item={props.name} onClick={props.onPick}>{[props.name, props.count, theme, props.tag].join('|')}</button> +} +export function Page() { + const [count, setCount] = useState(0) + const [theme, setTheme] = useState('light') + const [items, setItems] = useState(['a', 'b']) + const [picked, setPicked] = useState('none') + const ref = 'r' + count + return ( + <Theme.Provider value={theme}> + <button data-label="inc" onClick={() => setCount(count + 1)}>inc</button> + <button data-label="theme" onClick={() => setTheme(theme === 'light' ? 'dark' : 'light')}>theme</button> + <button data-label="reverse" onClick={() => setItems([...items].reverse())}>reverse</button> + <output>{picked}</output> + {items.map((item) => ( + <Hydrate key={item} when={interaction()} prefetch={async ({ preload }) => { await preload() }}${split}> + <Item name={item} count={count} tag={ref} onPick={() => setPicked(item + ':' + count + ':' + theme)} /> + </Hydrate> + ))} + </Theme.Provider> + ) +}` +} + +const fixtures: Record<string, string> = { + // A boundary nested in a split boundary, behind a gate that never opens: + // the outer boundary's split code is compiled again (Rsbuild loads it + // from the module's source alone, by its own loader run) and splits the + // nested boundary in turn, with this framework's packages: the outer + // children hydrate, the nested ones keep the server's markup and stay + // inert. (Solid: the "nested" row of hydrate-pages-solid.ts runs the same + // path on Rsbuild.) + // Source: hydrate-split-modules.test.ts "react chunks loaded from the + // source code alone ..." (its Rsbuild path, which that test no longer + // covers). + nestedGates: `import { Hydrate } from '@tanstack/react-start' +import { load, never } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <Hydrate when={load()}><section><Counter label="outer" /><Hydrate when={never()}><Counter label="inner" /></Hydrate></section></Hydrate> +}`, + // These are eleven literal boundaries in one + // source module, rather than eleven instances of one mapped boundary. + eleven: `${head}export function Page() { + return <>${Array.from({ length: 11 }, (_, index) => `<Hydrate when={idle()}><Counter label="boundary-${index}" /></Hydrate>`).join('')}</> + }`, + // Edge spaces are visible inline content. + edgeSpaces: `${head}export function Page() { + return <><span data-spacing>A<Hydrate when={load()}> B </Hydrate>C</span><Hydrate when={load()}><Counter label="ready" /></Hydrate></> + }`, + // The options object is shared by a boundary + // and an ordinary server/client render consumer. + sharedFallback: `${head}const opts = { when: idle(), fallback: <b>wait</b> } +export function Page() { + return <><Hydrate {...opts}><Counter label="child" /></Hydrate><aside>{opts.fallback}</aside></> + }`, + // A render-local hoisted function still + // captures this render's values when the child runs in another module. + hoistedRows: `${head}export function Page() { + const rows = ['a', 'b'] + const suffix = '-row' + return <Hydrate when={idle()}><ul>{rows.map(renderRow)}</ul></Hydrate> + function renderRow(row: string) { + return <li key={row}><Counter label={row + suffix} /></li> + } + }`, + // Source: hydrate-boundary-forms.test.ts "a nested boundary and a later + // sibling hydrate with the ids the server renders" + nested: `${head}export function Page() { + return ( + <> + <Hydrate when={visible()}> + <Counter label="outer" /> + <Hydrate when={interaction()}> + <Counter label="nested" /> + </Hydrate> + </Hydrate> + <Hydrate when={idle()}> + <Counter label="sibling" /> + </Hydrate> + </> + ) +}`, + // Repeated instances of one boundary: each hydrates its own children. + repeated: `${head}export function Page({ items }: { items: Array<string> }) { + return <ul>{items.map((item) => <li key={item}><Hydrate when={idle()}><Counter label={item} /></Hydrate></li>)}</ul> +}`, + // Source: hydrate-split-modules.test.ts "boundaries in conditionals and + // callbacks hydrate like the server renders them" + conditionals: `${head}export function Page({ flag, items }: { flag: boolean; items: Array<string> }) { + return <div> + {flag ? <Hydrate when={idle()}><Counter label="yes" /></Hydrate> : <Hydrate when={idle()}><Counter label="no" /></Hydrate>} + {flag && <Hydrate when={idle()}><Counter label="and" /></Hydrate>} + {items.map(function (item, idx) { return <Hydrate when={idle()} key={idx}><Counter label={'fn' + item} /></Hydrate> })} + {items.map((item) => <Hydrate when={idle()} key={item}><Counter label={'arrow' + item} /></Hydrate>)} + </div> +} +export function Other({ early }: { early: boolean }) { + if (early) { return <Hydrate when={idle()}><Counter label="early" /></Hydrate> } + return <Hydrate when={idle()}><Counter label="late" /></Hydrate> +}`, + // Boundaries in mutually exclusive branches at the same position, then + // the page switches branches after it hydrated. + switching: `${head}import { useState } from 'react' +export function Page() { + const [flag, setFlag] = useState(true) + return <div> + <button data-label="switch" onClick={() => setFlag(!flag)}>switch</button> + {flag ? <Hydrate when={idle()}><Counter label="yes" /></Hydrate> : <Hydrate when={idle()}><Counter label="no" /></Hydrate>} + <Hydrate when={idle()}><Counter label="last" /></Hydrate> + </div> +}`, + // Source: hydrate-boundary-forms.test.ts "a renamed import of Hydrate is a + // boundary" + renamed: `import { Hydrate as HW } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +export function Page() { + return ( + <HW when={interaction()}> + <Counter label="search" /> + </HW> + ) +}`, + // Source: hydrate-boundary-forms.test.ts "a namespace-imported + // <Start.Hydrate> hydrates like the server renders it" + namespace: `import * as Start from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <div><Start.Hydrate when={idle()}><Counter label="namespace" /></Start.Hydrate><Start.Hydrate when={idle()}><Counter label="second" /></Start.Hydrate></div> +}`, + // Source: hydrate-split-modules.test.ts "a split={false} boundary nested in + // another does not shift the ids of later boundaries" + splitFalse: `${head}export function Page() { + return <div><Hydrate when={idle()}><section><Hydrate when={idle()} split={false}><Counter label="inline" /></Hydrate></section></Hydrate><Hydrate when={idle()}><Counter label="second" /></Hydrate></div> +}`, + // Source: hydrate-boundary-forms.test.ts "a dynamic split={flag} (%s) + // still splits the children" + dynamicSplit: `${head}export function Page({ flag }: { flag: boolean }) { + return <div><Hydrate when={idle()} split={flag}><Counter label="dynamic" /></Hydrate><Hydrate when={idle()}><Counter label="after" /></Hydrate></div> +}`, + // A let the component reassigns before the boundary renders: the + // hydrated children read its latest value. + latestLet: `${head}export function Page({ active }: { active: boolean }) { + let label = 'first' + if (active) { + label = 'second' + } + return <Hydrate when={idle()}><Counter label={label} /></Hydrate> +}`, +} + +/** `Page` with an `other` boundary and a `child` boundary written as `child`. */ +const prefetchPage = ( + child: string, + setup = '', + app = '', +) => `${head}import type { HydrateOptions } from '@tanstack/react-start' +export function Page(props: any) { + ${setup}return <div><Hydrate when={interaction()}><Counter label="other" /></Hydrate>${child}</div> +} +${app}` + +// Source: hydrate-split-modules.test.ts "a boundary with $name preloads its +// own chunk" (hydrateWhen Basic fixture), with `interaction()` boundaries so +// that only `prefetch` loads code before a click. +const prefetchRows = { + // Control: without prefetch, nothing loads before a click. + prefetchNone: prefetchPage( + `<Hydrate when={interaction()}><Counter label="child" /></Hydrate>`, + ), + prefetchDirect: prefetchPage( + `<Hydrate when={interaction()} prefetch={idle({ timeout: 100 })}><Counter label="child" /></Hydrate>`, + ), + prefetchSpreadLiteral: prefetchPage( + `<Hydrate {...{ when: interaction(), prefetch: idle() }}><Counter label="child" /></Hydrate>`, + ), + prefetchSpreadConst: prefetchPage( + `<Hydrate {...opts}><Counter label="child" /></Hydrate>`, + '', + `const opts: HydrateOptions = { when: interaction(), prefetch: idle() }`, + ), + prefetchComputedKey: prefetchPage( + `<Hydrate when={interaction()} {...{ [props.name]: idle() }}><Counter label="child" /></Hydrate>`, + '', + `export const App = () => <Page name="prefetch" />`, + ), + prefetchNestedSpread: prefetchPage( + `<Hydrate {...{ ...props.rest }}><Counter label="child" /></Hydrate>`, + '', + `export const App = () => <Page rest={{ when: interaction(), prefetch: idle() }} />`, + ), + prefetchPropsSpread: prefetchPage( + `<Hydrate {...props}><Counter label="child" /></Hydrate>`, + '', + `export const App = () => <Page when={interaction()} prefetch={idle()} />`, + ), + prefetchMemberSpread: prefetchPage( + `<Hydrate {...props.options}><Counter label="child" /></Hydrate>`, + '', + `export const App = () => <Page options={{ when: interaction(), prefetch: idle() }} />`, + ), + prefetchReassigned: prefetchPage( + `<Hydrate {...opts}><Counter label="child" /></Hydrate>`, + `let opts: HydrateOptions = { when: interaction() } + if (props.eager) { + opts = { when: interaction(), prefetch: idle() } + } + `, + ), + // Source: hydrateWhen PrefetchState fixture + prefetchState: `${head}import { useState } from 'react' +export function Page({ split }: { split: boolean }) { + const [status, setStatus] = useState('idle') + return ( + <section> + <p data-status>{status}</p> + <Hydrate + when={interaction()} + prefetch={async ({ preload }) => { + await preload() + setStatus('prefetched') + }} + > + <Counter label="child" /> + </Hydrate> + </section> + ) +} +export function Inline() { + const [status, setStatus] = useState('idle') + return ( + <section> + <p data-status>{status}</p> + <Hydrate + when={interaction()} + split={false} + prefetch={async ({ preload }) => { + await preload() + setStatus('prefetched') + }} + > + <Counter label="child" /> + </Hydrate> + </section> + ) +}`, +} +// Source: hydrate-boundary-forms.test.ts "client: $name reaches the +// boundary" (hydrate-when-transform.test.ts fallback forms; hydrateWhen +// ObjectFallback and SplitFalse fixtures) +const fallbackForms = { + fallback_direct: `${head}export function Page() { + return <Hydrate when={visible()} fallback={<p>fallback-marker</p>}><Counter label="child" /></Hydrate> +}`, + fallback_directSplitFalse: `${head}export function Page() { + return <Hydrate when={visible()} split={false} fallback={<p>fallback-marker</p>}><Counter label="child" /></Hydrate> +}`, + fallback_directWithOthers: `${head}export function Page() { + return <Hydrate when={visible()} prefetch={() => {}} fallback={<p>fallback-marker</p>} onHydrated={() => {}}><Counter label="child" /></Hydrate> +}`, + fallback_inlineSpread: `${head}export function Page() { + return <Hydrate {...{ when: visible(), fallback: <p>fallback-marker</p> }}><Counter label="child" /></Hydrate> +}`, + fallback_parenSpread: `${head}export function Page() { + return <Hydrate {...({ when: visible(), fallback: <p>fallback-marker</p> })}><Counter label="child" /></Hydrate> +}`, + fallback_spreadBefore: `${head}const props = { when: visible(), fallback: <p>fallback-marker</p> } +export function Page() { + return <Hydrate {...props}><Counter label="child" /></Hydrate> +}`, + fallback_spreadAfter: `${head}export function Page() { + return <Hydrate {...props}><Counter label="child" /></Hydrate> +} +const props = { when: visible(), fallback: <p>fallback-marker</p> }`, + fallback_parenSpreadConst: `${head}const props = ({ when: visible(), fallback: <p>fallback-marker</p> }) +export function Page() { + return <Hydrate {...(props)}><Counter label="child" /></Hydrate> +}`, + fallback_moduleElement: `${head}const fallback = <p>fallback-marker</p> +export function Page() { + return <Hydrate when={visible()} fallback={fallback}><Counter label="child" /></Hydrate> +}`, + fallback_moduleElementSplitFalse: `${head}const fallback = <p>fallback-marker</p> +export function Page() { + return <Hydrate when={visible()} split={false} fallback={fallback}><Counter label="child" /></Hydrate> +}`, + fallback_computedKey: `${head}export function Page() { + return <Hydrate {...{ when: visible(), ['fallback']: <p>fallback-marker</p> }}><Counter label="child" /></Hydrate> +}`, + fallback_quotedKeys: `${head}export function Page() { + return <Hydrate {...{ 'when': visible(), 'fallback': <p>fallback-marker</p> }}><Counter label="child" /></Hydrate> +}`, + fallback_spreadSplitFalse: `${head}const props = { when: visible(), fallback: <p>fallback-marker</p> } +export function Page() { + return <Hydrate split={false} {...props}><Counter label="child" /></Hydrate> +}`, +} + +Object.assign(fixtures, fallbackForms, prefetchRows, { + // Source: hydrate-boundary-forms.test.ts "a direct fallback next to + // prefetch and onHydrated": both reach the client boundary. + callbacks: `${head}export function Page() { + return <Hydrate when={idle()} prefetch={() => { (globalThis as any).__prefetched = true }} onHydrated={() => { (globalThis as any).__hydrated = true }} fallback={<p>fallback-marker</p>}><Counter label="child" /></Hydrate> +}`, + // Source: hydrate-boundary-forms.test.ts \`when\` table (interaction + // with options): the boundary hydrates on the events written only. + focusGate: `${head}export function Page() { + return <Hydrate when={interaction({ events: 'focusin' })}><Counter label="child" /></Hydrate> +}`, + // Source: hydrate-split-modules.test.ts "client: children may contain + // return statements" (#8504, click handler and IIFE) + returns: `${head}const letters = ['a', 'b'] +export function Page() { + return <Hydrate when={load()}><ul onClick={() => { (globalThis as any).__clicked = 'click'; return 'click' }}>{letters.map((letter) => { const upper = letter.toUpperCase(); return <li key={letter}>{upper}</li> })}{(function () { return 'iife' })()}</ul></Hydrate> +}`, + // A function \`when\`: evaluated on the client only. + whenFunction: `${head}export function Page() { + return ( + <Hydrate + when={() => { + ;((globalThis as any).__whenCalls ??= []).push(typeof window) + return idle() + }} + > + <Counter label="dynamic" /> + </Hydrate> + ) +}`, + // Source: hydrate-split-modules.test.ts "$name is called from the split + // chunk by the id the server runs" (Qwik optimizer example_strip_exports_used) + serverFnExported: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +const call = () => { + greet({ fetch: (globalThis as any).__recordFetch }).catch(() => {}) +} +export const greet = createServerFn().handler(async () => 'greet-handler-marker') +export function Page() { + return <><button data-label="a" onClick={call}>a</button><Hydrate when={load()}><button data-label="b" onClick={() => greet({ fetch: (globalThis as any).__recordFetch }).catch(() => {})}>b</button></Hydrate></> +}`, + serverFnPrivate: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +const greet = createServerFn().handler(async () => 'greet-handler-marker') +export function Page() { + return <Hydrate when={load()}><button data-label="b" onClick={() => greet({ fetch: (globalThis as any).__recordFetch }).catch(() => {})}>b</button></Hydrate> +}`, + // A namespace-imported boundary hydrating on interaction (recognised like + // a named import, J5.1). + namespaceGated: `import * as Start from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <Start.Hydrate when={interaction()}><Counter label="child" /></Start.Hydrate> +}`, + // Variable indirection is not analysed (SPEC 2.2): the boundary still + // defers hydration at runtime, split or not. + destructured: `import * as Start from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { Counter } from '../counter' +const { Hydrate } = Start +export function Page() { + return <Hydrate when={interaction({ events: 'focusin' })}><Counter label="child" /></Hydrate> +}`, + updates: updatesPage(''), + updatesReference: updatesPage(' split={false}'), +}) + +/** + * What the page mounts for the rows of a boundary mounted on the client: + * the fixture's page below the fold (see the scripts that scroll to it). + */ +const belowTheFold = `h('div', { children: [h('div', { key: 'above', style: { height: '5000px' } }), h(m.Page, { key: 'page' })] })` + +/** + * Page script: clicks every counter once (in document order, each after the + * previous one updated, so a boundary that hydrates on interaction hydrates + * first) and returns the labels and counts the page then shows. + */ +const clickEveryCounter = `const counters = () => [...root.querySelectorAll('button[data-label]')].filter((button) => button.dataset.label !== 'switch') +for (const label of counters().map((button) => button.dataset.label)) { + const button = () => root.querySelector('button[data-label="' + label + '"]') + await clickUntil(button, () => button().textContent === label + ':1') +} +return counters().map((button) => button.textContent)` + +/** The React page tests, on an app built with `bundler`. */ +export function reactPageSuite(bundler: StartBundler) { + describe.concurrent('React Hydrate pages', () => { + let app: HydrationApp + const cleanups: Array<() => Promise<void>> = [] + + beforeAll(async () => { + app = await buildHydrationApp({ + bundler, + fixtures, + files: { 'src/counter.tsx': counterFile, 'src/theme.tsx': themeFile }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + }, 60_000) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + /** Hydrates fixture `name`; every child counts one click; no error. */ + async function expectChildrenHydrate( + name: string, + labels: Array<string>, + options: HydrateOptions = {}, + ) { + const page = await app.hydrate(name, { + script: clickEveryCounter, + ...options, + }) + for (const label of labels) { + expect(page.serverHtml).toContain(`>${label}:0<`) + } + expect({ + clicked: page.result, + recoverableErrors: page.recoverableErrors, + consoleErrors: page.consoleErrors, + }).toEqual({ + clicked: labels.map((label) => `${label}:1`), + recoverableErrors: [], + consoleErrors: [], + }) + return page + } + + describe.concurrent( + 'boundaries hydrate the HTML the server rendered', + () => { + test('eleven literal boundaries all hydrate and respond independently', async () => { + await expectChildrenHydrate( + 'eleven', + Array.from({ length: 11 }, (_, index) => `boundary-${index}`), + ) + }) + + test('inline text keeps its leading and trailing spaces after hydration', async () => { + const page = await app.hydrate('edgeSpaces', { + script: `await clickUntil(() => root.querySelector('button'), () => root.querySelector('button').textContent === 'ready:1') + return root.querySelector('[data-spacing]').textContent`, + }) + expect(page.result).toBe('A B C') + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + test('a shared fallback remains visible in an aside on server and client', async () => { + const page = await expectChildrenHydrate('sharedFallback', ['child']) + expect(page.serverHtml).toContain('<aside><b>wait</b></aside>') + expect(page.html).toContain('<aside><b>wait</b></aside>') + }) + + test('rows.map renders a function declared below its boundary', async () => { + await expectChildrenHydrate('hoistedRows', ['a-row', 'b-row']) + }) + test('a nested boundary in split children waits for its own gate', async () => { + const page = await app.hydrate('nestedGates', { + script: `const button = (label) => root.querySelector('button[data-label="' + label + '"]') +await clickUntil(() => button('outer'), () => button('outer').textContent === 'outer:1') +for (let i = 0; i < 3; i++) { + button('inner').click() + await settled(50) +} +return [button('outer').textContent, button('inner').textContent]`, + }) + expect(page.serverHtml).toContain('>outer:0<') + expect(page.serverHtml).toContain('>inner:0<') + expect(page.result).toEqual(['outer:1', 'inner:0']) + expect(page.consoleErrors).toEqual([]) + expect(page.recoverableErrors).toEqual([]) + }) + + test('a nested boundary and a later sibling', async () => { + await expectChildrenHydrate('nested', ['outer', 'nested', 'sibling']) + }) + + test('repeated instances of one boundary each hydrate their own children', async () => { + const page = await expectChildrenHydrate( + 'repeated', + ['a', 'b', 'c'], + { + props: { items: ['a', 'b', 'c'] }, + }, + ) + expect(page.requested).not.toEqual([]) + }) + + test.each([ + { + render: 'h(m.Page, { flag: true, items: ["x"] })', + labels: ['yes', 'and', 'fnx', 'arrowx'], + }, + { + render: 'h(m.Page, { flag: false, items: ["x"] })', + labels: ['no', 'fnx', 'arrowx'], + }, + { render: 'h(m.Other, { early: true })', labels: ['early'] }, + { render: 'h(m.Other, { early: false })', labels: ['late'] }, + ])( + 'boundaries in conditionals and callbacks: $render', + async ({ render, labels }) => { + await expectChildrenHydrate('conditionals', labels, { render }) + }, + ) + + // Boundaries in mutually exclusive branches may share an identity; after + // the switch the other branch's boundary renders and works, and the + // boundary after them keeps its state. + test('switching between boundaries in exclusive branches after hydration', async () => { + const page = await app.hydrate('switching', { + script: `const button = (label) => root.querySelector('button[data-label="' + label + '"]') + await clickUntil(() => button('last'), () => button('last').textContent === 'last:1') + button('switch').click() + await waitFor(() => button('no')) + await clickUntil(() => button('no'), () => button('no').textContent === 'no:1') + return { yes: Boolean(button('yes')), no: button('no').textContent, last: button('last').textContent }`, + }) + expect(page.result).toEqual({ + yes: false, + no: 'no:1', + last: 'last:1', + }) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + test('a renamed import of Hydrate', async () => { + await expectChildrenHydrate('renamed', ['search']) + }) + + test('namespace-imported Start.Hydrate boundaries', async () => { + await expectChildrenHydrate('namespace', ['namespace', 'second']) + }) + + test('a split={false} boundary nested in another, and a later boundary', async () => { + await expectChildrenHydrate('splitFalse', ['inline', 'second']) + }) + + test.each([true, false])( + 'a dynamic split={flag} (%s) and a later boundary', + async (flag) => { + await expectChildrenHydrate('dynamicSplit', ['dynamic', 'after'], { + props: { flag }, + }) + }, + ) + + test('children reading a let reassigned before the boundary show its latest value', async () => { + await expectChildrenHydrate('latestLet', ['second'], { + props: { active: true }, + }) + }) + }, + ) + + // The children of the prefetched boundary load before any interaction, and + // only them: clicking the other boundary loads its own code, clicking the + // prefetched one loads nothing more; both then work. + describe.concurrent('prefetch', () => { + test.each([ + { + name: 'prefetchDirect', + how: 'a direct prefetch prop', + render: undefined, + }, + { + name: 'prefetchSpreadLiteral', + how: 'a spread object literal', + render: undefined, + }, + { + name: 'prefetchSpreadConst', + how: 'a spread single-use object', + render: undefined, + }, + { + name: 'prefetchComputedKey', + how: 'a spread with a computed key', + render: 'h(m.App)', + }, + { + name: 'prefetchNestedSpread', + how: 'a nested spread', + render: 'h(m.App)', + }, + { + name: 'prefetchPropsSpread', + how: 'a spread of the props param', + render: 'h(m.App)', + }, + { + name: 'prefetchMemberSpread', + how: 'a spread of a member of the props', + render: 'h(m.App)', + }, + { + name: 'prefetchReassigned', + how: 'a spread of a reassigned object', + render: 'h(m.Page, { eager: true })', + }, + ])( + 'a boundary with $how loads its own children before any interaction', + async ({ name, render }) => { + const page = await app.hydrate(name, { + render, + script: `const button = (label) => root.querySelector('button[data-label="' + label + '"]') + // What the prefetch requested before any interaction (a prefetch still + // loading is not in the resource timeline yet) + const prefetched = await waitFor(() => requested().length > 0 && requested()).catch(() => []) + const click = async (label) => { + const before = requested().length + await clickUntil(() => button(label), () => button(label).textContent === label + ':1') + return requested().slice(before) + } + const other = await click('other') + const child = await click('child') + return { prefetched: prefetched.length > 0, other: other.length > 0, child }`, + }) + expect({ + result: page.result, + recoverableErrors: page.recoverableErrors, + consoleErrors: page.consoleErrors, + }).toEqual({ + result: { prefetched: true, other: true, child: [] }, + recoverableErrors: [], + consoleErrors: [], + }) + }, + ) + + test('control: without prefetch, the children load on interaction only', async () => { + const page = await app.hydrate('prefetchNone', { + script: `const prefetched = requested().length + const before = requested().length + await clickUntil(() => root.querySelector('button[data-label="child"]'), () => root.querySelector('button[data-label="child"]').textContent === 'child:1') + return { prefetched, child: requested().length - before }`, + }) + expect(page.result).toEqual({ + prefetched: 0, + child: expect.any(Number), + }) + expect((page.result as { child: number }).child).toBeGreaterThan(0) + expect(page.recoverableErrors).toEqual([]) + }) + + // A prefetch function's `preload()` loads the boundary's children; the + // state it sets shows before any interaction. + // Source: hydrateWhen PrefetchState fixture + test('a prefetch function preloads the children and updates the parent state', async () => { + const page = await app.hydrate('prefetchState', { + script: `await waitFor(() => root.querySelector('[data-status]').textContent === 'prefetched') + // What the prefetch requested before any interaction (a prefetch still + // loading is not in the resource timeline yet) + const prefetched = await waitFor(() => requested().length > 0 && requested()).catch(() => []) + const button = root.querySelector('button[data-label="child"]') + await clickUntil(() => root.querySelector('button[data-label="child"]'), () => root.querySelector('button[data-label="child"]').textContent === 'child:1') + return { prefetched: prefetched.length > 0, afterClick: requested().length - prefetched.length }`, + }) + expect(page.result).toEqual({ prefetched: true, afterClick: 0 }) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + // With `split={false}` there is no chunk: `preload()` settles without + // loading code. + test('with split={false}, preload() settles without loading code', async () => { + const page = await app.hydrate('prefetchState', { + render: 'h(m.Inline)', + script: `await waitFor(() => root.querySelector('[data-status]').textContent === 'prefetched') + return requested()`, + }) + expect(page.result).toEqual([]) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + }) + + // The function form of `when` is evaluated on the client only (J5.8): the + // server renders the boundary without calling it. + // Source: hydrate-boundary-forms.test.ts `when` table + test('a function when is called on the client only, and its strategy hydrates the children', async () => { + const page = await app.hydrate('whenFunction', { + serverScript: 'globalThis.__whenCalls ?? []', + script: `await clickUntil(() => root.querySelector('button'), () => root.querySelector('button').textContent === 'dynamic:1') + return globalThis.__whenCalls`, + }) + expect(page.serverResult).toEqual([]) + expect(page.result).toEqual(expect.arrayContaining(['object'])) + expect(page.result).not.toContain('undefined') + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + // A click in the split children calls the server fn by the id the server + // runs it under, however the chunk reaches it (its own caller or the + // parent's); the SSR build's server entry runs the handler for that id. + describe.concurrent('server fns called from split children', () => { + test.each([ + { + name: 'serverFnExported', + labels: ['a', 'b'], + what: 'an exported server fn also called by the parent', + }, + { + name: 'serverFnPrivate', + labels: ['b'], + what: 'a private server fn only called by the children', + }, + ])('$what', async ({ name, labels }) => { + const page = await app.hydrate(name, { + beforeHydration: `globalThis.__requests = [] + globalThis.__recordFetch = (url) => { + globalThis.__requests.push(new URL(String(url), location.href).pathname) + return Promise.reject(new Error('no server in the page')) + }`, + script: `for (const label of ${JSON.stringify(labels)}) { + const before = globalThis.__requests.length + await clickUntil(() => root.querySelector('button[data-label="' + label + '"]'), () => globalThis.__requests.length > before) + } + return globalThis.__requests`, + }) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + const paths = page.result as Array<string> + expect(paths.length).toBeGreaterThanOrEqual(labels.length) + for (const path of new Set(paths)) { + expect(await app.callServerFn(path)).toBe('greet-handler-marker') + } + }) + }) + + // A boundary that first mounts after the app started (no server HTML, e.g. + // after a client-side navigation) shows its fallback until its children + // load, then the children (J5.3: the client keeps the fallback, however it + // is passed; the server strips it, hydrate-boundary-forms.test.ts). The + // boundary (`visible()`) mounts below the fold, and the page scrolls to + // it once the page is idle (`requestIdleCallback`: React has no work + // left). A `visible()` boundary that becomes visible while React renders + // it hits a bug of the runtime boundary (react-start-client's + // `HydrationBoundary`, `src/hydration/visible.tsx`), outside the + // compilers, so these rows do not race it. + describe.concurrent( + 'the fallback of a boundary mounted on the client', + () => { + test.each([ + { name: 'fallback_direct', how: 'a direct fallback' }, + { + name: 'fallback_directSplitFalse', + how: 'a direct fallback with split={false}', + }, + { + name: 'fallback_directWithOthers', + how: 'a direct fallback next to prefetch and onHydrated', + }, + { name: 'fallback_inlineSpread', how: 'an inline spread' }, + { + name: 'fallback_parenSpread', + how: 'a parenthesized inline spread', + }, + { + name: 'fallback_spreadBefore', + how: 'a spread used once, declared before the component', + }, + { + name: 'fallback_spreadAfter', + how: 'a spread used once, declared after the component', + }, + { + name: 'fallback_parenSpreadConst', + how: 'a parenthesized spread used once', + }, + { name: 'fallback_moduleElement', how: 'a module-level element' }, + { + name: 'fallback_moduleElementSplitFalse', + how: 'a module-level element with split={false}', + }, + { name: 'fallback_computedKey', how: 'a computed fallback key' }, + { + name: 'fallback_quotedKeys', + how: 'an inline spread with quoted keys', + }, + { + name: 'fallback_spreadSplitFalse', + how: 'a spread used once with split={false}', + }, + ])('$how shows, then the children', async ({ name }) => { + const page = await app.hydrate(name, { + mode: 'mount', + render: belowTheFold, + script: `await new Promise((resolve) => requestIdleCallback(resolve)) + root.firstElementChild.lastElementChild.scrollIntoView() + await waitFor(() => root.querySelector('button')) + await clickUntil(() => root.querySelector('button'), () => root.querySelector('button').textContent === 'child:1')`, + }) + const fallbackAt = page.snapshots.findIndex((html) => + html.includes('fallback-marker'), + ) + expect(fallbackAt).toBeGreaterThanOrEqual(0) + expect(page.snapshots.slice(0, fallbackAt).join()).not.toContain( + 'child:', + ) + expect(page.html).not.toContain('fallback-marker') + expect(page.html).toContain('child:1') + expect(page.consoleErrors).toEqual([]) + }) + }, + ) + + describe.concurrent( + 'what the children and the boundary do once hydrated', + () => { + test('prefetch and onHydrated reach the client boundary', async () => { + const page = await app.hydrate('callbacks', { + script: `await waitFor(() => globalThis.__hydrated) + return { prefetched: globalThis.__prefetched ?? false, hydrated: globalThis.__hydrated }`, + }) + expect(page.serverHtml).not.toContain('fallback-marker') + expect(page.result).toEqual({ prefetched: true, hydrated: true }) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + test('an interaction strategy with options hydrates on its events only', async () => { + const page = await app.hydrate('focusGate', { + script: `const button = () => root.querySelector('button') + button().click() + await settled() + const beforeFocus = button().textContent + button().focus() + await clickUntil(() => button(), () => button().textContent === 'child:1') + return beforeFocus`, + }) + expect(page.result).toBe('child:0') + expect(page.html).toContain('child:1') + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + + test('a click handler with a return statement in the children runs', async () => { + const page = await app.hydrate('returns', { + script: `await clickUntil(() => root.querySelector('ul'), () => globalThis.__clicked) + return globalThis.__clicked`, + }) + expect(page.serverHtml).toContain('<li>A</li><li>B</li>iife') + expect(page.result).toBe('click') + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + }, + ) + + describe.concurrent('which elements are boundaries', () => { + // Goal (SPEC J5.1, J7.2): a + // namespace member `<Start.Hydrate>` is a boundary like a named import, + // so its children's code loads when it hydrates, not with the page. On + // main the compiler leaves it unsplit (it still hydrates the server's + // HTML: "namespace-imported Start.Hydrate boundaries" above), so the + // click loads nothing. + // Replaces the in-process goal of known-bugs-hydrate.test.ts. + test.fails( + 'a namespace-imported Start.Hydrate loads its children when it hydrates', + async () => { + const page = await app.hydrate('namespaceGated', { + script: loadedOnInteraction, + }) + expect(page.result).toEqual({ beforeClick: 0, loadedByClick: true }) + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }, + ) + + // `const { Hydrate } = Start` is not analysed (SPEC 2.2): split or not, + // the boundary keeps the server's HTML until its strategy fires (here: + // a focus, not a click), then hydrates. + test('a Hydrate destructured from the namespace still defers hydration', async () => { + const page = await app.hydrate('destructured', { + script: `const button = () => root.querySelector('button') +button().click() +await settled() +const beforeFocus = button().textContent +button().focus() +await clickUntil(() => button(), () => button().textContent === 'child:1') +return beforeFocus`, + }) + expect(page.serverHtml).toContain('child:0') + expect(page.result).toBe('child:0') + expect(page.recoverableErrors).toEqual([]) + expect(page.consoleErrors).toEqual([]) + }) + }) + + // The split children get the newest captures, context and callbacks of + // their parent, before their boundary hydrates, after their code loaded + // and after a keyed reorder, in the boundary clicked; a new `when` or + // `prefetch` object does not restart a hydrated boundary (it would show + // the server's HTML again). The same page with `split={false}` (left in + // place by the compiler) is the reference: the framework's behaviour + // (SPEC J5.8, J5.4). + test('split children follow their parent through updates and a reorder, like unsplit ones', async () => { + const [split, reference] = await Promise.all([ + app.hydrate('updates', { script: updatesScript }), + app.hydrate('updatesReference', { script: updatesScript }), + ]) + expect(reference.result).toEqual(updatesExpected) + for (const page of [split, reference]) { + expect({ + result: page.result, + recoverableErrors: page.recoverableErrors, + consoleErrors: page.consoleErrors, + }).toEqual({ + result: updatesExpected, + recoverableErrors: [], + consoleErrors: [], + }) + } + // The split page loaded the children's code (`prefetch`), the reference + // has none to load. + expect(split.requested).not.toEqual([]) + }) + }) +} diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/hydrate-pages-rsbuild.test.ts new file mode 100644 index 0000000000..06c5ff1215 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages-rsbuild.test.ts @@ -0,0 +1,7 @@ +/** + * The React `<Hydrate>` page tests (`hydrate-pages-react.ts`) on an app + * built with Start's Rsbuild plugin. + */ +import { reactPageSuite } from './hydrate-pages-react' + +reactPageSuite('rsbuild') diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages-solid-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/hydrate-pages-solid-rsbuild.test.ts new file mode 100644 index 0000000000..bc457e3414 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages-solid-rsbuild.test.ts @@ -0,0 +1,8 @@ +/** + * The Solid `<Hydrate>` page tests (`hydrate-pages-solid.ts`) on an app + * built with Start's Rsbuild plugin, `@rsbuild/plugin-babel` and + * `@rsbuild/plugin-solid`. + */ +import { solidPageSuite } from './hydrate-pages-solid' + +solidPageSuite('rsbuild') diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages-solid.test.ts b/packages/start-plugin-core/tests/integration/hydrate-pages-solid.test.ts new file mode 100644 index 0000000000..cd41158287 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages-solid.test.ts @@ -0,0 +1,7 @@ +/** + * The Solid `<Hydrate>` page tests (`hydrate-pages-solid.ts`) on an app + * built with Start's Vite plugin and `vite-plugin-solid`. + */ +import { solidPageSuite } from './hydrate-pages-solid' + +solidPageSuite('vite') diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages-solid.ts b/packages/start-plugin-core/tests/integration/hydrate-pages-solid.ts new file mode 100644 index 0000000000..8aac67fca0 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages-solid.ts @@ -0,0 +1,570 @@ +/** + * `<Hydrate>` pages of a Solid Start app (`@tanstack/solid-start`) in a + * real browser, run for each bundler by its own test file + * (`hydrate-pages-solid.test.ts`: Vite with `vite-plugin-solid`, + * `hydrate-pages-solid-rsbuild.test.ts`: Rsbuild with Solid's Babel + * preset): Start's plugin builds the app (`hydrate-pages.ts`), the SSR build renders a page with Solid's + * `renderToString`, and a page of headless Chromium runs Solid's hydration + * script and `hydrate` over that HTML with the client build. Each child is + * exercised (a click must update its signal); a hydration mismatch throws + * (failing the run) or logs. The Solid twin of the React page tests + * (`hydrate-pages-react.ts`) for what a compiler can get wrong per + * framework: the identities of the boundaries (SPEC J5.4), the boundaries + * it recognises (J5.1), the client-mount fallback (J5.3), `prefetch` + * (J5.2) and the children under parent updates (J5.8: a Solid read must + * not be frozen). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + buildHydrationApp, + loadedOnInteraction, + updatesExpected, + updatesScript, +} from './hydrate-pages' +import type { HydrateOptions, HydrationApp } from './hydrate-pages' +import type { StartBundler } from '../build-harness' + +/** A counter: `<label>:<clicks>`; clicking it counts. */ +const counterFile = `import { createSignal } from 'solid-js' +export function Counter(props: { label: string }) { + const [clicks, setClicks] = createSignal(0) + return <button data-label={props.label} onClick={() => setClicks(clicks() + 1)}>{props.label + ':' + clicks()}</button> +} +` + +/** A context of the app, declared in its own module. */ +const themeFile = `import { createContext } from 'solid-js' +export const Theme = createContext<() => string>(() => 'no-provider') +` + +const head = `import { Hydrate } from '@tanstack/solid-start' +import { idle, interaction, visible } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +` + +/** + * The parent-update page of `updatesScript` (see `hydrate-pages-react.ts` + * `updatesPage`) in Solid: signals, a context holding an accessor, `<For>`. + * With `inRow`, the boundary is in a component of its own (`Row`), whose + * children read the values from its reactive `props`. + */ +function updatesPage(split: string, inRow = false) { + const boundary = (values: string) => + `<Hydrate when={interaction()} prefetch={async ({ preload }) => { await preload() }}${split}> + <Item ${values} /> + </Hydrate>` + return `import { Hydrate } from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { For, createSignal, useContext } from 'solid-js' +import { Theme } from '../theme' +function Item(props: { name: string; count: number; tag: string; onPick: () => void }) { + const theme = useContext(Theme) + return <button data-item={props.name} onClick={() => props.onPick()}>{[props.name, props.count, theme(), props.tag].join('|')}</button> +} +${ + inRow + ? `function Row(props: { name: string; count: number; tag: string; onPick: () => void }) { + return ( + ${boundary('name={props.name} count={props.count} tag={props.tag} onPick={() => props.onPick()}')} + ) +} +` + : '' +}export function Page() { + const [count, setCount] = createSignal(0) + const [theme, setTheme] = createSignal('light') + const [items, setItems] = createSignal(['a', 'b']) + const [picked, setPicked] = createSignal('none') + const ref = () => 'r' + count() + return ( + <Theme.Provider value={theme}> + <button data-label="inc" onClick={() => setCount(count() + 1)}>inc</button> + <button data-label="theme" onClick={() => setTheme(theme() === 'light' ? 'dark' : 'light')}>theme</button> + <button data-label="reverse" onClick={() => setItems([...items()].reverse())}>reverse</button> + <output>{picked()}</output> + <For each={items()}> + {(item) => ( + ${ + inRow + ? `<Row name={item} count={count()} tag={ref()} onPick={() => setPicked(item + ':' + count() + ':' + theme())} />` + : boundary( + `name={item} count={count()} tag={ref()} onPick={() => setPicked(item + ':' + count() + ':' + theme())}`, + ) + } + )} + </For> + </Theme.Provider> + ) +}` +} + +/** + * A page whose boundary's children bind an element to a `let` of the + * component (Solid's `ref={input}` assigns the element to `input`), which a + * button outside the boundary reads. + */ +function letRefPage(split: string) { + return `${head}import { createSignal } from 'solid-js' +export function Page() { + let input: HTMLInputElement | undefined + const [read, setRead] = createSignal('none') + return ( + <div> + <button data-read onClick={() => setRead(input ? input.value : 'unset')}>read</button> + <output>{read()}</output> + <Hydrate when={interaction()}${split}><input ref={input} value="typed" /><Counter label="child" /></Hydrate> + </div> + ) +}` +} + +/** + * A page whose boundary's children use a Solid directive (`use:tip`, which + * Solid's JSX transform turns into a call of `tip` where the JSX ends up), + * declared at module level or in the component (`where`). + */ +function directivePage(where: 'module' | 'component') { + const tip = `function tip(el: HTMLElement) { + el.dataset.tip = '${where}' +} +` + return `${head}${where === 'module' ? tip : ''}export function Page() { + ${where === 'component' ? tip : ''}return <Hydrate when={idle()}><span use:tip><Counter label="child" /></span></Hydrate> +}` +} + +/** + * A page rendering `boundary` once the app hydrated (`useHydrated` of the + * real router), like a boundary that appears after the app started (e.g. + * after a client-side navigation): Solid's `Hydrate` then renders its + * fallback until its children load. (Mounted with the app instead, it + * treats the mount as the initial hydration and keeps the server's HTML, + * which a mounted page has not.) `setup` comes before the component. + */ +function afterHydration(setup: string, boundary: string) { + return `${head}import { Show } from 'solid-js' +import { useHydrated } from '@tanstack/solid-router' +${setup}export function Page() { + const hydrated = useHydrated() + return <Show when={hydrated()}>${boundary}</Show> +}` +} + +const fixtures: Record<string, string> = { + nested: `${head}export function Page() { + return ( + <> + <Hydrate when={visible()}> + <Counter label="outer" /> + <Hydrate when={interaction()}> + <Counter label="nested" /> + </Hydrate> + </Hydrate> + <Hydrate when={idle()}> + <Counter label="sibling" /> + </Hydrate> + </> + ) +}`, + repeated: `${head}import { For } from 'solid-js' +export function Page(props: { items: Array<string> }) { + return <ul><For each={props.items}>{(item) => <li><Hydrate when={idle()}><Counter label={item} /></Hydrate></li>}</For></ul> +}`, + conditionals: `${head}import { Show } from 'solid-js' +export function Page(props: { flag: boolean; items: Array<string> }) { + return <div> + <Show when={props.flag} fallback={<Hydrate when={idle()}><Counter label="no" /></Hydrate>}><Hydrate when={idle()}><Counter label="yes" /></Hydrate></Show> + {props.flag && <Hydrate when={idle()}><Counter label="and" /></Hydrate>} + {props.items.map((item) => <Hydrate when={idle()}><Counter label={'arrow' + item} /></Hydrate>)} + </div> +}`, + renamed: `import { Hydrate as HW } from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <HW when={interaction()}><Counter label="search" /></HW> +}`, + namespace: `import * as Start from '@tanstack/solid-start' +import { idle } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <div><Start.Hydrate when={idle()}><Counter label="namespace" /></Start.Hydrate><Start.Hydrate when={idle()}><Counter label="second" /></Start.Hydrate></div> +}`, + namespaceGated: `import * as Start from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +export function Page() { + return <Start.Hydrate when={interaction()}><Counter label="child" /></Start.Hydrate> +}`, + gated: `${head}export function Page() { + return <Hydrate when={interaction()}><Counter label="child" /></Hydrate> +}`, + destructured: `import * as Start from '@tanstack/solid-start' +import { interaction } from '@tanstack/solid-start/hydration' +import { Counter } from '../counter' +const { Hydrate } = Start +export function Page() { + return <Hydrate when={interaction({ events: 'focusin' })}><Counter label="child" /></Hydrate> +}`, + splitFalse: `${head}export function Page() { + return <div><Hydrate when={idle()}><section><Hydrate when={idle()} split={false}><Counter label="inline" /></Hydrate></section></Hydrate><Hydrate when={idle()}><Counter label="second" /></Hydrate></div> +}`, + dynamicSplit: `${head}export function Page(props: { flag: boolean }) { + return <div><Hydrate when={idle()} split={props.flag}><Counter label="dynamic" /></Hydrate><Hydrate when={idle()}><Counter label="after" /></Hydrate></div> +}`, + latestLet: `${head}export function Page(props: { active: boolean }) { + let label = 'first' + if (props.active) { + label = 'second' + } + return <Hydrate when={idle()}><Counter label={label} /></Hydrate> +}`, + prefetch: `${head}export function Page() { + return <div><Hydrate when={interaction()}><Counter label="other" /></Hydrate><Hydrate when={interaction()} prefetch={idle({ timeout: 100 })}><Counter label="child" /></Hydrate></div> +}`, + fallbackDirect: afterHydration( + '', + `<Hydrate when={visible()} fallback={<p>fallback-marker</p>}><Counter label="child" /></Hydrate>`, + ), + fallbackSpread: afterHydration( + `const props = { when: visible(), fallback: <p>fallback-marker</p> }\n`, + `<Hydrate {...props}><Counter label="child" /></Hydrate>`, + ), + fallbackModuleElement: afterHydration( + `const fallback = <p>fallback-marker</p>\n`, + `<Hydrate when={visible()} fallback={fallback}><Counter label="child" /></Hydrate>`, + ), + updates: updatesPage(''), + updatesReference: updatesPage(' split={false}'), + updatesProps: updatesPage('', true), + updatesPropsReference: updatesPage(' split={false}', true), + letRef: letRefPage(''), + letRefReference: letRefPage(' split={false}'), + directiveModule: directivePage('module'), + directiveComponent: directivePage('component'), + // A context declared in the page module itself. + localContext: `import { Hydrate } from '@tanstack/solid-start' +import { idle } from '@tanstack/solid-start/hydration' +import { createContext, useContext } from 'solid-js' +const Theme = createContext('no-provider') +function Label() { + return <span data-theme>{useContext(Theme)}</span> +} +export function Page() { + return <Theme.Provider value="dark"><Hydrate when={idle()}><Label /></Hydrate></Theme.Provider> +}`, +} + +/** + * Page script: clicks every counter once (in document order, each after the + * previous one updated) and returns the labels and counts the page shows. + */ +const clickEveryCounter = `const counters = () => [...root.querySelectorAll('button[data-label]')] +for (const label of counters().map((button) => button.dataset.label)) { + const button = () => root.querySelector('button[data-label="' + label + '"]') + await clickUntil(button, () => button().textContent === label + ':1') +} +return counters().map((button) => button.textContent)` + +/** The Solid page tests, on an app built with `bundler`. */ +export function solidPageSuite(bundler: StartBundler) { + let app: HydrationApp + const cleanups: Array<() => Promise<void>> = [] + + beforeAll(async () => { + app = await buildHydrationApp({ + framework: 'solid', + bundler, + fixtures, + files: { 'src/counter.tsx': counterFile, 'src/theme.tsx': themeFile }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + }, 60_000) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + /** Hydrates fixture `name`; every child counts one click; no error. */ + async function expectChildrenHydrate( + name: string, + labels: Array<string>, + options: HydrateOptions = {}, + ) { + const page = await app.hydrate(name, { + script: clickEveryCounter, + ...options, + }) + for (const label of labels) { + expect(page.serverHtml).toContain(`>${label}:0<`) + } + expect({ clicked: page.result, consoleErrors: page.consoleErrors }).toEqual( + { + clicked: labels.map((label) => `${label}:1`), + consoleErrors: [], + }, + ) + return page + } + + describe.concurrent('boundaries hydrate the HTML the server rendered', () => { + test('a nested boundary and a later sibling', async () => { + await expectChildrenHydrate('nested', ['outer', 'nested', 'sibling']) + }) + + test('repeated instances of one boundary each hydrate their own children', async () => { + const page = await expectChildrenHydrate('repeated', ['a', 'b', 'c'], { + props: { items: ['a', 'b', 'c'] }, + }) + expect(page.requested).not.toEqual([]) + }) + + test.each([ + { props: { flag: true, items: ['x'] }, labels: ['yes', 'and', 'arrowx'] }, + { props: { flag: false, items: ['x'] }, labels: ['no', 'arrowx'] }, + ])( + 'boundaries in conditionals and callbacks: $props.flag', + async ({ props, labels }) => { + await expectChildrenHydrate('conditionals', labels, { props }) + }, + ) + + test('a renamed import of Hydrate', async () => { + await expectChildrenHydrate('renamed', ['search']) + }) + + test('namespace-imported Start.Hydrate boundaries', async () => { + await expectChildrenHydrate('namespace', ['namespace', 'second']) + }) + + test('a split={false} boundary nested in another, and a later boundary', async () => { + await expectChildrenHydrate('splitFalse', ['inline', 'second']) + }) + + test.each([true, false])( + 'a dynamic split={flag} (%s) and a later boundary', + async (flag) => { + await expectChildrenHydrate('dynamicSplit', ['dynamic', 'after'], { + props: { flag }, + }) + }, + ) + + test('children reading a let reassigned before the boundary show its latest value', async () => { + await expectChildrenHydrate('latestLet', ['second'], { + props: { active: true }, + }) + }) + + // Bug: a Solid directive names its function in a JSX attribute only + // (`use:tip`), which the Hydrate transform does not take for a use of + // `tip`: the chunk neither declares a module-level `tip` nor receives a + // component's `tip` as a capture, and Solid's JSX transform turns the + // attribute into a call of `tip` in the chunk. SPEC G1, J5.2. + // Impact: the children throw "tip is not defined" when the boundary + // hydrates, and stay the server's HTML. + // (A directive runs on the client only: its attribute shows that the + // children hydrated.) + test.fails.each([ + { where: 'module', fixture: 'directiveModule' }, + { where: 'component', fixture: 'directiveComponent' }, + ])( + 'split children run a directive declared in the $where', + async ({ where, fixture }) => { + const page = await app.hydrate(fixture, { + script: `return root.querySelector('span').dataset.tip ?? 'none'`, + }) + expect({ + tip: page.result, + consoleErrors: page.consoleErrors, + }).toEqual({ tip: where, consoleErrors: [] }) + }, + ) + }) + + describe.concurrent( + 'which elements are boundaries, and when code loads', + () => { + // Control of the pin below: a named import's children load when the + // boundary hydrates. + test('a boundary loads its children when it hydrates', async () => { + const page = await app.hydrate('gated', { script: loadedOnInteraction }) + expect(page.result).toEqual({ beforeClick: 0, loadedByClick: true }) + expect(page.consoleErrors).toEqual([]) + }) + + // Goal (SPEC J5.1, J7.2): a + // namespace member `<Start.Hydrate>` of `@tanstack/solid-start` is a + // boundary like a named import. On main it is left unsplit (it hydrates: + // "namespace-imported Start.Hydrate boundaries" above), so the click + // loads nothing. + test.fails( + 'a namespace-imported Start.Hydrate loads its children when it hydrates', + async () => { + const page = await app.hydrate('namespaceGated', { + script: loadedOnInteraction, + }) + expect(page.result).toEqual({ beforeClick: 0, loadedByClick: true }) + expect(page.consoleErrors).toEqual([]) + }, + ) + + // Not analysed (SPEC 2.2): split or not, it keeps the server's HTML until + // its strategy fires (a focus, not a click). + test('a Hydrate destructured from the namespace still defers hydration', async () => { + const page = await app.hydrate('destructured', { + script: `const button = () => root.querySelector('button') + button().click() + await settled() + const beforeFocus = button().textContent + button().focus() + await clickUntil(() => button(), () => button().textContent === 'child:1') + return beforeFocus`, + }) + expect(page.result).toBe('child:0') + expect(page.consoleErrors).toEqual([]) + }) + + // The prefetched boundary's children load before any interaction; the + // other boundary's on its click; the prefetched one's click loads + // nothing more. + test('a prefetched boundary loads its own children before any interaction', async () => { + const page = await app.hydrate('prefetch', { + script: `const button = (label) => root.querySelector('button[data-label="' + label + '"]') + // What the prefetch requested before any interaction (a prefetch still + // loading is not in the resource timeline yet) + const prefetched = await waitFor(() => requested().length > 0 && requested()).catch(() => []) + const click = async (label) => { + const before = requested().length + await clickUntil(() => button(label), () => button(label).textContent === label + ':1') + return requested().slice(before) + } + const other = await click('other') + const child = await click('child') + return { prefetched: prefetched.length > 0, other: other.length > 0, child }`, + }) + expect(page.result).toEqual({ + prefetched: true, + other: true, + child: [], + }) + expect(page.consoleErrors).toEqual([]) + }) + }, + ) + + // A boundary that appears after the app started shows its fallback until + // its children load, then the children (J5.3: the client keeps the + // fallback, however it is passed). + describe.concurrent( + 'the fallback of a boundary mounted on the client', + () => { + test.each([ + { name: 'fallbackDirect', how: 'a direct fallback' }, + { name: 'fallbackSpread', how: 'a spread used once' }, + { name: 'fallbackModuleElement', how: 'a module-level element' }, + ])('$how shows, then the children', async ({ name }) => { + const page = await app.hydrate(name, { + mode: 'mount', + script: `await waitFor(() => root.querySelector('button')) + await clickUntil(() => root.querySelector('button'), () => root.querySelector('button').textContent === 'child:1')`, + }) + const fallbackAt = page.snapshots.findIndex((html) => + html.includes('fallback-marker'), + ) + expect(fallbackAt).toBeGreaterThanOrEqual(0) + expect(page.snapshots.slice(0, fallbackAt).join()).not.toContain( + 'child:', + ) + expect(page.html).not.toContain('fallback-marker') + expect(page.html).toContain('child:1') + expect(page.consoleErrors).toEqual([]) + }) + }, + ) + + describe.concurrent('the children under parent updates', () => { + // The split children read the newest signals, context and callbacks + // (never a frozen first read), before their boundary hydrates, after + // their code loaded and after a reorder, in the boundary clicked. The + // same page with `split={false}` is the reference (SPEC J5.8, J5.4). + test('split children follow their parent through updates and a reorder, like unsplit ones', async () => { + const [split, reference] = await Promise.all([ + app.hydrate('updates', { script: updatesScript }), + app.hydrate('updatesReference', { script: updatesScript }), + ]) + expect(reference.result).toEqual(updatesExpected) + for (const page of [split, reference]) { + expect({ + result: page.result, + consoleErrors: page.consoleErrors, + }).toEqual({ result: updatesExpected, consoleErrors: [] }) + } + expect(split.requested).not.toEqual([]) + }) + + // The same through the reactive `props` of the component holding the + // boundary (a Solid read of `props.count` must stay live, SPEC J5.8). + test('split children follow the props of their component through updates and a reorder, like unsplit ones', async () => { + const [split, reference] = await Promise.all([ + app.hydrate('updatesProps', { script: updatesScript }), + app.hydrate('updatesPropsReference', { script: updatesScript }), + ]) + for (const page of [split, reference]) { + expect({ + result: page.result, + consoleErrors: page.consoleErrors, + }).toEqual({ result: updatesExpected, consoleErrors: [] }) + } + expect(split.requested).not.toEqual([]) + }) + + // Bug: `ref={input}` in the children binds the element to the + // component's `let` (Solid assigns it), which code outside the boundary + // reads, as with `split={false}`. The chunk receives `input` as a prop + // and assigns its own parameter, so the component's `let` stays unset. + // SPEC J5.8 (extraction keeps legal `ref` behaviour). + // Impact: silently, the parent never sees the element (`input` stays + // `undefined`): focusing or reading it does nothing. + test.fails( + 'a ref in split children binds the let of their component', + async () => { + const script = `const counter = () => root.querySelector('button[data-label="child"]') +await clickUntil(counter, () => counter().textContent === 'child:1') +root.querySelector('button[data-read]').click() +await settled() +return root.querySelector('output').textContent` + const [split, reference] = await Promise.all([ + app.hydrate('letRef', { script }), + app.hydrate('letRefReference', { script }), + ]) + expect( + [split, reference].map((page) => ({ + read: page.result, + consoleErrors: page.consoleErrors, + })), + ).toEqual([ + { read: 'typed', consoleErrors: [] }, + { read: 'typed', consoleErrors: [] }, + ]) + }, + ) + + // Bug: the chunk re-declares the module-level bindings its children use + // instead of using the parent module's (`createContext` runs again + // there), the Solid twin of known-bugs-hydrate.test.ts "client: the + // children use the module-level context of the parent module". + // Found with a context declared in the page module. + // Impact: split children of a Solid page read another context than the + // one their parent provides (here its default value). + test.fails( + 'split children read a context declared in the page module', + async () => { + const page = await app.hydrate('localContext') + expect(page.serverHtml).toContain('>dark<') + expect(page.html).toContain('>dark<') + expect(page.consoleErrors).toEqual([]) + }, + ) + }) +} diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages.test.ts b/packages/start-plugin-core/tests/integration/hydrate-pages.test.ts new file mode 100644 index 0000000000..00711ab529 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages.test.ts @@ -0,0 +1,7 @@ +/** + * The React `<Hydrate>` page tests (`hydrate-pages-react.ts`) on an app + * built with Start's Vite plugin. + */ +import { reactPageSuite } from './hydrate-pages-react' + +reactPageSuite('vite') diff --git a/packages/start-plugin-core/tests/integration/hydrate-pages.ts b/packages/start-plugin-core/tests/integration/hydrate-pages.ts new file mode 100644 index 0000000000..43979c65bb --- /dev/null +++ b/packages/start-plugin-core/tests/integration/hydrate-pages.ts @@ -0,0 +1,457 @@ +/** + * Real hydration of `<Hydrate>` pages: an app built with Start's own Vite or + * Rsbuild plugin (`buildStart`: the Start compiler, its Hydrate plugin and + * the real `@tanstack/react-start` or `@tanstack/solid-start`, in a + * development build, so the framework reports hydration mismatches) + * renders each fixture module to HTML in its SSR build (Node, + * `react-dom/server` or Solid's `renderToString`), and a page of headless + * Chromium hydrates that HTML with the client build: React's `hydrateRoot` + * with its recoverable errors recorded, or Solid's `hydrate` after the + * hydration script Solid's server generates. `console.error` output is + * recorded too. A test script then runs in the page (e.g. clicks a child) + * and its result is returned with the page's markup and the scripts the + * page requested after it loaded. + * + * Solid apps get Solid's JSX transform of each bundler (`solidAppConfig`). + * + * Thin glue only: the compiler, bundler, React or Solid, router and Start + * runtime are the real ones; the harness writes the entries, moves the + * server's HTML into the page and waits until the page is quiet. + */ +import solid from 'vite-plugin-solid' +import { pluginBabel } from '@rsbuild/plugin-babel' +import { pluginSolid } from '@rsbuild/plugin-solid' +import { buildStart, callByIdExports, callByIdPrelude } from '../build-harness' +import type { StartBuild, StartBundler } from '../build-harness' +import type { RsbuildConfig } from '@rsbuild/core' + +/** The Start framework packages a page app can be built with. */ +export type PageFramework = 'react' | 'solid' + +/** + * JavaScript of a page script: waits until the page requested no new + * resource and changed no markup for `quiet` ms (default 150), and stays so + * across an idle period of the browser (`requestIdleCallback`: work that + * waits for idle time, such as an `idle()` boundary's hydration, has had + * its turn; parent-first hydration of nested boundaries shows up as a + * change, which restarts the wait), at most `timeout` ms (default 10 000). + * Only what the page shows and loads counts, no runtime marker. + */ +const settledSource = `async (quiet = 150, timeout = 10000) => { + const start = performance.now() + const state = () => performance.getEntriesByType('resource').length + ':' + document.body.innerHTML + let last = '' + let since = performance.now() + while (performance.now() - start < timeout) { + await new Promise((resolve) => setTimeout(resolve, 25)) + const now = state() + if (now !== last) { + last = now + since = performance.now() + continue + } + if (performance.now() - since < quiet) { + continue + } + await new Promise((resolve) => requestIdleCallback(resolve, { timeout: 500 })) + await new Promise((resolve) => setTimeout(resolve, 25)) + if (state() === last) { + return + } + } + throw new Error('the page did not settle: ' + document.body.innerHTML) +}` + +/** + * JavaScript of a page script: polls `condition` until it returns a truthy + * value (which it resolves to), at most `timeout` ms (default 5 000). + */ +const waitForSource = `async (condition, timeout = 5000) => { + const start = performance.now() + while (performance.now() - start < timeout) { + const value = await condition() + if (value) { + return value + } + await new Promise((resolve) => setTimeout(resolve, 20)) + } + throw new Error('timed out waiting for ' + condition + ': ' + document.body.innerHTML) +}` + +/** + * JavaScript of a page script: clicks `element()` until `done()` returns a + * truthy value (which it resolves to), at most `timeout` ms (default + * 10 000). After a click a deferred boundary took in (the page cancels it: + * the boundary's code loads, then it hydrates and redispatches the click, + * deferred-hydration.md), it waits for the page to change (the code loaded, + * the boundary hydrated) and settle before it clicks again: a click repeated + * while the code loads would be replayed with the first. Any other click + * that does not get `done()` (its boundary is not interactive yet) is + * repeated once the page settled. + */ +const clickUntilSource = `async (element, done, timeout = 10000) => { + const start = performance.now() + const left = () => Math.max(timeout - (performance.now() - start), 1) + const state = () => performance.getEntriesByType('resource').length + ':' + document.body.innerHTML + while (performance.now() - start < timeout) { + const before = state() + const click = new MouseEvent('click', { bubbles: true, cancelable: true, composed: true, view: window }) + if (!element().dispatchEvent(click)) { + await waitFor(async () => (await done()) || state() !== before, left()) + } + await settled(50) + const value = await done() + if (value) { + return value + } + } + throw new Error('timed out clicking until ' + done + ': ' + document.body.innerHTML) +}` + +export interface Hydrated { + /** The HTML the SSR build rendered (`''` when the page mounted). */ + serverHtml: string + /** What `serverScript` returned after the server render. */ + serverResult: unknown + /** Markup of the page root after hydration and the script. */ + html: string + /** + * Every markup the root had, in order, from before hydration (or the + * mount) until the script ran. + */ + snapshots: Array<string> + /** + * Errors React reported through `onRecoverableError` (always empty for + * Solid, which has no such channel: a Solid mismatch throws, which fails + * the run, or logs to `console.error`). + */ + recoverableErrors: Array<string> + /** `console.error` output of the page (hydration warnings). */ + consoleErrors: Array<string> + /** Scripts the page requested after the server HTML was in place. */ + requested: Array<string> + /** What the script returned. */ + result: unknown +} + +export interface HydrateOptions { + /** + * What to render: a JavaScript expression with the fixture module as `m`, + * `h(component, props)` (React's `createElement`, Solid's + * `createComponent`) and `props` in scope (default `h(m.Page, props)`). + */ + render?: string + /** JSON props of the default render. */ + props?: Record<string, unknown> + /** + * Body of an async function run in the page once it hydrated and settled, + * with `root` (the hydrated element), `settled()`, `waitFor(condition)`, + * `clickUntil(element, done)` and `requested()` (the scripts requested so + * far) in scope; its JSON result is returned. + */ + script?: string + /** + * Body of an async function run in the page after the server HTML is in + * place and before hydration starts (e.g. counters the fixture reads). + */ + beforeHydration?: string + /** + * A JavaScript expression evaluated in the SSR run after the server + * render (`entry` in scope); its JSON value is `serverResult`. + */ + serverScript?: string + /** + * `mount`: no server render; the page mounts the element into an empty + * root (React's `createRoot`, Solid's `render`), like a boundary that + * first appears after the app started (e.g. after a client-side + * navigation). Default `hydrate`. + */ + mode?: 'hydrate' | 'mount' +} + +export interface HydrationApp { + build: StartBuild + /** Renders fixture `name` on the server and hydrates it in a page. */ + hydrate: (name: string, options?: HydrateOptions) => Promise<Hydrated> + /** + * Sends the request of a client call of the server fn of `url` (a server + * fn URL a page requested) to Start's server entry of the SSR build + * (`callByIdPrelude`) and gives the result, or the error message (React + * apps). + */ + callServerFn: (url: string, data?: unknown) => Promise<unknown> +} + +/** + * Page script of the parent-update scenario (SPEC J5.8), + * for a page with two keyed boundaries (`a`, `b`, hydrating on + * interaction) rendering a child `<button data-item=name>` that shows + * `name|count|theme|tag` and, when clicked, puts `name:count:theme` in the + * page's `<output>`; the page's buttons `inc` (count), `theme` (the + * context's value) and `reverse` (the order of the boundaries). The page + * changes count and theme before any boundary hydrated, opens `a`, + * changes count after `a` loaded, reverses the boundaries, changes count + * again and opens `b`. Returns the children's texts at each step and the + * picks (`updatesExpected`). + */ +export const updatesScript = `const texts = () => [...root.querySelectorAll('button[data-item]')].map((button) => button.textContent) +const picked = () => root.querySelector('output').textContent +const press = async (label) => { + root.querySelector('button[data-label="' + label + '"]').click() + await settled(50) +} +const picks = [] +// Clicks the child until the page shows a new pick (the first click may only +// hydrate the boundary). +const pick = async (name) => { + const before = picked() + await clickUntil(() => root.querySelector('button[data-item="' + name + '"]'), () => picked() !== before) + picks.push(picked()) +} +await press('inc') +await press('theme') +const beforeGate = texts() +await pick('a') +const opened = texts() +await press('inc') +const updated = texts() +await pick('a') +await press('reverse') +await press('inc') +const reordered = texts() +await pick('b') +await pick('a') +return { beforeGate, opened, updated, reordered, final: texts(), picks }` + +/** What `updatesScript` returns when the children get the newest values. */ +export const updatesExpected = { + // Not hydrated yet: the server's HTML. + beforeGate: ['a|0|light|r0', 'b|0|light|r0'], + // `a` hydrates with the values of the latest render. + opened: ['a|1|dark|r1', 'b|0|light|r0'], + updated: ['a|2|dark|r2', 'b|0|light|r0'], + reordered: ['b|0|light|r0', 'a|3|dark|r3'], + final: ['b|3|dark|r3', 'a|3|dark|r3'], + // The callback of the latest render, of the boundary clicked. + picks: ['a:1:dark', 'a:2:dark', 'b:3:dark', 'a:3:dark'], +} + +/** + * Page script for a boundary hydrating on interaction around a counter + * `<button data-label="child">` showing `child:<clicks>`: how many scripts + * the page requested before the first click, and whether clicking (until + * the counter counts) requested more. + */ +export const loadedOnInteraction = `const beforeClick = requested().length +const button = () => root.querySelector('button[data-label="child"]') +await clickUntil(button, () => button().textContent === 'child:1') +return { beforeClick, loadedByClick: requested().length > beforeClick }` + +const exportName = (name: string) => `f_${name.replace(/\W/g, '_')}` + +/** + * The bundler configuration of a Solid Start app: Vite with + * `vite-plugin-solid` (SSR output in the server environment); Rsbuild with + * `@rsbuild/plugin-babel` and `@rsbuild/plugin-solid` (Solid's Babel preset, + * hydratable, generating the DOM output for the client and the SSR output + * for the server) and the `solid` export condition, which the Solid + * packages publish their JSX sources under. + */ +export const solidAppConfig = { + viteConfig: { plugins: [solid({ ssr: true })] }, + rsbuildConfig: { + plugins: [pluginBabel({ include: /\.(?:jsx|tsx)$/ })], + environments: { + client: { + plugins: [ + pluginSolid({ + solidPresetOptions: { generate: 'dom', hydratable: true }, + }), + ], + }, + ssr: { + plugins: [ + pluginSolid({ + solidPresetOptions: { generate: 'ssr', hydratable: true }, + }), + ], + }, + }, + resolve: { conditionNames: ['solid', '...'] }, + } satisfies RsbuildConfig, +} + +/** + * The entries of an app of `framework`: the fixtures and what renders them + * (`h`), and in the client what hydrates and mounts them. + */ +function pageEntries(framework: PageFramework, fixtureExports: string) { + if (framework === 'solid') { + return { + 'client-entry.ts': `${fixtureExports} +export { createComponent as h, hydrate, render } from 'solid-js/web' +`, + 'ssr-entry.ts': `${fixtureExports} +export { createComponent as h, generateHydrationScript, renderToString } from 'solid-js/web' +`, + } + } + return { + 'client-entry.ts': `${fixtureExports} +export { createElement as h } from 'react' +export { createRoot, hydrateRoot } from 'react-dom/client' +`, + 'ssr-entry.ts': `${fixtureExports} +export { createElement as h } from 'react' +export { renderToString } from 'react-dom/server' +${callByIdExports}`, + } +} + +/** + * Builds one app holding every fixture (`src/fixtures/<name>.tsx`, with the + * other `files` of the app next to them) with Start's plugin of `bundler` + * (default `vite`) and the Start package of `framework` (default `react`). + */ +export async function buildHydrationApp(options: { + fixtures: Record<string, string> + /** Other app files by path relative to the app root. */ + files?: Record<string, string> + registerCleanup?: (cleanup: () => Promise<void>) => void + framework?: PageFramework + bundler?: StartBundler +}): Promise<HydrationApp> { + const { framework = 'react', bundler = 'vite' } = options + const names = Object.keys(options.fixtures) + const fixtureExports = names + .map( + (name) => `export * as ${exportName(name)} from './src/fixtures/${name}'`, + ) + .join('\n') + const build = await buildStart({ + bundler, + framework, + mode: 'development', + registerCleanup: options.registerCleanup, + ...(framework === 'solid' && solidAppConfig), + files: { + ...options.files, + ...Object.fromEntries( + names.map((name) => [ + `src/fixtures/${name}.tsx`, + options.fixtures[name]!, + ]), + ), + ...pageEntries(framework, fixtureExports), + }, + entry: { client: 'client-entry.ts', ssr: 'ssr-entry.ts' }, + }) + /** + * A function returning what the page renders: Solid renders the function + * itself, React the element it returns. + */ + const make = (name: string, hydrateOptions: HydrateOptions) => `() => { + const m = entry.${exportName(name)} + const h = (type, props) => entry.h(type, props ?? {}) + const props = ${JSON.stringify(hydrateOptions.props ?? {})} + return ${hydrateOptions.render ?? 'h(m.Page, props)'} +}` + const renderServer = async ( + name: string, + hydrateOptions: HydrateOptions = {}, + ) => { + const { result } = await build.ssr.run( + framework === 'solid' + ? `const html = entry.renderToString(${make(name, hydrateOptions)}) +return { html, result: ${hydrateOptions.serverScript ?? 'null'}, hydrationScript: entry.generateHydrationScript() }` + : `const html = entry.renderToString((${make(name, hydrateOptions)})()) +return { html, result: ${hydrateOptions.serverScript ?? 'null'} }`, + ) + return result as { html: string; result: unknown; hydrationScript?: string } + } + /** Page code mounting or hydrating `element` (a `make` function) in `root`. */ + const start = + framework === 'solid' + ? { + mount: (element: string) => `entry.render(${element}, root)`, + hydrate: (element: string) => `entry.hydrate(${element}, root)`, + } + : { + mount: (element: string) => + `entry.createRoot(root).render(${element}())`, + hydrate: (element: string) => `entry.hydrateRoot(root, ${element}(), { + onRecoverableError: (error) => { + recoverableErrors.push(error instanceof Error ? error.message : String(error)) + }, + })`, + } + const hydrate = async (name: string, hydrateOptions: HydrateOptions = {}) => { + const mount = hydrateOptions.mode === 'mount' + const server: { html: string; result: unknown; hydrationScript?: string } = + mount + ? { html: '', result: null } + : await renderServer(name, hydrateOptions) + const { result } = await build.client.run(` +const settled = ${settledSource} +const waitFor = ${waitForSource} +const clickUntil = ${clickUntilSource} +const root = document.getElementById('root') +// What Solid's server puts in the document head (it records the events of +// the page until it hydrates). +const hydrationScript = ${JSON.stringify(server.hydrationScript ?? '')} +for (const script of new DOMParser().parseFromString(hydrationScript, 'text/html').querySelectorAll('script')) { + const running = document.createElement('script') + running.textContent = script.textContent + document.head.append(running) +} +root.innerHTML = ${JSON.stringify(server.html)} +const snapshots = [root.innerHTML] +new MutationObserver(() => { + if (snapshots.at(-1) !== root.innerHTML) { + snapshots.push(root.innerHTML) + } +}).observe(root, { subtree: true, childList: true, attributes: true, characterData: true }) +const consoleErrors = [] +const consoleError = console.error +console.error = (...args) => { + consoleErrors.push(args.map((arg) => (arg instanceof Error ? arg.message : String(arg))).join(' ')) + consoleError(...args) +} +const scripts = () => performance.getEntriesByType('resource').filter((entry) => entry.initiatorType === 'script' || /\\.m?js(\\?|$)/.test(entry.name)).map((entry) => new URL(entry.name).pathname) +const before = new Set(scripts()) +const requested = () => scripts().filter((name) => !before.has(name)) +await (async () => { ${hydrateOptions.beforeHydration ?? ''} })() +const recoverableErrors = [] +const element = ${make(name, hydrateOptions)} +if (${mount}) { + ${start.mount('element')} +} else { + ${start.hydrate('element')} +} +await settled() +const result = await (async () => { ${hydrateOptions.script ?? ''} })() +await settled() +return { html: root.innerHTML, snapshots, recoverableErrors, consoleErrors, requested: requested(), result } +`) + return { + serverHtml: server.html, + serverResult: server.result, + ...(result as Omit<Hydrated, 'serverHtml' | 'serverResult'>), + } + } + /** + * Calls the server fn a page requested at `url` (its server fn URL: the + * server fn base, then its id) the way the page does. + */ + const callServerFn = async (url: string, data?: unknown) => { + const { result } = await build.ssr.run(`${callByIdPrelude} +const id = decodeURIComponent(serverFnId(${JSON.stringify(url)})) +try { + return await callById(id, ${JSON.stringify(data ?? null)}) +} catch (error) { + return error instanceof Error ? error.message : String(error) +}`) + return result + } + return { build, hydrate, callServerFn } +} diff --git a/packages/start-plugin-core/tests/integration/importProtection/boundary-edges.test.ts b/packages/start-plugin-core/tests/integration/importProtection/boundary-edges.test.ts new file mode 100644 index 0000000000..47f5b127d3 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/boundary-edges.test.ts @@ -0,0 +1,223 @@ +/** + * Only surviving edges are reported (SPEC J6.4): a denied import used only + * inside code the Start compiler removes from an environment (a safe + * boundary: a server fn handler, `createServerOnlyFn`, a middleware's + * `.server()`, `createIsomorphicFn().server()` on the client; + * `createClientOnlyFn`, `createIsomorphicFn().client()` on the server) is no + * edge of that environment, so a dev server reports nothing for it, whatever + * way the boundary is written; a use the environment keeps is reported (one + * per environment: `src/cases/leaky.ts`, `src/cases/server-leaky.ts`), and + * the server keeps a handler's use (the handler runs with the real module). + * Read on dev servers with Start's whole public plugin (mock mode), Vite + * and Rsbuild, from what each reports through `onViolation`. Each case is a + * module of its own under `src/cases/`. + * + * Replaces the former internal control that compiled each case with today's + * compiler and read its imports. Where a surviving use is reported: + * `reported-location.test.ts`. + */ +import { afterAll, describe, expect, test } from 'vitest' +import { + inDevRequest, + startDevServer, + startRequestFiles, +} from '../../dev-server' +import { startRsbuildDevServer } from '../../rsbuild-dev-server' +import { + distinct, + reportedImporters, + violationRecorder, +} from '../../importProtection/start-apps' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +const timeout = 30_000 + +/** A package `name` whose `denied` gives `REAL_<name>`. */ +const sdk = (name: string) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: `export const denied = () => 'REAL_${name}'\n`, +}) + +const header = ( + sdkName: string, +) => `import { createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn, createMiddleware } from '@tanstack/react-start' +import { denied } from '${sdkName}' +` + +/** + * Uses of `server-sdk` (denied to the client) inside a boundary the client + * drops. + */ +const clientBoundaries: Record<string, string> = { + 'createServerFn().handler': `export const fn = createServerFn().handler(async () => denied())`, + 'a parenthesized createServerFn().handler argument': `export const fn = createServerFn().handler((() => denied()))`, + 'a wrapped createServerFn().handler argument': `const withAuth = <T,>(fn: T) => fn +export const fn = createServerFn().handler(withAuth(async () => denied()))`, + 'a createServerFn().handler argument with a type assertion': `export const fn = createServerFn().handler((async () => denied()) as any)`, + 'createServerFn().handler through a namespace import': `import * as Start from '@tanstack/react-start' +export const fn = Start.createServerFn().handler(() => denied())`, + 'createServerOnlyFn through a namespace import': `import * as Start from '@tanstack/react-start' +export const fn = Start.createServerOnlyFn(() => denied())`, + 'a handler after a validator': `export const fn = createServerFn({ method: 'GET' }).validator((d: unknown) => d).handler(() => denied())`, + createServerOnlyFn: `export const fn = createServerOnlyFn(() => denied())`, + 'createMiddleware().server': `export const middleware = createMiddleware({ type: 'function' }).server(({ next }) => { + const secret = denied() + return next({ context: { secret } }) +})`, + 'createIsomorphicFn().server': `export const fn = createIsomorphicFn().server(() => denied())`, +} + +/** + * Uses of `browser-sdk` (denied to the server) inside a boundary the server + * drops. + */ +const serverBoundaries: Record<string, string> = { + createClientOnlyFn: `export const fn = createClientOnlyFn(() => denied())`, + 'a createClientOnlyFn argument with a satisfies clause': `export const fn = createClientOnlyFn((() => denied()) satisfies () => unknown)`, + 'a parenthesized createIsomorphicFn().client argument': `export const fn = createIsomorphicFn().client((() => denied()))`, +} + +/** A use after a handler, which the client keeps. */ +const leaky = `export const fn = createServerFn().handler(async () => { + return denied() +}) +export function leakyReference() { + return denied() +}` + +/** A use outside a client-only boundary, which the server keeps. */ +const serverLeaky = `export const fn = createClientOnlyFn(() => denied()) +export const leak = () => denied()` + +const slug = (name: string) => + name + .replace(/[^a-z0-9]+/gi, '-') + .replace(/^-|-$/g, '') + .toLowerCase() + +const files: Record<string, string> = { + ...sdk('server-sdk'), + ...sdk('browser-sdk'), + ...Object.fromEntries([ + ...Object.entries(clientBoundaries).map(([name, body]) => [ + `src/cases/client-${slug(name)}.ts`, + header('server-sdk') + body + '\n', + ]), + ...Object.entries(serverBoundaries).map(([name, body]) => [ + `src/cases/server-${slug(name)}.ts`, + header('browser-sdk') + body + '\n', + ]), + ['src/cases/leaky.ts', header('server-sdk') + leaky + '\n'], + ['src/cases/server-leaky.ts', header('browser-sdk') + serverLeaky + '\n'], + ]), +} +files['src/entry.ts'] = Object.keys(files) + .filter((file) => file.startsWith('src/cases/')) + .map( + (file, index) => + `export * as c${index} from './${file.slice('src/'.length, -'.ts'.length)}'`, + ) + .join('\n') + +const importProtection = { + client: { specifiers: ['server-sdk'] }, + server: { specifiers: ['browser-sdk'] }, + mockAccess: 'off' as const, +} + +/** `importProtection`, recording what Start reports (`violations`). */ +const recording = () => violationRecorder(importProtection) + +describe('vite dev', () => { + const cleanups: Array<() => Promise<void>> = [] + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + const recorded = recording() + let started: Promise<DevServer> | undefined + /** + * The dev server (router entry `src/entry.ts`), started once for the + * file, with the client and the server having loaded the app. The router + * entry also exports the app's router (`startRequestFiles`), which serves + * the request a handler runs in (`inDevRequest`). + */ + const loaded = () => + (started ??= (async () => { + const server = await startDevServer({ + files: { + ...startRequestFiles, + ...files, + 'src/entry.ts': `${files['src/entry.ts']}\nexport { getRouter } from './router'\n`, + }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + start: { + router: { entry: 'entry.ts' }, + importProtection: recorded.importProtection, + }, + }) + await server.load('/src/entry.ts') + await server.import('/src/entry.ts', 'ssr') + return server + })()) + + test( + 'the client reports only the use it keeps, not the uses inside the boundaries it drops', + async () => { + const { root } = await loaded() + const reported = distinct(reportedImporters({ root, ...recorded })) + expect(reported.filter((entry) => entry.startsWith('client '))).toEqual([ + 'client src/cases/leaky.ts', + ]) + }, + timeout, + ) + + test( + 'the server reports only the use it keeps, not the uses inside the boundaries it drops', + async () => { + const { root } = await loaded() + const reported = distinct(reportedImporters({ root, ...recorded })) + expect(reported.filter((entry) => entry.startsWith('server '))).toEqual([ + 'server src/cases/server-leaky.ts', + ]) + }, + timeout, + ) + + test( + "the server keeps a handler's use: the handler runs with the real module", + async () => { + const server = await loaded() + const { fn } = await server.import( + `/src/cases/client-${slug('createServerFn().handler')}.ts`, + 'ssr', + ) + expect(await inDevRequest(server, () => fn())).toBe('REAL_server-sdk') + }, + timeout, + ) +}) + +describe('rsbuild dev', () => { + test( + 'each environment reports only the use it keeps', + async () => { + const recorded = recording() + const server = await startRsbuildDevServer({ + files, + importProtection: recorded.importProtection, + }) + expect( + distinct(reportedImporters({ root: server.root, ...recorded })).sort(), + ).toEqual([ + 'client src/cases/leaky.ts', + 'server src/cases/server-leaky.ts', + ]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/build-markers.test.ts b/packages/start-plugin-core/tests/integration/importProtection/build-markers.test.ts new file mode 100644 index 0000000000..9ad3b236c6 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/build-markers.test.ts @@ -0,0 +1,481 @@ +/** + * Import protection in a real Start build (Vite and Rsbuild), continued + * from build.test.ts and build-mock.test.ts (three files, to keep each + * within the per-file time budget): an `onViolation` that returns false, + * and the server-only marker. A mock is told by what it does + * (`mock-helpers.ts`, `describeValue`: `a safe mock`), and a violation by + * what `onViolation` receives. + */ +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + distinct, + expectMarkerViolation, + expectViolationsAt, + locationIn, + rejection, + reportedImporters, + reportedViolations, + traceFromEntry, + violationsOf, +} from '../../importProtection/start-apps' +import type { TanStackStartInputConfig } from '../../../src' +import type { ViolationInfo } from '../../importProtection/public-types' + +const timeout = 60_000 + +/** A server-only module (denied to the client by `importedAs`). */ +const deniedModules = { + 'a denied file': { + importedAs: './secret.server', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + }, + }, + 'a server-only-marked module': { + importedAs: './marked', + files: { + 'src/marked.ts': `import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_SECRET' +`, + }, + }, +} +type DeniedModule = keyof typeof deniedModules +const deniedModuleNames = Object.keys(deniedModules) as Array<DeniedModule> + +/** An app whose client entry `src/entry.ts` uses `denied`. */ +function appUsing(denied: DeniedModule) { + const { importedAs, files } = deniedModules[denied] + return { + ...files, + 'src/entry.ts': `import { secret } from '${importedAs}' +export const read = () => secret() +`, + } +} + +/** + * What a failed build reported, on every channel (a compiler may print the + * details to the console and fail the build with a short error, SPEC §5.7): + * the `StartBuildError`'s diagnostics. + */ +const everyChannel = (error: Error) => + (error as Error & { diagnostics?: Array<unknown> }).diagnostics ?? error + +/** + * Builds `files` with `bundler`; what the client gets from `entry.read()`, + * and what the build reported as a problem on any channel (`warnings`). + */ +async function clientRead( + bundler: (typeof startBundlers)[number], + files: Record<string, string>, + start: TanStackStartInputConfig, +) { + const build = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start, + }) + const { client } = build + const read = (await client.run(`return String(entry.read())`)) + .result as string + return { + /** The real module's code is in the client bundle. */ + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + /** `entry.read()` ran the real module. */ + ranReal: read === 'MARK_SECRET', + warnings: problems(build.diagnostics).map(({ text }) => text), + } +} + +// Bug: `onViolation` runs after the build has replaced the denied module +// (or import) with a mock: Vite substitutes the mock when it resolves the +// import and calls `onViolation` in `generateBundle` +// (vite/import-protection-plugin/plugin.ts `reportOrDeferViolation`); +// Rsbuild mocks in its loader and calls it when reporting in `processAssets` +// (rsbuild/import-protection.ts `reportViolation`). Returning `false` only +// silences the report. (A Vite build of a server-only marker violation keeps +// the real module either way, see the mock-mode pin above.) +// Impact: an import a project allows with `onViolation` (documented: +// "Return false ... to allow this specific import (override the denial)", +// guide/import-protection.md) is a mock in the client: its calls return mocks +// in production, without any warning. +// Source: review (`onViolation` false only had a recorder). +describe.each(startBundlers)( + '%s build, onViolation returning false', + (bundler) => { + const allowed = { hasRealCode: true, ranReal: true, warnings: [] } + const allowAll = { importProtection: { onViolation: () => false } } + + // Vite builds the module of a marker violation into the bundle either + // way (see the mock-mode pin above). + const pinned: Array<DeniedModule> = + bundler === 'vite' ? ['a denied file'] : deniedModuleNames + const passing = deniedModuleNames.filter( + (denied) => !pinned.includes(denied), + ) + + test.fails.each(pinned)( + 'allows the import of %s: the build succeeds and the client gets the real module', + async (denied) => { + expect(await clientRead(bundler, appUsing(denied), allowAll)).toEqual( + allowed, + ) + }, + timeout, + ) + + if (passing.length > 0) { + test.each(passing)( + 'allows the import of %s: the build succeeds and the client gets the real module', + async (denied) => { + expect(await clientRead(bundler, appUsing(denied), allowAll)).toEqual( + allowed, + ) + }, + timeout, + ) + } + + // Control for the pins above (same harness): the build succeeds. + test.each(pinned)( + 'allows the import of %s: the build succeeds', + async (denied) => { + const { warnings } = await clientRead( + bundler, + appUsing(denied), + allowAll, + ) + expect(warnings).toEqual([]) + }, + timeout, + ) + }, +) + +// Which client imports of a server-only-marked module are checked: a +// marker violation is reported for each importer that is in scope and +// compiles, whatever kind of module imports it; an importer `ignoreImporters` +// exempts is neither reported nor mocked (SPEC J6.7). +// Source: replaces the Rsbuild "registerImportProtection marker scope" tests +// that ran on a hand-built fake of the Rspack compilation +// (rsbuild/import-protection.test.ts); rubric-start item 25. +describe.each(startBundlers)('%s build, server-only marker', (bundler) => { + const marked = deniedModules['a server-only-marked module'].files + + /** + * The importer a violation blames, relative to the app root: `Importer:` + * when it is not the marked module itself, else the trace step that + * imports the marked module (a marker violation may be reported at + * either, SPEC J6.5). + */ + const blamedImporter = (info: ViolationInfo) => { + const fromRoot = (file: string | undefined) => + file + ?.split(path.sep) + .join('/') + .replace(/^.*?\/(?=src\/)/, '') + const importer = fromRoot(info.importer) + return importer === 'src/marked.ts' + ? fromRoot(traceFromEntry(info).at(-2)?.file) + : importer + } + + /** + * `src/ignored.ts` (exempt) and `src/other.ts` both use the marked + * module; the entry re-exports both. + */ + const ignoredAndOther = { + ...marked, + 'src/ignored.ts': `import { secret } from './marked'\nexport const a = () => secret()\n`, + 'src/other.ts': `import { secret } from './marked'\nexport const b = () => secret()\n`, + 'src/entry.ts': `export { a } from './ignored'\nexport { b } from './other'\n`, + } + + test( + 'imported by an ignored importer and another importer fails the build', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: ignoredAndOther, + entry: 'src/entry.ts', + start: { importProtection: { ignoreImporters: ['**/ignored.ts'] } }, + }), + ) + // (the exempt importer is never reported; with behavior "error", + // `onViolation` may get the other violation more than once) + const importers = reportedImporters(error) + expect(importers).not.toEqual([]) + expect(importers).not.toContain('client src/ignored.ts') + }, + timeout, + ) + + // Bug (Rsbuild): the Rsbuild adapter reports a marker violation at the + // marked module (SPEC J6.5 allows it) with the shortest import chain + // from the entry to the marked module (`buildTrace`, + // import-protection/trace.ts, a BFS to the nearest entry), whichever + // importer it runs through: here the exempt `src/ignored.ts`, two steps + // from the entry, while the importer the violation is for, `src/other.ts`, + // is three steps away. An exempt edge is no violation (SPEC J6.7), so a + // report whose chain ends with one names the wrong importer. Vite reports + // the violation at the importer's use, and blames the right one. + // Impact: on Rsbuild, the report of a server-only-marked module imported + // by an exempt importer and another one blames the exempt importer; the + // user looks at code the project ignores on purpose, and the real + // importer is not named. + // Source: review. + ;(bundler === 'rsbuild' ? test.fails : test)( + 'imported by an ignored importer and, further from the entry, another importer: the violation blames the other importer', + async () => { + const seen: Array<ViolationInfo> = [] + await rejection( + buildStart({ + bundler, + files: { + ...ignoredAndOther, + 'src/mid.ts': `export { b } from './other'\n`, + 'src/entry.ts': `export { a } from './ignored'\nexport { b } from './mid'\n`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + ignoreImporters: ['**/ignored.ts'], + onViolation: (info) => { + seen.push(info as ViolationInfo) + }, + }, + }, + }), + ) + expect(seen).not.toEqual([]) + expect(distinct(seen.map(blamedImporter))).toEqual(['src/other.ts']) + }, + timeout, + ) + + // Bug (Vite): the Vite adapter reports a marker violation for the marked + // module itself (`importer` is the module importing the marker) and does + // not look at which modules import it, so `ignoreImporters` cannot exempt + // them (vite/import-protection-plugin/plugin.ts, marker handling in + // `resolveId`). The Rsbuild adapter checks the marked module's importers. + // Impact: on Vite, `ignoreImporters` (documented: "Ignore violations from + // these importers") does not apply to server-only-marked modules; a build + // fails for an import the project ignores. + // Source: found replacing the Rsbuild marker-scope test "skips marker + // violations imported only by an ignored importer". + const ignoredTest = bundler === 'vite' ? test.fails : test + + /** Only the exempt `src/ignored.ts` imports the marked module. */ + const ignoredOnly = { + ...marked, + 'src/ignored.ts': `import { secret } from './marked'\nexport const read = () => secret()\n`, + 'src/entry.ts': `export { read } from './ignored'\n`, + } + + ignoredTest( + 'imported only by an ignored importer does not fail the build', + async () => { + const build = await buildStart({ + bundler, + files: ignoredOnly, + entry: 'src/entry.ts', + start: { importProtection: { ignoreImporters: ['**/ignored.ts'] } }, + }) + // Nothing reported, on any channel + expect(reportedViolations(build)).toEqual([]) + expect(problems(build.diagnostics).map(({ text }) => text)).toEqual([]) + }, + timeout, + ) + + // Bug: an importer `ignoreImporters` exempts still gets the mock of a + // server-only-marked module in a mock-mode build: Rsbuild replaces the + // marked module itself with a mock in its loader, for every importer + // (the exemption pins of exemptions.test.ts, SPEC J6.7); on + // Vite the marker violation is not exempt at all (the pin above), and in + // error mode the build fails. + // Impact: code a project exempts on purpose silently gets a mock instead + // of the module it imports. + test.fails( + 'imported only by an ignored importer: the ignored importer gets the real module', + async () => { + expect( + await clientRead(bundler, ignoredOnly, { + importProtection: { + behavior: 'mock', + ignoreImporters: ['**/ignored.ts'], + }, + }), + ).toEqual({ hasRealCode: true, ranReal: true, warnings: [] }) + }, + timeout, + ) + + // Bug: in a mock-mode build, a server-only-marked module imported by an + // exempt importer and another importer is a mock for both (Rsbuild), or + // the real module for the other importer (Vite). + // - Rsbuild replaces the marked module itself with a mock in its loader, + // for every importer, in every import order (the pin above). + // - Vite mocks an importer's import of a marked module only when the + // marked module's own marker import was resolved first (`resolveId` in + // vite/import-protection-plugin/plugin.ts reads `fileMarkerKind`); + // otherwise that importer gets the real module (the "is mocked, with a + // warning" pin of the mock-mode block). Only the exempt importer can load + // the marked module before the other importer's import is resolved, so + // the outcome is a race of the build: the other importer gets the real + // module in every build when it is nearer the entry than the exempt + // importer, in most builds when they are side by side, and in a few + // when the exempt importer is nearer. + // The orders where the other importer is nearer come first: they keep the + // pin red on both bundlers in every run; the racy orders follow, so the + // pin passes only when no order leaks. + // Source: review, with entry-order and indirection variants. + // Impact: exemptions either stop working (Rsbuild) or leak the denied real + // value to the importer that is not exempt (Vite). + // Blame is read from onViolation/trace: marker-origin display is allowed. + test.fails( + 'in mock mode, an ignored importer gets the real module, another importer a safe mock, and only the other importer is reported', + async () => { + for (const entry of [ + // The other importer nearer the entry, in both orders + `export { b } from './other'\nexport { a } from './mid-ignored'\n`, + `export { a } from './mid-ignored'\nexport { b } from './other'\n`, + // Side by side, in both orders + `export { a } from './ignored'\nexport { b } from './other'\n`, + `export { b } from './other'\nexport { a } from './ignored'\n`, + // The ignored importer nearer the entry + `export { a } from './ignored'\nexport { b } from './mid'\n`, + ]) { + const seen: Array<ViolationInfo> = [] + const { client } = await buildStart({ + bundler, + files: { + ...ignoredAndOther, + 'src/entry.ts': entry, + 'src/mid.ts': `export { b } from './other'\n`, + 'src/mid-ignored.ts': `export { a } from './ignored'\n`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + behavior: 'mock', + mockAccess: 'off', + ignoreImporters: ['**/ignored.ts'], + onViolation: (info) => { + seen.push(info as ViolationInfo) + }, + }, + }, + }) + const { result } = await client.run(`${describeValuePrelude} +return { + ignored: describeValue(entry.a(), 'MARK_SECRET'), + other: describeValue(entry.b(), 'MARK_SECRET'), +}`) + expect({ + ...(result as object), + reported: distinct(seen.map(blamedImporter)), + }).toEqual({ + ignored: 'MARK_SECRET', + other: 'a safe mock', + reported: ['src/other.ts'], + }) + } + }, + timeout, + ) + + test( + 'imported by a split route component fails the build', + async () => { + const splitRoute = `import { createFileRoute } from '@tanstack/react-router' +import { secret } from '../marked' +export const Route = createFileRoute('/')({ + component: () => String(secret()), +}) +` + const error = await rejection( + buildStart({ + bundler, + files: { + ...marked, + 'src/routes/index.tsx': splitRoute, + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router'\n`, + }, + entry: 'src/entry.ts', + }), + ) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + expectMarkerViolation(report!, { + marker: 'src/marked.ts:1', + use: locationIn('src/routes/index.tsx', splitRoute, 4, 'secret()'), + imports: ['src/routes/index.tsx:2'], + }) + }, + timeout, + ) + + test( + 'marking the client entry fails the build', + async () => { + const client = `import '@tanstack/react-start/server-only' +console.log('client') +` + const error = await rejection( + buildStart({ + bundler, + files: { + 'src/client.ts': client, + 'src/entry.ts': `export const read = () => 'entry'\n`, + }, + entry: 'src/entry.ts', + }), + ) + // At the client entry's marker import, line 1 (any column) + expect(reportedViolations(error)).toHaveLength(1) + expectViolationsAt(error, [ + { environment: 'client', use: 'src/client.ts:1' }, + ]) + }, + timeout, + ) + + // The build fails and names the broken file at its line (an actionable + // error, SPEC G5); other diagnostics may come with it. + test( + 'imported by a module that fails to compile: the build fails, naming the broken file and line', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: { + ...marked, + 'src/broken.ts': `import { secret } from './marked' +export const read = ( => secret() +`, + 'src/entry.ts': `export { read } from './broken'\n`, + }, + entry: 'src/entry.ts', + }), + ) + expectDiagnostic(everyChannel(error), { + severity: 'error', + file: 'src/broken.ts', + position: { line: 2 }, + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/build-mock.test.ts b/packages/start-plugin-core/tests/integration/importProtection/build-mock.test.ts new file mode 100644 index 0000000000..dbe83c1a06 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/build-mock.test.ts @@ -0,0 +1,471 @@ +/** + * Import protection in a real Start build (Vite and Rsbuild), continued + * from build.test.ts (three files with build-markers.test.ts, to keep each + * within the per-file time budget): mock mode. A mock is told by what it does (`mock-helpers.ts`, + * `describeValue`: `a safe mock`), and a violation by what `onViolation` + * receives. + */ +import { describe, expect, test } from 'vitest' +import { + diagnosticsOf, + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { StartBuildError, buildStart, startBundlers } from '../../build-harness' +import { + describeValuePrelude, + mockAccessDiagnostics, +} from '../../importProtection/mock-helpers' +import { + distinct, + expectViolationsAt, + inEnvironment, + locationIn, + reportedViolations, + starReexportApps, +} from '../../importProtection/start-apps' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' + +const timeout = 60_000 + +/** A server-only module (denied to the client by `importedAs`). */ +const deniedModules = { + 'a denied file': { + importedAs: './secret.server', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + }, + }, + 'a server-only-marked module': { + importedAs: './marked', + files: { + 'src/marked.ts': `import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_SECRET' +`, + }, + }, +} + +/** A client-only module (denied to the server by its marker). */ +const clientOnlyMarked = { + 'src/marked.ts': `import '@tanstack/react-start/client-only' +export const secret = () => 'MARK_SECRET' +`, +} + +/** + * `files` with each module recording that it ran (`globalThis.secretLoaded`), + * after its marker import when it has one. For the mock-mode rows: a mock + * runs no initializer of the denied module. (A side effect keeps a module + * in a bundle, so the tree-shaking rows use the modules as they are.) + */ +function recording(files: Record<string, string>): Record<string, string> { + const record = `;(globalThis as any).secretLoaded = 'MARK_SECRET_LOADED'\n` + return Object.fromEntries( + Object.entries(files).map(([file, code]) => { + if (!/\.[cm]?[jt]sx?$/.test(file) || code.includes('secretLoaded')) { + return [file, code] + } + return [ + file, + code.startsWith('import ') + ? code.replace('\n', `\n${record}`) + : record + code, + ] + }), + ) +} + +// `behavior: 'mock'` builds: a denied import is replaced with a mock (and +// a warning); the real module's code stays out of the bundle and its +// initializer never runs; `mockAccess` says whether using the mock is +// reported in the console (SPEC J6.3: it applies wherever a mock is served, +// a production build included; `off` for silence). +describe.each(startBundlers)('%s build, mock mode', (bundler) => { + interface MockedImport { + /** The specifier `src/entry.ts` imports `secret` with. */ + importedAs: string + files: Record<string, string> + /** Other imports of `src/entry.ts`. */ + imports?: string + /** The environment that imports it (default `client`). */ + env?: 'client' | 'ssr' + } + + /** + * What the environment that imports `secret` gets for it in a mock-mode + * build with `mockAccess`: whether the violation was reported (to + * `onViolation`, and printed as a warning at the importer's line of the + * import or of its use, or at a marked module's marker: SPEC J6.3, + * J6.5, J6.12), whether the real code is in the bundle and its + * initializer ran, what the import is (`a safe mock`), the severities of + * what using it (a call) logged to the console, and the texts of those + * that do not name the denied import (`mockAccessDiagnostics`; their + * prose is free). + */ + async function mockedRead( + denied: MockedImport, + mockAccess: 'error' | 'warn' | 'off' | undefined, + ) { + const env = denied.env ?? 'client' + const built = await buildStart({ + bundler, + files: { + ...recording(denied.files), + 'src/entry.ts': `${denied.imports ?? ''}import { secret } from '${denied.importedAs}' +export const read = () => secret +`, + 'src/other.ts': `export const read = () => 'other'\n`, + }, + entry: + env === 'client' + ? 'src/entry.ts' + : { client: 'src/other.ts', ssr: 'src/entry.ts' }, + start: { importProtection: { behavior: 'mock', mockAccess } }, + }) + const { result } = await built[env].run(`${describeValuePrelude} +const logged = [] +for (const level of ['warn', 'error']) { + console[level] = (...args) => { + logged.push({ + level, + text: args.map((arg) => (arg instanceof Error ? arg.message : String(arg))).join(' '), + }) + } +} +const secret = entry.read() +const read = describeValue(secret, 'MARK_SECRET') +secret() +return { read, ran: globalThis.secretLoaded ?? null, logged }`) + const { read, ran, logged } = result as { + read: string + ran: unknown + logged: Array<{ level: 'warn' | 'error'; text: string }> + } + const diagnostics = logged.flatMap(({ level, text }) => + diagnosticsOf(text, level === 'warn' ? 'warning' : 'error'), + ) + const deniedFile = Object.keys(denied.files).find((file) => + /\.[cm]?[jt]sx?$/.test(file), + ) + const identified = (diagnostic: Diagnostic) => + mockAccessDiagnostics([diagnostic], { + severity: diagnostic.severity, + specifier: denied.importedAs, + file: deniedFile, + }).length > 0 + // `src/entry.ts`: the other imports, then the import and its use + const importLine = (denied.imports ?? '').split('\n').length + const printedAt = [ + { file: 'src/entry.ts', line: importLine }, + { file: 'src/entry.ts', line: importLine + 1 }, + ...Object.entries(denied.files) + .filter(([, code]) => code.startsWith(`import '@tanstack/react-start/`)) + .map(([file]) => ({ file, line: 1 })), + ] + return { + warned: + reportedViolations( + inEnvironment(built, env === 'ssr' ? 'server' : 'client'), + ).length > 0 && + printedAt.some( + ({ file, line }) => + findDiagnostics(built.diagnostics, { + severity: 'warning', + file, + root: built.root, + position: { line }, + }).length > 0, + ), + hasRealCode: built[env].where('MARK_SECRET') !== 'nowhere', + ran, + read, + /** The console severities a use of the mock logged with, each once. */ + loggedWith: distinct(diagnostics.map(({ severity }) => severity)), + /** What it logged that does not name the denied import. */ + unidentified: diagnostics + .filter((diagnostic) => !identified(diagnostic)) + .map(({ text }) => text), + } + } + + /** A safe mock, silent with `mockAccess: 'off'`; the build warns. */ + const mocked = { + warned: true, + hasRealCode: false, + ran: null, + read: 'a safe mock', + loggedWith: [], + unidentified: [], + } + + const deniedFile = (extension: string): MockedImport => ({ + importedAs: `./secret.server.${extension}`, + files: { + [`src/secret.server.${extension}`]: `globalThis.secretLoaded = 'MARK_SECRET_LOADED' +export const secret = () => 'MARK_SECRET' +`, + }, + }) + + const deniedFiles: Record<string, MockedImport> = { + 'a denied file': deniedModules['a denied file'], + 'a denied .server.mts file': deniedFile('mts'), + 'a denied .server.mjs file': deniedFile('mjs'), + 'a denied file of a module that imports CSS': { + ...deniedModules['a denied file'], + files: { + ...deniedModules['a denied file'].files, + 'src/style.css': `.page { color: red }\n`, + }, + imports: `import './style.css'\n`, + }, + 'a denied .client file imported by the server': { + importedAs: './widget.client', + files: { + 'src/widget.client.ts': `export const secret = () => 'MARK_SECRET'\n`, + }, + env: 'ssr', + }, + } + + test.each(Object.keys(deniedFiles))( + '%s is mocked, with a warning', + async (name) => { + expect(await mockedRead(deniedFiles[name]!, 'off')).toEqual(mocked) + }, + timeout, + ) + + // Bug: a mock-mode build serves self-contained mocks that never report + // their use (`generateSelfContainedMockModule`, import-protection/ + // virtualModules.ts; the Vite transform's `isBuild` branch and the Rsbuild + // loader), whatever `mockAccess` says; only dev mocks carry the runtime + // diagnostic (`mockRuntimeModuleIdFromViolation`). `mockAccess` is + // documented for `behavior: 'mock'` without a dev restriction + // (schema.ts), and SPEC J6.3 applies it wherever a mock is served. + // Impact: in a production build with `behavior: { build: 'mock' }`, code + // that runs on a mocked import does so without any console diagnostic; + // the warning at build time is the only trace of it. + // Source: review (the rows above demanded silence with the default); the + // server rows: SPEC J6.3 (mock mode always logs: client and server, dev + // and build). + test.fails.each( + ( + [ + { mockAccess: undefined, severity: 'error' }, + { mockAccess: 'error', severity: 'error' }, + { mockAccess: 'warn', severity: 'warning' }, + ] as const + ).flatMap((row) => [ + { ...row, denied: 'a denied file' }, + { ...row, denied: 'a denied .client file imported by the server' }, + ]), + )( + 'with mockAccess $mockAccess, using the mock of $denied is reported as an $severity naming the import', + async ({ mockAccess, severity, denied }) => { + expect(await mockedRead(deniedFiles[denied]!, mockAccess)).toEqual({ + ...mocked, + loggedWith: [severity], + }) + }, + timeout, + ) + + const markedModules: Record<string, MockedImport> = { + 'a server-only-marked module': deniedModules['a server-only-marked module'], + 'a client-only-marked module imported by the server': { + importedAs: './marked', + files: clientOnlyMarked, + env: 'ssr', + }, + } + + // Bug (Vite): in a build, a violation of a marker (server-only in the + // client, client-only in the server) only replaces the marker import + // itself with a mock (`handleViolation` in + // vite/import-protection-plugin/plugin.ts returns a mock edge for the + // marker specifier); the marked module keeps its code, and its importers + // import it. The Rsbuild adapter replaces the module with a mock + // (self-denial in its import-protection loader). Vite dev mocks the + // importers' import (see dev.test.ts). + // Impact: a mock-mode Vite build ships the marked module's real code in + // the bundle of the environment it is denied to, and runs it (only a + // warning is logged). + // Source: review; client-only row: mutation testing. + const markerMockTest = bundler === 'vite' ? test.fails : test + markerMockTest.each(Object.keys(markedModules))( + '%s is mocked, with a warning', + async (name) => { + expect(await mockedRead(markedModules[name]!, 'off')).toEqual(mocked) + }, + timeout, + ) + + // A module that re-exports from a denied specifier is rewritten like a + // module that imports from it; re-exports of other modules keep their + // values. + test( + 're-exports from a denied specifier are mocked; other re-exports keep their values', + async () => { + const { client } = await buildStart({ + bundler, + files: { + 'node_modules/denied-pkg/package.json': JSON.stringify({ + name: 'denied-pkg', + type: 'module', + main: 'index.js', + sideEffects: false, + }), + 'node_modules/denied-pkg/index.js': `export const secret = () => 'MARK_SECRET'\n`, + 'node_modules/safe-pkg/package.json': JSON.stringify({ + name: 'safe-pkg', + type: 'module', + main: 'index.js', + }), + 'node_modules/safe-pkg/index.js': `export const ok = () => 'MARK_SAFE' +export const fine = () => 'MARK_FINE' +`, + 'src/barrel.ts': `export { secret } from 'denied-pkg'\n`, + 'src/mixed.ts': `import { secret as aliased } from 'denied-pkg' +export { ok } from 'safe-pkg' +export * from './fine' +export const s = () => aliased +`, + 'src/fine.ts': `export { fine } from 'safe-pkg'\n`, + 'src/entry.ts': `import { secret } from './barrel' +import { ok, fine, s } from './mixed' +export const read = () => [secret, ok(), fine(), s()] +`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + behavior: 'mock', + mockAccess: 'off', + client: { specifiers: ['denied-pkg'] }, + }, + }, + }) + expect({ + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + read: ( + await client.run(`${describeValuePrelude} +return entry.read().map((value) => describeValue(value, 'MARK_SECRET'))`) + ).result, + }).toEqual({ + hasRealCode: false, + read: ['a safe mock', 'MARK_SAFE', 'MARK_FINE', 'a safe mock'], + }) + }, + timeout, + ) + + // SPEC J6.8 (`export *` of a denied module): in a + // mock-mode build, a name a client module re-exports with `export *` from + // a denied module is a safe mock and the denied module's value is not in + // the bundle, or the build fails. + async function expectStarReexportMockedOrBuildFails({ + files, + importProtection, + }: (typeof starReexportApps)[number]) { + const built = await buildStart({ + bundler, + files, + entry: 'src/c.ts', + start: { + importProtection: { + ...importProtection, + behavior: 'mock', + mockAccess: 'off', + }, + }, + }).catch((error: unknown) => { + if (error instanceof StartBuildError) { + return 'the build fails' as const + } + throw error + }) + if (built === 'the build fails') { + return + } + expect({ + secret: built.client.where('MARK_SECRET'), + v: ( + await built.client.run(`${describeValuePrelude} +return describeValue(entry.v, 'MARK_SECRET')`) + ).result, + }).toEqual({ secret: 'nowhere', v: 'a safe mock' }) + } + const starApp = (name: string) => + starReexportApps.find((app) => app.name === name)! + test( + 'a name re-exported with `export *` from a denied file is a safe mock, or the build fails', + () => expectStarReexportMockedOrBuildFails(starApp('a denied file')), + timeout, + ) + // Bug (Rsbuild): the import-protection loader removes an `export * from` a + // denied specifier from the importer (today's `rewriteDeniedImports`), and + // the build of the module importing a name of it succeeds without that + // name. (Vite's build fails on the missing export, which SPEC J6.8 + // accepts.) + // Impact: a mock-mode Rsbuild build ships a client in which a name + // re-exported with `export *` from a denied package is `undefined`: using + // it throws instead of reaching a mock. + // Source: SPEC J6.8, the build row of the dev pin in + // known-bugs-dev-server.test.ts. + ;(bundler === 'rsbuild' ? test.fails : test)( + 'a name re-exported with `export *` from a denied specifier is a safe mock, or the build fails', + () => expectStarReexportMockedOrBuildFails(starApp('a denied specifier')), + timeout, + ) + + // The route module and its split component are two modules of the bundle + // that import the denied file for the same import of the source. + // Source: mutation testing. + test( + 'a denied import of a route used by its loader and its split component is warned once', + async () => { + const route = `import { createFileRoute } from '@tanstack/react-router' +import { secret } from '../secret.server' +export const Route = createFileRoute('/')({ + loader: () => String(secret()), + component: () => String(secret()), +}) +` + const build = await buildStart({ + bundler, + files: { + ...deniedModules['a denied file'].files, + 'src/routes/index.tsx': route, + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router'\n`, + }, + entry: 'src/entry.ts', + start: { importProtection: { behavior: 'mock' } }, + }) + expect(build.client.where('MARK_SECRET')).toBe('nowhere') + // One warning printed, naming the route file + expectDiagnostic(build.diagnostics, { + severity: 'warning', + file: 'src/routes/index.tsx', + root: build.root, + times: 1, + }) + // At either use or at the import (SPEC J6.5) + expectViolationsAt(inEnvironment(build, 'client'), [ + { + environment: 'client', + use: locationIn('src/routes/index.tsx', route, 4, 'secret()'), + also: [ + locationIn('src/routes/index.tsx', route, 5, 'secret()'), + 'src/routes/index.tsx:2', + ], + }, + ]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/build-options.test.ts b/packages/start-plugin-core/tests/integration/importProtection/build-options.test.ts new file mode 100644 index 0000000000..653700ca8f --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/build-options.test.ts @@ -0,0 +1,662 @@ +/** + * Start's `importProtection` options, by their effect on a real Start build + * (Vite and Rsbuild), as guide/import-protection.md documents them. Without + * options, a build fails on a violation (build.test.ts). + * Source: review (options that were parsed but never exercised for + * effect). + */ +import { describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + distinct, + expectMarkerViolation, + expectViolationsAt, + inEnvironment, + locationIn, + rejection, + relevantViolations, + reportedImporters, + reportedViolations, + violationLabel, + violationsOf, +} from '../../importProtection/start-apps' +import type { ExpectedViolation } from '../../importProtection/start-apps' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const timeout = 60_000 + +/** A server-only module, denied to the client by Start's default rules. */ +const secretServer = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, +} + +/** A module at `path` (under `src/`) that uses `secret` of `from`. */ +const userOf = (from: string) => `import { secret } from '${from}' +export const read = () => secret() +` + +/** A dependency `name` whose entry is `file`, exporting `secret`. */ +const dependency = (name: string, file = 'index.js') => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: { '.': `./${file}` }, + }), + [`node_modules/${name}/${file}`]: `export const secret = () => 'MARK_SECRET'\n`, +}) + +describe.each(startBundlers)('%s build', (bundler) => { + /** + * Builds `files` (client entry `src/entry.ts`, or `entry`) with + * `importProtection`; the violations reported (through `onViolation`), as + * `<environment> <importer file>`, or `built` when the build succeeds + * without any. + */ + async function outcome( + files: Record<string, string>, + importProtection: ImportProtectionOptions, + entry: string | { client: string; ssr: string } = 'src/entry.ts', + ): Promise<string | Array<string>> { + const built = buildStart({ + bundler, + files, + entry, + start: { importProtection }, + }) + // What the build or its failure reported + const toList = reportedImporters + try { + const warned = toList(await built) + return warned.length ? warned : 'built' + } catch { + return toList(await rejection(built)) + } + } + + describe('behavior', () => { + const app = { ...secretServer, 'src/entry.ts': userOf('./secret.server') } + + test( + "{ build: 'mock' }: the build mocks the import and warns", + async () => { + const build = await buildStart({ + bundler, + files: app, + entry: 'src/entry.ts', + start: { + importProtection: { behavior: { dev: 'error', build: 'mock' } }, + }, + }) + const { client } = build + const reports = inEnvironment(build, 'client') + expect(reportedViolations(reports)).toHaveLength(1) + expectViolationsAt(reports, [ + { + environment: 'client', + use: locationIn('src/entry.ts', app['src/entry.ts'], 2, 'secret()'), + also: ['src/entry.ts:1'], + }, + ]) + expect(client.where('MARK_SECRET')).toBe('nowhere') + }, + timeout, + ) + + test( + "{ dev: 'mock' }: the build keeps its default and fails", + async () => { + expect(await outcome(app, { behavior: { dev: 'mock' } })).toEqual([ + 'client src/entry.ts', + ]) + }, + timeout, + ) + }) + + // Scope: which importers are checked. + describe('include, exclude and ignoreImporters', () => { + test( + 'include: an importer outside the patterns is not checked', + async () => { + expect( + await outcome( + { + ...secretServer, + 'src/other/a.ts': userOf('../secret.server'), + 'src/entry.ts': `export { read } from './other/a'\n`, + }, + { include: ['src/app/**'] }, + ), + ).toBe('built') + }, + timeout, + ) + + test( + 'include: an importer matching the patterns is checked', + async () => { + expect( + await outcome( + { + ...secretServer, + 'src/app/a.ts': userOf('../secret.server'), + 'src/entry.ts': `export { read } from './app/a'\n`, + }, + { include: ['src/app/**'] }, + ), + ).toEqual(['client src/app/a.ts']) + }, + timeout, + ) + + // These rows check that nothing is reported; what the excluded or + // ignored importer then gets for the denied file (the real module) is + // pinned in exemptions.test.ts. + test.each([ + { + option: 'exclude', + importProtection: { exclude: ['src/generated/**'] }, + }, + { + option: 'ignoreImporters', + importProtection: { ignoreImporters: ['**/generated/*.ts'] }, + }, + ])( + '$option: a matching importer is not reported, others are', + async ({ importProtection }) => { + expect( + await outcome( + { + ...secretServer, + 'src/generated/a.ts': userOf('../secret.server'), + 'src/entry.ts': `export { read } from './generated/a'\n`, + }, + importProtection, + ), + ).toBe('built') + expect( + await outcome( + { + ...secretServer, + 'src/generated/a.ts': userOf('../secret.server'), + 'src/b.ts': `import { secret } from './secret.server' +export const other = () => secret() +`, + 'src/entry.ts': `export { read } from './generated/a' +export { other } from './b' +`, + }, + importProtection, + ), + ).toEqual(['client src/b.ts']) + }, + timeout, + ) + }) + + describe('specifiers', () => { + test( + 'client.specifiers adds to the defaults: both are denied to the client', + async () => { + const importProtection = { client: { specifiers: ['db-lib'] } } + expect( + await outcome( + { ...dependency('db-lib'), 'src/entry.ts': userOf('db-lib') }, + importProtection, + ), + ).toEqual(['client src/entry.ts']) + expect( + await outcome( + { + 'src/entry.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + }, + importProtection, + ), + ).toEqual(['client src/entry.ts']) + }, + timeout, + ) + + test( + 'server.specifiers are denied to the server build', + async () => { + expect( + await outcome( + { + ...dependency('browser-lib'), + 'src/client.ts': `export const read = () => 'client'\n`, + 'src/server.ts': userOf('browser-lib'), + }, + { server: { specifiers: ['browser-lib'] } }, + { client: 'src/client.ts', ssr: 'src/server.ts' }, + ), + ).toEqual(['server src/server.ts']) + }, + timeout, + ) + + // Source: mutation testing (Rsbuild host, the pattern of a specifier + // violation). + test( + 'a RegExp pattern is reported as the rule that matched', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: { + ...dependency('db-lib'), + 'src/entry.ts': userOf('db-lib'), + }, + entry: 'src/entry.ts', + start: { + importProtection: { client: { specifiers: [/^db-lib$/] } }, + }, + }), + ) + expect(error.violations).not.toEqual([]) + for (const info of error.violations) { + // The rule that matched is the one `onViolation` gets + expect(String(info.pattern)).toContain('^db-lib$') + } + }, + timeout, + ) + }) + + // `excludeFiles`: resolved files the file and marker rules skip; a value + // replaces the default (`**/node_modules/**`). + describe('excludeFiles', () => { + /** A dependency whose entry is a `*.server.*` file, used by the client. */ + const serverFileDependency = { + ...dependency('server-pkg', 'secret.server.js'), + 'src/entry.ts': userOf('server-pkg'), + } + + test.each<{ + name: string + importProtection: ImportProtectionOptions + expected: string | Array<string> + }>([ + { + name: 'by default, a *.server.* file of a dependency is not denied', + importProtection: {}, + expected: 'built', + }, + { + name: '[] checks dependencies: their *.server.* files are denied', + importProtection: { client: { excludeFiles: [] } }, + expected: ['client src/entry.ts'], + }, + { + name: 'other patterns replace the default: dependencies are checked', + importProtection: { client: { excludeFiles: ['**/vendor/**'] } }, + expected: ['client src/entry.ts'], + }, + { + name: 'a file matching any one of several patterns is not denied', + importProtection: { + client: { excludeFiles: ['**/vendor/**', '**/node_modules/**'] }, + }, + expected: 'built', + }, + ])( + '$name', + async ({ importProtection, expected }) => { + expect(await outcome(serverFileDependency, importProtection)).toEqual( + expected, + ) + }, + timeout, + ) + + test( + 'a file matching the patterns is not denied', + async () => { + expect( + await outcome( + { + 'src/vendor/secret.server.ts': + secretServer['src/secret.server.ts'], + 'src/entry.ts': userOf('./vendor/secret.server'), + }, + { client: { excludeFiles: ['**/vendor/**'] } }, + ), + ).toBe('built') + }, + timeout, + ) + + /** A dependency whose entry is marked server-only, used by the client. */ + const markedDependency = { + ...dependency('db-lib'), + 'node_modules/db-lib/index.js': `import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_SECRET' +`, + 'src/entry.ts': userOf('db-lib'), + } + + // Replaces the Rsbuild unit test of getRsbuildResolvedImportProtectionCheck + // ("skips file and marker checks for excluded resolved files"). + // NEW bug (Vite): the Vite adapter checks a server-only marker when it + // resolves the marker import, for any importer, and never applies + // `excludeFiles` to the marked module (vite/import-protection-plugin/ + // plugin.ts, marker handling in `resolveId`), so the build fails with a + // marker violation of `node_modules/db-lib/index.js`. The docs: "By + // default, resolved files inside `node_modules` are excluded from + // resolved-target deny checks (file-pattern and marker checks)" + // (guide/import-protection.md). Rsbuild follows them. + // Impact: on Vite, a client import of a dependency that marks itself + // server-only fails the build although the defaults exclude it (and + // `excludeFiles` cannot exempt it). + // Source: review (replaces a row of rsbuild/import-protection.test.ts). + ;(bundler === 'vite' ? test.fails : test)( + 'by default, the server-only marker of a dependency is not checked', + async () => { + expect(await outcome(markedDependency, {})).toBe('built') + }, + timeout, + ) + + // Bug (Rsbuild): with `excludeFiles: []`, the Rsbuild adapter still + // skips the marker check of files under `node_modules` (the build + // succeeds without any report); `excludeFiles` is documented as the + // files the file-pattern and marker checks skip (guide/import-protection.md), + // and Vite checks them. + // Impact: on Rsbuild, a project cannot opt in to checking the + // server-only markers of its dependencies. + // Source: review (this row ran on Vite only; the docs decide). + ;(bundler === 'rsbuild' ? test.fails : test)( + '[] checks the markers of dependencies: a server-only-marked dependency fails the build', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: markedDependency, + entry: 'src/entry.ts', + start: { importProtection: { client: { excludeFiles: [] } } }, + }), + ) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + expect(report!.environment).toBe('client') + expectMarkerViolation(report!, { + marker: 'node_modules/db-lib/index.js:1', + use: 'src/entry.ts:2:27', + imports: ['src/entry.ts:1'], + }) + }, + timeout, + ) + }) + + describe('onViolation', () => { + // Only `false` allows an import: a callback that returns nothing (one + // that logs, say) leaves the import denied. + // Each report is at the importer's use of the import (`use`), its import + // on line 1 (SPEC J6.5), or one of `others`. + test.each<{ + name: string + files: Record<string, string> + /** The importer's genuine use, `file:line:column`. */ + use: string + others?: Array<string> + type: Violation['type'] + }>([ + { + name: 'a denied file', + files: { ...secretServer, 'src/entry.ts': userOf('./secret.server') }, + use: 'src/entry.ts:2:27', + type: 'file', + }, + { + name: 'a server-only-marked module', + files: { + 'src/marked.ts': `export const before = 1 +import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_SECRET' +`, + 'src/entry.ts': userOf('./marked'), + }, + use: 'src/entry.ts:2:27', + // Or at the marker import (SPEC J6.5). + others: ['src/marked.ts:2'], + type: 'marker', + }, + // Source: mutation testing (Rsbuild host, the type of a specifier + // violation). + { + name: 'a denied specifier', + files: { + 'src/entry.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + }, + use: 'src/entry.ts:2:27', + type: 'specifier', + }, + ])( + 'a callback that returns nothing does not allow $name: the build fails, and the callback gets a $type violation', + async ({ files, use, others = [], type }) => { + const seen: Array<Violation> = [] + const error = await rejection( + buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start: { + importProtection: { + onViolation: (info) => { + seen.push(info as Violation) + }, + }, + }, + }), + ) + expect(reportedViolations(error)).toHaveLength(1) + expectViolationsAt(error, [ + { environment: 'client', use, also: ['src/entry.ts:1', ...others] }, + ]) + expect(distinct(seen.map((info) => info.type))).toEqual([type]) + }, + timeout, + ) + + // Source: mutation testing (the `specifier` type of the table above). + test( + 'the callback gets a specifier violation for an import of a denied specifier', + async () => { + const seen: Array<Violation> = [] + await rejection( + buildStart({ + bundler, + files: { + 'src/entry.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + onViolation: (info) => { + seen.push(info as Violation) + }, + }, + }, + }), + ) + expect( + distinct(seen.map((info) => `${info.type} ${info.specifier}`)), + ).toEqual(['specifier @tanstack/react-start/server']) + }, + timeout, + ) + + // `resolved` is optional (SPEC J6.5, §5.14: a compiler that denies by + // the raw specifier need not resolve it); when given, it is the file the + // specifier resolves to. + test( + 'in mock mode, it gets each import of a denied specifier, with the file the specifier resolves to when it gives one; the mocks are safe (and silent with mockAccess off)', + async () => { + const seen: Array<Violation> = [] + const { client } = await buildStart({ + bundler, + files: { + ...dependency('db-lib'), + ...dependency('mail-lib'), + 'src/a.ts': `import { secret } from 'db-lib' +import { secret as mail } from 'mail-lib' +import { b } from './b' +export const a = () => [secret(), mail(), b()] +`, + 'src/b.ts': `import { secret } from 'db-lib' +export const b = () => secret() +`, + 'src/entry.ts': `import { a } from './a' +export const read = () => a() +`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + behavior: 'mock', + mockAccess: 'off', + client: { specifiers: ['db-lib', 'mail-lib'] }, + onViolation: (info) => { + seen.push(info as Violation) + }, + }, + }, + }) + const fromRoot = (file: string) => + file.replace(/^.*?\/(src|node_modules)\//, '$1/') + const inClient = seen.filter((info) => info.envType === 'client') + expect( + distinct( + inClient.map( + (info) => `${fromRoot(info.importer)} ${info.specifier}`, + ), + ).sort(), + ).toEqual(['src/a.ts db-lib', 'src/a.ts mail-lib', 'src/b.ts db-lib']) + for (const info of inClient) { + if (info.resolved !== undefined) { + expect(fromRoot(info.resolved)).toBe( + `node_modules/${info.specifier}/index.js`, + ) + } + } + expect( + await client.run(`${describeValuePrelude} +return entry.read().map((value) => describeValue(value, 'MARK_SECRET'))`), + ).toMatchObject({ + result: ['a safe mock', 'a safe mock', 'a safe mock'], + logs: [], + }) + }, + timeout, + ) + }) + + describe('log', () => { + test( + "'always' reports each violation of a build once", + async () => { + const entry = `import { secret, other } from './secret.server' +export const read = () => secret() + other() + secret() +export { a } from './a' +export { b } from './b' +` + const error = await rejection( + buildStart({ + bundler, + files: { + 'src/secret.server.ts': `export const secret = () => 'secret' +export const other = () => 'other' +`, + 'src/marked.ts': `import '@tanstack/react-start/server-only' +export const m = () => 'MARK_SECRET' +`, + 'src/a.ts': `import { m } from './marked'\nexport const a = () => m()\n`, + 'src/b.ts': `import { m } from './marked'\nexport const b = () => m() + m()\n`, + 'src/entry.ts': entry, + }, + entry: 'src/entry.ts', + start: { importProtection: { log: 'always' } }, + }), + ) + const reported = reportedViolations(error).map( + ({ importer }) => importer, + ) + const use: ExpectedViolation = { + environment: 'client', + use: 'src/entry.ts:2:27', + also: ['src/entry.ts:1'], + } + expect(relevantViolations(error, [use])).toContain(violationLabel(use)) + expect(reported).toEqual(distinct(reported)) + }, + timeout, + ) + }) + + describe('maxTraceDepth', () => { + /** The client imports `src/secret.server.ts` through a chain of modules. */ + const chain = { + ...secretServer, + 'src/b.ts': userOf('./secret.server'), + 'src/a.ts': `import { read } from './b'\nexport const page = () => read()\n`, + 'src/entry.ts': `export * from './a'\n`, + } + + /** The modules of the trace of the violation the build reports. */ + async function traceOf(importProtection: ImportProtectionOptions) { + const error = await rejection( + buildStart({ + bundler, + files: chain, + entry: 'src/entry.ts', + start: { importProtection }, + }), + ) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + return report!.trace.map(({ at }) => at.replace(/(?::\d+)+$/, '')) + } + + test( + 'cuts a deeper trace, keeping the importer', + async () => { + // (which steps a cut keeps, besides the importer, is not specified) + const trace = await traceOf({ maxTraceDepth: 1 }) + expect(trace.length).toBeGreaterThan(0) + expect(trace.length).toBeLessThanOrEqual(1 + 1) + expect(trace.at(-1)).toBe('src/b.ts') + }, + timeout, + ) + + test( + 'keeps a trace that is not deeper complete', + async () => { + expect((await traceOf({ maxTraceDepth: 3 })).slice(-3)).toEqual([ + 'src/entry.ts', + 'src/a.ts', + 'src/b.ts', + ]) + }, + timeout, + ) + }) +}) + +/** What `onViolation` gets (guide/import-protection.md). */ +interface Violation { + envType: 'client' | 'server' + type: 'specifier' | 'file' | 'marker' + specifier: string + importer: string + resolved?: string + pattern?: string | RegExp +} diff --git a/packages/start-plugin-core/tests/integration/importProtection/build.test.ts b/packages/start-plugin-core/tests/integration/importProtection/build.test.ts new file mode 100644 index 0000000000..af6ead9540 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/build.test.ts @@ -0,0 +1,389 @@ +/** + * Import protection in a real Start build (Vite and Rsbuild): what survives + * into the client bundle is reported, and invalid markers fail the build. + * Import protection checks the modules of the source directory (`src`). + * A mock is told by what it does (`mock-helpers.ts`, `describeValue`: + * `a safe mock`), and a violation by what `onViolation` receives. + */ +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { buildStart, startBundlers } from '../../build-harness' +import { + expectMarkerViolation, + expectPrinted, + expectViolationsAt, + rejection, + reportedViolations, + violationsOf, +} from '../../importProtection/start-apps' +import type { StartBuild } from '../../build-harness' +import type { TanStackStartInputConfig } from '../../../src' + +const timeout = 60_000 + +/** + * Start's import protection options of a build that fails on a violation, + * denying `files` to the client. + */ +function importProtection(files: Array<string> = []) { + return { importProtection: { behavior: 'error', client: { files } } } as const +} + +/** A server-only module (denied to the client by `importedAs`). */ +const deniedModules = { + 'a denied file': { + importedAs: './secret.server', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + }, + }, + 'a server-only-marked module': { + importedAs: './marked', + files: { + 'src/marked.ts': `import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_SECRET' +`, + }, + }, +} +type DeniedModule = keyof typeof deniedModules + +/** A client-only module (denied to the server by its marker). */ +const clientOnlyMarked = { + 'src/marked.ts': `import '@tanstack/react-start/client-only' +export const secret = () => 'MARK_SECRET' +`, +} + +/** An app whose client entry `src/entry.ts` uses `denied`. */ +function appUsing(denied: DeniedModule) { + const { importedAs, files } = deniedModules[denied] + return { + ...files, + 'src/entry.ts': `import { secret } from '${importedAs}' +export const read = () => secret() +`, + } +} + +/** + * What a failed build reported, on every channel (a compiler may print the + * details to the console and fail the build with a short error, SPEC §5.7): + * the `StartBuildError`'s diagnostics. + */ +const everyChannel = (error: Error) => + (error as Error & { diagnostics?: Array<unknown> }).diagnostics ?? error + +/** + * Builds `files` with `bundler`; what the client gets from `entry.read()`, + * and what the build reported as a problem on any channel (`warnings`). + */ +async function clientRead( + bundler: (typeof startBundlers)[number], + files: Record<string, string>, + start: TanStackStartInputConfig, +) { + const build = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start, + }) + const { client } = build + const read = (await client.run(`return String(entry.read())`)) + .result as string + return { + /** The real module's code is in the client bundle. */ + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + /** `entry.read()` ran the real module. */ + ranReal: read === 'MARK_SECRET', + warnings: problems(build.diagnostics).map(({ text }) => text), + } +} + +/** + * The one violation of a failed build (`onViolation`), and its rule; the + * build's error output names its importer and location (SPEC §5.7: file and + * position). + */ +async function failureReport(build: Promise<StartBuild>) { + const error = await rejection(build) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + expectPrinted(error.diagnostics, error.root, report!, 'error') + return { ...report!, rule: String(error.violations[0]!.pattern) } +} + +describe.each(startBundlers)('%s build', (bundler) => { + // A denied pure re-export barrel whose export the client uses survives + // into the client bundle (as the code it re-exports), so it must be + // reported. + // Source: issue #8102 (closed without a reproduction: Rolldown may elide + // the barrel from `chunk.modules`). + test( + 'a denied re-export barrel the client uses fails the build', + async () => { + const report = await failureReport( + buildStart({ + bundler, + files: { + 'src/secret.ts': `export const secret = () => 'MARK_SECRET' + Math.random()\n`, + 'src/barrel.ts': `export { secret } from './secret'\n`, + 'src/entry.ts': `import { secret } from './barrel'\nexport const read = () => secret()\n`, + }, + entry: 'src/entry.ts', + start: importProtection(['**/barrel.ts']), + }), + ) + expect(report.environment).toBe('client') + expect(report.importer).toMatch(/^src\/entry\.ts/) + }, + timeout, + ) + + test( + 'a file with both a server-only and a client-only marker fails the build, naming the file', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: { + 'src/both.ts': `import '@tanstack/react-start/server-only' +import '@tanstack/react-start/client-only' +export const value = 1 +`, + 'src/entry.ts': `import { value } from './both'\nexport const read = () => value\n`, + }, + entry: 'src/entry.ts', + start: importProtection(), + }), + ) + expectDiagnostic(everyChannel(error), { + severity: 'error', + file: 'src/both.ts', + }) + }, + timeout, + ) +}) + +// Start's default import protection (no options): the defaults deny +// `*.server.*` files, `@tanstack/<framework>-start/server` and modules marked +// server-only to the client, and a build fails on a violation. +// Source: review (the default rules were never built in error mode: every +// build test replaced `client.files`). +describe.each(startBundlers)('%s build, default rules', (bundler) => { + // Each violation carries the rule that matched (the file pattern, or the + // denied specifier; SPEC J6.5). + test.each<{ + name: string + files: Record<string, string> + reported: string + rule: string + }>([ + { + name: 'a client import of a *.server.* file', + files: appUsing('a denied file'), + reported: 'src/entry.ts:2:27', + rule: '**/*.server.*', + }, + { + name: 'a client import of a *.server.* file in a dot directory', + files: { + 'src/.private/db.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/entry.ts': `import { secret } from './.private/db.server' +export const read = () => secret() +`, + }, + reported: 'src/entry.ts:2:27', + rule: '**/*.server.*', + }, + { + name: 'a client import of @tanstack/react-start/server', + files: { + 'src/entry.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + }, + reported: 'src/entry.ts:2:27', + rule: '@tanstack/react-start/server', + }, + ])( + '$name fails the build, naming the importer at the use or the import, and the rule', + async ({ files, reported, rule }) => { + const build = buildStart({ bundler, files, entry: 'src/entry.ts' }) + const report = await failureReport(build) + expectViolationsAt(await rejection(build), [ + { environment: 'client', use: reported, also: ['src/entry.ts:1'] }, + ]) + expect(report.rule).toContain(rule) + }, + timeout, + ) + + test( + 'a server import of a *.client.* file fails the build, naming the importer at the use or the import, and the rule', + async () => { + const server = `import { widget } from './widget.client' +export const read = () => widget() +` + const build = buildStart({ + bundler, + files: { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/server.ts': server, + 'src/client.ts': `export const read = () => 'client'\n`, + }, + entry: { client: 'src/client.ts', ssr: 'src/server.ts' }, + }) + const report = await failureReport(build) + expectViolationsAt(await rejection(build), [ + { + environment: 'server', + use: 'src/server.ts:2:27', + also: ['src/server.ts:1'], + }, + ]) + expect(report.rule).toContain('**/*.client.*') + }, + timeout, + ) + + test( + 'a client import of a server-only-marked module fails the build, naming the module and its importer', + async () => { + const report = await failureReport( + buildStart({ + bundler, + files: appUsing('a server-only-marked module'), + entry: 'src/entry.ts', + }), + ) + expect(report.environment).toBe('client') + expectMarkerViolation(report, { + marker: 'src/marked.ts:1', + use: 'src/entry.ts:2:27', + imports: ['src/entry.ts:1'], + }) + }, + timeout, + ) + + test( + 'a server import of a client-only-marked module fails the build, naming the module and its importer', + async () => { + const serverImportsMarked = `import { secret } from './marked' +export const read = () => secret() +` + const report = await failureReport( + buildStart({ + bundler, + files: { + ...clientOnlyMarked, + 'src/server.ts': serverImportsMarked, + 'src/client.ts': `export const read = () => 'client'\n`, + }, + entry: { client: 'src/client.ts', ssr: 'src/server.ts' }, + }), + ) + expect(report.environment).toBe('server') + expectMarkerViolation(report, { + marker: 'src/marked.ts:1', + use: 'src/server.ts:2:27', + imports: ['src/server.ts:1'], + }) + }, + timeout, + ) + + // Several modules import the marked module (directly and through a + // re-export), so the marker check sees it imported after it has seen its + // marker. + test.each([ + { env: 'ssr', marker: 'server-only', build: 'server' }, + { env: 'client', marker: 'client-only', build: 'client' }, + ] as const)( + 'the $build build may import a $marker-marked module from several modules, without any import-protection output', + async ({ env, marker }) => { + const built = await buildStart({ + bundler, + files: { + 'src/marked.ts': `import '@tanstack/react-start/${marker}' +export const secret = () => 'MARK_SECRET' +`, + 'src/d.ts': `import { secret } from './marked' +export const d = () => secret() +`, + 'src/c.ts': `export { d } from './d'\n`, + 'src/user.ts': `import { secret } from './marked' +import { d } from './c' +export const read = () => secret() + '|' + d() +`, + 'src/other.ts': `export const read = () => 'other'\n`, + }, + entry: + env === 'ssr' + ? { client: 'src/other.ts', ssr: 'src/user.ts' } + : { client: 'src/user.ts', ssr: 'src/other.ts' }, + }) + expect((await built[env].run(`return entry.read()`)).result).toBe( + 'MARK_SECRET|MARK_SECRET', + ) + expect(reportedViolations(built)).toEqual([]) + }, + timeout, + ) + + test( + 'enabled: false checks nothing: the client gets the real module', + async () => { + expect( + await clientRead(bundler, appUsing('a denied file'), { + importProtection: { enabled: false }, + }), + ).toEqual({ hasRealCode: true, ranReal: true, warnings: [] }) + }, + timeout, + ) +}) + +// A build reports the denied imports that survive tree-shaking: "If an import +// is eliminated from the final bundle, no violation is reported" +// (guide/import-protection.md, "False Positives: Dev vs Build"; its example is a marked file +// re-exported through a mixed barrel that the client never uses). +// Source: mutation testing (generateBundle's survival check). +describe.each(startBundlers)('%s build, tree-shaken imports', (bundler) => { + // Bug (Rsbuild): same as the pins "a denied module the client bundle drops + // does not fail the build" (known-bugs.test.ts): the Rsbuild report step + // walks every module of the module graph, used or not, so the marked + // module the client bundle drops still fails the build. + // Impact: on Rsbuild, a mixed barrel re-exporting a server-only-marked + // module fails the build even when the client only uses its other exports. + const barrelTest = bundler === 'rsbuild' ? test.fails : test + barrelTest( + 'a server-only-marked module re-exported by a barrel the client uses other exports of builds without any report', + async () => { + const build = await buildStart({ + bundler, + files: { + ...deniedModules['a server-only-marked module'].files, + 'src/barrel.ts': `export { secret } from './marked' +export const label = () => 'client' +`, + 'src/entry.ts': `import { label } from './barrel' +export const read = () => label() +`, + }, + entry: 'src/entry.ts', + }) + const { client } = build + expect({ + reported: reportedViolations(build), + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + read: (await client.run(`return entry.read()`)).result, + }).toEqual({ reported: [], hasRealCode: false, read: 'client' }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/client-pages.ts b/packages/start-plugin-core/tests/integration/importProtection/client-pages.ts new file mode 100644 index 0000000000..3fa2103214 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/client-pages.ts @@ -0,0 +1,179 @@ +/** + * Thin page glue for policy fixtures that expose values instead of a UI, on + * the one client runner of the dev-server tests (`withRecordedPage` of + * `../../rsbuild-dev-server`: a real Chromium page recording what the page's + * code logs and the errors it does not catch). Vite serves an actual HTML + * entry through its own HTML pipeline (`clientFixturePlugin`); Rsbuild's + * page loads the initial files of the client entry, as an app's HTML does + * (`runInClient`, `runRsbuildClient`), so the real host loads its runtime, + * dependencies and initial/async chunks. + */ +import { diagnosticsOf } from '@tanstack/compiler-test-utils/diagnostics' +import { startDevServer } from '../../dev-server' +import { startProtectedDevServer } from '../../importProtection/start-apps' +import { + clientPage, + startRsbuildDevServer, + startRsbuildStartDevServer, + throwUncaught, + withRecordedPage, +} from '../../rsbuild-dev-server' +import type { ClientRun } from '../../rsbuild-dev-server' +import type { Plugin } from 'vite' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +export { runInClient, runRsbuildClient } from '../../rsbuild-dev-server' + +/** Mounted before Start's SSR fallback, using Vite's actual HTML pipeline. */ +export const clientFixturePlugin: Plugin = { + name: 'ip-fixture-page', + configureServer(server) { + server.middlewares.use('/__ip-fixture.html', async (req, res, next) => { + try { + const html = await server.transformIndexHtml( + req.originalUrl!, + `<!doctype html><link rel="icon" href="data:,"><div id="root"></div> +<script type="module"> +import(/* @vite-ignore */ new URLSearchParams(location.search).get('entry')) + .then( + (entry) => { window.__ipEntry = entry }, + (error) => { window.__ipLoadError = error.stack ?? String(error) }, + ) + .then(() => dispatchEvent(new Event('ip-entry'))) +</script>`, + ) + res.setHeader('Content-Type', 'text/html') + res.end(html) + } catch (error) { + next(error) + } + }) + }, +} + +export function startBrowserStartDevServer( + options: Parameters<typeof startDevServer>[0], +) { + return startDevServer({ + ...options, + browser: true, + plugins: (app) => [ + clientFixturePlugin, + ...(typeof options.plugins === 'function' + ? options.plugins(app) + : (options.plugins ?? [])), + ], + }) +} + +/** + * Loads `entry` in the fixture page of a Vite dev server started with + * `clientFixturePlugin` and `browser: true`, then runs `script` (the body + * of an async function, with the module as `entry`). Returns what it + * returns (`result`), and what the page's code logged meanwhile + * (`messages`, `level: text`, and as `diagnostics`). Fails when the entry + * does not load, the page's code throws an error it does not catch, or the + * script throws. + */ +export async function runViteClient( + server: Pick<DevServer, 'url'>, + entry: string, + script: string, +) { + if (!server.url) { + throw new Error('The client policy fixture needs browser: true') + } + const url = new URL('/__ip-fixture.html', server.url) + url.searchParams.set('entry', entry) + return withRecordedPage(url.href, {}, async ({ page }) => { + // The page may reload at any time while it loads: Vite sends a + // `full-reload` (an edit, the dependency optimizer), and keeps one sent + // while no page is connected for the next page that connects. So one + // evaluation, in whichever document is current, waits for that + // document's entry, a turn of its event loop (what its load scheduled + // ran), and runs `script`: every value comes from one document. A reload + // during it destroys the evaluation's context; that alone is retried. + // Load errors, the errors the page's code did not catch while it loaded + // and the script's own errors still fail immediately. HMR/no-reload rows + // use their persistent page hosts instead. + for (let attempt = 0; ; attempt++) { + try { + const run = await page.evaluate<{ + uncaught: ClientRun['uncaught'] + calls?: ClientRun['calls'] + result?: unknown + }>( + `(async () => { +if (window.__ipEntry === undefined && window.__ipLoadError === undefined) { + await new Promise((resolve) => addEventListener('ip-entry', resolve, { once: true })) +} +await new Promise((resolve) => setTimeout(resolve)) +const { uncaught, calls } = globalThis.__clientRun +if (uncaught.length > 0) { + return { uncaught: [...uncaught] } +} +if (window.__ipLoadError) { throw new Error(window.__ipLoadError) } +const entry = window.__ipEntry +const result = await (async () => { +${script} +})() +return { uncaught: [], calls, result } +})()`, + ) + throwUncaught(run) + const { result, calls = [] } = run + const messages = calls.map(({ level, text }) => `${level}: ${text}`) + const diagnostics = calls.flatMap(({ level, text }) => + diagnosticsOf( + text, + level === 'error' ? 'error' : level === 'warn' ? 'warning' : 'info', + ), + ) + return { result, diagnostics, messages } + } catch (error) { + // A dependency the optimizer bundled again while the page loaded: + // the document still imports the previous bundle, and Vite reloads + // it (a user's browser reloads too); load the current document. + const staleDependency = /\/node_modules\/\.vite\/deps\//.test( + String(error), + ) + if ( + attempt >= 2 || + !( + staleDependency || + /Execution context was destroyed|Cannot find context with specified id/.test( + String(error), + ) + ) + ) { + throw error + } + if (staleDependency) { + await page.reload() + } + } + } + }) +} + +export async function startBrowserProtectedDevServer( + ...args: Parameters<typeof startProtectedDevServer> +) { + return startProtectedDevServer(args[0], args[1], { + ...args[2], + browser: true, + plugins: [clientFixturePlugin, ...(args[2]?.plugins ?? [])], + }) +} + +export async function startBrowserRsbuildDevServer( + ...args: Parameters<typeof startRsbuildDevServer> +) { + return startRsbuildDevServer({ ...args[0], ...clientPage }) +} + +export function startBrowserRsbuildStartDevServer( + options: Parameters<typeof startRsbuildStartDevServer>[0], +) { + return startRsbuildStartDevServer({ ...options, ...clientPage }) +} diff --git a/packages/start-plugin-core/tests/integration/importProtection/default-rules.test.ts b/packages/start-plugin-core/tests/integration/importProtection/default-rules.test.ts new file mode 100644 index 0000000000..dabe8711f7 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/default-rules.test.ts @@ -0,0 +1,356 @@ +/** + * Import protection's default rules and its pattern matching, on a real + * app (Vite dev server with Start's whole public plugin, mock mode): what a + * user gets with no `importProtection` option (SPEC J6.1, J6.10; the guide's + * options table), and how a configured glob or RegExp matches (J6.1, + * J6.11). Read from what the dev server reports (`reportedImporters`: the + * importer `onViolation` receives), in each environment. + * + * - The client denies the server entry of every Start framework + * (`@tanstack/{react,solid,vue}-start/server`) and every module marked + * server-only by any framework's marker; the server denies modules marked + * client-only by any framework's marker, and no specifier by default. + * - Files under `node_modules` skip the file-pattern checks by default in + * both environments (`excludeFiles: ['**\/node_modules/**']`). + * + * The framework packages other than React are stand-ins in the app's + * `node_modules` (this app is a React app): the rules name them by + * specifier, so the app needs only modules for them to resolve to. + * + * Replaces the internal controls of the default rule lists and of the + * matcher (main's `importProtection/defaults.test.ts`, + * `matchers.test.ts`), which read today's rule objects. + */ +import { describe, expect, test } from 'vitest' +import { + reportedImporters, + startProtectedDevServer, +} from '../../importProtection/start-apps' + +const timeout = 30_000 + +/** A stand-in package `name` whose subpath modules each export `value`. */ +function standInPackage(name: string, subpaths: Array<string>) { + return { + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: Object.fromEntries( + subpaths.map((subpath) => [`./${subpath}`, `./${subpath}.js`]), + ), + }), + ...Object.fromEntries( + subpaths.map((subpath) => [ + `node_modules/${name}/${subpath}.js`, + `export const value = () => 'REAL_${name}/${subpath}'\n`, + ]), + ), + } +} + +/** A package `name` whose entry is `index.js`, with other files. */ +function plainPackage(name: string, files: Record<string, string>) { + return { + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + ...Object.fromEntries( + Object.entries(files).map(([file, code]) => [ + `node_modules/${name}/${file}`, + code, + ]), + ), + } +} + +/** + * A dependency whose own entries resolve to files named like environment + * files (as `react-tweet` exports `index.client.js`): `dep-pkg/secret` is + * `db.server.js`, `dep-pkg/widget` is `widget.client.js`. The app imports + * both from `src/uses/dep.ts`, so the resolved targets the default + * `excludeFiles` skip are what the app's own module imports (a dependency's + * imports of its own files are outside Start's `srcDirectory`, which import + * protection never checks). + */ +const dependencyFiles = { + 'node_modules/dep-pkg/package.json': JSON.stringify({ + name: 'dep-pkg', + type: 'module', + exports: { './secret': './db.server.js', './widget': './widget.client.js' }, + }), + 'node_modules/dep-pkg/db.server.js': `export const secret = () => 'REAL_DEP_SERVER'\n`, + 'node_modules/dep-pkg/widget.client.js': `export const widget = () => 'REAL_DEP_CLIENT'\n`, +} +const dependencyUse = { + 'src/uses/dep.ts': `import { secret } from 'dep-pkg/secret' +import { widget } from 'dep-pkg/widget' +export const useDep = () => [secret(), widget()] +`, +} + +/** + * Asserts that the reports of `environment` (`located`, from + * `reportedImporters`) are exactly the `expected` violations, each reported + * (at least once) at one of its relevant files: the importer, or for a + * marker violation the marked module (SPEC J6.5). + */ +function expectReported( + located: Array<string>, + environment: 'client' | 'server', + expected: Record<string, Array<string>>, +) { + const files = [ + ...new Set( + located + .filter((entry) => entry.startsWith(`${environment} `)) + .map((entry) => entry.slice(environment.length + 1)), + ), + ] + const unexpected = files.filter( + (file) => !Object.values(expected).some((places) => places.includes(file)), + ) + const missing = Object.entries(expected) + .filter(([, places]) => !places.some((place) => files.includes(place))) + .map(([name]) => name) + expect({ unexpected, missing }).toEqual({ unexpected: [], missing: [] }) +} + +describe('the default rules', () => { + const files = { + ...standInPackage('@tanstack/solid-start', [ + 'server', + 'server-only', + 'client-only', + ]), + ...standInPackage('@tanstack/vue-start', [ + 'server', + 'server-only', + 'client-only', + ]), + // A dependency whose own files are named like denied files: excluded by + // default in both environments + ...dependencyFiles, + // Server entries of each framework (denied to the client by specifier) + 'src/uses/react-server.ts': `import { getRequest } from '@tanstack/react-start/server' +export const reactServer = () => getRequest() +`, + 'src/uses/solid-server.ts': `import { value } from '@tanstack/solid-start/server' +export const solidServer = () => value() +`, + 'src/uses/vue-server.ts': `import { value } from '@tanstack/vue-start/server' +export const vueServer = () => value() +`, + // Modules marked server-only by each framework's marker + 'src/solid-marked.ts': `import '@tanstack/solid-start/server-only' +export const solidMarked = () => 'MARK_SOLID_SERVER_ONLY' +`, + 'src/vue-marked.ts': `import '@tanstack/vue-start/server-only' +export const vueMarked = () => 'MARK_VUE_SERVER_ONLY' +`, + 'src/uses/solid-marked.ts': `import { solidMarked } from '../solid-marked' +export const useSolidMarked = () => solidMarked() +`, + 'src/uses/vue-marked.ts': `import { vueMarked } from '../vue-marked' +export const useVueMarked = () => vueMarked() +`, + // Modules marked client-only by each framework's marker + 'src/solid-client-marked.ts': `import '@tanstack/solid-start/client-only' +export const solidClient = () => 'MARK_SOLID_CLIENT_ONLY' +`, + 'src/vue-client-marked.ts': `import '@tanstack/vue-start/client-only' +export const vueClient = () => 'MARK_VUE_CLIENT_ONLY' +`, + 'src/uses/solid-client-marked.ts': `import { solidClient } from '../solid-client-marked' +export const useSolidClient = () => solidClient() +`, + 'src/uses/vue-client-marked.ts': `import { vueClient } from '../vue-client-marked' +export const useVueClient = () => vueClient() +`, + ...dependencyUse, + 'src/entry.ts': `export * from './uses/react-server' +export * from './uses/solid-server' +export * from './uses/vue-server' +export * from './uses/solid-marked' +export * from './uses/vue-marked' +export * from './uses/solid-client-marked' +export * from './uses/vue-client-marked' +export * from './uses/dep' +`, + } + + let located: Promise<Array<string>> | undefined + /** The reports of both environments loading the app, read once. */ + const reports = () => + (located ??= (async () => { + const server = await startProtectedDevServer(files, { + mockAccess: 'off', + }) + // The client loads the app the way a browser does; the server runs it + await server.load('/src/entry.ts', { + skip: /(?:^|\/)node_modules\/|^node:|^\/@vite\//, + }) + await server.import('/src/entry.ts', 'ssr') + return reportedImporters(server) + })()) + + test( + "the client denies every framework's server entry and server-only marker, not the files of a dependency", + async () => { + expectReported(await reports(), 'client', { + 'react server entry': ['src/uses/react-server.ts'], + 'solid server entry': ['src/uses/solid-server.ts'], + 'vue server entry': ['src/uses/vue-server.ts'], + 'solid server-only marker': [ + 'src/uses/solid-marked.ts', + 'src/solid-marked.ts', + ], + 'vue server-only marker': [ + 'src/uses/vue-marked.ts', + 'src/vue-marked.ts', + ], + }) + }, + timeout, + ) + + test( + "the server denies every framework's client-only marker, no specifier, and not the files of a dependency", + async () => { + expectReported(await reports(), 'server', { + 'solid client-only marker': [ + 'src/uses/solid-client-marked.ts', + 'src/solid-client-marked.ts', + ], + 'vue client-only marker': [ + 'src/uses/vue-client-marked.ts', + 'src/vue-client-marked.ts', + ], + }) + }, + timeout, + ) +}) + +// The default `excludeFiles` is what keeps the dependency's files out of +// the reports above: with it replaced by `[]` (the guide: "If you need to +// check third-party files, set `excludeFiles: []`"), the same imports must +// be reported; both environments are pinned (bugs below). The default rows +// above are not vacuous: without the exclusion, the server's mock rewrite of +// `dep-pkg/widget` fails the app's SSR import, so their shared run fails. +describe('excludeFiles: [] checks the files of a dependency', () => { + const files = { + ...dependencyFiles, + ...dependencyUse, + 'src/entry.ts': `export * from './uses/dep'\n`, + } + + // Bug: on the client in dev mock mode (the default), with + // `excludeFiles: []`, the denied import of a dependency's server file is + // rewritten to import the real file (`/node_modules/dep-pkg/db.server.js`, + // read as a `default` export it does not have) instead of a mock, and + // that rewritten import is reported a second time, at no position. + // Impact: the documented way to check third-party files still sends the + // dependency's server file to the browser, and the module reading it + // breaks. + // Fix-agnostic: the import is reported at its place only, and the client + // loads no code of the denied file. + // Source: review (the default `excludeFiles` had no reachable contrast). + test.fails( + 'the client reports the dependency file it denies, and does not load it', + async () => { + const server = await startProtectedDevServer(files, { + mockAccess: 'off', + client: { excludeFiles: [] }, + }) + const loaded = await server.load('/src/entry.ts', { + skip: /^node:|^\/@vite\//, + }) + expectReported(reportedImporters(server), 'client', { + 'dependency server file': ['src/uses/dep.ts'], + }) + expect( + Object.entries(loaded) + .filter(([, code]) => code.includes('REAL_DEP_SERVER')) + .map(([url]) => url), + ).toEqual([]) + }, + timeout, + ) + + // Bug: on the server in dev, with `excludeFiles: []`, a dependency's file + // the server denies (here `dep-pkg/widget`, which resolves to + // `widget.client.js`) is never reported: in mock mode (the dev default) + // the import is rewritten to read a `default` export of the real file + // (`/node_modules/dep-pkg/widget.client.js`, which has none), so loading + // the module fails ("does not provide an export named 'default'") without + // a report; in error mode nothing is reported and the real module loads. + // Impact: the documented way to check third-party files does nothing on + // the server in `vite dev`, and in mock mode breaks the module that + // imports the file. + // Fix-agnostic: the server reports the import at the importer, and the + // app loads. + // Source: review (the server's default `excludeFiles` had no reachable + // contrast). + test.fails( + 'the server reports the dependency file it denies', + async () => { + const server = await startProtectedDevServer(files, { + mockAccess: 'off', + server: { excludeFiles: [] }, + }) + await server.import('/src/entry.ts', 'ssr') + expectReported(reportedImporters(server), 'server', { + 'dependency client file': ['src/uses/dep.ts'], + }) + }, + timeout, + ) +}) + +describe('configured patterns', () => { + const files = { + ...plainPackage('pg', { + 'index.js': `export default () => 'REAL_pg'\n`, + }), + ...plainPackage('pg-pool', { + 'index.js': `export default () => 'REAL_pg-pool'\n`, + }), + 'src/.server/db.ts': `export const db = () => 'MARK_DEEP_SERVER'\n`, + 'src/.client/ui.ts': `export const ui = () => 'MARK_DEEP_CLIENT'\n`, + 'src/uses/deep-server.ts': `import { db } from '../.server/db' +export const useDeepServer = () => db() +`, + 'src/uses/deep-client.ts': `import { ui } from '../.client/ui' +export const useDeepClient = () => ui() +`, + 'src/uses/postgres.ts': `import pg from 'pg' +export const usePg = () => pg() +`, + 'src/uses/pg-pool.ts': `import pool from 'pg-pool' +export const usePool = () => pool() +`, + 'src/entry.ts': `export * from './uses/deep-server' +export * from './uses/deep-client' +export * from './uses/postgres' +export * from './uses/pg-pool' +`, + } + + test( + 'a ** glob matches files at any depth under a directory, and an anchored RegExp only the exact specifier', + async () => { + const server = await startProtectedDevServer(files, { + client: { files: ['**/.server/**'], specifiers: [/^pg$/] }, + mockAccess: 'off', + }) + await server.load('/src/entry.ts') + expectReported(reportedImporters(server), 'client', { + 'the deep glob': ['src/uses/deep-server.ts'], + 'the anchored RegExp': ['src/uses/postgres.ts'], + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/dev-page.test.ts b/packages/start-plugin-core/tests/integration/importProtection/dev-page.test.ts new file mode 100644 index 0000000000..e33a4c7b2f --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/dev-page.test.ts @@ -0,0 +1,285 @@ +/** + * Import protection on a Vite dev server with Start's whole plugin, seen the + * way users meet it: the client through a real browser page Start's dev + * middleware serves (its HTML, its client entry, a route rendered by the + * real router and React), the server through HTTP requests. Every entry of + * an environment counts (SPEC J6.9): the app's client entry, its server + * entry, the router's split route modules. No test names a module id Start + * generates. + */ +import react from '@vitejs/plugin-react' +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { startDevServer, startServerEntryFiles } from '../../dev-server' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + expectViolationsAt, + locationIn, + violationRecorder, +} from '../../importProtection/start-apps' + +const timeout = 30_000 + +const secretServer = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, +} + +/** + * A Start app a browser opens: Start's default server entry, the default + * client entry (hydration of `StartClient`), the real router over the + * generated route tree, a root route rendering the document (`#app`, a + * hydration marker), and `src/routes/index.tsx` (`index`). + */ +const pageApp = (index: string) => ({ + ...startServerEntryFiles, + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient)) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': index, +}) + +/** Pre-bundled up front, as Vite does for an app that installed them. */ +const config = { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + ], + }, +} + +const plainIndex = `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => 'MARK_PAGE' }) +` + +/** + * Starts the app of `files` and opens its page `/` once it hydrated; the + * server records the violations Start reports (`violations`). + */ +async function openApp(files: Record<string, string>) { + const recorder = violationRecorder() + const started = await startDevServer({ + start: { importProtection: { onViolation: recorder.onViolation } }, + browser: true, + config, + plugins: [react()], + files, + }) + const server = Object.assign(started, { violations: recorder.violations }) + const browser = await openPage(new URL('/', server.url).href, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + return { server, browser } +} + +describe("an app's client entry", () => { + const leak = `import { secret } from './secret.server' +export const leak = () => secret() +` + /** + * The app's own client entry `src/client.tsx` (Start loads it for the + * page) hydrates the document and keeps what `src/leak.ts` gives, which + * uses the denied file `src/secret.server.ts`. + */ + const clientEntryApp = { + ...pageApp(plainIndex), + ...secretServer, + 'src/leak.ts': leak, + 'src/client.tsx': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +import { leak } from './leak' +;(window as unknown as Record<string, unknown>).leaked = leak +hydrateRoot(document, createElement(StartClient)) +`, + } + + // Control for the pin below (same app, same page): the page runs the + // app's client entry, whose denied import is a safe mock. + test( + "the page runs the app's client entry, and its denied import is a safe mock", + async () => { + const { browser } = await openApp(clientEntryApp) + expect( + await browser.page.evaluate(`(() => { +${describeValuePrelude} +return describeValue(window.leaked(), 'MARK_SECRET') +})()`), + ).toBe('a safe mock') + }, + timeout, + ) + + // Bug: dev import protection only logs violations it can reach from the + // entries it registers, Start's router entry and start entry + // (vite/import-protection-plugin/plugin.ts `registerEntries`). The app's + // client entry is not one, and the browser loads it from Start's dev + // client entry, a virtual module whose imports import protection does not + // record, so the modules only the client entry imports are unreachable + // and their violations are discarded. + // Impact: in dev (mock mode), a denied import reached from the app's + // client entry (`src/client.tsx`) is mocked without any warning (the build + // reports it). + // Source: mutation testing (looking for edges without transform data). + test.fails( + 'a denied import of a module the client entry imports is logged', + async () => { + const { server } = await openApp(clientEntryApp) + expectViolationsAt(server, [ + { + environment: 'client', + use: locationIn('src/leak.ts', leak, 2, 'secret()'), + also: ['src/leak.ts:1'], + }, + ]) + }, + timeout, + ) +}) + +describe("an app's server entry", () => { + const handler = `import { widget } from './widget.client' +export const handler = () => widget() +` + /** + * The app's own server entry `src/server.ts` answers every request with + * what `src/handler.ts` gives (`handler`). + */ + const serverEntryApp = (handlerModule: string) => ({ + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/handler.ts': handlerModule, + 'src/server.ts': `import { handler } from './handler' +export default { fetch: () => new Response(String(handler())) } +`, + 'src/router.ts': `export const getRouter = () => undefined\n`, + }) + + const request = async (files: Record<string, string>) => { + const recorder = violationRecorder() + const started = await startDevServer({ + start: { importProtection: { onViolation: recorder.onViolation } }, + listen: true, + files, + }) + const server = Object.assign(started, { violations: recorder.violations }) + return { server, response: await server.fetch('/') } + } + + // Control for the pin below (same harness): a request runs the app's + // server entry. + test( + "a request runs the app's server entry", + async () => { + const { response } = await request( + serverEntryApp(`export const handler = () => 'MARK_HANDLER'\n`), + ) + expect(response.body).toBe('MARK_HANDLER') + }, + timeout, + ) + + // Bug: dev import protection only logs violations it can reach from the + // entries it registers, Start's router entry and start entry + // (vite/import-protection-plugin/plugin.ts `registerEntries`). The app's + // server entry is not one, and the entry branch of `resolveId` (no + // importer) never runs in dev, where Vite passes `<root>/index.html` as + // the importer, so the modules only the server entry imports are + // unreachable and their violations are discarded. The server twin of the + // client entry pin above. + // Impact: in dev (mock mode), a client-only import reached from the app's + // custom server entry (`src/server.ts`) is mocked on the server without + // any warning (the request returns the mock's value). + // Source: mutation testing. + test.fails( + 'a client-only import of a module the server entry imports is mocked on the server and logged', + async () => { + const { server, response } = await request(serverEntryApp(handler)) + expect(response.body).not.toContain('MARK_CLIENT') + expectViolationsAt(server, [ + { + environment: 'server', + use: locationIn('src/handler.ts', handler, 2, 'widget()'), + also: ['src/handler.ts:1'], + }, + ]) + }, + timeout, + ) +}) + +// The router plugin splits a route's component into a module of its own, +// which the browser loads when the route renders. +describe('a split route component', () => { + const widget = `import { secret } from './secret.server' +export const widget = () => String(secret()) +` + // `ssr: false` (selective SSR): the server renders no component, which + // may use the denied file there. + const route = `import { createFileRoute } from '@tanstack/react-router' +import { secret } from '../secret.server' +import { widget } from '../widget' +export const Route = createFileRoute('/')({ + ssr: false, + component: () => 'MARK_RENDERED ' + String(secret()) + widget(), +}) +` + + // Source: mutation testing (the cache of compiled split modules: the + // denied import, and the import of the module using the denied file, are + // only in the split module). + test( + 'using a denied file, directly or through a module, renders with the mock, and the dev server logs a warning at each use or import', + async () => { + const { server, browser } = await openApp({ + ...pageApp(route), + ...secretServer, + 'src/widget.ts': widget, + }) + await browser.waitForText('MARK_RENDERED', { selector: '#app' }) + expect(await browser.text('#app')).not.toContain('MARK_SECRET') + expectViolationsAt(server, [ + { + environment: 'client', + use: locationIn('src/routes/index.tsx', route, 6, 'secret()'), + also: ['src/routes/index.tsx:2'], + }, + { + environment: 'client', + use: locationIn('src/widget.ts', widget, 2, 'secret()'), + also: ['src/widget.ts:1'], + }, + ]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/dev.test.ts b/packages/start-plugin-core/tests/integration/importProtection/dev.test.ts new file mode 100644 index 0000000000..956e545a25 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/dev.test.ts @@ -0,0 +1,2655 @@ +/** + * Import protection on a Vite dev server (Start's import-protection plugin + * after the Start compiler, with Start's entries registered): what the + * browser gets for a denied import, and the warnings the dev server logs, + * including after edits (without a restart). The client loads modules the way + * a browser does: from the app's router entry `src/entry.ts`, an importer + * before the modules it imports. + */ +import path from 'node:path' +import mdx from '@mdx-js/rollup' +import { + captureConsole, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { afterEach, describe, expect, test, vi } from 'vitest' +import { startDevServer } from '../../dev-server' +import { + describeValue, + describeValuePrelude, + expectMockAccess, + mockAccessDiagnostics, + probeMockPrelude, + safeMock, + warningsAndErrors, +} from '../../importProtection/mock-helpers' +import { + distinct, + expectPrinted, + expectViolationsAt, + factoryTopLevelCall, + locationIn, + problemsNaming, + receivedViolations, + rejection, + relevantViolations, + reportedViolations, + serverFnFactoryApp, + startProtectedDevServer, + startRscProtectedDevServer, + violationLabel, + violationRecorder, + violationsOf, +} from '../../importProtection/start-apps' +import { originalLocation } from '../../importProtection/original-location' +import { + clientFixturePlugin, + runViteClient, + startBrowserProtectedDevServer, +} from './client-pages' +import type { + ExpectedViolation, + ProtectedDevServer, + Recorded, + Violation, +} from '../../importProtection/start-apps' +import type { + ImportProtectionOptions, + ViolationInfo, +} from '../../importProtection/public-types' +import type { DevEnvironment, Plugin } from 'vite' + +const timeout = 30_000 + +afterEach(() => { + vi.restoreAllMocks() +}) + +/** + * Starts a dev server with Start's whole plugin (without HMR), recording + * the violations Start reports through `onViolation` (`violations`). + */ +async function startRecordingApp(files: Record<string, string>) { + const recorder = violationRecorder() + const server = await startDevServer({ + start: { importProtection: { onViolation: recorder.onViolation } }, + files, + config: { server: { hmr: false } }, + }) + return Object.assign(server, { violations: recorder.violations }) +} + +/** Client modules (by URL) whose served code contains `marker`. */ +function modulesContaining(modules: Record<string, string>, marker: string) { + return Object.keys(modules).filter((url) => modules[url]!.includes(marker)) +} + +/** `environment importer` of each distinct violation of `recorded`. */ +function loggedViolations(recorded: Recorded) { + return distinct( + reportedViolations(recorded).map( + ({ environment, importer }) => `${environment} ${importer}`, + ), + ) +} + +/** + * The warnings the dev server printed (on any channel) that name `file` + * (relative to the app root), from `since` (a `server.diagnostics.length` + * mark) on: what `log` governs (SPEC J6.5). + */ +function warningsNaming(server: ProtectedDevServer, file: string, since = 0) { + return findDiagnostics(server.diagnostics.slice(since), { + severity: 'warning', + file, + root: server.root, + }) +} + +/** The violations of `recorded`, one per environment type and importer. */ +function distinctReports(recorded: Recorded): Array<Violation> { + const seen = new Set<string>() + return violationsOf(recorded).filter((report) => { + const key = `${report.environment} ${report.importer}` + const fresh = !seen.has(key) + seen.add(key) + return fresh + }) +} + +/** + * Nothing is reported about `files` (relative to the app root): no + * violation `onViolation` received, and no warning or error naming them on + * any channel, whatever its wording. + */ +function expectNothingReportedAbout( + server: ProtectedDevServer, + files: Array<string>, +) { + expect(reportedViolations(server)).toEqual([]) + expect(problemsNaming(server, files)).toEqual([]) +} + +/** The modules of the trace of `report`, without locations. */ +const traceModules = (report: Violation) => + report.trace.map(({ at }) => at.replace(/(?::\d+)+$/, '')) + +/** + * `src/a.ts` uses `secret` of the denied file `src/secret.server.ts`; the + * router entry re-exports `src/a.ts`. + */ +const deniedFileApp = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/a.ts': `import { secret } from './secret.server' +export const read = () => secret() +`, + 'src/entry.ts': `export * from './a'\n`, +} + +/** The location of `src/a.ts`'s use of `secret`. */ +const deniedFileUse = 'src/a.ts:2:27' + +/** + * The violation of `deniedFileApp`, reported at the use of `secret` or at + * the import of the denied file (SPEC J6.5). + */ +const deniedFileViolation: ExpectedViolation = { + environment: 'client', + use: deniedFileUse, + also: ['src/a.ts:1'], +} + +describe('a client import of a denied file', () => { + // Source: review (the warning channel of dev violations). + test( + 'is mocked, and the dev server logs a warning naming the importer at the use or the import', + async () => { + const server = await startProtectedDevServer(deniedFileApp) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expectViolationsAt(server, [deniedFileViolation]) + }, + timeout, + ) + + /** + * Starts the app with a `src/a.ts` that imports nothing, loads it, then + * edits `src/a.ts` to import the denied file and loads it again. + */ + async function addDeniedImportByAnEdit() { + const server = await startProtectedDevServer({ + ...deniedFileApp, + 'src/a.ts': `export const read = () => 'plain'\n`, + }) + await server.load('/src/entry.ts') + await server.edit({ 'src/a.ts': deniedFileApp['src/a.ts'] }) + const client = await server.load('/src/entry.ts') + return { server, client } + } + + test( + 'added by an edit of the importer is mocked, without a restart', + async () => { + const { client } = await addDeniedImportByAnEdit() + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + }, + timeout, + ) + + // Bug: when a module changes, dev import protection drops every import + // graph edge that points to it (`hotUpdate` → `ImportGraph.invalidate`, + // import-protection/trace.ts, removes the edges where the file is the + // target, not only those where it is the importer). Its importers are not + // transformed again, so the edges do not come back, and a violation found + // when the edited module is transformed again is unreachable from Start's + // router entry: `processPendingViolations` + // (vite/import-protection-plugin/plugin.ts) discards it. + // Impact: in dev (mock mode), a denied import added to an existing module + // by an edit is mocked without any warning; with `log: 'always'`, a + // violation is not logged again after an edit (the 'always' pin below). + // A scratch run that keeps the incoming edges passes both pins. + // Source: found registering Start's entries in the dev harness; the trace + // part: mutation testing. + test.fails( + 'added by an edit of the importer is logged at its original import or surviving use, with a trace from the entry', + async () => { + const { server } = await addDeniedImportByAnEdit() + const reports = violationsOf(server) + expectViolationsAt(server, [deniedFileViolation]) + for (const report of reports) { + expect(traceModules(report)).toEqual(['src/entry.ts', 'src/a.ts']) + } + }, + timeout, + ) + + // Source: review (`behavior: { dev, build }`, `behavior: 'error'` in dev). + test.each<{ behavior: NonNullable<ImportProtectionOptions>['behavior'] }>([ + { behavior: 'error' }, + { behavior: { dev: 'error', build: 'mock' } }, + ])( + 'fails to load with behavior $behavior, naming the importer at the use or the import', + async ({ behavior }) => { + const server = await startProtectedDevServer(deniedFileApp, { + behavior, + }) + await rejection(server.load('/src/entry.ts')) + expectViolationsAt(server, [deniedFileViolation]) + }, + timeout, + ) + + test( + 'is mocked with behavior { build: "error" } (the dev default applies)', + async () => { + const server = await startProtectedDevServer(deniedFileApp, { + behavior: { build: 'error' }, + }) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(reportedViolations(server)).not.toEqual([]) + }, + timeout, + ) +}) + +describe('the trace of a client import of a denied file', () => { + // A module under `src/routes` is not an entry: the trace goes on to the + // router entry. + // Source: mutation testing (route modules taken as entries). + test( + 'leads from the router entry through a module of src/routes to the importer', + async () => { + const server = await startProtectedDevServer({ + ...deniedFileApp, + 'src/routes/page.ts': `export { read } from '../a'\n`, + 'src/entry.ts': `export * from './routes/page'\n`, + }) + await server.load('/src/entry.ts') + const reports = violationsOf(server) + expect(reports).not.toEqual([]) + for (const report of reports) { + expect(traceModules(report)).toEqual([ + 'src/entry.ts', + 'src/routes/page.ts', + 'src/a.ts', + ]) + } + }, + timeout, + ) + + // Source: mutation testing (the dev server's module graph, which + // still has the edges an edit drops from import protection's own graph). + test( + 'with behavior "error", of an import added by an edit, leads from the router entry', + async () => { + const server = await startProtectedDevServer( + { ...deniedFileApp, 'src/a.ts': `export const read = () => 'plain'\n` }, + { behavior: 'error' }, + ) + await server.load('/src/entry.ts') + await server.edit({ 'src/a.ts': deniedFileApp['src/a.ts'] }) + await rejection(server.load('/src/entry.ts')) + // (one violation) + const [report, ...others] = distinctReports(server) + expect(others).toEqual([]) + expectViolationsAt(server, [deniedFileViolation]) + expect(traceModules(report!)).toEqual(['src/entry.ts', 'src/a.ts']) + }, + timeout, + ) + + // In every Start app, a module imports the router entry: Start's client + // runtime. The trace still starts at the router entry. + // Source: mutation testing (the module graph trace does not stop at an + // entry). + test( + 'starts at the router entry when another module imports the router entry', + async () => { + const server = await startProtectedDevServer({ + ...deniedFileApp, + 'src/main.ts': `export * from './entry'\n`, + }) + await server.load('/src/main.ts') + const reports = violationsOf(server) + expect(reports).not.toEqual([]) + for (const report of reports) { + expect(traceModules(report)).toEqual(['src/entry.ts', 'src/a.ts']) + } + }, + timeout, + ) + + // The dev twin of the build test in reported-location.test.ts "the trace is + // a real import chain from the entry to the importer": any real chain will + // do, not necessarily the shortest (SPEC J6.5). + // Source: mutation testing (the module graph search revisits modules). + test( + 'is a real import chain from the entry to the importer', + async () => { + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/s.ts': `import { secret } from './secret.server' +export const s = () => secret() +`, + 'src/c.ts': `import { s } from './s'\nexport const c = () => s()\n`, + 'src/a.ts': `import { c } from './c' +import { s } from './s' +export const page = () => c() + s() +`, + 'src/entry.ts': `export * from './a'\n`, + }, + {}, + // Without Vite's pre-transforms, the client transforms `src/c.ts` + // before `src/s.ts` (`load()` goes breadth first), so both chains + // are in the dev server's module graph when the violation is + // reported, whatever the timing. + { config: { server: { preTransformRequests: false } } }, + ) + await server.load('/src/entry.ts') + const reports = violationsOf(server) + expect(reports).not.toEqual([]) + for (const report of reports) { + expect([ + ['src/entry.ts', 'src/a.ts', 'src/s.ts'], + ['src/entry.ts', 'src/a.ts', 'src/c.ts', 'src/s.ts'], + ]).toContainEqual(traceModules(report)) + } + }, + timeout, + ) +}) + +// Edits in the order people make them: a module, then the module importing +// it, each loaded by the client in between. +// Source: mutation testing (dropping the edges of the first edit left +// the importer's edges pointing at nothing, and the second edit's HMR +// handling threw). +test( + 'an edit of a module, then of its importer, updates both without an error', + async () => { + const server = await startBrowserProtectedDevServer({ + 'src/b.ts': `export const b = () => 'b1'\n`, + 'src/a.ts': `import { b } from './b'\nexport const a = () => 'a1' + b()\n`, + 'src/entry.ts': `export * from './a'\n`, + }) + await server.load('/src/entry.ts') + const logged = server.logs.length + const updates = [ + ...(await server.edit({ 'src/b.ts': `export const b = () => 'b2'\n` })), + ] + await server.load('/src/entry.ts') + updates.push( + ...(await server.edit({ + 'src/a.ts': `import { b } from './b'\nexport const a = () => 'a2' + b()\n`, + })), + ) + expect(updates.filter(({ type }) => type === 'error')).toEqual([]) + expect(server.logs.slice(logged)).toEqual([]) + expect( + (await runViteClient(server, '/src/entry.ts', 'return entry.a()')).result, + ).toBe('a2b2') + }, + timeout, +) + +// Import protection checks only JavaScript and TypeScript modules; edits of +// the app's other modules update as usual. +// Source: mutation testing (the edit of a module import protection never +// compiled). +test( + 'an edit of a CSS module and a JSON module the app imports updates them without an error', + async () => { + const server = await startProtectedDevServer({ + 'src/style.css': `.page { color: red }\n`, + 'src/data.json': `{ "count": 1 }\n`, + 'src/entry.ts': `import './style.css' +import data from './data.json' +export const count = () => data.count +`, + }) + await server.load('/src/entry.ts') + const logged = server.logs.length + const updates = await server.edit({ + 'src/style.css': `.page { color: blue }\n`, + 'src/data.json': `{ "count": 2 }\n`, + }) + expect(updates.filter(({ type }) => type === 'error')).toEqual([]) + expect(server.logs.slice(logged)).toEqual([]) + }, + timeout, +) + +// A CSS file that another one `@import`s is in Vite's module graph only as +// a file (a module without an id). +// Source: mutation testing (such a module reached import protection's +// HMR handling, which threw). +test( + 'an edit of a CSS file another CSS module @imports updates it without an error', + async () => { + const server = await startProtectedDevServer({ + 'src/base.css': `.page { color: red }\n`, + 'src/style.css': `@import './base.css';\n.title { color: green }\n`, + 'src/entry.ts': `import './style.css'\nexport const page = 1\n`, + }) + await server.load('/src/entry.ts') + const logged = server.logs.length + const updates = await server.edit({ + 'src/base.css': `.page { color: blue }\n`, + }) + expect(updates.filter(({ type }) => type === 'error')).toEqual([]) + expect(updates).not.toEqual([]) + expect(server.logs.slice(logged)).toEqual([]) + }, + timeout, +) + +describe('log', () => { + /** + * How many warnings naming the importer `src/a.ts` are printed when the + * client loads the app, and when it loads it again after an edit of + * `src/a.ts` that keeps the denied import. + */ + async function logsAroundAnEdit(log: 'once' | 'always') { + const server = await startProtectedDevServer(deniedFileApp, { log }) + await server.load('/src/entry.ts') + const first = warningsNaming(server, 'src/a.ts').length + const mark = server.diagnostics.length + await server.edit({ + 'src/a.ts': `import { secret } from './secret.server' +export const read = () => secret() +export const other = 1 +`, + }) + await server.load('/src/entry.ts') + return { + first, + afterEdit: warningsNaming(server, 'src/a.ts', mark).length, + } + } + + // Source: review (`log`). + test( + "'once' does not log a violation again after an edit", + async () => { + const { first, afterEdit } = await logsAroundAnEdit('once') + expect(first).toBeGreaterThan(0) + expect(afterEdit).toBe(0) + }, + timeout, + ) + + // Bug: same as "added by an edit of the importer is logged at the use" + // above: the edit drops the import graph edges to `src/a.ts`, and the + // violation found when it is transformed again is discarded as unreachable + // from Start's router entry. + // Impact: with `log: 'always'`, a violation is not logged again after an + // edit of its module. + // Source: found registering Start's entries in the dev harness; this test + // passed while the harness registered no entry. + test.fails( + "'always' logs a violation again after an edit", + async () => { + const { first, afterEdit } = await logsAroundAnEdit('always') + expect(first).toBeGreaterThan(0) + expect(afterEdit).toBeGreaterThan(0) + }, + timeout, + ) + + /** + * How many warnings naming the importer `src/a.ts` are printed when the + * client loads the app, and when it loads it again after an edit of + * `tsconfig.json`, which changes + * no module: Vite invalidates every module for it (as when it + * re-optimizes dependencies), so the client's next load transforms them + * again. Whether Vite also tells the page to reload is Vite's business + * (SPEC G10: no test requires a full reload); the `'always'` row is the + * control that the modules were transformed again. + */ + async function logsAroundAReload(log: 'once' | 'always') { + const server = await startProtectedDevServer( + { ...deniedFileApp, 'tsconfig.json': `{}\n` }, + { log }, + ) + await server.load('/src/entry.ts') + const first = warningsNaming(server, 'src/a.ts').length + const mark = server.diagnostics.length + await server.edit({ 'tsconfig.json': `{ "compilerOptions": {} }\n` }) + await server.load('/src/entry.ts') + return { + first, + afterReload: warningsNaming(server, 'src/a.ts', mark).length, + } + } + + // Source: mutation testing (`log` regressions: the edit-based test above + // is a pin). + test( + "'once' does not log a violation again when the dev server reloads every module", + async () => { + const { first, afterReload } = await logsAroundAReload('once') + expect(first).toBeGreaterThan(0) + expect(afterReload).toBe(0) + }, + timeout, + ) + + // Source: mutation testing, as above. + test( + "'always' logs a violation again when the dev server reloads every module", + async () => { + const { first, afterReload } = await logsAroundAReload('always') + expect(first).toBeGreaterThan(0) + expect(afterReload).toBeGreaterThan(0) + }, + timeout, + ) + + // Source: mutation testing. + test( + "'always' does not log a violation again when the client loads other modules", + async () => { + const server = await startProtectedDevServer( + { + ...deniedFileApp, + 'src/b.ts': `export const b = 1\n`, + 'src/c.ts': `export const c = 1\n`, + 'src/entry.ts': `export * from './a' +export { b } from './b' +`, + }, + { log: 'always' }, + ) + await server.load('/src/entry.ts') + const first = warningsNaming(server, 'src/a.ts').length + expect(first).toBeGreaterThan(0) + await server.load('/src/c.ts') + expect(warningsNaming(server, 'src/a.ts')).toHaveLength(first) + }, + timeout, + ) + + // Bug: in dev, one client import of a denied file is logged twice: once + // for the import as written (`./secret.server`) and once for the resolved + // path the dev mock rewrite puts in its place, which Vite resolves again; + // the dedupe key of `log: 'once'` includes the specifier + // (`dedupeViolationKey`, import-protection/utils.ts), so the two do not + // dedupe (vite/import-protection-plugin/plugin.ts, transform-cache import + // loop and `resolveId`). + // Impact: every violation of a denied file appears twice in the dev server + // output, the second time naming the resolved path as the import. + // Source: found writing the `log` rows (review). + test.fails( + "'once' logs one warning for one import", + async () => { + const server = await startProtectedDevServer(deniedFileApp) + await server.load('/src/entry.ts') + expect(warningsNaming(server, 'src/a.ts')).toHaveLength(1) + }, + timeout, + ) + + // Bug: with `log: 'always'`, one client import of a denied file is logged + // three times when the client loads its module once: twice for the import + // as written, because import protection finds the same violation both + // when the import resolves (`resolveId`) and when it checks the module's + // compiled imports (transform-cache import loop), and 'always' does not + // dedupe them (vite/import-protection-plugin/plugin.ts `hasSeen`), plus + // once for the resolved path (the 'once' pin above). + // Impact: with 'always', the dev server output repeats each violation of + // a denied file three times per load of its module. + // Source: mutation testing (the 'always' rows of the reload tests above). + test.fails( + "'always' logs one warning for one import each time its module is loaded", + async () => { + const server = await startProtectedDevServer(deniedFileApp, { + log: 'always', + }) + await server.load('/src/entry.ts') + expect(warningsNaming(server, 'src/a.ts')).toHaveLength(1) + }, + timeout, + ) +}) + +describe('a client import of a denied specifier', () => { + /** + * `src/a.ts` uses the denied file `src/secret.server.ts` and the denied + * specifier `@tanstack/react-start/server`. + */ + const deniedSpecifierApp = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/a.ts': `import { secret } from './secret.server' +import { getRequest } from '@tanstack/react-start/server' +export const read = () => secret() +export const request = () => getRequest() +`, + 'src/entry.ts': `export * from './a'\n`, + } + + // Source: mutation testing. + test( + 'is logged at its original import or surviving use, alongside the denied file', + async () => { + const server = await startProtectedDevServer(deniedSpecifierApp) + await server.load('/src/entry.ts') + expectViolationsAt(server, [ + { environment: 'client', use: 'src/a.ts:3:27', also: ['src/a.ts:1'] }, + { environment: 'client', use: 'src/a.ts:4:30', also: ['src/a.ts:2'] }, + ]) + }, + timeout, + ) + + // Source: mutation testing. + test( + 'is a mock that reports its use in the browser console, naming the import, like the mock of the denied file', + async () => { + const server = await startBrowserProtectedDevServer(deniedSpecifierApp) + const { result, diagnostics } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return [probeMock(entry.request(), 'MARK_SECRET'), probeMock(entry.read(), 'MARK_SECRET')]`, + ) + expect(result).toEqual([safeMock, safeMock]) + const access = { severity: 'error' } as const + expectMockAccess(diagnostics, { + ...access, + specifier: '@tanstack/react-start/server', + root: server.root, + }) + expectMockAccess(diagnostics, { + ...access, + specifier: './secret.server', + file: 'src/secret.server.ts', + root: server.root, + }) + }, + timeout, + ) + + // `mockAccess` (guide/import-protection.md): how the dev client mocks + // report their use. + // Source: mutation testing (the option ignored). + test.each([ + { mockAccess: 'warn', severities: ['warning'] }, + { mockAccess: 'off', severities: [] }, + ] as const)( + 'with mockAccess $mockAccess, using the mocks logs $severities', + async ({ mockAccess, severities }) => { + const server = await startBrowserProtectedDevServer(deniedSpecifierApp, { + mockAccess, + }) + const { result, diagnostics } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return [probeMock(entry.request(), 'MARK_SECRET'), probeMock(entry.read(), 'MARK_SECRET')]`, + ) + expect(result).toEqual([safeMock, safeMock]) + const logged = warningsAndErrors(diagnostics) + expect(distinct(logged.map(({ severity }) => severity))).toEqual( + severities, + ) + for (const severity of severities) { + expectMockAccess(logged, { + severity, + specifier: '@tanstack/react-start/server', + root: server.root, + }) + } + }, + timeout, + ) + + // Source: mutation testing (the names the mock exports, read from + // the importer, after an edit of the importer). + test( + 'added to an importer by an edit is a mock the edited module can import', + async () => { + const server = await startBrowserProtectedDevServer({ + 'src/a.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => [getRequest()] +`, + 'src/entry.ts': `export * from './a'\n`, + }) + // (what the mocks log is silenced: the rows above check it) + const described = async () => + ( + await runViteClient( + server, + '/src/entry.ts', + `${describeValuePrelude} +return entry.read().map((value) => describeValue(value, 'MARK_'))`, + ) + ).result + expect(await described()).toEqual(['a safe mock']) + await server.edit({ + 'src/a.ts': `import { getRequest, getResponse } from '@tanstack/react-start/server' +export const read = () => [getRequest(), getResponse()] +`, + }) + expect(await described()).toEqual(['a safe mock', 'a safe mock']) + }, + timeout, + ) +}) + +// A module another Vite plugin compiles to JavaScript from a file that is +// not JavaScript or TypeScript (MDX, Vue and Svelte components...): the +// real MDX plugin (`@mdx-js/rollup`), before the Start plugins like a user +// lists it; its output imports React's JSX runtime. +describe('a module of another compiler (`.mdx`)', () => { + // `@mdx-js/rollup` always emits source maps: report positions can be in + // `src/page.mdx`. + const mdxPlugin: Plugin = { enforce: 'pre', ...mdx() } + const plugins = [mdxPlugin] + /** An MDX page whose import and use of the denied file follow prose. */ + const page = `# Title + +Some *prose* before the code. + +import { secret } from './secret.server' +import { leak } from './leak' +export const read = () => secret() + leak() +` + /** + * The page, located at the import of the denied module (line 5) or at + * its use (7:27), with a column; never at a position of MDX's compiled + * JavaScript. `located: false`: or without coordinates (pinned below). + */ + const inPage = ({ located = true } = {}) => + originalLocation('src/page.mdx:7:27', 5, { unavailable: !located }) + // Source: mutation testing (the module has no compiled imports import + // protection could check its violations against; nor can it tell whether its imports survived compiling, so a module it + // imports is reachable through it). + test( + 'importing a denied file, directly or through a module, gets the mock, and the dev server logs a warning at each importer', + async () => { + const leak = `import { secret } from './secret.server' +export const leak = () => secret() +` + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/leak.ts': leak, + 'src/page.mdx': page, + 'src/entry.ts': `export * from './page.mdx'\n`, + }, + {}, + { plugins }, + ) + const client = await server.load('/src/entry.ts') + expect(Object.keys(client)).toContain('/src/page.mdx') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + const importers = reportedViolations(server).map( + ({ importer }) => importer, + ) + // (located if at all at the import or the use: no coordinates is the + // bug pinned below) + expect(importers).toContainEqual(inPage({ located: false })) + expect(importers).toContainEqual( + originalLocation(locationIn('src/leak.ts', leak, 2, 'secret()'), 1), + ) + for (const violation of violationsOf(server)) { + expectPrinted(server.diagnostics, server.root, violation, 'warning') + } + }, + timeout, + ) + + // Bug: the warning drops original coordinates for an MDX file even + // though @mdx-js/rollup supplies a source map for its import and use. + // Source: start-plugin-core src/vite/import-protection-plugin/plugin.ts: + // 2116-2119: the transform cache records only `.[cm][tj]sx?` modules, so + // an `.mdx` importer has no transform result (code and composed source + // map), and each finder `resolveImporterLocation` (534-557) tries gives + // up on it (import-protection/sourceLocation.ts:412-415, 451-452, + // 482-483). A probe that let the cache record `.mdx` + // located the report at the use (7:27) but logged it twice, as written + // and as the resolved path: the "'once' logs one warning for one import" + // pin above (src/import-protection/utils.ts:61, the dedupe key includes + // the specifier), which this test also needs fixed. + // Impact: the user cannot navigate to the offending original source. + test.fails( + 'importing a denied file, the warning names the .mdx page, located in its original mapped source', + async () => { + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/leak.ts': `export const leak = () => ''\n`, + 'src/page.mdx': page, + 'src/entry.ts': `export * from './page.mdx'\n`, + }, + {}, + { plugins }, + ) + await server.load('/src/entry.ts') + expect( + reportedViolations(server).map(({ importer }) => importer), + ).toEqual([inPage()]) + }, + timeout, + ) + + // Bug: to give the mock of a denied specifier the named exports its + // importer imports, import protection reads the importer's code from its + // own cache of compiled modules, which only has JavaScript and TypeScript + // files, and otherwise from Vite's `getModuleInfo(importer).code`, which + // Vite's dev server does not support: it throws "[vite] The "code" + // property of ModuleInfo is not supported." + // (vite/import-protection-plugin/plugin.ts + // `resolveExportsForDeniedSpecifier`). + // Impact: in dev, an `.mdx` (or other non-JS) module that imports a denied + // specifier fails to load with that internal error, instead of getting + // the mock and a warning. + // Source: mutation testing. + test.fails( + 'importing a denied specifier gets the mock, and the dev server logs a warning naming it', + async () => { + const server = await startBrowserProtectedDevServer( + { + 'src/page.mdx': `# Title +import { getRequest } from '@tanstack/react-start/server' +export const request = () => getRequest() +`, + 'src/entry.ts': `export * from './page.mdx'\n`, + }, + {}, + { plugins }, + ) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return probeMock(entry.request(), 'MARK_')`, + ) + expect(result).toEqual(safeMock) + // (the page, located if at all at the import, line 2, or at the use + // `getRequest()`, 3:30, of the .mdx source) + expect( + reportedViolations(server).map(({ importer }) => importer), + ).toContainEqual(originalLocation('src/page.mdx:3:30', 2)) + }, + timeout, + ) +}) + +describe('onViolation', () => { + // What the client then gets is pinned below. + // Source: mutation testing. + test( + 'returning false silences the warning; it receives the importer', + async () => { + const importers: Array<string> = [] + const server = await startProtectedDevServer(deniedFileApp, { + onViolation: (info) => { + importers.push((info as ViolationInfo).importer) + return false + }, + }) + await server.load('/src/entry.ts') + expectNothingReportedAbout(server, ['src/a.ts', 'src/secret.server.ts']) + expect( + distinct( + importers.map((importer) => path.relative(server.root, importer)), + ), + ).toEqual(['src/a.ts']) + }, + timeout, + ) + + // Bug: dev import protection replaces a denied file with its mock when it + // resolves (and transforms) the import, before it calls `onViolation`; + // returning `false` only silences the warning (the dev twin of the build + // pin "onViolation returning false allows the import of a denied file", + // build.test.ts). + // Impact: an import a project allows with `onViolation` (documented: + // "Return false ... to allow this specific import (override the denial)", + // guide/import-protection.md) is a mock in the browser, whose calls return + // mocks, without any warning. + // Source: review (dev.test.ts "returning false silences the warning" + // asserted the mock). + test.fails( + 'returning false allows the import: the client gets the real module', + async () => { + const server = await startBrowserProtectedDevServer(deniedFileApp, { + onViolation: () => false, + }) + // The real module's value, in the browser (a mock gives none) + const { result } = await runViteClient( + server, + '/src/entry.ts', + 'return String(entry.read())', + ) + expect(result).toBe('MARK_SECRET') + }, + timeout, + ) + + // Control for the pin below (same harness). + test.each([ + { name: 'a denied file', files: deniedFileApp }, + { + name: 'a denied specifier', + files: { + 'src/a.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + 'src/entry.ts': `export * from './a'\n`, + }, + }, + ])( + 'with behavior "error", an import of $name it allows loads', + async ({ files }) => { + const server = await startProtectedDevServer(files, { + behavior: 'error', + onViolation: () => false, + }) + // The app's modules: `@tanstack/react-start/server` itself imports + // Start's entries, which only Start's whole plugin provides. + const client = await server.load('/src/entry.ts', { + skip: /^\/@(vite|fs)\//, + }) + expect(Object.keys(client)).toContain('/src/a.ts') + expectNothingReportedAbout(server, ['src/a.ts']) + }, + timeout, + ) + + // Bug: same as the pin "returning false allows the import" above, with + // behavior "error": the denied file is still replaced with its mock. + // Impact: an allowed import is a mock in the browser. + // Source: review (dev.test.ts "with behavior "error", an import of $name + // it allows loads" passed with the mock). + test.fails( + 'with behavior "error", an import of a denied file it allows gets the real module', + async () => { + const server = await startBrowserProtectedDevServer(deniedFileApp, { + behavior: 'error', + onViolation: () => false, + }) + // The real module's value, in the browser (a mock gives none) + const { result } = await runViteClient( + server, + '/src/entry.ts', + 'return String(entry.read())', + ) + expect(result).toBe('MARK_SECRET') + }, + timeout, + ) + + // Only `false` overrides the denial (guide/import-protection.md): an + // `onViolation` that only records (returns nothing) changes nothing. + // Source: mutation testing. + test( + 'that returns nothing keeps the warning; it receives the importer', + async () => { + const importers: Array<string> = [] + const server = await startProtectedDevServer(deniedFileApp, { + onViolation: (info) => { + importers.push((info as ViolationInfo).importer) + }, + }) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expectViolationsAt(server, [deniedFileViolation]) + expect( + distinct( + importers.map((importer) => path.relative(server.root, importer)), + ), + ).toEqual(['src/a.ts']) + }, + timeout, + ) + + // Source: mutation testing. + test.each<{ name: string; files: Record<string, string>; use: string }>([ + { name: 'a denied file', files: deniedFileApp, use: deniedFileUse }, + { + name: 'a denied specifier', + files: { + 'src/a.ts': `import { getRequest } from '@tanstack/react-start/server' +export const read = () => getRequest() +`, + 'src/entry.ts': `export * from './a'\n`, + }, + use: 'src/a.ts:2:27', + }, + ])( + 'with behavior "error", an import of $name it does not return false for fails to load', + async ({ files, use }) => { + const server = await startProtectedDevServer(files, { + behavior: 'error', + onViolation: () => true, + }) + await rejection(server.load('/src/entry.ts')) + expectViolationsAt(server, [ + { environment: 'client', use, also: ['src/a.ts:1'] }, + ]) + }, + timeout, + ) +}) + +describe('a client import of a server-only-marked module', () => { + /** + * `src/a.ts` imports `src/b.ts`, which starts with `marker`; the router + * entry re-exports `src/a.ts`. + */ + const markedApp = (marker: string) => ({ + 'src/b.ts': `${marker}export const secret = () => 'MARK_B_CODE'\n`, + 'src/a.ts': `import { secret } from './b' +export const read = () => secret() +`, + 'src/entry.ts': `export * from './a'\n`, + }) + const serverOnly = `import '@tanstack/react-start/server-only'\n` + + /** + * A logged report of the client import of the marked `src/<marked>.ts` by + * `src/<importer>.ts` (whose line 1 imports it and whose line 2 uses it at + * column 27): at the importer's use, at its import, or at the marked + * module (SPEC J6.5). + */ + const markerReport = (importer: string, marked: string) => + originalLocation(`client src/${importer}.ts:2:27`, 1, { + others: [`src/${marked}.ts:1`, `src/${marked}.ts`], + }) + + // Control for the pins below (same harness): once the server knows the + // module is server-only, its importers get a mock. + test( + 'is mocked when the client loaded the module before its importer', + async () => { + const server = await startProtectedDevServer(markedApp(serverOnly)) + await server.load('/src/b.ts') + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_B_CODE')).toEqual([]) + }, + timeout, + ) + + // Source: mutation testing (the logging half of the pin below, + // which passes). + test( + 'is logged when the client loads the importer first', + async () => { + const server = await startProtectedDevServer(markedApp(serverOnly)) + await server.load('/src/entry.ts') + expect(loggedViolations(server)).toContainEqual(markerReport('a', 'b')) + }, + timeout, + ) + + // Source: mutation testing (only the first marked module's + // importers were checked). + test( + 'the importers of each of several server-only-marked modules are logged when the client loads the importers first', + async () => { + const server = await startProtectedDevServer({ + ...markedApp(serverOnly), + 'src/d.ts': `${serverOnly}export const other = () => 'MARK_D_CODE'\n`, + 'src/c.ts': `import { other } from './d' +export const peek = () => other() +`, + 'src/entry.ts': `export * from './a'\nexport * from './c'\n`, + }) + await server.load('/src/entry.ts') + expect(loggedViolations(server)).toEqual( + expect.arrayContaining([ + markerReport('a', 'b'), + markerReport('c', 'd'), + ]), + ) + }, + timeout, + ) + + // Bug: import protection decides to mock an import of a server-only-marked + // module when it resolves the import, and only knows a module is marked + // once it has transformed it. A browser requests the importer first, so + // the import resolves to the real module; when the marker is then found, + // the violation is only logged (vite/import-protection-plugin/plugin.ts, + // retroactive marker check in `resolveId`), and the importer keeps its + // import of the real module. + // Impact: in dev, the browser runs the real code of server-only-marked + // modules (in mock mode the import should be a mock), unlike the build, + // which fails; whether the client gets the mock depends on load order. + // Source: found writing the pin "after an edit adds the marker, the + // violation is logged" below (review). + test.fails( + 'is mocked when the client loads the importer first', + async () => { + const server = await startProtectedDevServer(markedApp(serverOnly)) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_B_CODE')).toEqual([]) + }, + timeout, + ) + + /** + * Loads the app with `src/b.ts` unmarked, edits only `src/b.ts` to add + * the server-only marker, and loads it again (SPEC J6.13: edits + * reclassify in dev). The violations logged after the edit, and the + * client modules then served with the marked module's code. + */ + async function addMarkerByAnEdit() { + const server = await startProtectedDevServer(markedApp('')) + expect( + modulesContaining(await server.load('/src/entry.ts'), 'MARK_B_CODE'), + ).toEqual(['/src/b.ts']) + const logged = server.violations.length + await server.edit({ 'src/b.ts': markedApp(serverOnly)['src/b.ts'] }) + await server.load('/src/b.ts') + const client = await server.load('/src/entry.ts') + await server.idle() + return { + reported: loggedViolations({ + root: server.root, + violations: server.violations.slice(logged), + }), + realCodeIn: modulesContaining(client, 'MARK_B_CODE'), + } + } + + // Bug: when an edit adds a server-only marker to a module the client + // already loaded, nothing happens to its importers: import protection + // only clears its own caches on the edit (`hotUpdate`), and Vite keeps the + // importers' transforms (a soft invalidation), so their import of the + // module is never resolved again, where the marker violation would be + // found (the retroactive marker check of `resolveId`, + // vite/import-protection-plugin/plugin.ts). Neither the report nor the + // mock follows (the opposite edit is pinned in known-bugs-dev-server.test.ts + // "the importer of a module whose server-only marker was removed loads the + // module"). The two outcomes are pinned apart (the report was + // claimed to work). + // Impact: after marking a module server-only in dev, the browser keeps + // running its real code, without any warning, until the importers are + // edited or the server restarts. + // Source: review (the adding direction). + test.fails( + 'after an edit adds the marker, the violation is logged', + async () => { + const { reported } = await addMarkerByAnEdit() + expect(reported).toContainEqual(markerReport('a', 'b')) + }, + timeout, + ) + + test.fails( + 'after an edit adds the marker, the importer gets the mock', + async () => { + const { realCodeIn } = await addMarkerByAnEdit() + expect(realCodeIn).toEqual([]) + }, + timeout, + ) +}) + +// Source: mutation testing (the SSR counterpart of the client control +// above). +test( + 'an SSR import of a client-only-marked module the server already transformed is mocked and logged', + async () => { + const server = await startProtectedDevServer({ + 'src/b.ts': `import '@tanstack/react-start/client-only' +export const widget = () => 'MARK_B_CODE' +`, + 'src/a.ts': `import { widget } from './b' +export const read = () => widget() +`, + 'src/entry.ts': `export * from './a'\n`, + }) + await server.load('/src/b.ts', { environment: 'ssr' }) + const served = await server.load('/src/entry.ts', { environment: 'ssr' }) + expect(modulesContaining(served, 'MARK_B_CODE')).toEqual([]) + expect(relevantViolations(server, [clientOnlyImporter.a])).toContain( + violationLabel(clientOnlyImporter.a), + ) + }, + timeout, +) + +/** + * The SSR violations of an app whose `src/a.ts` imports the client-only + * marked `src/b.ts`: at `a`'s use of `widget` or its import of `./b`, or + * at `b`'s marker import (SPEC J6.5). + */ +const clientOnlyImporter = { + a: { environment: 'server', use: 'src/a.ts:2:27', also: ['src/a.ts:1'] }, + marker: { environment: 'server', use: 'src/b.ts:1:8', also: ['src/b.ts:1'] }, +} satisfies Record<string, ExpectedViolation> + +// A marker violation may also be reported at the marker (SPEC J6.5); the +// use in the importer must be logged. +// Source: mutation testing (the SSR counterpart of the client +// logging test "is logged at the importer's use when the client loads the +// importer first"). +test( + "an SSR load of a client-only-marked module through its importer is logged at the importer's use or import", + async () => { + const server = await startProtectedDevServer({ + 'src/b.ts': `import '@tanstack/react-start/client-only' +export const widget = () => 'MARK_B_CODE' +`, + 'src/a.ts': `import { widget } from './b' +export const read = () => widget() +`, + 'src/entry.ts': `export * from './a'\n`, + }) + await server.load('/src/entry.ts', { environment: 'ssr' }) + const expected = [clientOnlyImporter.a, clientOnlyImporter.marker] + const logged = relevantViolations(server, expected) + expect(logged).toContain(violationLabel(clientOnlyImporter.a)) + // (any other report is at the marker) + expect( + logged.filter( + (violation) => !expected.map(violationLabel).includes(violation), + ), + ).toEqual([]) + }, + timeout, +) + +// The provider environment of a React Start app with RSC enabled (its +// `rsc` environment, `tanstackStart({ rsc: { enabled: true } })`). +// Source: mutation testing. +test( + 'the server fn provider environment (rsc) mocks and logs an import of a .client file', + async () => { + const server = await startRscProtectedDevServer({ + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/fn.ts': `import { widget } from './widget.client' +export const read = () => widget() +`, + 'src/entry.ts': `export * from './fn'\n`, + }) + const served = await server.load('/src/entry.ts', { environment: 'rsc' }) + expect(modulesContaining(served, 'MARK_CLIENT')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation('server src/fn.ts:2:27', 1), + ]) + }, + timeout, +) + +// Dependencies (SPEC J6.10): files under `node_modules` skip the file and +// marker checks by default, a dependency marking itself server-only +// included; `excludeFiles: []` checks them. The build rows are in +// build-options.test.ts ("excludeFiles"). +// Source: review (SPEC J6.10 had no dev row). +describe('a client import of a dependency that marks itself server-only', () => { + const app = { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `import '@tanstack/react-start/server-only' +export const query = () => 'MARK_LIB' +`, + 'src/a.ts': `import { query } from 'db-lib' +export const read = () => query() +`, + 'src/entry.ts': `export * from './a'\n`, + } + /** What the client evaluates without loading: Vite's client only. */ + /** + * The dependency is served as it is, not pre-bundled (as for a package + * an app lists in `optimizeDeps.exclude`; the harness pre-bundles + * nothing). + */ + const options = { config: { optimizeDeps: { exclude: ['db-lib'] } } } + + // Bug: in dev, the Vite adapter checks the server-only marker a + // dependency imports when it resolves the marker import, whatever + // `excludeFiles` says (vite/import-protection-plugin/plugin.ts, marker + // handling in `resolveId`; the build twin is pinned in + // build-options.test.ts), and then reads the importer's code from + // Vite's `getModuleInfo(importer).code`, which the dev server does not + // support: loading the dependency throws "[vite] The "code" property of + // ModuleInfo is not supported." + // Impact: in dev, a client module importing a dependency that marks + // itself server-only and is not pre-bundled (`optimizeDeps.exclude`) + // fails to load with an internal error, by default and with + // `excludeFiles: []` alike. + // Source: review (the dev row of SPEC J6.10 was missing). + test.fails( + 'by default, is not logged, and the client gets the real module', + async () => { + const server = await startBrowserProtectedDevServer(app, {}, options) + expect( + (await runViteClient(server, '/src/entry.ts', 'return entry.read()')) + .result, + ).toBe('MARK_LIB') + expectNothingReportedAbout(server, ['src/a.ts']) + }, + timeout, + ) + + test.fails( + 'with excludeFiles: [], is logged, and the client gets a safe mock', + async () => { + const server = await startBrowserProtectedDevServer( + app, + { client: { excludeFiles: [] }, mockAccess: 'off' }, + options, + ) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return probeMock(entry.read(), 'MARK_LIB')`, + ) + expect(result).toEqual(safeMock) + // (at the importer's import or use, or at the dependency's marker + // import, SPEC J6.5) + expect(loggedViolations(server)).toEqual([ + originalLocation('client src/a.ts:2:27', 1, { + others: [ + 'node_modules/db-lib/index.js:1', + 'node_modules/db-lib/index.js', + ], + }), + ]) + }, + timeout, + ) +}) + +// The violations a dev server logs for a module both environments load do +// not depend on which environment transforms it first (SPEC J6.11). +// Source: review (per-environment first-transform order had no row). +describe('a module the client and the server both load', () => { + /** `src/a.ts` uses a denied file of each environment. */ + const app = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/a.ts': `import { secret } from './secret.server' +import { widget } from './widget.client' +export const read = () => [secret(), widget()] +`, + 'src/entry.ts': `export * from './a'\n`, + } + + test.each([ + ['client', 'ssr'], + ['ssr', 'client'], + ])( + 'loaded by the %s first, then by the %s, each environment logs its violation', + async (first, second) => { + const server = await startProtectedDevServer(app) + await server.load('/src/entry.ts', { environment: first }) + await server.load('/src/entry.ts', { environment: second }) + expectViolationsAt(server, [ + { + environment: 'client', + use: locationIn('src/a.ts', app['src/a.ts'], 3, 'secret()'), + also: ['src/a.ts:1'], + }, + { + environment: 'server', + use: locationIn('src/a.ts', app['src/a.ts'], 3, 'widget()'), + also: ['src/a.ts:2'], + }, + ]) + }, + timeout, + ) +}) + +// `mockAccess` applies wherever a mock is served, the server environments +// included (SPEC J6.3; schema.ts documents it for `behavior: 'mock'` +// without a client restriction): the mock an SSR import of a `.client` file +// gets reports its use in the server console as configured. +describe('an SSR import of a .client file: mockAccess', () => { + /** + * Imports the app in the SSR environment and calls the mocked `widget`; + * what it is, the severities of what the call logged, and whether each + * names the denied import, with `mockAccess`. + */ + async function useOnTheServer( + mockAccess: 'error' | 'warn' | 'off' | undefined, + ) { + const server = await startProtectedDevServer( + { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/a.ts': `import { widget } from './widget.client' +export const read = () => widget() +`, + 'src/entry.ts': `export * from './a'\n`, + }, + { mockAccess }, + ) + const module = await server.import('/src/entry.ts', 'ssr') + expect( + reportedViolations(server).some( + ({ environment }) => environment === 'server', + ), + ).toBe(true) + // (described inside: a mock is a thenable that resolves to itself, never + // awaited) + const { result: read, diagnostics } = await captureConsole(() => + describeValue(module.read(), 'MARK_'), + ) + const logged = warningsAndErrors(diagnostics) + return { + read, + loggedWith: distinct(logged.map(({ severity }) => severity)), + unidentified: logged.filter( + (diagnostic) => + mockAccessDiagnostics([diagnostic], { + severity: diagnostic.severity, + specifier: './widget.client', + file: 'src/widget.client.ts', + root: server.root, + }).length === 0, + ), + } + } + + // Control for the pins below (same harness): a safe mock, silent. + test( + 'off: the server gets a safe mock, and using it is not reported', + async () => { + expect(await useOnTheServer('off')).toEqual({ + read: 'a safe mock', + loggedWith: [], + unidentified: [], + }) + }, + timeout, + ) + + // Bug: the mock runtime of a violation in a server environment is always + // the silent one (`mockRuntimeModuleIdFromViolation`, import-protection/ + // virtualModules.ts: `if (info.env !== 'client') return MOCK_MODULE_ID`), + // whatever `mockAccess` says; the client's runtime diagnostic has no + // server counterpart. + // Impact: on the server (SSR, the server fn provider), code that runs on + // a mocked client-only import does so without any console diagnostic; the + // violation warning of the dev server is the only trace of it. + // Source: review (the unit row demanded that silence); SPEC J6.3: mock + // mode always logs. + test.fails.each([ + { mockAccess: undefined, severity: 'error' }, + { mockAccess: 'error', severity: 'error' }, + { mockAccess: 'warn', severity: 'warning' }, + ] as const)( + '$mockAccess: the server gets a safe mock, and using it is reported as an $severity naming the import', + async ({ mockAccess, severity }) => { + expect(await useOnTheServer(mockAccess)).toEqual({ + read: 'a safe mock', + loggedWith: [severity], + unidentified: [], + }) + }, + timeout, + ) +}) + +describe('reachability from the router entry', () => { + // Source: mutation testing. + test( + 'only a leak is logged, not the imports a server fn factory uses inside .server()', + async () => { + const server = await startProtectedDevServer(serverFnFactoryApp()) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation('client src/leak.ts:2:27', 1), + ]) + }, + timeout, + ) + + /** + * `serverFnFactoryApp` without the leak, whose server fn factory module + * uses a helper `src/helper.ts` (which uses the denied file and the denied + * specifier) only inside `createMiddleware().server()`: the client never + * imports the helper. + */ + const handlerOnlyHelperApp = () => { + const app: Record<string, string> = { + ...serverFnFactoryApp(), + 'src/helper.ts': `import { getSecret } from './secret.server' +import { getRequest } from '@tanstack/react-start/server' +export const readSecret = () => [getSecret(), getRequest()] +`, + 'src/factory.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { readSecret } from './helper' +const mw = createMiddleware({ type: 'function' }).server(({ next }) => { + return next({ context: { secret: readSecret() } }) +}) +export const createSecretFn = createServerFn().middleware([mw]) +`, + 'src/entry.ts': `export { fn } from './usage'\n`, + } + delete app['src/leak.ts'] + return app + } + + // Control for the pin below: without Vite's pre-transform requests, the + // helper is never transformed for the client, and nothing is logged. + // Source: harness realism: the harness used to turn + // pre-transform requests off for every test. + test( + 'with preTransformRequests off, a helper a server fn factory module uses only inside .server() is not logged', + async () => { + const server = await startProtectedDevServer( + handlerOnlyHelperApp(), + {}, + { config: { server: { preTransformRequests: false } } }, + ) + const client = await server.load('/src/entry.ts') + // (what the transforms Vite runs in the background log) + await server.idle() + expect(Object.keys(client)).not.toContain('/src/helper.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expectNothingReportedAbout(server, ['src/helper.ts']) + }, + timeout, + ) + + /** + * Orders two transforms of the client environment the way a loaded + * machine may: holds the client transform of `src/factory.ts` (the module + * itself, not the Start compiler's lookup of it) until the client has + * transformed `src/helper.ts`, which the lookup's import analysis + * pre-transforms. Fix-agnostic: with the bug fixed, the order does not + * matter, and the hold ends on its own when the helper is never + * transformed for the client. + */ + function helperBeforeFactory(): Plugin { + let root = '' + return { + name: 'helper-before-factory', + enforce: 'pre', + configResolved(config) { + root = config.root + }, + async transform(_code, id) { + if ( + this.environment.name !== 'client' || + id !== path.join(root, 'src/factory.ts') + ) { + return null + } + const helper = path.join(root, 'src/helper.ts') + const deadline = Date.now() + 5_000 + while ( + !(this.environment as DevEnvironment).moduleGraph.getModuleById( + helper, + )?.transformResult && + Date.now() < deadline + ) { + await new Promise((resolve) => setTimeout(resolve, 5)) + } + return null + }, + } + } + + // Bug: with Vite's default pre-transform requests, the Start compiler's + // lookup of the server fn factory module (`?server-fn-module-lookup`, in + // the client environment) goes through Vite's import analysis, which + // pre-transforms `src/helper.ts` for the client. Import protection stores + // the lookup's transform under the factory's file + // (`cacheTransformResult`), so the factory → helper edge stays pending + // until the factory's own client transform lands, and the 'unknown' + // reachability fallback of `processPendingViolations` + // (vite/import-protection-plugin/plugin.ts) logs the helper's denied file + // import conservatively, when the helper's transform is processed before + // the factory's: `helperBeforeFactory` forces that order (on an idle + // machine the factory often wins, and the warning does not appear). + // Impact: in dev (Vite's defaults), a module a server fn factory uses only + // inside `.server()` is logged as a client violation, with a trace through + // an import the client never has; the client is correct (it never loads + // the helper). A false warning in the most common server fn layout. + // Source: mutation testing, hidden while the harness + // turned pre-transform requests off. + test.fails( + 'a helper a server fn factory module uses only inside .server() is not logged', + async () => { + const server = await startProtectedDevServer( + handlerOnlyHelperApp(), + {}, + { plugins: [helperBeforeFactory()] }, + ) + const client = await server.load('/src/entry.ts') + // (what the transforms Vite runs in the background log) + await server.idle() + expect(Object.keys(client)).not.toContain('/src/helper.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expectNothingReportedAbout(server, ['src/helper.ts']) + }, + timeout, + ) + + // The start entry (`src/start.ts`) is an entry like the router entry: the + // client loads it, and so what it imports. + // Source: mutation testing. + test( + 'a denied import reached only from the start entry is mocked and logged', + async () => { + const server = await startProtectedDevServer({ + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/leak.ts': `import { secret } from './secret.server' +export const leak = () => secret() +`, + 'src/start.ts': `import { leak } from './leak' +export const startInstance = { leak } +`, + 'src/entry.ts': `export const getRouter = () => undefined\n`, + }) + const client = await server.load('/src/start.ts') + expect(Object.keys(client)).toContain('/src/leak.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation('client src/leak.ts:2:27', 1), + ]) + }, + timeout, + ) + + // Source: mutation testing; a control of the harness + // registering Start's router entry: the factory module is a module the + // Start compiler looked up, whose violations are only logged once they + // are known to be reachable from an entry (without the entry, this test + // fails). + test( + 'a server fn factory module that also calls a denied import at the top level is logged', + async () => { + const server = await startProtectedDevServer( + serverFnFactoryApp(factoryTopLevelCall), + ) + await server.load('/src/entry.ts') + expect(loggedViolations(server)).toContainEqual( + originalLocation('client src/factory.ts:9:24', 2), + ) + }, + timeout, + ) + + // Source: mutation testing (the factory module's violations found when + // the Start compiler looked it up, which include the imports used inside + // `.server()`, were logged without waiting for its compiled imports). + test( + 'a server fn factory module reports the surviving denied import at its original import or use', + async () => { + const tail = `export const secret = getSecret()\n` + const server = await startProtectedDevServer(serverFnFactoryApp(tail)) + await server.load('/src/entry.ts') + await server.idle() + expect(loggedViolations(server).sort()).toEqual([ + originalLocation( + `client src/factory.ts:9:${tail.indexOf('getSecret') + 1}`, + 3, + ), + originalLocation('client src/leak.ts:2:27', 1), + ]) + }, + timeout, + ) + + /** + * `serverFnFactoryApp` without the leak, whose server fn factory module + * re-exports `request` of `src/other.ts`, which calls the denied + * `getRequest()` at the top level. The client loads the app. Returns the + * reports, the warnings printed naming `src/other.ts` and the use in it. + */ + async function reExportedByAFactory(preTransformRequests?: boolean) { + const other = `import { getRequest } from '@tanstack/react-start/server' +${factoryTopLevelCall}` + const app: Record<string, string> = { + ...serverFnFactoryApp(`export { request } from './other'\n`), + 'src/other.ts': other, + 'src/entry.ts': `export { fn } from './usage'\n`, + } + delete app['src/leak.ts'] + const server = await startProtectedDevServer( + app, + {}, + { config: { server: { preTransformRequests } } }, + ) + const client = await server.load('/src/entry.ts') + await server.idle() + expect(Object.keys(client)).toContain('/src/other.ts') + return { + reports: violationsOf(server), + printed: warningsNaming(server, 'src/other.ts'), + use: locationIn('src/other.ts', other, 2, 'getRequest()'), + } + } + + // Source: mutation testing (the client's edge from a module the Start + // compiler looked up to the modules it imports). + test( + 'a denied import of a module a server fn factory module re-exports is logged, with a trace to the use', + async () => { + const { reports, printed, use } = await reExportedByAFactory() + expect(printed).toHaveLength(1) + expect(reports[0]!.trace.map(({ at }) => at)).toEqual([ + expect.stringMatching(/^src\/entry\.ts\b/), + expect.stringMatching(/^src\/usage\.ts\b/), + expect.stringMatching(/^src\/factory\.ts\b/), + originalLocation(use, 1), + ]) + }, + timeout, + ) + + // Bug: the location of the use is read from a source map of the module + // whose `sources` are relative to it (`other.ts`), and import protection + // takes the source as it is (import-protection/sourceLocation.ts + // `mapGeneratedToOriginal`, `orig.source`), so `Importer:` names the + // file without its directory. The trace, located from the module's id, + // is right. + // Impact: in dev, the warning for a module a server fn factory module + // re-exports names `other.ts:2:24` instead of `src/other.ts:2:24` (low: + // diagnostics only; an editor link does not open the file). + // Source: found writing the test above. + test.fails( + 'a denied import of a module a server fn factory module re-exports is reported at its original import or use, with its path', + async () => { + for (const preTransformRequests of [false, true]) { + const { reports, use } = + await reExportedByAFactory(preTransformRequests) + expect(reports.map(({ importer }) => importer)).toEqual([ + originalLocation(use, 1), + ]) + } + }, + timeout, + ) + + // Source: mutation testing. The factory module's + // violations wait for its compiled imports (the Start compiler looked it + // up), and its denied file import comes before its denied specifier. + test( + 'a server fn factory module calling a denied file and a denied specifier at the top level reports both at their original imports or uses', + async () => { + const factory = `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { getSecret } from './secret.server' +import { getRequest } from '@tanstack/react-start/server' +const mw = createMiddleware({ type: 'function' }).server(({ next }) => { + return next({ context: { secret: getSecret(), req: getRequest() } }) +}) +export const createSecretFn = createServerFn().middleware([mw]) +export const secret = getSecret() +export const request = getRequest() +` + const server = await startProtectedDevServer({ + ...serverFnFactoryApp(), + 'src/factory.ts': factory, + 'src/entry.ts': `export { fn } from './usage'\n`, + }) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server).sort()).toEqual([ + originalLocation( + `client ${locationIn('src/factory.ts', factory, 8, 'getSecret')}`, + 2, + ), + originalLocation( + `client ${locationIn('src/factory.ts', factory, 9, 'getRequest')}`, + 3, + ), + ]) + }, + timeout, + ) + + /** + * `src/p.ts` uses the denied file `src/secret.server.ts` and the denied + * specifier `@tanstack/react-start/server`; its only importer `src/q.ts`, + * which the router entry re-exports, also imports `src/slow.ts`. + */ + const overlapApp = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/p.ts': `import { secret } from './secret.server' +import { getRequest } from '@tanstack/react-start/server' +export const read = () => secret() +export const request = () => getRequest() +`, + 'src/slow.ts': `export const slow = 1\n`, + 'src/q.ts': `import { read, request } from './p' +import { slow } from './slow' +export const q = () => [read(), request(), slow] +`, + 'src/entry.ts': `export * from './q'\n`, + } + + /** + * Serves `src/p.ts` while its only importer `src/q.ts` is still being + * transformed, as overlapping requests do (Vite's `server.warmup`, + * parallel requests, a slow resolver): a resolver plugin holds the + * resolution of `src/q.ts`'s import of `./slow` until `src/p.ts` and its + * imports are served. Then the client loads the app. Returns the modules + * served for `src/p.ts`. + */ + async function serveWhileItsImporterTransforms() { + let release!: () => void + const released = new Promise<void>((resolve) => { + release = resolve + }) + let holding!: () => void + const held = new Promise<void>((resolve) => { + holding = resolve + }) + const slowResolver: Plugin = { + name: 'slow-resolver', + enforce: 'pre', + async resolveId(source, importer) { + if (source === './slow' && importer?.endsWith('/src/q.ts')) { + holding() + await released + } + return null + }, + } + const server = await startProtectedDevServer( + overlapApp, + {}, + { plugins: [slowResolver] }, + ) + await server.transform('/src/entry.ts') + const importer = server.transform('/src/q.ts') + await held + const served = await server.load('/src/p.ts') + release() + await importer + await server.load('/src/entry.ts') + return { server, served } + } + + // Source: mutation testing (the dev 'unknown'-reachability fallback: some + // edges to the module lack transform data). + test( + 'a module served while its only importer is still being transformed has its denied imports mocked and logged at their original imports or uses', + async () => { + const { server, served } = await serveWhileItsImporterTransforms() + expect(modulesContaining(served, 'MARK_SECRET')).toEqual([]) + const p = overlapApp['src/p.ts'] + expectViolationsAt(server, [ + { + environment: 'client', + use: locationIn('src/p.ts', p, 3, 'secret()'), + also: ['src/p.ts:1'], + }, + { + environment: 'client', + use: locationIn('src/p.ts', p, 4, 'getRequest()'), + also: ['src/p.ts:2'], + }, + ]) + // Source: mutation testing (the trace from Vite's + // module graph, which does not have the importer yet, replaced it). + for (const report of violationsOf(server)) { + expect( + report.trace.map(({ at }) => at.replace(/(?::\d+)+$/, '')), + ).toEqual(['src/entry.ts', 'src/q.ts', 'src/p.ts']) + } + }, + timeout, + ) + + // Bug: a module the dev server transforms before any importer of it is + // known (Vite's `server.warmup`, which transforms the listed files as the + // server starts, or any request that comes first) has its violations + // discarded as unreachable from Start's entries + // (vite/import-protection-plugin/plugin.ts `processPendingViolations`, + // `'unreachable'`; only bundled dev keeps them pending), and Vite caches + // its transform, so they are never checked again, even once the app loads + // the module from its entry. + // Impact: in dev (mock mode), denied imports of warmed-up modules are + // mocked without any warning (the build still reports them). + // Source: mutation testing (looking for edges without transform data); + // the control is "a client import of a denied file is mocked, and + // the dev server logs a warning naming the importer at the use". + test.fails( + 'a denied import of a module warmed up before its importers is logged once the client loads the app', + async () => { + const server = await startProtectedDevServer( + deniedFileApp, + {}, + { config: { server: { warmup: { clientFiles: ['./src/a.ts'] } } } }, + ) + // (waits for the warmup's transform of the module) + await server.transform('/src/a.ts') + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation(`client ${deniedFileUse}`, 1), + ]) + }, + timeout, + ) + + /** + * `src/late.ts` uses the denied file `src/secret.server.ts`; `src/a.ts`, + * which the router entry re-exports, imports it dynamically. The client + * loads the app, the server renders it (`ssr`), then the client loads + * `src/late.ts`. The violations logged. + */ + async function logsOfALateModule(perEnvironmentStartEndDuringDev: boolean) { + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/late.ts': `import { secret } from './secret.server' +export const read = () => secret() +`, + 'src/a.ts': `export const late = () => import('./late')\n`, + 'src/entry.ts': `export * from './a'\n`, + }, + {}, + { config: { server: { perEnvironmentStartEndDuringDev } } }, + ) + // The client loads the app as a page does at start: the modules it + // imports statically (`load()` would also load what they import + // lazily, `src/late.ts`, which the page requests only later) + await server.transform('/src/entry.ts') + await server.transform('/src/a.ts') + await server.load('/src/entry.ts', { environment: 'ssr' }) + await server.load('/src/late.ts') + return loggedViolations(server) + } + + // Control for the pin below (same harness). + test( + 'a denied import of a module the client loads after the server rendered is logged', + async () => { + expect(await logsOfALateModule(false)).toEqual([ + originalLocation('client src/late.ts:2:27', 1), + ]) + }, + timeout, + ) + + // Bug: with Vite's `server.perEnvironmentStartEndDuringDev`, each + // environment runs `buildStart` when it first handles a module, and import + // protection's `buildStart` clears the state of every environment + // (vite/import-protection-plugin/plugin.ts `clearEnvState` for each), so + // the server's first request drops the client's import graph: a module the + // client loads afterwards is unreachable from Start's entries and its + // violations are discarded. + // Impact: with that Vite option, dev import protection mocks the denied + // imports of modules loaded after the first server request without any + // warning (low: opt-in option). + // Source: mutation testing (clearEnvState mutants). + test.fails( + 'with perEnvironmentStartEndDuringDev, a denied import of a module the client loads after the server rendered is logged', + async () => { + expect(await logsOfALateModule(true)).toEqual([ + originalLocation('client src/late.ts:2:27', 1), + ]) + }, + timeout, + ) +}) + +describe("an app's client entry, with Start's whole plugin", () => { + /** + * An app whose `src/leak.ts` uses the denied file `src/secret.server.ts`, + * imported by the app's client entry `src/client.tsx` or by its router + * entry `src/router.ts`. + */ + const leakApp = (importer: 'src/client.tsx' | 'src/router.ts') => ({ + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/leak.ts': `import { secret } from './secret.server' +export const leak = () => secret() +`, + 'src/client.tsx': + importer === 'src/client.tsx' + ? `import { leak } from './leak'\nexport const read = () => leak()\n` + : `export {}\n`, + 'src/router.ts': + importer === 'src/router.ts' + ? `import { leak } from './leak'\nexport const getRouter = () => leak\n` + : `export const getRouter = () => undefined\n`, + }) + + /** The use of `secret` in `src/leak.ts`. */ + const leakUse = locationIn( + 'src/leak.ts', + leakApp('src/client.tsx')['src/leak.ts'], + 2, + 'secret()', + ) + + /** + * Starts a dev server with Start's whole plugin (without HMR, so that its + * dev client entry imports the app's client entry statically). + */ + const startApp = startRecordingApp + + // The router entry counts; its client entry twin is pinned in + // dev-page.test.ts. + test( + 'a denied import of a module the router entry imports is mocked and logged', + async () => { + const server = await startApp(leakApp('src/router.ts')) + const client = await server.load('/src/router.ts') + expect(Object.keys(client)).toContain('/src/leak.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation(`client ${leakUse}`, 1), + ]) + }, + timeout, + ) + + // The `importProtection` option of `tanstackStart()` reaches the plugin + // (the adapter harness above wires the plugin by hand): `onViolation` + // receives the violation, `mockAccess: 'off'` silences the mock's use. + // Source: review. + test( + "Start's plugin passes the importProtection option on: onViolation and mockAccess apply", + async () => { + const violations: Array<ViolationInfo> = [] + const server = await startDevServer({ + browser: true, + plugins: [clientFixturePlugin], + start: { + importProtection: { + mockAccess: 'off', + onViolation: (info) => { + violations.push(info as ViolationInfo) + }, + }, + }, + files: leakApp('src/router.ts'), + config: { server: { hmr: false } }, + }) + const { result, diagnostics } = await runViteClient( + server, + '/src/router.ts', + `${probeMockPrelude} +return probeMock(entry.getRouter()(), 'MARK_')`, + ) + expect(result).toEqual(safeMock) + expect(warningsAndErrors(diagnostics)).toEqual([]) + expect(receivedViolations(violations, server.root)).toEqual([ + originalLocation(`client ${leakUse}`, 1), + ]) + }, + timeout, + ) + + // The app's client entry, loaded by a real page: dev-page.test.ts. +}) + +describe("an app's server entry, with Start's whole plugin", () => { + const handler = `import { widget } from './widget.client' +export const handler = () => widget() +` + /** + * An app whose `src/handler.ts` uses the client-only file + * `src/widget.client.ts`, imported by the app's server entry + * `src/server.ts` or by its router entry `src/router.ts`. + */ + const handlerApp = (importer: 'src/server.ts' | 'src/router.ts') => ({ + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/handler.ts': handler, + ...(importer === 'src/server.ts' && { + 'src/server.ts': `import { handler } from './handler' +export default { fetch: () => new Response(String(handler())) } +`, + }), + 'src/router.ts': + importer === 'src/router.ts' + ? `import { handler } from './handler'\nexport const getRouter = () => handler\n` + : `export const getRouter = () => undefined\n`, + }) + const handlerUse = `server ${locationIn('src/handler.ts', handler, 2, 'widget()')}` + + const startApp = startRecordingApp + + // The router entry counts; its server entry twin is pinned in + // dev-page.test.ts. + test( + 'a client-only import of a module the router entry imports is mocked on the server and logged', + async () => { + const server = await startApp(handlerApp('src/router.ts')) + const router = await server.import('/src/router.ts') + expect(String(router.getRouter()())).not.toContain('MARK_CLIENT') + expect(loggedViolations(server)).toEqual([ + originalLocation(handlerUse, 1), + ]) + }, + timeout, + ) + + // The app's server entry, run by a request: dev-page.test.ts. +}) + +// Vite's full-bundle dev (`experimental.bundledDev`), which Start supports: +// Rolldown bundles the client, so a module can be transformed before its +// importers. +// Source: mutation testing (the bundledDev branches of the plugin had no +// unit test; e2e import-protection runs them with E2E_VITE_BUNDLED_DEV). +describe('full-bundle dev', () => { + test.each([ + { name: 'its router entry', files: deniedFileApp }, + { + name: 'a module of src/routes', + files: { + ...deniedFileApp, + 'src/routes/page.ts': `export { read } from '../a'\n`, + 'src/entry.ts': `export * from './routes/page'\n`, + }, + }, + ])( + 'a denied file imported from $name is mocked in the client bundle and logged at its original import or use', + async ({ files }) => { + const server = await startProtectedDevServer( + files, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + const bundle = await server.clientBundle() + expect(modulesContaining(bundle, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation(`client ${deniedFileUse}`, 1), + ]) + }, + timeout, + ) + + // Source: mutation testing (full-bundle dev had no import-protection test). + test( + 'denied imports are mocked in the client bundle, and the dev server logs each at its original import or use', + async () => { + const x = `import { getRequest } from '@tanstack/react-start/server' +export const request = () => getRequest() +` + const server = await startProtectedDevServer( + { + ...deniedFileApp, + 'src/x.ts': x, + 'src/entry.ts': `export * from './a'\nexport * from './x'\n`, + }, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + const bundle = await server.clientBundle() + expect(modulesContaining(bundle, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server).sort()).toEqual([ + originalLocation(`client ${deniedFileUse}`, 1), + originalLocation( + `client ${locationIn('src/x.ts', x, 2, 'getRequest()')}`, + 1, + ), + ]) + }, + timeout, + ) + + /** The modules of the trace of each violation of `recorded`. */ + const traces = (recorded: Recorded) => + violationsOf(recorded).map(traceModules) + + // Source: mutation testing (every importer taken as an entry). + test( + 'the trace of a denied file imported through a chain of modules leads from the router entry', + async () => { + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/lib/a.ts': `import { secret } from '../secret.server' +export const read = () => secret() +`, + 'src/b.ts': `export { read } from './lib/a'\n`, + 'src/entry.ts': `export * from './b'\n`, + }, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + await server.clientBundle() + const logged = traces(server) + expect(logged).not.toEqual([]) + for (const trace of logged) { + expect(trace).toEqual(['src/entry.ts', 'src/b.ts', 'src/lib/a.ts']) + } + }, + timeout, + ) + + // Bug: in full-bundle dev, import protection takes each client module of + // `src/routes` as an entry, so that a violation under a route the bundle + // reaches before the router entry's imports are known is not discarded + // (vite/import-protection-plugin/plugin.ts `resolveId`, bundled dev + // `env.graph.addEntry(normalizedImporter)`); the trace then stops at the + // first entry it meets. + // Impact: in full-bundle dev, the trace of a violation under a route + // starts at the route module: it does not show how the app reaches the + // route (unbundled dev and builds start at the router entry). Low: + // diagnostics only. + // Source: mutation testing. + test.fails( + 'the trace of a denied file imported from a module of src/routes leads from the router entry', + async () => { + const server = await startProtectedDevServer( + { + ...deniedFileApp, + 'src/routes/page.ts': `export { read } from '../a'\n`, + 'src/entry.ts': `export * from './routes/page'\n`, + }, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + await server.clientBundle() + const logged = traces(server) + expect(logged).not.toEqual([]) + for (const trace of logged) { + expect(trace).toEqual([ + 'src/entry.ts', + 'src/routes/page.ts', + 'src/a.ts', + ]) + } + }, + timeout, + ) + + // Full-bundle dev bundles only the client: the server still loads modules + // one by one, and its traces do not change. + // Source: mutation testing (route modules taken as server entries). + test( + 'the SSR trace of a .client file imported from a module of src/routes leads from the router entry', + async () => { + const server = await startProtectedDevServer( + { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/a.ts': `import { widget } from './widget.client' +export const read = () => widget() +`, + 'src/routes/page.ts': `export { read } from '../a'\n`, + 'src/entry.ts': `export * from './routes/page'\n`, + }, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + await server.load('/src/entry.ts', { environment: 'ssr' }) + const logged = traces(server) + expect(logged).not.toEqual([]) + for (const trace of logged) { + expect(trace).toEqual([ + 'src/entry.ts', + 'src/routes/page.ts', + 'src/a.ts', + ]) + } + }, + timeout, + ) + + /** + * An app whose server fn factory module is a denied file + * (`src/factory.server.ts`); `src/usage.ts`, which the router entry + * re-exports, defines a server fn with it. + */ + const deniedFactoryApp = { + 'src/factory.server.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +const mw = createMiddleware({ type: 'function' }).server(({ next }) => next()) +export const createSecretFn = createServerFn().middleware([mw]) +export const marker = 'MARK_SECRET' +`, + 'src/usage.ts': `import { createSecretFn } from './factory.server' +export const fn = createSecretFn().handler(async () => 'data') +`, + 'src/entry.ts': `export { fn } from './usage'\n`, + } + const deniedFactoryUse = 'src/usage.ts:2:19' + + // Source: mutation testing (the mock the Start compiler's lookup of the + // denied factory module gets). + test( + 'a server fn built with a factory of a denied file gets the mock in the client bundle and is logged at its original import or use', + async () => { + const server = await startProtectedDevServer( + deniedFactoryApp, + {}, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + const bundle = await server.clientBundle() + expect(modulesContaining(bundle, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toContainEqual( + originalLocation(`client ${deniedFactoryUse}`, 1), + ) + }, + timeout, + ) + + // Bug: the Start compiler looks up the factory in the denied file's mock + // (`import mock from 'tanstack-start-import-protection:mock'`) with its + // lookup query, and the Vite adapter loads the silent mock only by its + // exact id (vite/import-protection-plugin/virtualModules.ts + // `loadResolvedVirtualModule`): Rolldown cannot load + // `\0tanstack-start-import-protection:mock?server-fn-module-lookup`. With + // the default `mockAccess`, the mock-runtime module hides it (the control + // above). + // Impact: in full-bundle dev with `mockAccess: 'off'`, an app with a server + // fn built from a factory in a denied file fails to bundle the client + // (UNLOADABLE_DEPENDENCY). Low: opt-in option, unusual layout. + // Source: mutation testing. + test.fails( + 'with mockAccess off, a server fn built with a factory of a denied file gets the mock in the client bundle and is logged at its original import or use', + async () => { + const server = await startProtectedDevServer( + deniedFactoryApp, + { mockAccess: 'off' }, + { bundledDev: { entry: 'src/entry.ts' } }, + ) + const bundle = await server.clientBundle() + expect(modulesContaining(bundle, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toContainEqual( + originalLocation(`client ${deniedFactoryUse}`, 1), + ) + }, + timeout, + ) + + // Start's virtual client entry, the bundle's input, imports the app's + // `src/client.tsx`, which may import modules before the router entry's + // imports reach them. + // Source: mutation testing (the violations of a module the bundle + // reaches before the router entry does are kept until it does). + test( + 'a denied import of a module the bundle input imports before the router entry reaches it is logged at its original import or use', + async () => { + let release!: () => void + const released = new Promise<void>((resolve) => { + release = resolve + }) + // Holds the router entry until the bundle has asked for `src/a.ts`'s + // import of the denied file (its resolution, which happens whatever + // the compiler then serves: the real file, a mock, a virtual module), + // or for at most 5 s: fix-agnostic, and it never hangs. + const slowEntry: Plugin = { + name: 'slow-entry', + enforce: 'pre', + resolveId(source, importer) { + if (source === './secret.server' && importer?.endsWith('/src/a.ts')) { + release() + } + return null + }, + async transform(_code, id) { + if (id.endsWith('/src/entry.ts')) { + await Promise.race([ + released, + new Promise((resolve) => setTimeout(resolve, 5_000)), + ]) + } + return null + }, + } + const server = await startProtectedDevServer( + { + ...deniedFileApp, + 'src/page.ts': `export { read } from './a'\n`, + 'src/entry.ts': `export { read } from './page'\n`, + 'src/client.ts': `import { read } from './page' +import * as router from './entry' +export const app = [read, router] +`, + }, + {}, + { bundledDev: { entry: 'src/client.ts' }, plugins: [slowEntry] }, + ) + const bundle = await server.clientBundle() + expect(modulesContaining(bundle, 'MARK_SECRET')).toEqual([]) + expect(loggedViolations(server)).toEqual([ + originalLocation(`client ${deniedFileUse}`, 1), + ]) + }, + timeout, + ) +}) + +// A split route component, rendered by a real page: dev-page.test.ts. + +// The route module the router plugin compiles (with route HMR in dev): a +// violation is located in the route file as the user wrote it. +// Source: mutation testing (the route module's source map without +// the source text, so import protection showed the compiled module). +test( + "a denied import used in a route module is located in the route file's source, with Start's whole plugin", + async () => { + const route = `import { createFileRoute } from '@tanstack/react-router' +import { secret } from '../secret.server' /* ORIGINAL_IMPORT */ + +// a comment that compiling drops +export const Route = createFileRoute('/')({ + loader: () => secret() /* ORIGINAL_LOADER_USE */, + component: () => 'page', +}) +` + const server = await startRecordingApp({ + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/routes/index.tsx': route, + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + }) + await server.load('/src/router.ts') + await server.idle() + const use = locationIn('src/routes/index.tsx', route, 6, 'secret()') + // At the use or the import (SPEC J6.5). + expectViolationsAt(server, [ + { environment: 'client', use, also: ['src/routes/index.tsx:2'] }, + ]) + }, + timeout, +) + +describe('diagnostics', () => { + // Source: mutation testing (the served code of a JSX module + // has an extra import line, of the JSX runtime). + test.each([ + { + name: 'a use of a denied specifier (client)', + a: `import { getRequest } from '@tanstack/react-start/server' +export const Page = () => <div>{String(getRequest())}</div> +`, + environment: 'client', + importProtection: {}, + expected: 'client src/a.tsx:2:40', + }, + { + name: 'a use of a file denied by a custom file rule (client)', + a: `import { secret } from './private/db' +export const Page = () => <div>{String(secret())}</div> +`, + environment: 'client', + importProtection: { client: { files: ['**/private/**'] } }, + expected: 'client src/a.tsx:2:40', + }, + // Source: mutation testing (a module without exports, imported for + // its side effects, was located in its compiled code). + { + name: 'a use of a denied file in a module without exports (client)', + a: `import { secret } from './private/db' +console.log(<div>{String(secret())}</div>) +`, + environment: 'client', + importProtection: { client: { files: ['**/private/**'] } }, + expected: 'client src/a.tsx:2:26', + }, + { + name: 'a client-only marker (SSR)', + a: `import '@tanstack/react-start/client-only' +export const Page = () => <div>{String(1)}</div> +`, + environment: 'ssr', + importProtection: {}, + expected: 'server src/a.tsx:1:8', + // A marker violation may be reported at the importer's use instead + // (SPEC J6.5): a report in `src/a.tsx` must be at the marker. + marker: true, + }, + ])( + 'in a JSX module, $name is located on its source line', + async ({ a, environment, importProtection, expected, marker }) => { + const server = await startProtectedDevServer( + { + 'src/private/db.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/a.tsx': a, + 'src/entry.ts': `export * from './a'\n`, + }, + importProtection, + ) + await server.load('/src/entry.ts', { environment }) + // (SSR: the entry's import of the marked module is reported as well) + const inA = loggedViolations(server).filter((violation) => + violation.includes(' src/a.tsx'), + ) + expect(marker ? distinct([...inA, expected]) : inA).toEqual([ + originalLocation(expected, 1), + ]) + expect(loggedViolations(server)).not.toEqual([]) + }, + timeout, + ) + + // Bug: import protection keeps a module's source map for its diagnostics + // up front only when the module's compiled code names a denied module + // (`shouldCaptureDiagnosticSourceMap`, vite/import-protection-plugin/ + // plugin.ts). Through an alias (here the app's package.json `imports`), + // the denied file is only known once the import resolves, and `resolveId` + // reports it (transform-cache import loop → `reportOrDeferViolation`) + // before the loop captures the map (`'devViolation'`), so the location is + // read from the compiled code. + // Impact: in dev, the warning for a denied file imported through an alias + // in a JSX module points at a line that is not in the source (here 4:77 + // of a two-line module). + // Source: mutation testing (that late source map capture). + test.fails( + 'in a JSX module, a use of a denied file imported through a subpath import alias is located on its source line', + async () => { + const server = await startProtectedDevServer({ + 'package.json': JSON.stringify({ + name: 'app', + type: 'module', + imports: { '#secret': './src/secret.server.ts' }, + }), + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/a.tsx': `import { secret } from '#secret' +export const Page = () => <div>{String(secret())}</div> +`, + 'src/entry.ts': `export * from './a'\n`, + }) + const client = await server.load('/src/entry.ts') + expect(modulesContaining(client, 'MARK_SECRET')).toEqual([]) + // (the reports with a location: the one naming the resolved path + // has none, see the 'once' pin of `log`) + expect( + loggedViolations(server).filter((v) => /:\d+:\d+$/.test(v)), + ).toEqual([originalLocation('client src/a.tsx:2:40', 1)]) + }, + timeout, + ) + + // Source: mutation testing (a pattern rule cannot be found in + // the module's code as text, unlike the specifiers of the rows above). + test( + 'in a JSX module, a use of a specifier denied by a custom pattern rule (client) is located on its source line', + async () => { + const server = await startProtectedDevServer( + { + 'node_modules/@acme/private/package.json': JSON.stringify({ + name: '@acme/private', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/@acme/private/index.js': `export const secret = () => 'MARK_SECRET'\n`, + 'src/a.tsx': `import { secret } from '@acme/private' +export const Page = () => <div>{String(secret())}</div> +`, + 'src/entry.ts': `export * from './a'\n`, + }, + { client: { specifiers: ['@acme/*'] } }, + ) + await server.load('/src/entry.ts') + expect(loggedViolations(server)).toEqual([ + originalLocation('client src/a.tsx:2:40', 1), + ]) + }, + timeout, + ) + + /** + * The client imports `src/secret.server.ts` through a chain of modules + * (`src/b.ts` uses it). + */ + const chainApp = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/b.ts': `import { secret } from './secret.server' +export const read = () => secret() +`, + 'src/a.ts': `import { read } from './b'\nexport const page = () => read()\n`, + 'src/entry.ts': `export * from './a'\n`, + } + + /** The trace steps of each warning logged when the client loads the app. */ + async function tracesOf(importProtection: ImportProtectionOptions) { + const server = await startProtectedDevServer(chainApp, importProtection) + await server.load('/src/entry.ts') + const reports = violationsOf(server) + expect(reports).not.toEqual([]) + return reports.map(({ trace }) => + trace.map(({ at, imports }) => ({ + file: at.replace(/(?::\d+)+$/, ''), + imports, + })), + ) + } + + // Source: mutation testing (the trace from Vite's module graph, which dev + // import protection prefers when it is longer than its own: here, its own + // stops at `maxTraceDepth`). + test( + 'with maxTraceDepth, the trace ends at the importer, each step naming the import of the next', + async () => { + for (const trace of await tracesOf({ maxTraceDepth: 1 })) { + expect(trace.at(-1)?.file).toBe('src/b.ts') + for (const [index, step] of trace.slice(0, -1).entries()) { + expect(step.imports).toBe( + `./${path.basename(trace[index + 1]!.file, '.ts')}`, + ) + } + } + }, + timeout, + ) + + // Bug: dev import protection replaces its trace (cut at `maxTraceDepth`) + // with the trace it finds in Vite's module graph whenever that one is + // longer (vite/import-protection-plugin/plugin.ts + // `rebuildAndAnnotateTrace`); the module graph trace runs from the entry + // and is only cut at `maxTraceDepth + 2` steps, from the entry side (so in + // a chain deeper than that, it does not reach the importer). A build cuts + // the trace, keeping the importer (build-options.test.ts "cuts a deeper + // trace, keeping the importer"). + // Impact: in dev, `maxTraceDepth` does not cut traces (low: diagnostics + // only). + // Source: mutation testing (module graph trace mutants). + test.fails( + 'with maxTraceDepth, a deeper trace is cut, keeping the importer', + async () => { + // (which steps a cut keeps, besides the importer, is not specified) + for (const trace of await tracesOf({ maxTraceDepth: 1 })) { + expect(trace.length).toBeLessThanOrEqual(1 + 1) + expect(trace.at(-1)?.file).toBe('src/b.ts') + } + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/exemptions.test.ts b/packages/start-plugin-core/tests/integration/importProtection/exemptions.test.ts new file mode 100644 index 0000000000..a35b6c90de --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/exemptions.test.ts @@ -0,0 +1,483 @@ +/** + * What an importer exempted from import protection gets for a denied file: + * the real module (SPEC J6.7). Exempt means matched by + * `ignoreImporters` or `exclude`, or outside `include`. Exempting a file + * does more than silence the report; importers that are not exempt still get + * the mock and a report. Client environment, mock mode. That nothing is + * reported for an exempt importer is also checked in build-options.test.ts. + * Same rule for a denied file `client.excludeFiles` / `server.excludeFiles` + * match (end of the file): its importers get the real module. + */ +import { afterAll, afterEach, describe, expect, test, vi } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + inEnvironment, + reportedImporters, +} from '../../importProtection/start-apps' +import { runViteClient, startBrowserProtectedDevServer } from './client-pages' +import type { Recorded } from '../../importProtection/start-apps' +import type { StartBuild, StartBundler } from '../../build-harness' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const timeout = 60_000 + +/** + * What a use gives, described: the real value's text, `a safe mock` + * (`mock-helpers.ts`), or what calling it threw. + */ +const mockText = 'a safe mock' +/** `read` for the scripts of a build (`describeValuePrelude`). */ +const readPrelude = `${describeValuePrelude} +const read = (use) => { + try { + return describeValue(use(), 'MARK_') + } catch (error) { + return 'throws: ' + String(error) + } +} +` + +afterEach(() => { + vi.restoreAllMocks() + for (const loaded of [ + 'secretLoaded', + 'vendorLoaded', + 'widgetLoaded', + 'packageLoaded', + ]) { + delete (globalThis as Record<string, unknown>)[loaded] + } +}) + +/** + * `src/exempt/a.ts` and `src/app/b.ts` both use the denied file + * `src/secret.server.ts`, which records that it ran; the entry re-exports + * both uses. + */ +const files = { + 'src/secret.server.ts': `;(globalThis as any).secretLoaded = 'MARK_SECRET_LOADED' +export const secret = () => 'MARK_SECRET' +`, + 'src/exempt/a.ts': `import { secret } from '../secret.server' +export const exemptRead = () => secret() +`, + 'src/app/b.ts': `import { secret } from '../secret.server' +export const otherRead = () => secret() +`, + 'src/entry.ts': `export { exemptRead } from './exempt/a' +export { otherRead } from './app/b' +`, +} + +/** + * Each way to exempt `src/exempt/a.ts` but not `src/app/b.ts`, and which of + * the tests below main fails (`.fails`): `exempt` in builds and dev, + * `control` in builds and dev. + */ +const exemptions: Array<{ + option: string + importProtection: ImportProtectionOptions + fails: { + build: { exempt: boolean; control: boolean } + dev: { exempt: boolean; control: boolean } + } +}> = [ + { + option: 'ignoreImporters', + importProtection: { ignoreImporters: ['**/exempt/*.ts'] }, + fails: { + build: { exempt: true, control: false }, + dev: { exempt: true, control: false }, + }, + }, + { + option: 'exclude', + importProtection: { exclude: ['src/exempt/**'] }, + fails: { + build: { exempt: true, control: false }, + dev: { exempt: true, control: false }, + }, + }, + { + // The denied file is outside `include` too: see the NEW bug below. + option: 'an importer outside include', + importProtection: { include: ['src/app/**'] }, + fails: { + build: { exempt: false, control: true }, + dev: { exempt: true, control: true }, + }, + }, +] + +/** + * The files of the reported violations (`onViolation`), `<environment> + * <file>`, each once, sorted. + */ +const reportedFiles = (recorded: Recorded) => + [...new Set(reportedImporters(recorded))].sort() + +/** What each re-exported use returns, and whether the denied file ran. */ +const readScript = `${readPrelude} +return { + exempt: read(entry.exemptRead), + other: read(entry.otherRead), + loaded: globalThis.secretLoaded ?? null, +}` + +type Outcome = { + exempt: string + other: string + loaded: unknown + reported: Array<string> +} + +// Bug: an exempt importer is only left out of the reports: it still gets +// the mock, because the denied file is mocked by its own transform, for +// every importer (vite/import-protection-plugin/plugin.ts:2158 self-denial; +// the Rsbuild adapter behaves the same). SPEC J6.7. +// Impact: code a project exempts on purpose (tests, generated code) +// silently gets a mock instead of the module it imports. +const expectExemptGetsRealModule = (outcome: Outcome) => + expect({ + exempt: outcome.exempt, + loaded: outcome.loaded, + reported: outcome.reported, + }).toEqual({ + exempt: 'MARK_SECRET', + loaded: 'MARK_SECRET_LOADED', + reported: ['client src/app/b.ts'], + }) + +// Control: the importer that is not exempt gets the mock and is reported. +// NEW bug (`include` rows): with `importProtection.include`, a denied file +// outside the patterns is never mocked, because its own transform skips +// files out of scope before the self-denial +// (vite/import-protection-plugin/plugin.ts:2139 `shouldCheckImporter(file)`; +// Rsbuild: same outcome). An included importer is reported, but a mock-mode +// build ships the real server-only module to the client, and in Vite dev the +// importer's rewrite (`import __tss_deny_0 from '/src/secret.server.ts'`) +// reads a default export the real file lacks, so the page fails to load. +// Impact: server-only code in the client bundle in mock mode (the dev +// default, and `behavior: { build: 'mock' }`), or a broken dev page. +const expectOtherGetsMock = (outcome: Outcome) => + expect({ other: outcome.other, reported: outcome.reported }).toEqual({ + other: mockText, + reported: expect.arrayContaining(['client src/app/b.ts']), + }) + +describe.each(startBundlers)('%s build', (bundler) => { + describe.each(exemptions)('$option', ({ importProtection, fails }) => { + // One build for both tests. + let built: Promise<StartBuild> | undefined + let dispose: (() => Promise<void>) | undefined + const app = () => + (built ??= buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start: { importProtection: { ...importProtection, behavior: 'mock' } }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + afterAll(() => dispose?.()) + + async function outcome(): Promise<Outcome> { + const build = await app() + const { result } = await build.client.run(readScript) + return { + ...(result as Omit<Outcome, 'reported'>), + // What the build reported for the client + reported: reportedFiles(inEnvironment(build, 'client')), + } + } + + ;(fails.build.control ? test.fails : test)( + 'an importer that is not exempt gets the mock and is reported', + async () => { + expectOtherGetsMock(await outcome()) + }, + timeout, + ) + ;(fails.build.exempt ? test.fails : test)( + 'the exempt importer gets the real module, and is not reported', + async () => { + expectExemptGetsRealModule(await outcome()) + }, + timeout, + ) + }) +}) + +describe.each(exemptions)( + 'vite dev: $option', + ({ importProtection, fails }) => { + /** Loads the entry as a browser would; what it reads, and the logs. */ + async function outcome(): Promise<Outcome> { + const server = await startBrowserProtectedDevServer( + files, + importProtection, + ) + const { result } = await runViteClient( + server, + '/src/entry.ts', + readScript, + ) + return { + ...(result as Omit<Outcome, 'reported'>), + reported: reportedFiles(server), + } + } + + ;(fails.dev.control ? test.fails : test)( + 'an importer that is not exempt gets the mock and is reported', + async () => { + expectOtherGetsMock(await outcome()) + }, + timeout, + ) + ;(fails.dev.exempt ? test.fails : test)( + 'the exempt importer gets the real module, and is not reported', + async () => { + expectExemptGetsRealModule(await outcome()) + }, + timeout, + ) + }, +) + +/** + * `client.excludeFiles` / `server.excludeFiles` (SPEC J6.7): a + * denied file the patterns match is not checked, so its importers get the + * real module and nothing is reported. Each use records whether its denied + * file ran: + * - `vendor`: `src/vendor/secret.server.ts`, denied to the client; + * - `widget`: `src/vendor/widget.client.ts`, denied to the server (SSR); + * - `package`: the `*.server.*` entry of the dependency `server-pkg`, which + * the default patterns (`**\/node_modules/**`) match. + */ +const excludedFiles = { + 'src/vendor/secret.server.ts': `;(globalThis as any).vendorLoaded = 'MARK_VENDOR_LOADED' +export const secret = () => 'MARK_VENDOR' +`, + 'src/vendor/widget.client.ts': `;(globalThis as any).widgetLoaded = 'MARK_WIDGET_LOADED' +export const widget = () => 'MARK_WIDGET' +`, + 'node_modules/server-pkg/package.json': JSON.stringify({ + name: 'server-pkg', + type: 'module', + exports: { '.': './secret.server.js' }, + }), + 'node_modules/server-pkg/secret.server.js': `globalThis.packageLoaded = 'MARK_PACKAGE_LOADED' +export const secret = () => 'MARK_PACKAGE' +`, + 'src/app/vendor-user.ts': `import { secret } from '../vendor/secret.server' +export const vendorRead = () => secret() +`, + 'src/app/widget-user.ts': `import { widget } from '../vendor/widget.client' +export const widgetRead = () => widget() +`, + 'src/app/package-user.ts': `import { secret } from 'server-pkg' +export const packageRead = () => secret() +`, + 'src/entry.ts': `export { vendorRead } from './app/vendor-user' +export { widgetRead } from './app/widget-user' +export { packageRead } from './app/package-user' +`, +} + +type Use = { read: string; loaded: unknown } + +/** Each use of `excludedFiles`: what it returns, and whether its file ran. */ +type ExcludedOutcome = Record<'vendor' | 'widget' | 'package', Use> & { + reported: Array<string> +} + +const excludedReadScript = `${readPrelude} +const use = (fn, loaded) => ({ read: read(fn), loaded: globalThis[loaded] ?? null }) +return { + vendor: use(entry.vendorRead, 'vendorLoaded'), + widget: use(entry.widgetRead, 'widgetLoaded'), + package: use(entry.packageRead, 'packageLoaded'), +}` + +/** The real module of a use: its value, and its file ran. */ +const realModule = (name: string): Use => ({ + read: `MARK_${name.toUpperCase()}`, + loaded: `MARK_${name.toUpperCase()}_LOADED`, +}) + +/** A mock: it converts to the mock's text, and the denied file never ran. */ +const mockedModule = { read: mockText, loaded: null } + +/** Custom patterns that match `src/vendor`; `node_modules` stays excluded. */ +const vendorExcluded = ['**/vendor/**', '**/node_modules/**'] + +const vendorExcludedOptions: ImportProtectionOptions = { + client: { excludeFiles: vendorExcluded }, + server: { excludeFiles: vendorExcluded }, +} + +/** + * One mock-mode build of `excludedFiles` with `importProtection`, shared by + * the tests of the enclosing `describe`; what an environment's uses read, + * and the files it reports. + */ +function excludedBuild( + bundler: StartBundler, + importProtection: ImportProtectionOptions, +) { + let built: Promise<StartBuild> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + return async (environment: 'client' | 'ssr'): Promise<ExcludedOutcome> => { + built ??= buildStart({ + bundler, + files: excludedFiles, + entry: 'src/entry.ts', + start: { importProtection: { ...importProtection, behavior: 'mock' } }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + const build = await built + const { result: read } = await build[environment].run(excludedReadScript) + return { + ...(read as Omit<ExcludedOutcome, 'reported'>), + // What the build reported for the environment + reported: reportedFiles( + inEnvironment(build, environment === 'ssr' ? 'server' : 'client'), + ), + } + } +} + +describe.each(startBundlers)('%s build: excludeFiles', (bundler) => { + describe('custom patterns', () => { + const outcome = excludedBuild(bundler, vendorExcludedOptions) + + test( + 'client: the importer of a denied file client.excludeFiles matches gets the real module, and nothing is reported', + async () => { + const { vendor, reported } = await outcome('client') + expect({ vendor, reported }).toEqual({ + vendor: realModule('vendor'), + reported: [], + }) + }, + timeout, + ) + test( + 'ssr: the importer of a denied file server.excludeFiles matches gets the real module, and nothing is reported', + async () => { + const { widget, reported } = await outcome('ssr') + expect({ widget, reported }).toEqual({ + widget: realModule('widget'), + reported: [], + }) + }, + timeout, + ) + }) + + describe('default patterns', () => { + const outcome = excludedBuild(bundler, {}) + + // Controls: the same files, which the default patterns do not match. + test( + 'client: the importer of the same denied file outside the patterns gets the mock and is reported', + async () => { + const { vendor, reported } = await outcome('client') + expect({ vendor, reported }).toEqual({ + vendor: mockedModule, + reported: expect.arrayContaining(['client src/app/vendor-user.ts']), + }) + }, + timeout, + ) + test( + 'ssr: the importer of the same denied file outside the patterns gets the mock and is reported', + async () => { + const { widget, reported } = await outcome('ssr') + expect({ widget, reported }).toEqual({ + widget: mockedModule, + reported: expect.arrayContaining(['server src/app/widget-user.ts']), + }) + }, + timeout, + ) + test( + 'client: the importer of a denied file of a dependency gets the real module, and is not reported', + async () => { + const { package: used, reported } = await outcome('client') + expect({ package: used, reported }).toEqual({ + package: realModule('package'), + reported: expect.not.arrayContaining([ + 'client src/app/package-user.ts', + ]), + }) + }, + timeout, + ) + }) +}) + +describe('vite dev: excludeFiles', () => { + /** Loads the entry as a browser would; what its uses read, and the logs. */ + async function outcome( + importProtection: ImportProtectionOptions, + ): Promise<Omit<ExcludedOutcome, 'widget'>> { + const server = await startBrowserProtectedDevServer( + excludedFiles, + importProtection, + ) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${readPrelude} +const use = (fn, loaded) => ({ read: read(fn), loaded: globalThis[loaded] ?? null }) +return { vendor: use(entry.vendorRead, 'vendorLoaded'), package: use(entry.packageRead, 'packageLoaded') }`, + ) + return { + ...(result as Omit<ExcludedOutcome, 'widget' | 'reported'>), + reported: reportedFiles(server), + } + } + + test( + 'custom patterns: the importer of a denied file client.excludeFiles matches gets the real module, and nothing is reported', + async () => { + const { vendor, reported } = await outcome(vendorExcludedOptions) + expect({ vendor, reported }).toEqual({ + vendor: realModule('vendor'), + reported: [], + }) + }, + timeout, + ) + test( + 'default patterns: the importer of the same denied file outside the patterns gets the mock and is reported', + async () => { + const { vendor, reported } = await outcome({}) + expect({ vendor, reported }).toEqual({ + vendor: mockedModule, + reported: expect.arrayContaining(['client src/app/vendor-user.ts']), + }) + }, + timeout, + ) + test( + 'default patterns: the importer of a denied file of a dependency gets the real module, and is not reported', + async () => { + const { package: used, reported } = await outcome({}) + expect({ package: used, reported }).toEqual({ + package: realModule('package'), + reported: expect.not.arrayContaining([ + 'client src/app/package-user.ts', + ]), + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/known-bugs-dev.test.ts b/packages/start-plugin-core/tests/integration/importProtection/known-bugs-dev.test.ts new file mode 100644 index 0000000000..750d11ffbb --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/known-bugs-dev.test.ts @@ -0,0 +1,720 @@ +/** + * Known import-protection bugs, continued from known-bugs.test.ts (two + * files, to keep each within the per-file time budget): Vite dev with + * `behavior: 'error'`, Rsbuild dev, and the app-level twins of the mock + * pins. Each test asserts correct behaviour for a bug on main and is marked + * .fails; remove .fails when the bug is fixed. A mock is told by what it + * does (`mock-helpers.ts`, `describeValue`: `a safe mock`), and a violation + * by what `onViolation` receives. + */ +import { createRequire } from 'node:module' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { afterEach, describe, expect, test, vi } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + distinct, + factoryTopLevelCall, + rejection, + reportedImporters, + reportedViolations, + serverFnFactoryApp, + startProtectedDevServer, + violationRecorder, +} from '../../importProtection/start-apps' +import { originalLocation } from '../../importProtection/original-location' +import { + runRsbuildClient, + runViteClient, + startBrowserProtectedDevServer, + startBrowserRsbuildDevServer, +} from './client-pages' +import type { RsbuildConfig } from '@rsbuild/core' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const require = createRequire(import.meta.url) + +describe('Vite dev, behavior "error"', () => { + /** + * `serverFnFactoryApp` with a top-level call of the denied `getRequest()` + * in `module` (the server fn factory module or another one), without the + * leak (behavior "error" stops at the first violation). + */ + const topLevelCallApp = (module: 'src/factory.ts' | 'src/other.ts') => { + const app: Record<string, string> = { + ...serverFnFactoryApp( + module === 'src/factory.ts' ? factoryTopLevelCall : '', + ), + 'src/entry.ts': `export { fn } from './usage'\nexport * from './other'\n`, + 'src/other.ts': + module === 'src/other.ts' + ? `import { getRequest } from '@tanstack/react-start/server'\n${factoryTopLevelCall}` + : `export const other = 1\n`, + } + delete app['src/leak.ts'] + return app + } + + /** + * The importers of the violations loading the app's modules reports + * (`onViolation`), or `'loaded'`. (Not the modules of + * `@tanstack/react-start/server`, which imports Start's entries, which + * only Start's whole plugin provides.) + */ + async function loadOutcome(files: Record<string, string>) { + const server = await startProtectedDevServer(files, { behavior: 'error' }) + const failed = await rejection( + server.load('/src/entry.ts', { skip: /^\/@(vite|fs)\// }), + ).then( + () => true, + () => false, + ) + // (each time the import resolves, with behavior "error") + return failed ? distinct(reportedImporters(server)) : 'loaded' + } + + // Control for the pin below (same harness): a top-level call of a denied + // specifier in a module the Start compiler did not look up fails to load. + test('a module calling a denied import at the top level fails to load', async () => { + expect(await loadOutcome(topLevelCallApp('src/other.ts'))).toEqual([ + 'client src/other.ts', + ]) + }, 30_000) + + // Bug: the Start compiler resolves the imports of a server fn factory + // module with a lookup query (`SERVER_FN_LOOKUP`), and import protection + // records the module as a lookup module by its path without the query + // (`serverFnLookupModules`, vite/import-protection-plugin/plugin.ts + // `resolveId`). The client's own transform of the module then counts as a + // lookup too, whose violations behavior "error" silences in dev (no later + // verification). + // Impact: in dev with behavior "error", the client of a server fn factory + // module that calls a denied import (here `getRequest()` of + // `@tanstack/react-start/server`) at the top level gets the real module, + // without any error; in mock mode the same module is mocked and logged + // (dev.test.ts "a server fn factory module that also calls a denied import + // at the top level is logged"). + // Source: mutation testing. + test.fails( + 'a server fn factory module calling a denied import at the top level fails to load', + async () => { + expect(await loadOutcome(topLevelCallApp('src/factory.ts'))).toEqual([ + 'client src/factory.ts', + ]) + }, + 30_000, + ) + + // Bug: same cause as the pin above, one module further: when the Start + // compiler's lookup of a server fn factory module resolves the module's + // imports, import protection records each imported module as a lookup + // module too (vite/import-protection-plugin/plugin.ts `resolveId`, + // "Propagate pre-transform status transitively"), by its path, so the + // client's own transform of that module is silenced as well. + // Impact: in dev with behavior "error", any module a server fn factory + // module imports gets the real denied module when it calls it at the top + // level, without any error (the control above fails to load). + // Source: mutation testing. + test.fails( + 'a module a server fn factory module imports, calling a denied import at the top level, fails to load', + async () => { + const app = topLevelCallApp('src/other.ts') + app['src/factory.ts'] += `export { request } from './other'\n` + app['src/entry.ts'] = `export { fn } from './usage'\n` + expect(await loadOutcome(app)).toEqual(['client src/other.ts']) + }, + 30_000, + ) +}) + +describe('Rsbuild dev', () => { + /** + * Only a guard against a compile that never comes, never shorter than the + * test's timeout (rsbuild/import-protection.test.ts). + */ + const timeout = 60_000 + const compileTimeout = timeout + + /** + * A custom module type of the app: an Rspack rule takes `.page` files as + * JavaScript (no other compiler; the real MDX loader is below). + */ + const pageModules: RsbuildConfig = { + tools: { + rspack: { + module: { rules: [{ test: /\.page$/, type: 'javascript/auto' }] }, + }, + }, + } + + // Control for the pins below (same config and import protection): a + // module of that type is compiled, and its code runs in the client. + test( + 'a module of a custom type without a denied import runs in the client', + async () => { + const server = await startBrowserRsbuildDevServer({ + compileTimeout, + importProtection: { + behavior: 'error', + client: { specifiers: ['db-lib'] }, + }, + config: pageModules, + files: { + 'src/home.page': `export const page = () => 'MARK_PAGE'\n`, + 'src/entry.ts': `import { page } from './home.page'\nconsole.log(page())\n`, + }, + }) + // Nothing fails, on any channel + expect( + findDiagnostics(server.diagnostics, { severity: 'error' }), + ).toEqual([]) + expect( + (await runRsbuildClient(server)).filter((text) => + text.includes('MARK_'), + ), + ).toEqual(['MARK_PAGE']) + }, + timeout, + ) + + // Bug: Rsbuild import protection checks importers by file extension + // (`isImportProtectionSourceFile`, rsbuild/import-protection.ts, only + // JS/TS extensions), and its loader rule only rewrites those files, so an + // importer of another module type that compiles to JS (a custom type + // here, `.mdx` through its real loader below) is never checked: a denied + // file is mocked (the file rule) but not reported, and a denied specifier + // is neither reported nor mocked. + // Impact: behavior "error" does not fail for denied imports of such + // modules, and the real code of a denied specifier runs on the client. + // Source: mutation testing; the JS/TS + // extensions are covered by rsbuild/import-protection.test.ts "is reported + // when it is a .$extension file". + test.fails.each<{ name: string; files: Record<string, string> }>([ + { + name: 'a denied file', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/home.page': `import { secret } from './secret.server'\nexport const page = () => secret()\n`, + }, + }, + { + name: 'a denied specifier', + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const secret = () => 'MARK_LIB'\n`, + 'src/home.page': `import { secret } from 'db-lib'\nexport const page = () => secret()\n`, + }, + }, + ])( + 'a module of a custom type importing $name is reported, and its real code does not run', + async ({ files }) => { + const recorder = violationRecorder({ + behavior: 'error', + client: { specifiers: ['db-lib'] }, + }) + const server = await startBrowserRsbuildDevServer({ + compileTimeout, + importProtection: recorder.importProtection, + config: pageModules, + files: { + ...files, + 'src/entry.ts': `import { page } from './home.page'\nconsole.log(page())\n`, + }, + }) + const messages = await runRsbuildClient(server) + expect({ + reported: reportedImporters({ + root: server.root, + violations: recorder.violations, + }), + ranRealCode: messages.some((message) => message.includes('MARK_')), + }).toEqual({ reported: ['client src/home.page'], ranRealCode: false }) + }, + timeout, + ) + + /** MDX pages through the real MDX loader, as an Rsbuild app adds it. */ + const mdxModules: RsbuildConfig = { + output: { sourceMap: { js: 'source-map' } }, + tools: { + rspack: { + module: { + rules: [ + { + test: /\.mdx$/, + use: [{ loader: require.resolve('@mdx-js/loader') }], + }, + ], + }, + }, + }, + } + + // The same bug through the real `@mdx-js/loader`: the page is + // compiled from MDX, with the loader's source map; a report names the page + // at the import (line 3) or the use (4:27) in the .mdx + // source (SPEC J6.5). + test.fails.each<{ name: string; files: Record<string, string> }>([ + { + name: 'a denied file', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/home.mdx': `# Home + +import { secret } from './secret.server' +export const page = () => secret() +`, + }, + }, + { + name: 'a denied specifier', + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const secret = () => 'MARK_LIB'\n`, + 'src/home.mdx': `# Home + +import { secret } from 'db-lib' +export const page = () => secret() +`, + }, + }, + ])( + 'an .mdx page importing $name is reported in its source, and its real code does not run', + async ({ files }) => { + const recorder = violationRecorder({ + behavior: 'error', + client: { specifiers: ['db-lib'] }, + }) + const server = await startBrowserRsbuildDevServer({ + compileTimeout, + importProtection: recorder.importProtection, + config: mdxModules, + files: { + ...files, + 'src/entry.ts': `import { page } from './home.mdx'\nconsole.log(page())\n`, + }, + }) + const messages = await runRsbuildClient(server) + expect({ + reported: reportedViolations({ + root: server.root, + violations: recorder.violations, + }).map(({ environment, importer }) => `${environment} ${importer}`), + ranRealCode: messages.some((message) => message.includes('MARK_')), + }).toEqual({ + reported: [originalLocation('client src/home.mdx:4:27', 3)], + ranRealCode: false, + }) + }, + timeout, + ) + + // Control for the pins above (same loader): the page compiles and runs. + test( + 'an .mdx page without a denied import runs in the client', + async () => { + const server = await startBrowserRsbuildDevServer({ + compileTimeout, + importProtection: { behavior: 'error' }, + config: mdxModules, + files: { + 'src/home.mdx': `# Home + +export const page = () => 'MARK_PAGE' +`, + 'src/entry.ts': `import { page } from './home.mdx'\nconsole.log(page())\n`, + }, + }) + // Nothing fails, on any channel + expect( + findDiagnostics(server.diagnostics, { severity: 'error' }), + ).toEqual([]) + expect( + (await runRsbuildClient(server)).filter((text) => + text.includes('MARK_'), + ), + ).toEqual(['MARK_PAGE']) + }, + timeout, + ) + + // In Rsbuild dev, an error thrown by `onViolation` (awaited in the + // `processAssets` hook, rsbuild/import-protection.ts `reportViolation`) + // fails the compile: Rspack gives up on it (`compiler.hooks.failed`, no + // `done`) and Rsbuild logs the error, like a build fails with it. + // Source: mutation testing. This was a pin ("never reported") while the + // dev harness only waited for `done`; the harness now fails the compile + // wait with the error Rspack reports. + test( + 'an onViolation that throws ends the compile with its error', + async () => { + const outcome = await startBrowserRsbuildDevServer({ + importProtection: { + onViolation: () => { + throw new Error('MARK_THROWN') + }, + }, + // Only a guard: the failed compile ends the wait. + compileTimeout, + files: { + 'src/secret.server.ts': `export const secret = () => 'secret'\n`, + 'src/entry.ts': `import { secret } from './secret.server'\nconsole.log(secret())\n`, + }, + }).then( + (server) => + findDiagnostics(server.diagnostics, { severity: 'error' }) + .map(({ text }) => text) + .join('\n'), + (error: Error) => error.message, + ) + expect(outcome).toContain('MARK_THROWN') + }, + timeout, + ) +}) + +/** + * App-level twins of the pins on internal functions (the rewrite and the + * mock modules): a real app with each input, on a Vite dev server (mock + * mode, the dev default) and in mock-mode builds. `src/entry.ts` exports + * `read()`, which returns what the app gets from its denied import, as an + * array of values; each must be a safe mock (`a safe mock`) unless a row + * expects a real value, and the app must load or build. + * Source: review (missing coverage, computed keys). + */ +describe('app-level twins of the mock pins', () => { + afterEach(() => { + vi.restoreAllMocks() + }) + + /** A dependency `name` exporting `query` and `epsilon`, denied by `client.specifiers`. */ + const deniedDependency = (name: string) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: { '.': './index.js' }, + }), + [`node_modules/${name}/index.js`]: `export const query = () => 'MARK_SECRET' +export const epsilon = () => ({ deep: () => 'MARK_SECRET' }) +`, + }) + + const mock = 'a safe mock' + + /** A custom JSX runtime whose `jsx` renders `MARK_CUSTOM_JSX`. */ + const customJsx = { + 'node_modules/custom-jsx/package.json': JSON.stringify({ + name: 'custom-jsx', + type: 'module', + exports: { + './jsx-runtime': './jsx-runtime.js', + './jsx-dev-runtime': './jsx-runtime.js', + }, + }), + 'node_modules/custom-jsx/jsx-runtime.js': `export const Fragment = Symbol('Fragment') +export const jsx = () => 'MARK_CUSTOM_JSX' +export const jsxs = jsx +export const jsxDEV = jsx +`, + } + + interface TwinCase { + files: Record<string, string> + importProtection?: ImportProtectionOptions + /** What `entry.read()` gives, described (default: one safe mock). */ + expected?: Array<string> + } + + const twins: Record<string, TwinCase> = { + // Twin of the rewrite pin "a denied namespace re-export keeps its + // exported name" (a former in-process pin). + 'a module re-exporting a denied file as a namespace': { + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/barrel.ts': `export * as secrets from './secret.server'\n`, + 'src/entry.ts': `import { secrets } from './barrel' +export const read = () => [secrets.secret()] +`, + }, + }, + // Twin of "a namespace re-export" (the mock of a denied file). + 'a denied file re-exporting a namespace': { + files: { + 'src/helpers.ts': `export const format = () => 'MARK_SECRET'\n`, + 'src/lib.server.ts': `export * as helpers from './helpers'\n`, + 'src/entry.ts': `import { helpers } from './lib.server' +export const read = () => [helpers.format()] +`, + }, + }, + // Twin of "the mock of a denied file exporting `delete` exports it" and + // "a denied import used as `api.delete()` evaluates to a mock". + 'a denied file exporting `delete`, used as `api.delete()`': { + files: { + 'src/api.server.ts': `const remove = () => 'MARK_SECRET' +export { remove as delete } +`, + 'src/entry.ts': `import * as api from './api.server' +export const read = () => [api.delete()] +`, + }, + }, + // Same bug, the other names a module cannot bind. + 'a denied file exporting `eval` and `arguments`': { + files: { + 'src/api.server.ts': `const a = () => 'MARK_SECRET' +const b = () => 'MARK_SECRET' +export { a as eval, b as arguments } +`, + 'src/entry.ts': `import * as api from './api.server' +export const read = () => [api.eval(), api.arguments()] +`, + }, + expected: [mock, mock], + }, + // A JSX pragma leading a denied import: the page renders with the + // runtime its pragma names (a custom JSX runtime is valid user input), + // whatever the rewrite does with the comment (SPEC J2.16, §5 item 5). + 'a JSX pragma leading a denied import': { + files: { + ...customJsx, + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/page.tsx': `/** @jsxImportSource custom-jsx */ +import { secret } from './secret.server' +export const Page = () => <div>{String(secret())}</div> +`, + 'src/entry.ts': `import { Page } from './page' +export const read = () => [Page()] +`, + }, + expected: ['MARK_CUSTOM_JSX'], + }, + // The same pragma leading the import of a denied specifier, which is + // rewritten in the importer itself (a denied file is mocked in its own + // module instead). + 'a JSX pragma leading the import of a denied specifier': { + files: { + ...customJsx, + ...deniedDependency('db-lib'), + 'src/page.tsx': `/** @jsxImportSource custom-jsx */ +import { query } from 'db-lib' +export const Page = () => <div>{String(query())}</div> +`, + 'src/entry.ts': `import { Page } from './page' +export const read = () => [Page()] +`, + }, + importProtection: { client: { specifiers: ['db-lib'] } }, + expected: ['MARK_CUSTOM_JSX'], + }, + // The pragma after a directive (a regression of the Yuku migration, PR + // #8504, kept the comment of this shape only). + 'a JSX pragma after a directive, leading the import of a denied specifier': + { + files: { + ...customJsx, + ...deniedDependency('db-lib'), + 'src/page.tsx': `'use client' +/** @jsxImportSource custom-jsx */ +import { query } from 'db-lib' +export const Page = () => <div>{String(query())}</div> +`, + 'src/entry.ts': `import { Page } from './page' +export const read = () => [Page()] +`, + }, + importProtection: { client: { specifiers: ['db-lib'] } }, + expected: ['MARK_CUSTOM_JSX'], + }, + // Twin of "a namespace member read before the import". + 'a namespace member read in a function declared before the import': { + files: { + ...deniedDependency('db-lib'), + 'src/entry.ts': `export function read() { + return [db.query()] +} +import * as db from 'db-lib' +`, + }, + importProtection: { client: { specifiers: ['db-lib'] } }, + }, + // A namespace member read with a computed key (SPEC J6.8, `ns[key]`): + // the key names a real export of the denied file, and a deeper member + // of what it gives. + 'a namespace member read with a computed key, of a denied file': { + files: { + 'src/model.server.ts': `export const epsilon = () => ({ deep: () => 'MARK_SECRET' })\n`, + 'src/entry.ts': `import * as ns from './model.server' +const key = 'epsilon' +export const read = () => [ns[key](), ns[key]().deep()] +`, + }, + expected: [mock, mock], + }, + 'a namespace member read with a computed key, of a denied specifier': { + files: { + ...deniedDependency('db-lib'), + 'src/entry.ts': `import * as ns from 'db-lib' +const key = 'epsilon' +export const read = () => [ns[key](), ns[key]().deep()] +`, + }, + importProtection: { client: { specifiers: ['db-lib'] } }, + expected: [mock, mock], + }, + // Twin of "an enum and a namespace" (the mock of a denied file). + 'a denied file exporting an enum and a namespace': { + files: { + 'src/model.server.ts': `export enum Color { + Red = 'MARK_SECRET', +} +export namespace Util { + export const x = 'MARK_SECRET' +} +`, + 'src/entry.ts': `import { Color, Util } from './model.server' +export const read = () => [Color.Red, Util.x] +`, + }, + expected: [mock, mock], + }, + } + + /** + * The channels on which main fails each twin (`.fails`, red reason in + * brackets). The JSX pragma twins pass everywhere: Vite (Oxc) and Rsbuild + * (SWC) compile JSX before import protection rewrites the import. (A + * former in-process pin, "a JSX pragma that leads a denied import stays in + * effect", needed a JSX plugin that runs after the rewrite; none of the + * available real plugins does, so it was removed.) + */ + const failsOn: Record<string, Array<string>> = { + // Bug: the dev rewrite of the importer drops `export * as ns` (the + // rewrite pin "a denied namespace re-export keeps its exported name", + // import-protection/rewrite.ts). + // Impact: in dev, the page fails to load [SyntaxError: '/src/barrel.ts' + // does not provide an export named 'secrets']. Builds mock the denied + // file itself and pass. + 'a module re-exporting a denied file as a namespace': ['vite dev'], + // Bug: the export names of a denied file skip namespace re-exports + // (`export * as ns from`; import-protection/analysis.ts collects only + // the names of `ExportSpecifier`s), so the self-contained mock of the + // file has no `helpers`. + // Impact: a mock-mode build fails [Vite MISSING_EXPORT, Rspack + // ESModulesLinkingError 'helpers']. Vite dev passes. + 'a denied file re-exporting a namespace': ['vite build', 'rsbuild build'], + // Bug: mock modules declare each mocked name as `export const <name>`, + // and reserved words such as `delete` pass the identifier check + // (`isValidExportName`, import-protection/analysis.ts); `eval` and + // `arguments` cannot be bound in a module either. + // Impact: the dev page and mock-mode builds fail with a parse error + // [Unexpected token 'delete'; PARSE_ERROR; Expected ident]. + 'a denied file exporting `delete`, used as `api.delete()`': [ + 'vite dev', + 'vite build', + 'rsbuild build', + ], + 'a denied file exporting `eval` and `arguments`': [ + 'vite dev', + 'vite build', + 'rsbuild build', + ], + // Bug: namespace member reads are collected only after the import + // declaration that binds the namespace, but imports are hoisted: a + // member read earlier in the file is not exported by the mock edge of + // a denied specifier (the mock edge exports only the members read + // after the import). Rsbuild mocks the whole namespace and passes. + // Impact: the read gets `undefined` [db.query is not a function; Vite + // build: (void 0) is not a function]. + // Source: PR #8504 (analysis.exports.test.ts "collects namespace member + // usage that precedes the import"). + 'a namespace member read in a function declared before the import': [ + 'vite dev', + 'vite build', + ], + // Bug: the mock edge of a denied specifier exports only the names the + // importer reads statically; a member read with a computed key is no + // export of it, so `ns[key]` is `undefined`. A denied file is mocked by + // its own exports and passes; Rsbuild mocks the whole namespace. + // Impact: the read gets `undefined` [ns[key] is not a function]. + 'a namespace member read with a computed key, of a denied specifier': [ + 'vite dev', + 'vite build', + ], + // NEW bug (Rsbuild), not the internal pin's cause (Vite passes): a + // mock-mode Rsbuild production build ships the real value of an enum + // member of a denied file [read 'MARK_SECRET', the bundle contains + // MARK_SECRET]; the namespace member is mocked. + // Cause: Rsbuild's production SWC config collects exported enums + // (`collectTypeScriptInfo.exportedEnum: isProd`), and Rspack inlines + // `Color.Red` into the importer (`"MARK_SECRET"`) from the + // denied file's own source; the import-protection loader's mock (which + // does export `Color`) is never read. A scratch build with + // `exportedEnum: false` mocks it. + // Impact: server-only values declared as enum members reach the client + // bundle in mock mode (`behavior: { build: 'mock' }`), with only a + // warning. + 'a denied file exporting an enum and a namespace': ['rsbuild build'], + } + + const twinTest = (channel: string, name: string) => + (failsOn[name] ?? []).includes(channel) ? test.fails : test + + for (const [name, twin] of Object.entries(twins)) { + const { files, importProtection = {}, expected = [mock] } = twin + twinTest('vite dev', name)( + `vite dev: ${name}`, + async () => { + const server = await startBrowserProtectedDevServer( + files, + importProtection, + ) + // The mock reports each use in the browser console. + vi.spyOn(console, 'error').mockImplementation(() => {}) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${describeValuePrelude} +return entry.read().map((value) => describeValue(value, 'MARK_SECRET'))`, + ) + expect(result).toEqual(expected) + }, + 30_000, + ) + for (const bundler of startBundlers) { + twinTest(`${bundler} build`, name)( + `${bundler} build, mock mode: ${name}`, + async () => { + const { client } = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start: { + importProtection: { + ...importProtection, + behavior: 'mock', + mockAccess: 'off', + }, + }, + }) + expect({ + read: ( + await client.run(`${describeValuePrelude} +return entry.read().map((value) => describeValue(value, 'MARK_SECRET'))`) + ).result, + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + }).toEqual({ read: expected, hasRealCode: false }) + }, + 60_000, + ) + } + } +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/known-bugs.test.ts b/packages/start-plugin-core/tests/integration/importProtection/known-bugs.test.ts new file mode 100644 index 0000000000..b748ab4f7e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/known-bugs.test.ts @@ -0,0 +1,303 @@ +/** + * Known import-protection bugs. Each test asserts correct behaviour for a bug + * on main and is marked .fails; remove .fails when the bug is fixed. A mock + * is told by what it does (`mock-helpers.ts`, `describeValue`: `a safe + * mock`), and a violation by what `onViolation` receives. + */ +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { + inEnvironment, + rejection, + reportedViolations, +} from '../../importProtection/start-apps' + +/** + * Start's import protection options of a build that denies `files` to the + * client and fails on a violation. + */ +function denyToClient(files: Array<string>) { + return { importProtection: { behavior: 'error', client: { files } } } as const +} + +/** Same as `denyToClient`, mocking the denied modules instead. */ +function mockToClient(files: Array<string>) { + return { importProtection: { behavior: 'mock', client: { files } } } as const +} + +/** A denied module whose code marks the bundle it is in. */ +const corpusModule = `function initialize() { + ;(globalThis as Record<string, unknown>).corpusInitialized = true + return () => 'MARK_CORPUS' + Math.random() +} +export const corpus = /*#__PURE__*/ initialize() +` + +/** + * A client entry re-exporting a server fn of `layout.ts`, which also + * exports a function using the denied-to-be `corpus.ts` that nothing calls. + * Import protection checks the modules of the source directory (`src`). + */ +const droppedCorpusFiles = { + 'src/corpus.ts': corpusModule, + 'src/layout.ts': `import { createServerFn } from '@tanstack/react-start' +import { corpus } from './corpus' +export const size = () => corpus() +export const nav = createServerFn().handler(async () => 1) +`, + 'src/entry.ts': `export { nav } from './layout'\n`, +} + +describe.each(startBundlers)('%s build', (bundler) => { + // Control for the pin below (same harness): a denied module whose code the + // client bundle contains fails the build. + test('a denied module the client uses fails the build', async () => { + const error = await rejection( + buildStart({ + bundler, + files: { + 'src/corpus.ts': corpusModule, + 'src/entry.ts': `import { corpus } from './corpus'\nexport const read = () => corpus()\n`, + }, + entry: 'src/entry.ts', + start: denyToClient(['**/corpus.ts']), + }), + ) + expect( + reportedViolations(error).map(({ environment }) => environment), + ).toEqual(['client']) + }, 60_000) + + // Control for the pin below (same files, no import protection): the client + // bundle does not contain the module's code. + test('without import protection, the client bundle drops the unused module', async () => { + const { client } = await buildStart({ + bundler, + files: droppedCorpusFiles, + entry: 'src/entry.ts', + start: { importProtection: { enabled: false } }, + }) + expect(client.where('MARK_CORPUS')).toBe('nowhere') + }, 60_000) + + // Control for the pins below (same harness and files, import protection + // on): the build succeeds in mock mode, without the module's code. + test('in mock mode, the client bundle drops the unused module', async () => { + const { client } = await buildStart({ + bundler, + files: droppedCorpusFiles, + entry: 'src/entry.ts', + start: mockToClient(['**/corpus.ts']), + }) + expect(client.where('MARK_CORPUS')).toBe('nowhere') + }, 60_000) + + // Bug: the build check counts a denied module as surviving when the + // compilation contains it, whether or not the client uses it. Vite: the + // mock that replaces the module is never tree-shaken, because its exports + // read members of the mock (`export const corpus = mock.corpus`, + // import-protection/virtualModules.ts), which the bundler keeps (with + // side-effect-free exports, a scratch run passes this pin on Vite). + // Rsbuild: the report step walks every module of the module graph + // (connections are not filtered by whether they are used, + // INTERNALS-import-protection.md). + // Impact: a denied module that a client-reachable module imports, but that + // the client never uses, still fails the build. + // Source: issue #8101 (closed without a reproduction). + test.fails( + 'a denied module the client bundle drops does not fail the build', + async () => { + const { client } = await buildStart({ + bundler, + files: droppedCorpusFiles, + entry: 'src/entry.ts', + start: denyToClient(['**/corpus.ts']), + }) + expect(client.where('MARK_CORPUS')).toBe('nowhere') + }, + 60_000, + ) + + // Bug: same as above, in mock mode: the mock of a denied module the client + // never uses stays in the client bundle, and the build warns about it. + // The mock module is marked side-effect free (`@__NO_SIDE_EFFECTS__`, + // `@__PURE__`), but its exports read members of the mock. + // Impact: mock-mode builds ship mock code (a Proxy runtime) for unused + // imports, and report violations the client never reaches. + // Source: review (the check "returns mock code" of virtualModules.test.ts + // asserted the purity annotations as text). + // Judged by what the user sees: + // no report on any channel, no code or effect of the module in the + // bundle; not by comparing the bundle's statements with another build's. + // The live-denial controls show the same harness sees a used mock: its + // report, its safe value, and the real value without protection. + test.fails( + 'in mock mode, an unused denied module leaves nothing in the client bundle and no warning', + async () => { + // (one build at a time: a Vite build runs in its app's directory) + const mocked = await buildStart({ + bundler, + files: droppedCorpusFiles, + entry: 'src/entry.ts', + start: mockToClient(['**/corpus.ts']), + }) + const usedFiles = { + ...droppedCorpusFiles, + 'src/entry.ts': `export { size } from './layout'\n`, + } + const used = await buildStart({ + bundler, + files: usedFiles, + entry: 'src/entry.ts', + start: mockToClient(['**/corpus.ts']), + }) + const usedDisabled = await buildStart({ + bundler, + files: usedFiles, + entry: 'src/entry.ts', + start: { importProtection: { enabled: false } }, + }) + expect(reportedViolations(inEnvironment(used, 'client'))).toHaveLength(1) + expect( + ( + await used.client.run( + `${describeValuePrelude}\nreturn describeValue(entry.size(), 'MARK_CORPUS')`, + ) + ).result, + ).toBe('a safe mock') + expect( + (await usedDisabled.client.run('return entry.size()')).result, + ).toContain('MARK_CORPUS') + // Nothing reported, on any channel + expect(reportedViolations(mocked)).toEqual([]) + expect(problems(mocked.diagnostics).map(({ text }) => text)).toEqual([]) + expect(mocked.client.where('MARK_CORPUS')).toBe('nowhere') + expect( + (await mocked.client.run('return globalThis.corpusInitialized ?? null')) + .result, + ).toBe(null) + }, + 60_000, + ) +}) + +describe.each(startBundlers)('%s build', (bundler) => { + // Bug (Rsbuild): a dynamic `import('db-lib')` of a denied specifier is + // neither reported nor mocked: the Rsbuild loader only rewrites static + // imports and re-exports (`rewriteDeniedImports`, + // import-protection/rewrite.ts), and the build reports specifier + // violations only through the mock modules of rewritten imports + // (`processAssets` in rsbuild/import-protection.ts). Vite fails the build. + // Impact: the real module ships to the client in a lazy chunk and runs + // there, without any error or warning. + // Source: mutation testing. + const dynamicImportTest = bundler === 'rsbuild' ? test.fails : test + dynamicImportTest( + 'a client dynamic import of a denied specifier fails the build, reporting one client violation', + async () => { + const error = await rejection( + buildStart({ + bundler, + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const secret = () => 'MARK_SECRET'\n`, + 'src/entry.ts': `export const read = () => import('db-lib').then((m) => m.secret())\n`, + }, + entry: 'src/entry.ts', + start: { importProtection: { client: { specifiers: ['db-lib'] } } }, + }), + ) + expect( + reportedViolations(error).map(({ environment }) => environment), + ).toEqual(['client']) + }, + 60_000, + ) + + /** + * What the client gets in a mock-mode build of an entry that imports + * `secret` from the denied `file` (control: the mock-mode rows of + * build.test.ts, same harness). + */ + async function mockModeOutcome( + file: string, + code: string, + importStatement: string, + ) { + const build = await buildStart({ + bundler, + files: { + [`src/${file}`]: code, + 'src/entry.ts': `${importStatement} +export const read = () => secret +`, + }, + entry: 'src/entry.ts', + start: { importProtection: { behavior: 'mock', mockAccess: 'off' } }, + }) + const { client } = build + return { + warned: reportedViolations(inEnvironment(build, 'client')).length > 0, + hasRealCode: client.where('MARK_SECRET') !== 'nowhere', + read: ( + await client.run(`${describeValuePrelude} +return describeValue(entry.read(), 'MARK_SECRET')`) + ).result, + } + } + + // Bug: in mock mode, a denied file that is not JavaScript or TypeScript + // keeps its content: Vite replaces a denied file with its mock in a + // transform hook whose filter only lets JS/TS modules through + // (`/\.[cm]?[tj]sx?($|\?)/`, transform-cache plugin of + // vite/import-protection-plugin/plugin.ts), and the Rsbuild loader rule + // only applies to JS/TS modules (`test: /\.[cm]?[tj]sx?$/`, + // rsbuild/import-protection.ts). Both warn. + // Impact: a mock-mode build ships the real content of a denied + // `*.server.json` (e.g. server configuration or credentials) to the client. + // Source: mutation testing. + test.fails( + 'in mock mode, a denied .server.json file is mocked, with a warning', + async () => { + expect( + await mockModeOutcome( + 'secret.server.json', + `{ "secret": "MARK_SECRET" }\n`, + `import data from './secret.server.json' +const secret = data.secret`, + ), + ).toEqual({ warned: true, hasRealCode: false, read: 'a safe mock' }) + }, + 60_000, + ) + + // Bug: in mock mode, a denied CommonJS file (`.server.cjs`) fails the + // build: the mock that replaces the file is an ES module, which Vite's + // parser rejects in a `.cjs` file (`export default mock`), and whose named + // exports are the ES exports of the denied file, which a CommonJS file has + // none of, so Rspack cannot link the named import (`export 'secret' ... + // was not found`). With import protection off, both build the named + // import of the real module. + // Impact: a mock-mode build of a project with a `*.server.cjs` the client + // imports fails instead of mocking it. + // Source: mutation testing. + test.fails( + 'in mock mode, a denied .server.cjs file is mocked, with a warning', + async () => { + expect( + await mockModeOutcome( + 'secret.server.cjs', + `exports.secret = () => 'MARK_SECRET'\n`, + `import { secret } from './secret.server.cjs'`, + ), + ).toEqual({ warned: true, hasRealCode: false, read: 'a safe mock' }) + }, + 60_000, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/mock-access.test.ts b/packages/start-plugin-core/tests/integration/importProtection/mock-access.test.ts new file mode 100644 index 0000000000..6acfcc759d --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/mock-access.test.ts @@ -0,0 +1,187 @@ +/** + * The runtime side of dev mocks on a Vite dev server with Start's whole + * public plugin (SPEC J6.3, J6.8): in the browser, a client import of a + * denied file or of a denied specifier gets a safe mock whatever + * `mockAccess` says, a call of the mock is reported in the browser console + * with the severity `mockAccess` gives (`error`, `warn`), naming the denied + * import, and with `mockAccess: 'off'` no use of it is reported or has a side + * effect. Which other uses of a mock are reported (a conversion to a string, + * `toString()`, `new`, a property write) is free (SPEC J6.3, §5.18). What is + * reported is read through the shared diagnostic oracle: the severity and + * the denied import, never the prose (J6.12). (The Rsbuild twin: + * `integration/rsbuild/import-protection.test.ts`, "Rsbuild dev: + * mockAccess"; builds: `build.test.ts`, mock mode.) + * + * Replaces the internal controls that evaluated today's generated dev mock + * modules and mock runtime in process + * (main's `importProtection/virtualModules.test.ts`). + */ +import { afterAll, describe, expect, test } from 'vitest' +import { startDevServer } from '../../dev-server' +import { + expectMockAccess, + probeMockPrelude, + safeMock, + warningsAndErrors, +} from '../../importProtection/mock-helpers' +import { clientFixturePlugin, runViteClient } from './client-pages' +import type { ImportProtectionOptions } from '../../importProtection/public-types' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +const timeout = 30_000 + +/** + * `src/secret.server.ts` (a denied file) and `db-lib` (a package denied by + * a specifier rule), both used by the client through `src/uses.ts`. + */ +const files = { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const query = () => 'MARK_LIB'\n`, + 'src/secret.server.ts': `export const getSecret = () => 'MARK_SECRET' +export const api = { Client: class {} } +`, + 'src/uses.ts': `import { api, getSecret } from './secret.server' +import { query } from 'db-lib' +export const denied = { getSecret, api, query } +`, + 'src/entry.ts': `export { denied } from './uses'\n`, +} + +/** The denied imports and how a report may name each. */ +const deniedImports = [ + { + name: 'getSecret', + specifier: './secret.server', + file: 'src/secret.server.ts', + }, + { name: 'query', specifier: 'db-lib' }, +] as const + +/** Uses of a mock a page may make, as page scripts on `value`. */ +const uses: Record<string, string> = { + 'a call': `value()`, + 'a conversion to a string': `String(value)`, + 'a toString() call': `value.toString()`, + '`new`': `new value()`, + 'a property write': `value.written = 1`, +} + +const servers = new Map<string, Promise<DevServer>>() +const cleanups: Array<() => Promise<void>> = [] +afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) +}) + +/** + * The dev server of `mockAccess`, started once for the file: Start's whole + * plugin, the router entry `src/entry.ts`, the page of `client-pages.ts`. + */ +function serverOf(mockAccess: ImportProtectionOptions['mockAccess']) { + const key = String(mockAccess) + let server = servers.get(key) + if (!server) { + server = startDevServer({ + files, + browser: true, + registerCleanup: (cleanup) => cleanups.push(cleanup), + plugins: [clientFixturePlugin], + start: { + router: { entry: 'entry.ts' }, + importProtection: { client: { specifiers: ['db-lib'] }, mockAccess }, + }, + }) + servers.set(key, server) + } + return server +} + +/** + * Runs `script` (with the denied value `name` as `value`) in a new page of + * the server of `mockAccess`: what it returns, and the warnings and errors + * the page's code logged. + */ +async function inPage( + mockAccess: ImportProtectionOptions['mockAccess'], + name: string, + script: string, +) { + const server = await serverOf(mockAccess) + const { result, diagnostics } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +const value = entry.denied.${name} +${script}`, + ) + return { + result, + logged: warningsAndErrors(diagnostics), + all: diagnostics.map(({ severity, text }) => `${severity}: ${text}`), + } +} + +const modes = ['error', 'warn', 'off'] as const + +describe.each(deniedImports)('a client import of $specifier', (denied) => { + test.each(modes)( + 'mockAccess %s: the client gets a safe mock, and what it gives is one too', + async (mockAccess) => { + const { result } = await inPage( + mockAccess, + denied.name, + `return [probeMock(value, 'MARK_'), probeMock(value(), 'MARK_'), probeMock(value.member, 'MARK_')]`, + ) + expect(result).toEqual([safeMock, safeMock, safeMock]) + }, + timeout, + ) + + test.each([ + { mockAccess: 'error', severity: 'error' }, + { mockAccess: 'warn', severity: 'warning' }, + ] as const)( + 'mockAccess $mockAccess: a call in the client is reported as an $severity naming the import', + async ({ mockAccess, severity }) => { + const { logged } = await inPage(mockAccess, denied.name, `value()`) + expect([...new Set(logged.map((entry) => entry.severity))]).toEqual([ + severity, + ]) + expectMockAccess(logged, { + severity, + specifier: denied.specifier, + ...('file' in denied && { + file: denied.file, + root: (await serverOf(mockAccess)).root, + }), + }) + }, + timeout, + ) + + // Silent means no side effect a page can see: nothing logged on any + // channel at any severity (the same output as a page that does not use + // the mock), and no global the uses define. + test( + 'mockAccess off: no use is reported, and the uses have no side effect', + async () => { + const control = await inPage('off', denied.name, `return []`) + const { logged, all, result } = await inPage( + 'off', + denied.name, + `const before = new Set(Object.getOwnPropertyNames(globalThis)) +${Object.values(uses).join('\n')} +String(value.member()) +new value.Client() +return Object.getOwnPropertyNames(globalThis).filter((name) => !before.has(name))`, + ) + expect(logged).toEqual([]) + expect(all).toEqual(control.all) + expect(result).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/mock-shapes.test.ts b/packages/start-plugin-core/tests/integration/importProtection/mock-shapes.test.ts new file mode 100644 index 0000000000..62c8bb2d4d --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/mock-shapes.test.ts @@ -0,0 +1,450 @@ +/** + * What a client importer gets for a denied import, for each way of writing + * the import and each shape of the denied module's exports (SPEC J6.8: + * mocking is complete; J6.2: type-only parts are not imports), on a real + * app in mock mode: a Vite dev server with Start's whole public plugin (the + * page in a real browser) and mock-mode Vite and Rsbuild builds (the client + * bundle in a real browser). A mock is told by what it does (`mock-helpers.ts`, + * `describeValue`: `a safe mock`), never by its label or its module. + * + * Two kinds of denied modules: a package denied by a specifier rule + * (`private-sdk`, `other-sdk`, the JSON package `private-config`: the + * importer gets a mock of each name it uses) and denied files (`src/shapes/*.server.ts`: the importer gets a mock + * of each export of the file). Each case is a module of its own under + * `src/cases/` whose `values()` gives what it read from the denied module; + * one app holds every case, so each channel builds or serves it once. + * + * Replaces main's internal tests that evaluated today's generated mock + * modules in process (`importProtection/analysis.exports.test.ts`, + * `rewrite.test.ts`, deleted). The names today's mocks miss + * (reserved words, namespace re-exports, enums, a member read before the + * import, computed keys) are pinned in `known-bugs.test.ts` ("app-level + * twins of the mock pins"); `export *` and `export * as ns` of a denied + * module are pinned there and in `known-bugs-dev-server.test.ts`. + */ +import { afterAll, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { runViteClient, startBrowserProtectedDevServer } from './client-pages' +import type { StartBuild } from '../../build-harness' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const timeout = 60_000 + +/** Names an importer may use, including ones no identifier can spell. */ +const oddNames = [ + 'valid', + '_private', + '$ref', + 'camelCase', + 'A', + '1foo', + 'foo-bar', + 'foo.bar', + 'foo bar', + '~lead', + 'a~b', + 'a:b', + '|x', + 'a^b', + 'default', +] + +/** Names `private-sdk` exports (its real values carry `MARK_SECRET`). */ +const sdkNames = [ + 'alpha', + 'beta', + 'gamma', + 'delta', + 'bar', + 'read', + 'write', + 'value', + 'kebab-name', + 'reexported', + 'a-b', + ...oddNames.filter((name) => name !== 'default'), +] + +/** A package `name` exporting each of `names`, and a default, as secrets. */ +function deniedPackage(name: string, names: Array<string>) { + return { + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: `${names + .map( + (exported, index) => `const v${index} = () => 'MARK_SECRET_${index}'`, + ) + .join('\n')} +export { ${names.map((exported, index) => `v${index} as ${JSON.stringify(exported)}`).join(', ')} } +export default { getSecret: () => 'MARK_SECRET_DEFAULT', 'foo-bar': 'MARK_SECRET_KEBAB' } +`, + } +} + +const quotedImports = (names: Array<string>) => + names.map((name, index) => `${JSON.stringify(name)} as n${index}`).join(', ') + +/** The importer cases of the denied packages: file, then its `values` body. */ +const packageCases: Record<string, string> = { + 'named imports': `import { alpha, beta } from 'private-sdk' +export const values = () => [alpha, beta] +`, + 'a default import': `import def from 'private-sdk' +export const values = () => [def] +`, + '`{ default as x }`': `import { default as myDefault } from 'private-sdk' +export const values = () => [myDefault] +`, + 'namespace members': `import * as ns from 'private-sdk' +export const values = () => [ns.alpha, ns.beta] +`, + 'an optional namespace member call': `import * as ns from 'private-sdk' +export const values = () => [ns.gamma?.()] +`, + 'a string-literal computed namespace member': `import * as ns from 'private-sdk' +export const values = () => [ns['delta']] +`, + 'members of a default import': `import mock from 'private-sdk' +export const values = () => [mock.getSecret, mock['foo-bar']] +`, + 'a value specifier next to a type specifier': `import { type Foo, bar } from 'private-sdk' +export const values = () => [bar as unknown as Foo] +`, + 'several imports of the same source': `import { alpha } from 'private-sdk' +import { beta } from 'private-sdk' +export const values = () => [alpha, beta] +`, + 'a string-keyed import specifier': `import { "foo-bar" as x } from 'private-sdk' +export const values = () => [x] +`, + 'parenthesized namespace calls': `import * as denied from 'private-sdk' +export const values = () => [(denied).read(), (denied)['write']()] +`, + 're-exports': `export { alpha, beta } from 'private-sdk' +`, + 'a string-literal re-export': `export { "foo-bar" as baz } from 'private-sdk' +`, + 'an import and a re-export of the same name': `import { alpha } from 'private-sdk' +export { alpha } from 'private-sdk' +export const used = alpha +`, + 'imports of several denied sources': `import { alpha } from 'private-sdk' +import { beta } from 'other-sdk' +export const values = () => [alpha, beta] +`, + 'every name an importer can use': `import { ${quotedImports(oddNames)} } from 'private-sdk' +export const values = () => [${oddNames.map((_, index) => `n${index}`).join(', ')}] +`, + // (a default and a string-keyed named import in one declaration are + // split: Vite's import analysis fails to parse that valid declaration, + // with or without Start) + 'every form of import and re-export': `import 'private-sdk' +import def, { type T, value } from 'private-sdk' +import { value as renamed, "kebab-name" as kebab } from 'private-sdk' +import * as ns from 'private-sdk' +export { type U, reexported, reexported as aliased, reexported as "string export", "a-b" as ab } from 'private-sdk' +export { default as renamedDefault } from 'private-sdk' +export const values = (): T => [def, ns.value, value, renamed, kebab] as unknown as T +`, + // An import carrying an import attribute: the denied package is JSON + 'a default import with an import attribute': `import config from 'private-config' with { type: 'json' } +export const values = () => [config] +`, + 'a .ts module with angle-bracket type assertions': `import { alpha } from 'private-sdk' +const identity = <T>(value: T) => value +export const values = () => [<unknown>identity(<unknown>alpha)] +`, +} + +/** What each re-exporting case gives: the names it exports. */ +const reexported: Record<string, Array<string>> = { + 're-exports': ['alpha', 'beta'], + 'a string-literal re-export': ['baz'], + 'an import and a re-export of the same name': ['alpha', 'used'], + 'every form of import and re-export': [ + 'reexported', + 'aliased', + 'string export', + 'ab', + 'renamedDefault', + ], +} + +/** + * The denied files: each a shape of exports (with `obj` and `arr` declared + * in the file), and the names it exports, which its importer reads from its + * namespace. + */ +const fileCases: Record<string, { code: string; names: Array<string> }> = { + declarations: { + code: `export function alpha() { return 'MARK_SECRET' } +export const beta = 'MARK_SECRET' +export class Gamma {} +`, + names: ['alpha', 'beta', 'Gamma'], + }, + 'export specifiers and aliases': { + code: `const local = 'MARK_SECRET' +const x = 'MARK_SECRET' +export { local as renamed, x } +`, + names: ['renamed', 'x'], + }, + 'a default export next to a type-only re-export': { + code: `export default function main() { return 'MARK_SECRET' } +export type { Foo } from '../types' +`, + names: ['default'], + }, + 'object destructuring': { + code: `const obj = { a: 'MARK_SECRET', b: 'MARK_SECRET' } +export const { a, b } = obj +`, + names: ['a', 'b'], + }, + 'array destructuring': { + code: `const arr = ['MARK_SECRET', 'MARK_SECRET'] +export const [x, y] = arr +`, + names: ['x', 'y'], + }, + 'an array destructuring rest element': { + code: `const arr = ['MARK_SECRET', 'MARK_SECRET'] +export const [first, ...others] = arr +`, + names: ['first', 'others'], + }, + 'renamed destructuring': { + code: `const obj = { a: 'MARK_SECRET' } +export const { a: renamed } = obj +`, + names: ['renamed'], + }, + 'nested destructuring': { + code: `const obj = { a: { b: 'MARK_SECRET', c: 'MARK_SECRET' } } +export const { a: { b, c } } = obj +`, + names: ['b', 'c'], + }, + 'destructuring with defaults': { + code: `const obj: { a?: string; b?: string } = {} +export const { a = 'MARK_SECRET', b = 'MARK_SECRET' } = obj +`, + names: ['a', 'b'], + }, + 'a destructuring rest element': { + code: `const obj = { a: 'MARK_SECRET', d: 'MARK_SECRET' } +export const { a, ...rest } = obj +`, + names: ['a', 'rest'], + }, + 'a default re-export alias': { + code: `export { default as hello } from '../secret-default' +`, + names: ['hello'], + }, + 'a string export name': { + code: `const local = 'MARK_SECRET' +export { local as "foo-bar" } +`, + names: ['foo-bar'], + }, + 'every name an importer can use': { + code: `const local = () => 'MARK_SECRET' +export { ${oddNames.map((name) => `local as ${JSON.stringify(name)}`).join(', ')} } +`, + names: oddNames, + }, + // The enum itself is pinned (known-bugs.test.ts); it must not cost the + // other exports. + 'an enum next to other exports': { + code: `export enum Color { Red = 'MARK_SECRET' } +export const secret = 'MARK_SECRET' +`, + names: ['secret'], + }, +} + +/** File name of a case. */ +const slug = (name: string) => + name + .replace(/[^a-z0-9]+/gi, '-') + .replace(/^-|-$/g, '') + .toLowerCase() + +const files: Record<string, string> = { + ...deniedPackage('private-sdk', sdkNames), + ...deniedPackage('other-sdk', ['beta']), + // A JSON package (its secret in its data) + 'node_modules/private-config/package.json': JSON.stringify({ + name: 'private-config', + exports: './config.json', + }), + 'node_modules/private-config/config.json': `{ "secret": "MARK_SECRET_JSON" }\n`, + 'src/types.ts': `export type Foo = string\n`, + 'src/secret-default.ts': `export default 'MARK_SECRET'\n`, + 'src/ok.ts': `export const safe = 'MARK_REAL_OK'\n`, + 'src/cases/not-denied.ts': `import { safe } from '../ok' +import { alpha } from 'private-sdk' +export const values = () => [safe, alpha] +`, + ...Object.fromEntries( + Object.entries(packageCases).map(([name, code]) => [ + `src/cases/sdk-${slug(name)}.ts`, + code, + ]), + ), + ...Object.fromEntries( + Object.entries(fileCases).flatMap(([name, { code, names }]) => [ + [`src/shapes/${slug(name)}.server.ts`, code], + [ + `src/cases/file-${slug(name)}.ts`, + `import * as ns from '../shapes/${slug(name)}.server' +export const values = () => [${names.map((exported) => `(ns as any)[${JSON.stringify(exported)}]`).join(', ')}] +`, + ], + ]), + ), +} + +/** The entry: each case's `values`, by case name. */ +files['src/entry.ts'] = `${[ + ['not denied', 'not-denied'], + ...Object.keys(packageCases).map((name) => [name, `sdk-${slug(name)}`]), + ...Object.keys(fileCases).map((name) => [ + `file: ${name}`, + `file-${slug(name)}`, + ]), +] + .map(([, file], index) => `import * as c${index} from './cases/${file}'`) + .join('\n')} +const read = (module: any, names: Array<string> = []) => () => [ + ...(module.values?.() ?? []), + ...names.map((name) => module[name]), +] +export const cases: Record<string, () => Array<unknown>> = { +${[ + ['not denied', 'not-denied'], + ...Object.keys(packageCases).map((name) => [name, `sdk-${slug(name)}`]), + ...Object.keys(fileCases).map((name) => [ + `file: ${name}`, + `file-${slug(name)}`, + ]), +] + .map( + ([name], index) => + ` ${JSON.stringify(name)}: read(c${index}${reexported[name!] ? `, ${JSON.stringify(reexported[name!])}` : ''}),`, + ) + .join('\n')} +} +` + +/** The script of every channel: each case's values, described. */ +const script = `${describeValuePrelude} +return Object.fromEntries( + Object.entries(entry.cases).map(([name, values]) => { + try { + return [name, values().map((value) => describeValue(value, 'MARK_SECRET'))] + } catch (error) { + return [name, ['throws: ' + String(error)]] + } + }), +)` + +const importProtection: ImportProtectionOptions = { + client: { specifiers: ['private-sdk', 'other-sdk', 'private-config'] }, + mockAccess: 'off', +} + +const mock = 'a safe mock' + +/** What each case gives: a safe mock for every value read from a denied module. */ +const expected: Record<string, Array<string>> = { + 'not denied': ['MARK_REAL_OK', mock], + ...Object.fromEntries( + Object.entries(packageCases).map(([name]) => [ + name, + (reexported[name] ?? [null]).map(() => mock), + ]), + ), + ...Object.fromEntries( + Object.entries(fileCases).map(([name, { names }]) => [ + `file: ${name}`, + names.map(() => mock), + ]), + ), +} +// (cases whose `values` read a fixed number of values) +expected['named imports'] = [mock, mock] +expected['namespace members'] = [mock, mock] +expected['members of a default import'] = [mock, mock] +expected['several imports of the same source'] = [mock, mock] +expected['parenthesized namespace calls'] = [mock, mock] +expected['imports of several denied sources'] = [mock, mock] +expected['every name an importer can use'] = oddNames.map(() => mock) +expected['every form of import and re-export'] = [ + // its imports: `def`, `ns.value`, `value`, `renamed`, `kebab` + ...[1, 2, 3, 4, 5].map(() => mock), + ...reexported['every form of import and re-export']!.map(() => mock), +] + +type Channel = 'vite dev' | 'vite build' | 'rsbuild build' +const channels: Array<Channel> = [ + 'vite dev', + ...startBundlers.map((bundler) => `${bundler} build` as Channel), +] + +const builds: Array<StartBuild> = [] +afterAll(async () => { + await Promise.all(builds.map((build) => build.client.dispose())) +}) + +const outcomes = new Map<Channel, Promise<Record<string, Array<string>>>>() +/** What each case gives on `channel`, run once per channel. */ +function outcomeOf(channel: Channel) { + let outcome = outcomes.get(channel) + if (!outcome) { + outcome = (async () => { + if (channel === 'vite dev') { + const server = await startBrowserProtectedDevServer( + files, + importProtection, + ) + try { + return (await runViteClient(server, '/src/entry.ts', script)) + .result as Record<string, Array<string>> + } finally { + await server.close() + } + } + const build = await buildStart({ + bundler: channel === 'vite build' ? 'vite' : 'rsbuild', + files, + entry: 'src/entry.ts', + start: { importProtection: { ...importProtection, behavior: 'mock' } }, + registerCleanup: () => {}, + }) + builds.push(build) + return (await build.client.run(script)).result as Record< + string, + Array<string> + > + })() + outcomes.set(channel, outcome) + } + return outcome +} + +describe.each(channels)('%s, mock mode', (channel) => { + test.each(Object.keys(expected))( + '%s: the importer gets a safe mock of what it uses from the denied module', + async (name) => { + expect((await outcomeOf(channel))[name]).toEqual(expected[name]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/reported-location-app.ts b/packages/start-plugin-core/tests/integration/importProtection/reported-location-app.ts new file mode 100644 index 0000000000..a4985a0b53 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/reported-location-app.ts @@ -0,0 +1,149 @@ +/** + * The app of the reported-location tests (reported-location.test.ts, + * reported-location-removed.test.ts): where a real app reports the + * violation of an importer `src/a.tsx` of the denied `src/secret.server.ts`, + * on each channel (the Vite dev server's warnings in mock mode; the errors + * of an Rsbuild dev server and of Vite and Rsbuild builds in error mode), + * as `onViolation` receives it. + */ +import { expect } from 'vitest' +import { + findDiagnostics, + mentionsFile, +} from '@tanstack/compiler-test-utils/diagnostics' +import { buildStart } from '../../build-harness' +import { startRsbuildDevServer } from '../../rsbuild-dev-server' +import { + appFileOf, + distinct, + isAt, + locationIn, + reportedViolations, + startProtectedDevServer, + violationRecorder, +} from '../../importProtection/start-apps' +import type { Recorded } from '../../importProtection/start-apps' +import type { StartBuildError } from '../../build-harness' + +export const timeout = 60_000 + +export type Channel = + | 'vite dev' + | 'rsbuild dev' + | 'vite build' + | 'rsbuild build' + +/** + * The importer locations reported for an app whose `src/a.tsx` is `code` + * (imported by the entry `src/entry.ts`) and imports from the denied + * `src/secret.server.ts` (none when nothing is reported). JSX compiles + * with the real React (a dependency of this package). + */ +export async function reportedLocations( + channel: Channel, + code: string, + /** Builds: emit source maps (Rsbuild's `output.sourceMap.js`, Vite's `build.sourcemap`). */ + { sourcemap = false }: { sourcemap?: boolean } = {}, +): Promise<Array<string>> { + const files = { + 'src/secret.server.ts': `export const eq = () => 1 +export const secret = () => 'secret' +export default function Secret() { + return 'secret' +} +`, + 'src/a.tsx': code, + 'src/entry.ts': `export * from './a'\n`, + } + let output: Recorded + if (channel === 'vite dev') { + const server = await startProtectedDevServer(files) + await server.load('/src/entry.ts') + output = server + } else if (channel === 'rsbuild dev') { + const recorder = violationRecorder({ behavior: 'error' }) + const server = await startRsbuildDevServer({ + files, + importProtection: recorder.importProtection, + // Rsbuild's default source maps in development + config: { output: { sourceMap: { js: 'cheap-module-source-map' } } }, + }) + output = { root: server.root, violations: recorder.violations } + expectNoOtherErrors({ ...output, diagnostics: server.diagnostics }) + } else { + const bundler = channel === 'vite build' ? 'vite' : 'rsbuild' + // (a build without any violation succeeds) + output = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + sourcemap, + }).then( + (build) => build, + (error: StartBuildError) => { + // (a build that fails for another reason fails the test) + if (reportedViolations(error).length === 0) { + throw error + } + return error + }, + ) + } + return distinct(reportedViolations(output).map((report) => report.importer)) +} + +/** + * Fails when `output` (a dev server's `diagnostics`, every channel) has an + * error that names none of the importers' files `onViolation` received + * (`appFileOf`): a compile that fails for another reason fails the test, + * whatever the reports' wording (SPEC §5.7, J6.12). + */ +export function expectNoOtherErrors( + output: Recorded & { + diagnostics: Array<{ severity: string; text: string }> + }, +) { + const reported = distinct( + reportedViolations(output).map(({ importer }) => appFileOf(importer)), + ) + const others = findDiagnostics(output.diagnostics, { + severity: 'error', + }).filter( + ({ text }) => + !reported.some((file) => mentionsFile(text, file, { root: output.root })), + ) + expect(others.map(({ text }) => text)).toEqual([]) +} + +/** Every channel. */ +export const channels: Array<Channel> = [ + 'vite dev', + 'rsbuild dev', + 'vite build', + 'rsbuild build', +] + +/** + * Fails unless one violation is reported, at one of `places` + * (`file:line:column`, or `file:line` for any column; SPEC J6.5): the + * genuine surviving uses, or the line of the original import of + * the denied module, written out by the test. Never a type position, a use + * inside a removed boundary, an unrelated member named like the import, + * compiled coordinates, nor no coordinates. + */ +export function expectRelevantLocation( + reported: Array<string>, + places: Array<string>, +) { + expect(reported).toHaveLength(1) + // (the file without a URL scheme: `appFileOf`) + const at = reported[0]!.replace(/^[a-z]+:\/+/, '') + expect( + places.some((place) => isAt(at, place)), + `${reported[0]} is one of ${places.join(', ')}`, + ).toBe(true) +} + +/** `src/a.tsx:line:column` of the first `needle` on `line` of `code`. */ +export const at = (code: string, line: number, needle: string) => + locationIn('src/a.tsx', code, line, needle) diff --git a/packages/start-plugin-core/tests/integration/importProtection/reported-location-removed.test.ts b/packages/start-plugin-core/tests/integration/importProtection/reported-location-removed.test.ts new file mode 100644 index 0000000000..677f916388 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/reported-location-removed.test.ts @@ -0,0 +1,168 @@ +/** + * Where import protection reports a violation when the Start compiler + * removes some uses of the denied import from an environment (SPEC J6.4, + * J6.5): a use inside removed code is not reported, a use the environment + * keeps is, at that use, on the client and on the server. Read from what a + * real app reports (reported-location-app.ts), on every channel. Split from + * reported-location.test.ts to keep each file of the slow tier short. + */ +import { describe, expect, test } from 'vitest' +import { buildStart } from '../../build-harness' +import { + distinct, + locationIn, + reportedViolations, + startProtectedDevServer, +} from '../../importProtection/start-apps' +import { + channels, + expectRelevantLocation, + reportedLocations, + timeout, +} from './reported-location-app' +import type { Recorded } from '../../importProtection/start-apps' +import type { StartBuildError } from '../../build-harness' + +// A use inside code the Start compiler removes from the client (a safe +// boundary) is not reported: the client no longer imports the denied file. +// Source: review; moved from analysis.usage.test.ts, which decided "no +// violation" from the compiled code's imports. +describe('a use inside code the Start compiler removes from the client is not reported', () => { + const safeUses = { + 'the server of a middleware variable': `import { createMiddleware } from '@tanstack/react-start' +import { secret } from './secret.server' +const authMiddleware = createMiddleware() +export const middleware = authMiddleware.server(({ next }) => + next({ context: { secret: secret() } }), +) +`, + 'a nested middleware server callback': `import { createMiddleware } from '@tanstack/react-start' +import { secret } from './secret.server' +export const middleware = createMiddleware().server(({ next }) => { + const read = () => ({ nested: secret() }) + return next({ context: read() }) +}) +`, + 'the handler of a server fn builder variable': `import { createServerFn } from '@tanstack/react-start' +import { secret } from './secret.server' +const myServerFn = createServerFn({ method: 'GET' }) +export const fn = myServerFn.handler(async () => secret()) +`, + } + + test.each( + Object.entries(safeUses).flatMap(([name, code]) => + channels.map((channel) => ({ name, code, channel })), + ), + )( + '$channel: $name', + async ({ channel, code }) => { + expect(await reportedLocations(channel, code)).toEqual([]) + }, + timeout, + ) +}) + +// The server side: a `.client` file (denied to the server by the default +// rules) used only inside code the Start compiler removes from the server +// (`createClientOnlyFn`) is not reported; a use the server keeps is reported +// on the server, at that use. +// Source: review (the compiler-removal rows of analysis.usage.test.ts had +// no server-side twin on a real adapter). +describe('the reported location of a server violation is the leaking use or the import', () => { + type ServerChannel = 'vite dev' | 'vite build' | 'rsbuild build' + const serverChannels: Array<ServerChannel> = [ + 'vite dev', + 'vite build', + 'rsbuild build', + ] + + const insideOnly = `import { createClientOnlyFn } from '@tanstack/react-start' +import { widget } from './widget.client' +export const fn = createClientOnlyFn(() => widget()) +` + const insideAndOutside = `${insideOnly}export const leak = () => widget() +` + + /** + * `<environment> <importer>` of each violation reported for an app whose + * `src/a.ts` is `code` (the server entry re-exports it) and imports the + * client-only `src/widget.client.ts`. + */ + async function serverReports( + channel: ServerChannel, + code: string, + ): Promise<Array<string>> { + const files = { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/a.ts': code, + 'src/entry.ts': `export * from './a'\n`, + 'src/client.ts': `export const read = () => 'client'\n`, + } + let output: Recorded + if (channel === 'vite dev') { + const server = await startProtectedDevServer(files) + await server.load('/src/entry.ts', { environment: 'ssr' }) + output = server + } else { + const bundler = channel === 'vite build' ? 'vite' : 'rsbuild' + output = await buildStart({ + bundler, + files, + entry: { client: 'src/client.ts', ssr: 'src/entry.ts' }, + }).then( + (build) => build, + (error: StartBuildError) => { + if (reportedViolations(error).length === 0) { + throw error + } + return error + }, + ) + } + return distinct( + reportedViolations(output).map( + ({ environment, importer }) => `${environment} ${importer}`, + ), + ) + } + + test.each(serverChannels)( + '%s: a use outside createClientOnlyFn is reported on the server at the use or the import; the use inside is not', + async (channel) => { + const reports = await serverReports(channel, insideAndOutside) + expect(reports.map((report) => report.split(' ')[0])).toEqual(['server']) + expectRelevantLocation( + reports.map((report) => report.split(' ')[1]!), + [locationIn('src/a.ts', insideAndOutside, 4, 'widget()'), 'src/a.ts:2'], + ) + }, + timeout, + ) + + test.each(serverChannels)( + '%s: createIsomorphicFn client use is removed; its server use is located in the original source', + async (channel) => { + const code = `import { createIsomorphicFn } from '@tanstack/react-start' +import { widget } from './widget.client' +export const readClient = createIsomorphicFn().client(() => widget()) +export const readServer = createIsomorphicFn().server(() => widget()) +` + const reports = await serverReports(channel, code) + expect(reports.map((report) => report.split(' ')[0])).toEqual(['server']) + expectRelevantLocation( + reports.map((report) => report.split(' ')[1]!), + [locationIn('src/a.ts', code, 4, 'widget()'), 'src/a.ts:2'], + ) + }, + timeout, + ) + + test.each(serverChannels)( + '%s: a use only inside createClientOnlyFn is not reported', + async (channel) => { + expect(await serverReports(channel, insideOnly)).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/reported-location-trace.test.ts b/packages/start-plugin-core/tests/integration/importProtection/reported-location-trace.test.ts new file mode 100644 index 0000000000..b24e04e427 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/reported-location-trace.test.ts @@ -0,0 +1,386 @@ +/** + * What a build reports about where a violation comes from, besides the + * importer's location (reported-location.test.ts): the import chain from an + * entry to the importer (SPEC J6.5: any real bounded chain from an entry, + * printed in any order, SPEC §5.19; each import located on its + * line in the user's file). Read from Vite and Rsbuild builds with Start's + * default rules (error mode), as `onViolation` receives it. Split from + * reported-location.test.ts to keep each file of the slow tier short. + */ +import { describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { + isAt, + rejection, + violationsOf, +} from '../../importProtection/start-apps' +import type { StartBuildOptions, StartBundler } from '../../build-harness' +import type { Violation } from '../../importProtection/start-apps' + +const timeout = 60_000 + +/** + * The report of the one violation of a build of `files` (client entry + * `src/entry.ts`, default rules). + */ +async function buildReport( + bundler: StartBundler, + files: Record<string, string>, + { + sourcemap = false, + viteConfig, + }: Pick<StartBuildOptions, 'sourcemap' | 'viteConfig'> = {}, +): Promise<Violation> { + const error = await rejection( + buildStart({ + bundler, + files, + entry: 'src/entry.ts', + sourcemap, + viteConfig, + }), + ) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + return report! +} + +/** The modules of the steps of `trace`, without their locations. */ +const modulesOf = (trace: Violation['trace']) => + trace.map(({ at }) => at.replace(/(?::\d+)+$/, '')) + +/** + * The modules a client trace of these apps may start at: the client entry + * Start builds (the harness's, `harness/client-entry.ts`), or the test's + * entry module it imports (a trace may leave out modules outside `src`, + * pinned in "the trace goes through modules outside the source directory"). + */ +const clientEntries = ['harness/client-entry.ts', 'src/entry.ts'] + +/** + * The steps of a trace from the app's entry `src/entry.ts` on (a build's + * trace may start at the harness's own client entry, which imports it). + */ +const fromEntry = (modules: Array<string>) => + modules.slice(Math.max(0, modules.indexOf('src/entry.ts'))) + +/** + * The real import chains from the entry to `src/s.ts` in the app where + * `src/a.ts` imports `src/s.ts` directly and through `src/c.ts`. + */ +const realChains = [ + ['src/entry.ts', 'src/a.ts', 'src/s.ts'], + ['src/entry.ts', 'src/a.ts', 'src/c.ts', 'src/s.ts'], +] + +const secretServer = { + 'src/secret.server.ts': `export const secret = () => 'secret'\n`, +} + +/** + * The client entry imports `src/secret.server.ts` through `src/a.ts` and + * `src/b.ts`, each import after the first line of its module. + */ +const chain = { + ...secretServer, + 'src/b.ts': `// helper +export const one = 1 +import { secret } from './secret.server' /* ORIGINAL_IMPORT */ +export const leak = () => secret() /* ORIGINAL_USE */ +`, + 'src/a.ts': `export const two = 2 +export const three = 3 +import { leak } from './b' +export const page = () => leak() +`, + 'src/entry.ts': `export const zero = 0 +export * from './a' +`, +} + +/** + * Whether `importer` is where the `chain` build may report `src/b.ts`: its + * use of `secret` or its import of the denied module (SPEC J6.5). + */ +const atChainImporter = (importer: string) => + ['src/b.ts:4:27', 'src/b.ts:3'].some((place) => isAt(importer, place)) + +/** `src/b.ts` imports the denied module, and `src/a.ts` imports `b`. */ +const leakingB = { + ...secretServer, + 'src/b.ts': `import { secret } from './secret.server' +export const leak = () => secret() +`, +} + +// What a build reports about where a violation comes from: the trace of +// imports from the entry to the importer. +describe.each(startBundlers)( + '%s build: the report of a violation', + (bundler) => { + let chainReport: Promise<Violation> | undefined + /** The report of the `chain` build, built once. */ + const reportOfChain = () => + (chainReport ??= buildReport(bundler, chain, {})) + + // The middle steps are located on the line of their import (which + // column of the import statement is not specified). + test( + 'the trace lists each import from the entry, located on its line', + async () => { + const { importer, trace } = await reportOfChain() + expect(atChainImporter(importer), importer).toBe(true) + // The chain starts at an entry (by its position: no marker needed) + expect(clientEntries).toContain(modulesOf(trace)[0]) + expect( + trace.slice(-3).map(({ at, imports }) => ({ at, imports })), + ).toEqual([ + { + at: expect.stringMatching(/^src\/entry\.ts:2(?::\d+)?$/), + imports: './a', + }, + { + at: expect.stringMatching(/^src\/a\.ts:3(?::\d+)?$/), + imports: './b', + }, + { at: importer, imports: './secret.server' }, + ]) + }, + timeout, + ) + + // Any real chain from the entry to the importer will do, not + // necessarily the shortest (SPEC J6.5): `src/a.ts` imports + // `src/s.ts` directly and through `src/c.ts`. + test( + 'the trace is a real import chain from the entry to the importer', + async () => { + const { trace } = await buildReport(bundler, { + ...secretServer, + 'src/s.ts': `import { secret } from './secret.server' +export const s = () => secret() +`, + 'src/c.ts': `import { s } from './s'\nexport const c = () => s()\n`, + 'src/a.ts': `import { c } from './c' +import { s } from './s' +export const page = () => c() + s() +`, + 'src/entry.ts': `export * from './a'\n`, + }) + expect(realChains).toContainEqual(fromEntry(modulesOf(trace))) + }, + timeout, + ) + + // Bug (Vite): the trace of a Vite build starts at the first module of the + // trace that is in the source directory and not in `node_modules`: the + // Vite adapter does not record the imports of other modules in its import + // graph (vite/import-protection-plugin/plugin.ts). Rsbuild traces through + // them (and from the harness's client entry, outside `src`). + // Impact: the trace of a Vite build leaves out how the client reaches the + // importer when the chain goes through a module outside `src` (a shared + // directory of a monorepo, a dependency). + // Source: mutation testing. + const outsideSrcTest = bundler === 'vite' ? test.fails : test + outsideSrcTest( + 'the trace goes through modules outside the source directory', + async () => { + const { trace } = await buildReport(bundler, { + ...leakingB, + 'shared/a.ts': `import { leak } from '../src/b' +export const page = () => leak() +`, + 'src/entry.ts': `export * from '../shared/a'\n`, + }) + expect(modulesOf(trace).slice(-3)).toEqual([ + 'src/entry.ts', + 'shared/a.ts', + 'src/b.ts', + ]) + }, + timeout, + ) + }, +) + +// An app that sets Vite's full-bundle dev (`experimental.bundledDev`) keeps +// it set for `vite build` (as the e2e apps do with E2E_VITE_BUNDLED_DEV): +// the build's trace does not change. +// Source: mutation testing (route modules taken as entries in the build, as +// full-bundle dev does). +test( + 'vite build with experimental.bundledDev: the trace of a violation under a module of src/routes leads from the entry through it', + async () => { + const { trace } = await buildReport( + 'vite', + { + ...leakingB, + 'src/routes/page.ts': `export { leak } from '../b'\n`, + 'src/entry.ts': `export * from './routes/page'\n`, + }, + { viteConfig: { experimental: { bundledDev: true } } }, + ) + expect(modulesOf(trace).slice(-3)).toEqual([ + 'src/entry.ts', + 'src/routes/page.ts', + 'src/b.ts', + ]) + }, + timeout, +) + +// Bug (Rsbuild): the trace stops at an entry only when it finds no importer +// of the module: in a production build the entry module is a concatenated +// module (scope hoisting), which has no `resourceResolveData`, so the +// Rsbuild adapter registers it by its identifier, the loader request, read +// as the path of the first loader (rsbuild/import-protection.ts +// `addEntryModulesToGraph` → `getModuleResource`), and no module of the +// graph is a registered entry. When a module imports the entry back, the +// trace search finds no root, and the trace is the importer alone, tagged +// as the entry. (A scratch registration of the concatenated module's +// `rootModule` passes this pin.) +// Impact: an Rsbuild build reports such a violation with a one-step trace +// (low: diagnostics only, and an import of the app's entry is rare). Vite is +// right. +// Source: mutation testing (removing that registration changes nothing +// while it registers the wrong path). +describe.each(startBundlers)('%s build', (bundler) => { + const entryBackTest = bundler === 'rsbuild' ? test.fails : test + entryBackTest( + 'the trace starts at the entry when a module imports the entry back', + async () => { + const { importer, trace } = await buildReport(bundler, { + ...leakingB, + // The app's client entry (Start's default `src/client.tsx`) + 'src/client.tsx': `import { page } from './a' +export const start = () => page() +`, + 'src/back.ts': `import * as app from './client'\nexport const back = app\n`, + 'src/a.ts': `import { leak } from './b' +import { back } from './back' +export const page = () => [leak(), back] +`, + 'src/entry.ts': `export * from './a'\n`, + }) + // The chain starts at the entry (by its position: no marker needed) + expect(modulesOf(trace)[0]).toBe('src/client.tsx') + expect(modulesOf(trace).slice(-3)).toEqual([ + 'src/client.tsx', + 'src/a.ts', + 'src/b.ts', + ]) + expect(trace.at(-1)!.at).toBe(importer) + }, + timeout, + ) +}) + +// The trace locates each import on its line in the user's file, whatever +// compiling the module moves. +const movedImports: Record< + string, + { files: Record<string, string>; step: string; line: number } +> = { + 'a leading comment': { + files: { + ...leakingB, + 'src/a.ts': `import { leak } from './b'\nexport const page = () => leak()\n`, + 'src/entry.ts': `// entry +export const zero = 0 +export * from './a' +`, + }, + step: 'src/entry.ts', + line: 3, + }, + 'a blank line': { + files: { + ...leakingB, + 'src/a.ts': `export const two = 2 + +import { leak } from './b' +export const page = () => leak() +`, + 'src/entry.ts': `export * from './a'\n`, + }, + step: 'src/a.ts', + line: 3, + }, + 'a type-only import': { + files: { + ...leakingB, + 'src/types.ts': `export type Count = number\n`, + 'src/a.ts': `import type { Count } from './types' +export const count: Count = 1 +import { leak } from './b' +export const page = () => leak() + count +`, + 'src/entry.ts': `export * from './a'\n`, + }, + step: 'src/a.ts', + line: 3, + }, +} + +/** The rows of `movedImports` named `names`, built with `bundler`. */ +const movedImportRows = ( + bundler: StartBundler, + sourcemap: boolean, + names: Array<string>, +) => + names.map((name) => ({ + name, + build: `${bundler} build${sourcemap ? ' with source maps' : ''}`, + bundler, + sourcemap, + ...movedImports[name]!, + })) + +describe('the trace locates each import on its line after compiling moved it', () => { + async function stepLine({ + bundler, + sourcemap, + files, + step, + }: ReturnType<typeof movedImportRows>[number]) { + const { trace } = await buildReport(bundler, files, { sourcemap }) + const at = trace.find((candidate) => candidate.at.startsWith(`${step}:`)) + return Number(at?.at.split(':')[1]) + } + + test.each([ + ...movedImportRows('rsbuild', true, Object.keys(movedImports)), + ...movedImportRows('rsbuild', false, ['a leading comment']), + ])( + '$build: after $name', + async (row) => { + expect(await stepLine(row)).toBe(row.line) + }, + timeout, + ) + + // Bug: a trace step's location is the import's position in the compiled + // code of the module unless import protection captured a source map of + // it: the Vite adapter captures one only for modules whose code names a + // denied file or specifier pattern or a marker + // (`shouldCaptureDiagnosticSourceMap` in + // vite/import-protection-plugin/plugin.ts), the Rsbuild adapter only when + // the build emits source maps. Compiling drops comments (Vite), blank + // lines and type-only imports, which moves the imports after them up. + // Impact: the trace points at the wrong line of the modules between the + // entry and the importer. + // Source: mutation testing. + test.fails.each([ + ...movedImportRows('vite', false, Object.keys(movedImports)), + ...movedImportRows('rsbuild', false, [ + 'a blank line', + 'a type-only import', + ]), + ])( + '$build: after $name', + async (row) => { + expect(await stepLine(row)).toBe(row.line) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/reported-location.test.ts b/packages/start-plugin-core/tests/integration/importProtection/reported-location.test.ts new file mode 100644 index 0000000000..01e4870316 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/reported-location.test.ts @@ -0,0 +1,362 @@ +/** + * Where import protection tells the user a violation is: the location it + * reports for the importer (its `file:line:column`) should be the use + * of the denied import that leaks into the environment, in the user's + * source. Read from what a real app reports with Start's default rules: the + * Vite dev server's warnings (mock mode), and the errors of an Rsbuild dev + * server and of Vite and Rsbuild builds (error mode). The Vite and Rsbuild + * adapters look for the use in a different order (Vite: compiled code first, + * Rsbuild: original source first), so each case runs on both. The chain + * and the code frame of a report: reported-location-trace.test.ts. + */ +import { describe, expect, test } from 'vitest' +import { locationParts } from '../../importProtection/start-apps' +import { + at, + channels, + expectRelevantLocation, + reportedLocations, + timeout, +} from './reported-location-app' +import type { Channel } from './reported-location-app' + +interface LocationCase { + name: string + code: string + /** + * The places the report may point at: the genuine surviving uses + * (`src/a.tsx:line:column`, or `src/a.tsx:line` for any column of the + * line) and the line of the static import of the denied module + * (`expectRelevantLocation`). + */ + expected: Array<string> +} + +const afterHandler = `import { createServerFn } from '@tanstack/react-start' +import { secret } from './secret.server' +export const fn = createServerFn().handler(async () => secret()) +export const leak = () => secret() +` + +const memberProperty = `import { eq } from './secret.server' +const db = { eq: (n: number) => n } +export const a = db.eq(1) +export const b = eq +` + +const typePosition = `import { secret } from './secret.server' +type Secret = typeof secret +export const check = (value: Secret) => value +export const leak = secret +` + +const jsxElement = `import Secret from './secret.server' +export const Page = () => <Secret /> +` + +// A value named like a server fn builder (`*ServerFn`) is not one: the +// client keeps its `handler` callback and the use inside it. +const lookAlike = `import { secret } from './secret.server' +const myServerFn = { handler: (fn: () => unknown) => fn() } +export const fn = myServerFn.handler(() => secret()) +` + +const isomorphicClient = `import { createIsomorphicFn } from '@tanstack/react-start' +import { secret } from './secret.server' +export const fn = createIsomorphicFn().client(() => secret()) +` + +const unicode = + "import { secret } from './secret.server'\r\n" + + '// 👨‍👩‍👧 𝒳𝒴 日本語\r\n' + + "\texport const label = '🎉'; export const value = () => secret()\r\n" + +// (Each shadowing binding is read like the real use, so a lookup that +// prefers calls cannot step over a shadow it does not see.) +const catchShadow = `import { secret } from './secret.server' +export const run = () => { + try { return 1 } catch (secret) { console.log(secret) } +} +export const leak = secret +` + +const scopeShadow = `import { secret } from './secret.server' +export const inner = (secret: unknown) => secret +export function hoisted() { + if (Math.random() > 2) { + var secret = 1 + } + return secret +} +export const leak = secret +` + +const wrappedBoundary = `import { createServerOnlyFn } from '@tanstack/react-start' +import { secret } from './secret.server' +const wrap = <T,>(fn: T) => fn +const run = (fn: () => unknown) => fn() +export const a = createServerOnlyFn(wrap(() => secret())) +export const b = run(() => secret()) +` + +const dynamicImport = `export const load = () => + import('./secret.server', { with: {} }) +` + +const reExport = `export const one = 1 +export { secret } from './secret.server' +` + +const cases: Record<string, LocationCase> = { + afterHandler: { + name: 'a use after a server fn handler (the handler is not reported)', + code: afterHandler, + expected: [at(afterHandler, 4, 'secret()'), 'src/a.tsx:2'], + }, + memberProperty: { + name: 'a use after a member property named like the import', + code: memberProperty, + expected: [at(memberProperty, 4, 'eq'), 'src/a.tsx:1'], + }, + typePosition: { + name: 'a use after a type position', + code: typePosition, + expected: [at(typePosition, 4, 'secret'), 'src/a.tsx:1'], + }, + jsxElement: { + name: 'a JSX element', + code: jsxElement, + expected: [ + at(jsxElement, 2, '<Secret'), + at(jsxElement, 2, 'Secret'), + 'src/a.tsx:1', + ], + }, + lookAlike: { + name: 'a use inside the handler method of an object named like a server fn', + code: lookAlike, + expected: [at(lookAlike, 3, 'secret()'), 'src/a.tsx:1'], + }, + isomorphicClient: { + name: 'a use inside createIsomorphicFn().client', + code: isomorphicClient, + expected: [at(isomorphicClient, 3, 'secret()'), 'src/a.tsx:2'], + }, + // A lone CR is a line terminator, like LF. Source: the #8504 probe (R-11). + loneCr: { + name: 'a use after a server fn handler, in a file with lone CR line endings', + code: afterHandler.replaceAll('\n', '\r'), + expected: [at(afterHandler, 4, 'secret()'), 'src/a.tsx:2'], + }, + // Ported from the internal usage lookup: columns count UTF-16 + // code units (what editors and source maps count) after astral + // characters, a tab and CRLF line endings. + unicode: { + name: 'a use after astral characters and a tab, with CRLF line endings', + code: unicode, + expected: [at(unicode, 3, 'secret()'), 'src/a.tsx:1'], + }, + catchShadow: { + name: 'a use after a catch clause parameter named like the import', + code: catchShadow, + expected: [at(catchShadow, 5, 'secret'), 'src/a.tsx:1'], + }, + scopeShadow: { + name: 'a use after a parameter and a hoisted var named like the import', + code: scopeShadow, + expected: [at(scopeShadow, 9, 'secret'), 'src/a.tsx:1'], + }, + // The client compile removes a `createServerOnlyFn(...)` call whatever + // its argument is, so a use inside a wrapped function is gone (replacing + // the internal pin on the original-source lookup). + wrappedBoundary: { + name: 'a use after a createServerOnlyFn whose function is wrapped in a call', + code: wrappedBoundary, + expected: [at(wrappedBoundary, 6, 'secret()'), 'src/a.tsx:2'], + }, + // Other import forms: the dynamic import (with import + // attributes) and the re-export are the uses, on their line. + dynamicImport: { + name: 'a dynamic import with import attributes', + code: dynamicImport, + expected: [`src/a.tsx:2`], + }, + reExport: { + name: 'a re-export', + code: reExport, + expected: [`src/a.tsx:2`], + }, +} + +/** The rows of `cases` on `channels`. */ +const rows = (names: Array<string>, on: Array<Channel>) => + names.flatMap((name) => on.map((channel) => ({ ...cases[name]!, channel }))) + +describe('the reported location of a violation is the leaking use or the import', () => { + // Source (lookAlike, isomorphicClient): moved from + // analysis.usage.test.ts, which rebuilt the Vite plugin's location + // lookup from internals (review). + test.each([ + ...rows(['afterHandler', 'loneCr', 'isomorphicClient'], channels), + ...rows(['unicode', 'catchShadow', 'scopeShadow', 'reExport'], channels), + ...rows(['wrappedBoundary', 'dynamicImport'], ['vite dev', 'vite build']), + ...rows(['lookAlike'], ['vite dev', 'vite build']), + ...rows(['typePosition', 'jsxElement'], ['vite dev', 'vite build']), + ])( + '$channel: $name', + async ({ channel, code, expected }) => { + expectRelevantLocation(await reportedLocations(channel, code), expected) + }, + timeout, + ) + + // Bug: the usage lookup counts a member property named like a denied import + // (`db.eq`) as a use of the import (shared `findPostCompileUsagePos` / + // `findOriginalUnsafeUsagePos` in import-protection/analysis.ts, used by + // both adapters). + // Impact: the violation points at an unrelated line, so the user looks for + // the leak in the wrong place. + // Source: PR #8504 (analysis.usage.test.ts "ignores a member property named + // like the import but still finds later usage"); moved from the pin on the + // internal helper (analysis.usage.test.ts). + test.fails.each(rows(['memberProperty'], channels))( + '$channel: $name', + async ({ channel, code, expected }) => { + expectRelevantLocation(await reportedLocations(channel, code), expected) + }, + timeout, + ) + + // NEW bug (Rsbuild): the original-source usage lookup, which the Rsbuild + // adapter tries first, takes any `<name>ServerFn.handler(...)` callback for + // a server fn handler by its name (`/ServerFn$/`, `isCompilerSafeBoundaryCall` + // in import-protection/analysis.ts) and skips the use inside it; the + // compiled-code lookup it then falls back to reports compiled-code + // coordinates (the same fallback as the pins below). + // Impact: on Rsbuild, a violation inside the callback of an object that + // is only named like a server fn points at a line/column that does not + // exist in the user's file (here 3:1 in dev, 5:42 in a build; in dev the + // file is also named by its source-map URL, `webpack:/src/a.tsx`, the bug + // pinned in "the reported importer is a file of the app"). + // Source: review (moved from analysis.usage.test.ts, which followed the + // Vite order). + test.fails.each(rows(['lookAlike'], ['rsbuild dev', 'rsbuild build']))( + '$channel: $name', + async ({ channel, code, expected }) => { + expectRelevantLocation(await reportedLocations(channel, code), expected) + }, + timeout, + ) + + // Bug: the original-source usage lookup, which the Rsbuild adapter tries + // first, counts uses in type positions (`typeof secret`), which TypeScript + // erases, and does not count a JSX element (`<Secret />`) as a use; the + // compiled-code lookup it then falls back to reports compiled-code + // coordinates when the module has no column source map (production builds, + // and Rsbuild's default `cheap-module-source-map` in development). + // Impact: on Rsbuild, the violation points at a type annotation, or at a + // line/column that does not exist in the user's file (the JSX element in + // dev: `webpack:/src/a.tsx:2:1`, also named by its source-map URL). + // Source: PR #8504 (analysis.usage.test.ts "ignores type positions, which + // TypeScript erases", "finds $name usage"); moved from the pins on the + // internal helper (analysis.usage.test.ts). + test.fails.each( + rows(['typePosition', 'jsxElement'], ['rsbuild dev', 'rsbuild build']), + )( + '$channel: $name', + async ({ channel, code, expected }) => { + expectRelevantLocation(await reportedLocations(channel, code), expected) + }, + timeout, + ) + + // Bug (Rsbuild): the original-source usage lookup, which the Rsbuild + // adapter tries first, skips only functions passed directly to a + // compiler-safe boundary call (`isInsideCompilerSafeBoundaryNodes`, + // import-protection/analysis.ts), but the client compile removes the + // whole `createServerOnlyFn(...)` call, whatever its argument (here a + // function wrapped in `wrap(...)`), so the use inside it never runs in + // the client; the lookup reports it (src/a.tsx:5:48) instead of the leak + // on line 6. + // Impact: on Rsbuild, the violation points at code the client never runs, + // not at the leak (location only). + // Source: mutation testing, reproduced on a real app (the internal pin on + // the lookup is removed). + // + // Bug (Rsbuild): a dynamic import of a denied module is reported neither + // on the line of the `import()` nor at a static import: the dev server + // reports the first column of the module (`webpack:/src/a.tsx:1:1`, also + // named by its source-map URL), a build compiled-code coordinates + // (src/a.tsx:1:33, a column line 1 does not have). + // Impact: on Rsbuild, the violation of a lazily loaded denied module + // points at the wrong line. + // Source: review (an input shape the internal index tests had). + test.fails.each( + rows( + ['wrappedBoundary', 'dynamicImport'], + ['rsbuild dev', 'rsbuild build'], + ), + )( + '$channel: $name', + async ({ channel, code, expected }) => { + expectRelevantLocation(await reportedLocations(channel, code), expected) + }, + timeout, + ) +}) + +// Bug (Rsbuild): when the app has source maps, a location import protection +// finds in the compiled code of the importer and maps back through the +// module's source map takes its file from the map's source URL +// (`mapGeneratedToOriginal`, import-protection/sourceLocation.ts:248, +// `file: orig.source`), which Rspack names after its +// `devtoolModuleFilenameTemplate` (`webpack://<namespace>/./src/a.tsx`); the +// report prints that file in place of the importer (`formatViolation`, +// import-protection/trace.ts:203). Reachable with Rsbuild's defaults: its +// development source maps (`cheap-module-source-map`) are on, and so are +// production ones once an app sets `output.sourceMap.js`. +// Impact: the importer is named `webpack:/src/a.tsx:...`, a path that is no +// file of the app (editors and terminals do not open it), only for the +// imports found in the compiled code (here a JSX element; the same happens +// to an import `source.transformImport` rewrote). SPEC J6.5: the importer's +// location in the original source, with or without source maps. +// Source: review, reproduced with the public options of an app. +describe('the reported importer is a file of the app, whatever source maps it has', () => { + const jsx = cases.jsxElement!.code + /** The files the reports name as the importer. */ + const reportedFiles = async ( + channel: Channel, + options: { sourcemap?: boolean } = {}, + ) => + (await reportedLocations(channel, jsx, options)).map( + (importer) => locationParts(importer).file, + ) + + // (the location itself is pinned above, "a JSX element") + test( + 'rsbuild build without source maps: a JSX element (control)', + async () => { + expect(await reportedFiles('rsbuild build')).toEqual(['src/a.tsx']) + }, + timeout, + ) + + test.fails.each([ + { + channel: 'rsbuild dev' as const, + name: "Rsbuild's default development source maps", + sourcemap: false, + }, + { + channel: 'rsbuild build' as const, + name: 'a build with source maps', + sourcemap: true, + }, + ])( + '$channel ($name): a JSX element', + async ({ channel, sourcemap }) => { + expect(await reportedFiles(channel, { sourcemap })).toEqual(['src/a.tsx']) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/rewritten-importer-maps.test.ts b/packages/start-plugin-core/tests/integration/importProtection/rewritten-importer-maps.test.ts new file mode 100644 index 0000000000..4998217fb6 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/rewritten-importer-maps.test.ts @@ -0,0 +1,63 @@ +/** + * An importer whose denied import import protection replaces still maps to + * its own source (SPEC G6, J6.8): on a Vite dev server with Start's whole + * public plugin (mock mode), a module of each environment imports a denied + * module (the client a `*.server.*` file, the server a `*.client.*` file) + * and throws on a line after that import; the source map the environment + * serves with the module (Vite's `transformRequest`) maps its `throw` statement back to that original + * line. The served code is parsed independently (`tokenOffsets`) and mapped + * with a standard consumer (`expectMapsTo`); the rewritten code's text is + * never read. + * + * Replaces the internal control that read the source map of today's + * rewrite output (main's `importProtection/rewrite.test.ts`, + * "the source map maps code after a rewritten import back to its origin"). + */ +import { describe, test } from 'vitest' +import { + expectMapsTo, + inlineSourceMap, + positionAt, + tokenOffsets, +} from '@tanstack/compiler-test-utils/source-maps' +import { startProtectedDevServer } from '../../importProtection/start-apps' + +/** A module importing `denied` and throwing on line 3. */ +const importer = (denied: string) => `import { value } from '${denied}' +const unrelated = 'MARK_UNRELATED' +export const fail = (): never => { throw new Error('MARK_THROWN ' + unrelated + String(typeof value)) } +` + +describe.each([ + { environment: 'client', denied: './secret.server' }, + { environment: 'ssr', denied: './widget.client' }, +])('$environment', ({ environment, denied }) => { + test('the throw after a mocked import maps to its original line', async () => { + const server = await startProtectedDevServer( + { + 'src/secret.server.ts': `export const value = () => 'MARK_SECRET'\n`, + 'src/widget.client.ts': `export const value = () => 'MARK_CLIENT'\n`, + 'src/mapped.ts': importer(denied), + 'src/entry.ts': `export * from './mapped'\n`, + }, + { mockAccess: 'off' }, + ) + // What the environment serves for the module, with its map (Vite's + // `transformRequest`) + const served = + await server.vite.environments[environment]!.transformRequest( + '/src/mapped.ts', + ) + const code = served!.code + const map = (served!.map ?? inlineSourceMap(code)) as Parameters< + typeof expectMapsTo + >[0] + const [throwAt] = tokenOffsets(code, { throw: true }) + expectMapsTo(map, positionAt(code, throwAt!), { + file: 'src/mapped.ts', + root: server.root, + mapUrl: server.file('src/mapped.ts'), + line: 3, + }) + }, 30_000) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/rule-outcomes.test.ts b/packages/start-plugin-core/tests/integration/importProtection/rule-outcomes.test.ts new file mode 100644 index 0000000000..c318cd11ab --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/rule-outcomes.test.ts @@ -0,0 +1,218 @@ +/** Public rule configuration, exercised by real Start builds (J6.1/J6.8). */ +import { describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { + inEnvironment, + receivedViolations, + rejection, + startProtectedDevServer, + violationsOf, +} from '../../importProtection/start-apps' +import { probeMockPrelude, safeMock } from '../../importProtection/mock-helpers' +import { originalLocation } from '../../importProtection/original-location' +import { runViteClient, startBrowserProtectedDevServer } from './client-pages' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const timeout = 60_000 +const packageFiles = (name: string) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + }), + [`node_modules/${name}/index.js`]: `export default () => 'REAL_${name}'\n`, +}) + +const rules: Array<{ + name: string + specifiers: NonNullable< + NonNullable<ImportProtectionOptions>['client'] + >['specifiers'] +}> = [ + { name: 'an extglob', specifiers: ['@(private-sdk|internal-sdk)'] }, + { name: 'an exact literal', specifiers: ['private-sdk'] }, + { + name: 'case-sensitive then case-insensitive expressions', + specifiers: [/^PRIVATE-SDK$/, /^PRIVATE-SDK$/i], + }, + { + name: 'case-insensitive then case-sensitive expressions', + specifiers: [/^PRIVATE-SDK$/i, /^PRIVATE-SDK$/], + }, +] + +describe.each(startBundlers)('%s public import rules', (bundler) => { + test.each(rules)( + '$name denies the exact client package import', + async ({ specifiers }) => { + const files = { + ...packageFiles('private-sdk'), + 'src/entry.ts': `import read from 'private-sdk'\nexport const live = read()\n`, + } + const error = await rejection( + buildStart({ + bundler, + entry: 'src/entry.ts', + files, + start: { importProtection: { client: { specifiers } } }, + }), + ) + expect(violationsOf(error)).toEqual([ + expect.objectContaining({ + environment: 'client', + specifier: 'private-sdk', + }), + ]) + // (at the use, or the import on line 1) + expect(receivedViolations(error.violations, error.root)).toEqual([ + originalLocation('client src/entry.ts:2:21', 1), + ]) + }, + timeout, + ) + + test.each(['private-sdk-ui', 'private-sdk2'])( + 'a literal permits the near-prefix package %s', + async (name) => { + const build = await buildStart({ + bundler, + entry: 'src/entry.ts', + files: { + ...packageFiles(name), + 'src/entry.ts': `import read from '${name}'\nexport const value = read()\n`, + }, + start: { + importProtection: { client: { specifiers: ['private-sdk'] } }, + }, + }) + const { client } = build + expect(violationsOf(inEnvironment(build, 'client'))).toEqual([]) + expect((await client.run('return entry.value')).result).toBe( + `REAL_${name}`, + ) + }, + timeout, + ) + + test.skipIf(process.platform !== 'linux')( + 'Src is outside the case-sensitive srcDirectory', + async () => { + const build = await buildStart({ + bundler, + entry: 'src/entry.ts', + files: { + ...packageFiles('private-sdk'), + 'Src/utility.ts': `import read from 'private-sdk'\nexport const value = read()\n`, + 'src/entry.ts': `export { value } from '../Src/utility'\n`, + }, + start: { + srcDirectory: 'src', + importProtection: { client: { specifiers: ['private-sdk'] } }, + }, + }) + const { client } = build + expect(violationsOf(inEnvironment(build, 'client'))).toEqual([]) + expect((await client.run('return entry.value')).result).toBe( + 'REAL_private-sdk', + ) + }, + timeout, + ) + + test( + 'inherited member names of a mocked import remain safe to consume', + async () => { + const build = await buildStart({ + bundler, + entry: 'src/entry.ts', + files: { + 'src/private.server.ts': `export default () => 'MARK_SECRET'\n`, + 'src/entry.ts': `import mock from './private.server'\nexport { mock }\n`, + }, + start: { importProtection: { behavior: 'mock', mockAccess: 'off' } }, + }) + const { client } = build + expect(violationsOf(inEnvironment(build, 'client'))).toHaveLength(1) + expect(client.where('MARK_SECRET')).toBe('nowhere') + expect( + ( + await client.run(`${probeMockPrelude} +const mock = entry.mock +mock.constructor.member() +mock.__proto__.member() +return [probeMock(mock.constructor), probeMock(mock.__proto__)]`) + ).result, + ).toEqual([safeMock, safeMock]) + }, + timeout, + ) +}) + +// A bare side-effect import is reachable user code in dev too (no build +// tree-shaking can remove it before the adapter sees the edge). +test( + 'an extglob denies a bare client import of private-sdk', + async () => { + const files = { + ...packageFiles('private-sdk'), + 'src/entry.ts': `import 'private-sdk'\nexport const live = 1\n`, + } + const server = await startProtectedDevServer(files, { + behavior: 'error', + client: { specifiers: ['@(private-sdk|internal-sdk)'] }, + }) + await rejection(server.load('/src/entry.ts')) + // (each time the dev server resolves the import, with behavior "error") + const reported = violationsOf(server) + expect(reported).not.toEqual([]) + for (const violation of reported) { + expect(violation).toEqual( + expect.objectContaining({ + environment: 'client', + specifier: 'private-sdk', + }), + ) + } + // (at the bare import, line 1) + expect(receivedViolations(server.violations, server.root)).toEqual([ + originalLocation('client src/entry.ts:1:1', 1), + ]) + }, + timeout, +) + +// J6.11: stateful RegExp flags must not make repeated public edges alternate +// between permitted and denied. +test.each([/^private-sdk$/g, /^private-sdk$/y])( + 'a stateful %s rule denies every client importer', + async (pattern) => { + const files = { + ...packageFiles('private-sdk'), + ...Object.fromEntries( + ['a', 'b', 'c'].map((name) => [ + `src/${name}.ts`, + `import read from 'private-sdk'\nexport const ${name} = () => read()\n`, + ]), + ), + 'src/entry.ts': `import { a } from './a'\nimport { b } from './b'\nimport { c } from './c'\nexport const readAll = () => [a(), b(), c()]\n`, + } + const server = await startBrowserProtectedDevServer(files, { + client: { specifiers: [pattern] }, + mockAccess: 'off', + }) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return entry.readAll().map((value) => probeMock(value, 'REAL_private-sdk'))`, + ) + expect(result).toEqual([safeMock, safeMock, safeMock]) + // (each at its use, or its import on line 1) + expect(receivedViolations(server.violations, server.root).sort()).toEqual( + ['a', 'b', 'c'].map((name) => + originalLocation(`client src/${name}.ts:2:24`, 1), + ), + ) + }, + timeout, +) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-alias.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-alias.test.ts new file mode 100644 index 0000000000..d7c8b91e76 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-alias.test.ts @@ -0,0 +1,326 @@ +/** + * Import protection through path aliases (SPEC J6.1, J6.5, + * G11): a client module imports the denied file `src/secret.server.ts` as + * `~/secret.server`, an alias of the app's `tsconfig.json` `paths`, and uses + * it live. Rules match the file the alias resolves to, whichever resolver + * resolves it: `vite-tsconfig-paths` before Start's plugin (the usual order + * of a `vite.config.ts`) or after it, Vite's own `resolve.tsconfigPaths`, and + * Rsbuild, which reads `paths` itself. Per resolver: + * - a build (default `behavior`: error) fails, and its report names the + * specifier as written (`~/secret.server`) and the importer at an original + * line of the import or the use; + * - dev (default `behavior`: mock) gives the importer a safe mock: no secret, + * no initializer of the denied file runs; + * - dev with `behavior: { dev: 'error' }` reports the same violation. + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import tsconfigPaths from 'vite-tsconfig-paths' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { + captureConsole, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { afterEach, describe, expect, onTestFinished, test } from 'vitest' +import { buildStart, startRuntimeLinks } from '../../build-harness' +import { startPlugin, startPluginFiles } from '../../dev-server' +import { probeMockPrelude, safeMock } from '../../importProtection/mock-helpers' +import { + locationIn, + rejection, + violationRecorder, + violationsOf, +} from '../../importProtection/start-apps' +import { originalLocation } from '../../importProtection/original-location' +import { + clientFixturePlugin, + runInClient, + runViteClient, + startBrowserRsbuildStartDevServer as startRsbuildStartDevServer, +} from './client-pages' +import type { ImportProtectionOptions } from '../../importProtection/public-types' +import type { Recorded } from '../../importProtection/start-apps' +import type { PluginOption } from 'vite' + +const timeout = 60_000 +const compileTimeout = timeout + +/** The directory the apps stand in for (where their imports resolve). */ +const testsDir = path.resolve( + path.dirname(fileURLToPath(import.meta.url)), + '../..', +) + +afterEach(() => { + delete (globalThis as Record<string, unknown>).secretLoaded +}) + +const widget = `import { secret } from '~/secret.server' +export const widget = () => secret() +` + +/** + * `src/components/widget.ts` uses the denied file through the alias `~/` + * (`tsconfig.json` `paths`); the entry re-exports it, and gives it to the + * page (`globalThis.widget`) for the Rsbuild dev runs. The denied file + * records that it ran. + */ +const aliasApp = { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + paths: { '~/*': ['./src/*'] }, + }, + include: ['src'], + }), + 'src/secret.server.ts': `;(globalThis as any).secretLoaded = 'MARK_SECRET_LOADED' +export const secret = () => 'MARK_SECRET' +`, + 'src/components/widget.ts': widget, + 'src/entry.ts': `import { widget } from './components/widget' +;(globalThis as any).widget = widget +export { widget } +`, +} + +/** + * The report of the violation: the specifier as the importer wrote it, and + * the importer, located (if at all, SPEC §5 item 14) at the import (line 1, + * any column) or at the use of `secret` (SPEC J6.5). + */ +const expectedReport = { + environment: 'client', + specifier: '~/secret.server', + importer: originalLocation( + locationIn('src/components/widget.ts', widget, 2, 'secret()'), + 1, + { unavailable: true }, + ), +} + +const reportsOf = (recorded: Recorded) => + violationsOf(recorded).map(({ environment, specifier, importer }) => ({ + environment, + specifier, + importer, + })) + +type ViteAlias = + | 'vite-tsconfig-paths before Start' + | 'vite-tsconfig-paths after Start' + | 'resolve.tsconfigPaths' + +/** + * Each Vite resolver of the alias: the app's `vite.config.ts` (loaded + * before the harness's inline plugins, as a user's config file is) or the + * inline configuration of a build; the plugins of a dev server, in order. + */ +const viteAliases: Array<{ + alias: ViteAlias + files: Record<string, string> + viteConfig: object + devPlugins: (start: PluginOption) => Array<PluginOption> + devConfig: object + /** Whether main reports another specifier (the pins below). */ + reportPinned: boolean +}> = [ + { + alias: 'vite-tsconfig-paths before Start', + files: { + 'vite.config.ts': `import tsconfigPaths from 'vite-tsconfig-paths' +export default { plugins: [tsconfigPaths()] } +`, + }, + // `vite build` runs in the app directory: Vite loads the app's config + // file, whose plugins come before the inline ones (Start's). + viteConfig: { configFile: 'vite.config.ts' }, + devPlugins: (start) => [tsconfigPaths(), start], + devConfig: {}, + reportPinned: true, + }, + { + alias: 'vite-tsconfig-paths after Start', + files: {}, + viteConfig: { plugins: [tsconfigPaths()] }, + devPlugins: (start) => [start, tsconfigPaths()], + devConfig: {}, + reportPinned: true, + }, + { + alias: 'resolve.tsconfigPaths', + files: {}, + viteConfig: { resolve: { tsconfigPaths: true } }, + devPlugins: (start) => [start], + devConfig: { resolve: { tsconfigPaths: true } }, + reportPinned: false, + }, +] + +/** + * A Vite dev server with Start's whole plugin (as `@tanstack/react-start` + * passes it) and the alias resolver of `alias`, in the order the app lists + * them. + */ +async function startAliasDevServer( + alias: (typeof viteAliases)[number], + importProtection: ImportProtectionOptions, +) { + const recorder = violationRecorder(importProtection) + const server = await createDevServer({ + dir: testsDir, + prefix: '.start-dev-server-', + registerCleanup: onTestFinished, + files: { ...startPluginFiles, ...aliasApp }, + browser: true, + symlinks: startRuntimeLinks(), + config: alias.devConfig, + plugins: ({ root }) => [ + clientFixturePlugin, + ...alias.devPlugins( + startPlugin(root, { importProtection: recorder.importProtection }), + ), + ], + }) + return Object.assign(server, { violations: recorder.violations }) +} + +/** + * The violation reported is `expectedReport` (in dev with behavior "error", + * each time the import resolves). + */ +function expectAliasFailure(recorded: Recorded) { + const reports = reportsOf(recorded) + expect(reports).not.toEqual([]) + for (const report of reports) { + expect(report).toEqual(expectedReport) + } +} + +// Bug (the `.fails` rows): with vite-tsconfig-paths, in either order, the +// report names the specifier `src/secret.server` (and no location) instead +// of `~/secret.server`. vite-tsconfig-paths maps the alias and resolves the +// mapped absolute path again through the plugins (`this.resolve`, its +// `resolveId`), and import protection reports the specifier of that nested +// resolution (vite/import-protection-plugin/plugin.ts `resolveId`), shown +// relative to the root; Vite's own `resolve.tsconfigPaths` resolves inside +// Vite's resolver and is reported as written. +// Impact: the report names an import that is nowhere in the user's code +// (SPEC J6.1, J6.5: the specifier the user wrote), and has no location; 72 +// of 165 surveyed Start configs use vite-tsconfig-paths. +describe.each(viteAliases)('vite: $alias', (alias) => { + const reportTest = alias.reportPinned ? test.fails : test + + reportTest( + 'the build fails, reporting the aliased specifier at its original line', + async () => { + const error = await rejection( + buildStart({ + files: { ...aliasApp, ...alias.files }, + entry: 'src/entry.ts', + viteConfig: alias.viteConfig, + }), + ) + expectAliasFailure(error) + }, + timeout, + ) + + test( + 'dev: the importer gets a safe mock, and the denied file never runs', + async () => { + const server = await startAliasDevServer(alias, {}) + const { result } = await runViteClient( + server, + '/src/entry.ts', + `${probeMockPrelude} +return { probe: probeMock(entry.widget(), 'MARK_SECRET'), loaded: globalThis.secretLoaded ?? null }`, + ) + expect(result).toEqual({ probe: safeMock, loaded: null }) + }, + timeout, + ) + + reportTest( + 'dev with behavior error: the load fails, reporting the aliased specifier at its original line', + async () => { + const server = await startAliasDevServer(alias, { + behavior: { dev: 'error' }, + }) + await rejection(server.load('/src/entry.ts')) + expectAliasFailure(server) + }, + timeout, + ) +}) + +describe('rsbuild: tsconfig paths', () => { + test( + 'the build fails, reporting the aliased specifier at its original line', + async () => { + const error = await rejection( + buildStart({ + bundler: 'rsbuild', + files: aliasApp, + entry: 'src/entry.ts', + }), + ) + expect(reportsOf(error)).toEqual([expectedReport]) + }, + timeout, + ) + + test( + 'dev: the importer gets a safe mock, and the denied file never runs', + async () => { + const recorder = violationRecorder() + const server = await startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + files: aliasApp, + start: { importProtection: recorder.importProtection }, + }) + // Nothing fails, on any channel + expect( + findDiagnostics(server.diagnostics, { severity: 'error' }), + ).toEqual([]) + // The probe of `expectSafeMock`, run where the mock lives. + const { result } = await captureConsole(() => + runInClient( + server, + `${probeMockPrelude} +return { + probe: probeMock(globalThis.widget(), 'MARK_SECRET'), + loaded: globalThis.secretLoaded ?? null, +}`, + ), + ) + expect(result).toEqual({ result: { probe: safeMock, loaded: null } }) + expect(reportsOf({ root: server.root, ...recorder })).toEqual([ + expectedReport, + ]) + }, + timeout, + ) + + test( + 'dev with behavior error: the compile fails, reporting the aliased specifier at its original line', + async () => { + const recorder = violationRecorder({ behavior: { dev: 'error' } }) + const server = await startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + files: aliasApp, + start: { importProtection: recorder.importProtection }, + }) + expect(reportsOf({ root: server.root, ...recorder })).toEqual([ + expectedReport, + ]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page-rsbuild.test.ts new file mode 100644 index 0000000000..694bd1951e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page-rsbuild.test.ts @@ -0,0 +1,161 @@ +/** + * The edits of v2-edits-page.test.ts (SPEC J6.13, G10) seen + * by a real browser page of a Start app on Rsbuild's dev server (Start's + * whole Rsbuild plugin, `@rsbuild/plugin-react` for React Refresh, as the + * hydrate-dev Rsbuild rows): the component uses the server-only + * `src/secret.server.ts` only in `createIsomorphicFn().server()` (allowed), + * then also live (denied), then only in `.server()` again; the target is + * deleted and recreated between the steps. After each step the page shows + * the edited component through a hot update (no page load), never the + * secret, the live use reads a safe mock, and the step reports its + * violations and only those. + */ +import { pluginReact } from '@rsbuild/plugin-react' +import { afterAll, describe, expect, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { startRsbuildStartDevServer } from '../../rsbuild-dev-server' +import { violationRecorder } from '../../importProtection/start-apps' +import { + importersIn, + pageApp, + pageSteps, + pageWidget, + recordedSince, + secretServerModule, + settledAcrossTurn, +} from './v2-hosts' + +const timeout = 60_000 +const compileTimeout = timeout + +interface StepOutcome { + /** The widget's text. */ + text: string + /** `window.liveSecret()`, described, when the step uses it. */ + live?: string + /** Page loads so far (1: no full reload). */ + loads: number + /** Whether the client's code (its chunks or the step's hot updates) contains the secret. */ + servedSecret: boolean + /** The importers reported for the client by the compile of the step. */ + reported: Array<string> +} + +/** The server and page close after the last test. */ +const cleanups: Array<() => Promise<void>> = [] +afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } +}) +const registerCleanup = (cleanup: () => Promise<void>) => { + cleanups.push(cleanup) +} + +/** Runs every step once, shared by the tests. */ +let outcomes: Promise<Array<StepOutcome>> | undefined +const run = () => + (outcomes ??= (async () => { + const recorder = violationRecorder({ log: 'always' }) + const server = await startRsbuildStartDevServer({ + compileTimeout, + hmr: true, + browser: true, + // Start serves the pages, not an HTML template. + config: { tools: { htmlPlugin: false }, plugins: [pluginReact()] }, + // `log: 'always'`: each compile reports what it finds, so a stale + // violation shows in the compile of the step that removed it. + start: { importProtection: recorder.importProtection }, + files: pageApp, + registerCleanup, + }) + const browser = await openPage(server.url!, { registerCleanup }) + const result: Array<StepOutcome> = [] + for (const { step, live } of pageSteps) { + let since = 0 + if (step > 1) { + // The deletion and the recreation each in their own edit, settled: + // a removal landing while Rspack compiles is lost (watchpack 2.5.2 + // vendored by Rspack; KNOWN-BUGS.md, upstream issues). + // Merge the steps back once Rspack bundles watchpack >= 2.6. + // (Settled first too: a compile the previous step still has + // pending would pause the watcher while the removal lands.) + await settledAcrossTurn(server) + await server.edit({ 'src/secret.server.ts': null }) + await settledAcrossTurn(server) + await server.edit({ 'src/secret.server.ts': secretServerModule }) + await settledAcrossTurn(server) + since = recorder.violations.length + await server.edit({ 'src/widget.tsx': pageWidget(step, live) }) + } + await browser.waitForText(`step-${step}`, { + selector: '[data-testid=widget]', + }) + await settledAcrossTurn(server) + const client = [ + ...Object.values(await server.outputs('client')), + ...Object.values(await server.hotUpdates('client')), + ] + result.push({ + text: await browser.text('[data-testid=widget]'), + ...(live && { + live: await browser.page.evaluate(`(() => { +${describeValuePrelude} +return describeValue(window.liveSecret(), 'MARK_SECRET') +})()`), + }), + loads: browser.loads(), + servedSecret: client.some((code) => code.includes('MARK_SECRET')), + // Every compile in this state, excluding target-missing intermediates. + reported: importersIn( + recordedSince({ root: server.root, ...recorder }, since), + 'client', + ), + }) + } + return result + })()) + +describe.each(pageSteps)('step $step (live use: $live)', ({ step, live }) => { + const outcome = async () => (await run())[step - 1]! + + test( + 'the page shows the edit without a page load, and never the secret', + async () => { + const { text, loads } = await outcome() + expect({ + clientBranch: text.includes('MARK_CLIENT_BRANCH'), + secret: text.includes('MARK_SECRET'), + loads, + }).toEqual({ clientBranch: true, secret: false, loads: 1 }) + }, + timeout, + ) + + test( + 'no code the client gets contains the secret', + async () => { + expect((await outcome()).servedSecret).toBe(false) + }, + timeout, + ) + + if (live) { + test( + 'the live use reads a safe mock', + async () => { + expect((await outcome()).live).toBe('a safe mock') + }, + timeout, + ) + } + + test( + 'the step reports its violations, and only those', + async () => { + expect((await outcome()).reported).toEqual(live ? ['src/widget.tsx'] : []) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page.test.ts new file mode 100644 index 0000000000..5bd54df230 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-edits-page.test.ts @@ -0,0 +1,191 @@ +/** + * The edits of v2-edits.test.ts (SPEC J6.13, G10) seen by a + * real browser page of a Start app on Vite's dev server: a component uses + * the server-only `src/secret.server.ts` only in + * `createIsomorphicFn().server()` (allowed), then also live (denied), then + * only in `.server()` again; the target is deleted and recreated between + * the steps. After each step the page shows the edited component through a + * hot update (no full reload: the component module accepts it), never the + * secret, the live use reads a safe mock, and the step reports its + * violations and only those. + */ +import react from '@vitejs/plugin-react' +import { afterAll, describe, expect, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { + hmrSyncModule, + settlePage, + trackRequests, +} from '@tanstack/compiler-test-utils/hmr-sync' +import { startDevServer } from '../../dev-server' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { violationRecorder } from '../../importProtection/start-apps' +import { + importersIn, + pageApp, + pageSteps, + pageWidget, + recordedSince, + secretServerModule, +} from './v2-hosts' + +const timeout = 30_000 + +/** Pre-bundled up front, as Vite does for an app that installed them. */ +const config = { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + ], + }, +} + +interface StepOutcome { + /** The widget's text. */ + text: string + /** `window.liveSecret()`, described, when the step uses it. */ + live?: string + /** + * Page loads so far (1: no full reload), once the page took in what the + * server sent it for the step (`settlePage`). + */ + loads: number + /** Whether a module the client loads contains the secret. */ + servedSecret: boolean + /** The importers reported for the client since the step's edit. */ + reported: Array<string> +} + +/** The server and page close after the last test. */ +const cleanups: Array<() => Promise<void>> = [] +afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } +}) +const registerCleanup = (cleanup: () => Promise<void>) => { + cleanups.push(cleanup) +} + +/** Runs every step once, shared by the tests. */ +let outcomes: Promise<Array<StepOutcome>> | undefined +const run = () => + (outcomes ??= (async () => { + const recorder = violationRecorder({ log: 'always' }) + const server = await startDevServer({ + start: { importProtection: recorder.importProtection }, + browser: true, + config, + plugins: [react()], + // The router module loads `src/hmr-sync.ts` (`settlePage`) + files: { + ...pageApp, + 'src/router.ts': `${pageApp['src/router.ts']}import './hmr-sync'\n`, + 'src/hmr-sync.ts': hmrSyncModule, + }, + registerCleanup, + }) + const browser = await openPage(new URL('/', server.url).href, { + registerCleanup, + }) + const inFlight = trackRequests(browser) + const result: Array<StepOutcome> = [] + for (const { step, live } of pageSteps) { + let since = 0 + if (step > 1) { + await server.edit({ 'src/secret.server.ts': null }) + await server.edit({ 'src/secret.server.ts': secretServerModule }) + await server.idle() + since = recorder.violations.length + await server.edit({ 'src/widget.tsx': pageWidget(step, live) }) + } + await browser.waitForText(`step-${step}`, { + selector: '[data-testid=widget]', + }) + await settlePage(server, browser, inFlight) + const served = await server.load('/src/widget.tsx') + await server.idle() + result.push({ + text: await browser.text('[data-testid=widget]'), + ...(live && { + live: await browser.page.evaluate(`(() => { +${describeValuePrelude} +return describeValue(window.liveSecret(), 'MARK_SECRET') +})()`), + }), + loads: browser.loads(), + servedSecret: Object.values(served).some((code) => + code.includes('MARK_SECRET'), + ), + reported: importersIn( + recordedSince({ root: server.root, ...recorder }, since), + 'client', + ), + }) + } + return result + })()) + +describe.each(pageSteps)('step $step (live use: $live)', ({ step, live }) => { + const outcome = async () => (await run())[step - 1]! + + test( + 'the page shows the edit without a full reload, and never the secret', + async () => { + const { text, loads } = await outcome() + expect({ + clientBranch: text.includes('MARK_CLIENT_BRANCH'), + secret: text.includes('MARK_SECRET'), + loads, + }).toEqual({ + clientBranch: true, + secret: false, + loads: 1, + }) + }, + timeout, + ) + + test( + 'no module the client loads contains the secret', + async () => { + expect((await outcome()).servedSecret).toBe(false) + }, + timeout, + ) + + if (live) { + test( + 'the live use reads a safe mock', + async () => { + expect((await outcome()).live).toBe('a safe mock') + }, + timeout, + ) + } + + // Bug (step 2): the violation the edit adds is never logged. When a module + // changes, dev import protection drops the import graph edges that point + // to it (`hotUpdate` -> `ImportGraph.invalidate`, import-protection/ + // trace.ts), its importer (the split route component) is not transformed + // again, and the violation found in the edited `src/widget.tsx` is + // unreachable from Start's entries, so `processPendingViolations` + // (vite/import-protection-plugin/plugin.ts) discards it. The page twin of + // the dev.test.ts pin "added by an edit of the importer is logged at the + // use"; a scratch run keeping the incoming edges passes this pin. + // Impact: a server-only import a developer adds to a component while the + // dev server runs is mocked in the page without any warning. + ;(live ? test.fails : test)( + 'the step reports its violations, and only those', + async () => { + expect((await outcome()).reported).toEqual(live ? ['src/widget.tsx'] : []) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-edits.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-edits.test.ts new file mode 100644 index 0000000000..c795398d61 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-edits.test.ts @@ -0,0 +1,373 @@ +/** + * Edits move an import across the import-protection boundary in a running + * dev server (SPEC J6.13, J6.4): each denied import is first + * used only where the compiler removes it for the environment (allowed), + * then also live (denied), then only removed again (allowed), and its + * target is deleted and recreated between the steps. After each step: the + * reports of that step (no stale report, no missed one), what each importer + * gets (real module or safe mock) in each environment, and no secret in the + * client's code. + * - `src/client-side.ts` uses the server-only `src/secret.server.ts` in + * `createIsomorphicFn().server()` (the client never runs it), then also + * in `liveSecret`; + * - `src/server-side.ts` uses the client-only `src/widget.client.ts` in + * `.client()` (the server never runs it), then also in `liveWidget`. + * Vite and Rsbuild dev servers with Start's whole plugin; the same edits + * seen by a browser page are in v2-edits-page.test.ts. + */ +import { captureConsole } from '@tanstack/compiler-test-utils/diagnostics' +import { afterAll, describe, expect, test } from 'vitest' +import { + describeValue, + describeValuePrelude, +} from '../../importProtection/mock-helpers' +import { violationRecorder } from '../../importProtection/start-apps' +import { + runInClient, + runViteClient, + startBrowserStartDevServer as startDevServer, + startBrowserRsbuildStartDevServer as startRsbuildStartDevServer, +} from './client-pages' +import { + importersIn, + recordedSince, + runRsbuildSsr, + settledAcrossTurn, + ssrNodeOutput, +} from './v2-hosts' + +const timeout = 60_000 +const compileTimeout = timeout + +/** The targets; `version` marks a recreated file (same behaviour, new text). */ +const secretServer = (version = 0) => + `// version ${version}\nexport const secret = () => 'MARK_SECRET'\n` +const widgetClient = (version = 0) => + `// version ${version}\nexport const widget = () => 'MARK_WIDGET'\n` + +/** `src/client-side.ts`; `live`: also uses the denied import live. */ +const clientSide = ( + live: boolean, +) => `import { createIsomorphicFn } from '@tanstack/react-start' +import { secret } from './secret.server' +export const readSecret = createIsomorphicFn() + .server(() => secret()) + .client(() => 'MARK_CLIENT_BRANCH') +${live ? `export const liveSecret = () => secret()\n` : ''}` + +/** `src/server-side.ts`; `live`: also uses the denied import live. */ +const serverSide = ( + live: boolean, +) => `import { createIsomorphicFn } from '@tanstack/react-start' +import { widget } from './widget.client' +export const readWidget = createIsomorphicFn() + .client(() => widget()) + .server(() => Buffer.from('MARK_SERVER_BRANCH').toString()) +${live ? `export const liveWidget = () => widget()\n` : ''}` + +const app = { + 'src/secret.server.ts': secretServer(), + 'src/widget.client.ts': widgetClient(), + 'src/client-side.ts': clientSide(false), + 'src/server-side.ts': serverSide(false), + 'src/entry.ts': `import * as clientSide from './client-side' +import * as serverSide from './server-side' +export { clientSide, serverSide } +;(globalThis as any).app = { clientSide, serverSide } +`, + // Start's router entry reaches the app's modules, as a router reaches its + // routes. + 'src/router.ts': `export * from './entry' +export const getRouter = () => undefined +`, +} + +/** The edits of each step after the first, each after deleting and recreating the targets. */ +const steps = [ + { name: 'allowed', live: false }, + { name: 'denied', live: true }, + { name: 'allowed again', live: false }, +] as const + +/** + * What each export of the app returns in one environment, described (`a + * safe mock`, the value's text, or `absent`). Self-contained, for the + * scripts of an Rsbuild run too (`observePrelude`). + */ +function observe( + app: Record<string, Record<string, (() => unknown) | undefined>>, + describe: (value: unknown, secret?: string) => string, +): Record<string, string> { + const call = (fn: (() => unknown) | undefined) => { + if (fn === undefined) { + return 'absent' + } + try { + return describe(fn(), 'MARK_') + } catch (error) { + return `throws: ${String(error)}` + } + } + return { + readSecret: call(app.clientSide!.readSecret), + liveSecret: call(app.clientSide!.liveSecret), + readWidget: call(app.serverSide!.readWidget), + liveWidget: call(app.serverSide!.liveWidget), + } +} + +const observeScript = `${describeValuePrelude} +return (${observe.toString()})(globalThis.app, describeValue)` + +/** What one step shows in one environment. */ +interface Seen { + values: Record<string, string> + /** The importers reported for this environment during the step. */ + reported: Array<string> +} + +interface StepOutcome { + client: Seen + server: Seen + /** Whether the client's code contains the server-only value. */ + clientHasSecret: boolean +} + +/** What each step should show. */ +const expected = (live: boolean): Omit<StepOutcome, 'clientHasSecret'> => ({ + client: { + values: { + readSecret: 'MARK_CLIENT_BRANCH', + liveSecret: live ? 'a safe mock' : 'absent', + readWidget: 'MARK_WIDGET', + liveWidget: live ? 'MARK_WIDGET' : 'absent', + }, + reported: live ? ['src/client-side.ts'] : [], + }, + server: { + values: { + readSecret: 'MARK_SECRET', + liveSecret: live ? 'MARK_SECRET' : 'absent', + readWidget: 'MARK_SERVER_BRANCH', + liveWidget: live ? 'a safe mock' : 'absent', + }, + reported: live ? ['src/server-side.ts'] : [], + }, +}) + +/** + * The tests of a host: `run()` runs every step once (shared by the tests) + * and gives what each step showed. + */ +function hostSuite(run: () => Promise<Array<StepOutcome>>) { + let outcomes: Promise<Array<StepOutcome>> | undefined + const outcome = async (step: number) => (await (outcomes ??= run()))[step]! + + describe.each(steps.map((step, index) => ({ ...step, index })))( + 'step $index, $name', + ({ index, live }) => { + test( + 'each environment gets the real module or a safe mock, per importer', + async () => { + const { client, server } = await outcome(index) + expect({ client: client.values, server: server.values }).toEqual({ + client: expected(live).client.values, + server: expected(live).server.values, + }) + }, + timeout, + ) + + test( + "the client's code has no secret", + async () => { + expect((await outcome(index)).clientHasSecret).toBe(false) + }, + timeout, + ) + test( + 'the step reports its violations, and only those', + async () => { + const { client, server } = await outcome(index) + expect({ + client: client.reported, + server: server.reported, + }).toEqual({ + client: expected(live).client.reported, + server: expected(live).server.reported, + }) + }, + timeout, + ) + }, + ) +} + +describe('vite dev', () => { + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + + hostSuite( + async () => { + // `log: 'always'`: a violation is logged on each load, so a stale + // violation shows in the logs of the step that removed it. + const recorder = violationRecorder({ log: 'always' }) + const server = await startDevServer({ + browser: true, + start: { importProtection: recorder.importProtection }, + files: app, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + const recorded = { root: server.root, ...recorder } + const outcomes: Array<StepOutcome> = [] + for (const [index, step] of steps.entries()) { + let clientReports: Array<string> | undefined + let serverSince = 0 + if (index > 0) { + await server.edit({ + 'src/secret.server.ts': null, + 'src/widget.client.ts': null, + }) + await server.edit({ + 'src/secret.server.ts': secretServer(index), + 'src/widget.client.ts': widgetClient(index), + }) + // The recreated state, loaded in both environments before the + // step's edit: the handling of the recreations (the SSR runner's + // reload, the transforms it starts) ends here, by the loads' + // completion, not by a timer, so the logs from `since` on are the + // step's edit alone. + await runViteClient(server, '/src/router.ts', 'return null') + await server.import('/src/router.ts', 'ssr') + await server.idle() + // The logs of the step: from its edit on + const clientSince = recorder.violations.length + await server.edit({ 'src/client-side.ts': clientSide(step.live) }) + await server.load('/src/router.ts') + await server.idle() + clientReports = importersIn( + recordedSince(recorded, clientSince), + 'client', + ) + serverSince = recorder.violations.length + await server.edit({ 'src/server-side.ts': serverSide(step.live) }) + } + const client = await runViteClient( + server, + '/src/router.ts', + observeScript, + ) + const { result: serverValues } = await captureConsole(async () => { + const ssr = (await server.import( + '/src/router.ts', + 'ssr', + )) as Parameters<typeof observe>[0] + return observe(ssr, describeValue) + }) + const result = { + clientValues: client.result as Record<string, string>, + serverValues, + } + const served = await server.load('/src/router.ts') + await server.idle() + const logs = recordedSince(recorded, serverSince) + outcomes.push({ + client: { + values: result.clientValues, + reported: clientReports ?? importersIn(logs, 'client'), + }, + server: { + values: result.serverValues, + reported: importersIn(logs, 'server'), + }, + clientHasSecret: Object.values(served).some((code) => + code.includes('MARK_SECRET'), + ), + }) + } + return outcomes + }, + // The server importer's removal has its own settled window. The + // original combined-write pin passes with this isolation and a real page; + // retain the strict empty report set to detect future stale violations. + ) +}) + +describe('rsbuild dev', () => { + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + + hostSuite(async () => { + // `log: 'always'`: each compile reports what it finds, so a stale + // violation shows in the compile of the step that removed it. + const recorder = violationRecorder({ log: 'always', mockAccess: 'off' }) + const server = await startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + config: ssrNodeOutput, + files: app, + start: { importProtection: recorder.importProtection }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + const recorded = { root: server.root, ...recorder } + const outcomes: Array<StepOutcome> = [] + for (const [index, step] of steps.entries()) { + let clientReports: Array<string> | undefined + let serverSince = 0 + if (index > 0) { + // Each deletion and each recreation in its own edit, settled before + // the next write: a removal (or a write) landing while Rspack + // compiles the previous one can be lost (watchpack 2.5.2 + // vendored by Rspack, fixed in 2.6.0; KNOWN-BUGS.md, upstream + // issues). Merge the deletions, then the recreations, back into one + // edit each once Rspack bundles watchpack >= 2.6. (Settled first + // too: a compile the start or the previous step still has pending + // would pause the watcher while the first removal lands.) + await settledAcrossTurn(server) + await server.edit({ 'src/secret.server.ts': null }) + await settledAcrossTurn(server) + await server.edit({ 'src/widget.client.ts': null }) + await settledAcrossTurn(server) + await server.edit({ 'src/secret.server.ts': secretServer(index) }) + await settledAcrossTurn(server) + await server.edit({ 'src/widget.client.ts': widgetClient(index) }) + await settledAcrossTurn(server) + const clientSince = recorder.violations.length + await server.edit({ 'src/client-side.ts': clientSide(step.live) }) + await settledAcrossTurn(server) + clientReports = importersIn( + recordedSince(recorded, clientSince), + 'client', + ) + serverSince = recorder.violations.length + await server.edit({ 'src/server-side.ts': serverSide(step.live) }) + await settledAcrossTurn(server) + } + const values = (ran: { result: unknown } | { error: string }) => { + expect(ran).toEqual({ result: expect.anything() }) + return (ran as { result: Record<string, string> }).result + } + // Copy this settled state's window before executing code. + const warnings = recordedSince(recorded, serverSince) + outcomes.push({ + client: { + values: values(await runInClient(server, observeScript)), + reported: clientReports ?? importersIn(warnings, 'client'), + }, + server: { + values: values(await runRsbuildSsr(server, observeScript)), + reported: importersIn(warnings, 'server'), + }, + clientHasSecret: Object.values(await server.outputs('client')).some( + (code) => code.includes('MARK_SECRET'), + ), + }) + } + return outcomes + }) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-file-rules.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-file-rules.test.ts new file mode 100644 index 0000000000..62c4727007 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-file-rules.test.ts @@ -0,0 +1,362 @@ +/** + * `client.files` and `server.files` replace the default file rules (SPEC + * J6.1, docs table "replaces defaults"): with `client.files: + * ['**\/private/**']`, a live client import of `src/private/db.ts` is denied, + * and one of `src/db.server.ts` no longer is (the client gets the real + * module, nothing is reported); the marker and specifier rules still apply. + * Mirror on the server with `server.files: ['**\/browser/**']`: + * `src/browser/storage.ts` is denied, `src/widget.client.ts` no longer is, + * and the client-only marker still applies. Each use lives in a module of + * its own (`src/uses/<name>.ts`), so the reports tell the edges apart. Mock + * mode (dev default; `behavior: 'mock'` in builds), Vite and Rsbuild, builds + * and dev servers with Start's whole plugin. + */ +import { captureConsole } from '@tanstack/compiler-test-utils/diagnostics' +import { afterAll, afterEach, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { + describeValue, + describeValuePrelude, +} from '../../importProtection/mock-helpers' +import { violationRecorder } from '../../importProtection/start-apps' +import { + runInClient, + runViteClient, + startBrowserStartDevServer as startDevServer, + startBrowserRsbuildStartDevServer as startRsbuildStartDevServer, +} from './client-pages' +import { importersIn, runRsbuildSsr, ssrNodeOutput } from './v2-hosts' +import type { Recorded } from '../../importProtection/start-apps' +import type { StartBuild } from '../../build-harness' +import type { ImportProtectionOptions } from '../../importProtection/public-types' + +const timeout = 60_000 +const compileTimeout = timeout + +const importProtection: ImportProtectionOptions = { + client: { files: ['**/private/**'] }, + server: { files: ['**/browser/**'] }, + mockAccess: 'off', +} + +/** A module that records that it ran, then gives `value`. */ +const recording = (name: string, value: string, head = '') => + `${head};((globalThis as any).loaded ??= []).push('${name}') +export const ${name} = () => '${value}' +` + +const app = { + // Denied to the client by the default rule only + 'src/db.server.ts': recording('db', 'MARK_DB'), + // Denied to the client by the configured rule + 'src/private/db.ts': recording('privateDb', 'MARK_PRIVATE'), + // Denied to the client by its marker + 'src/marked.ts': recording( + 'marked', + 'MARK_MARKED', + `import '@tanstack/react-start/server-only'\n`, + ), + // Denied to the server by the default rule only + 'src/widget.client.ts': recording('widget', 'MARK_WIDGET'), + // Denied to the server by the configured rule + 'src/browser/storage.ts': recording('storage', 'MARK_STORAGE'), + // Denied to the server by its marker + 'src/client-marked.ts': recording( + 'clientMarked', + 'MARK_CLIENT_MARKED', + `import '@tanstack/react-start/client-only'\n`, + ), + 'src/uses/db.ts': `import { db } from '../db.server'\nexport default () => db()\n`, + 'src/uses/private.ts': `import { privateDb } from '../private/db'\nexport default () => privateDb()\n`, + 'src/uses/marked.ts': `import { marked } from '../marked'\nexport default () => marked()\n`, + // Denied to the client by the default specifier rule + 'src/uses/request.ts': `import { getRequest } from '@tanstack/react-start/server'\nexport default () => getRequest()\n`, + 'src/uses/widget.ts': `import { widget } from '../widget.client'\nexport default () => widget()\n`, + 'src/uses/storage.ts': `import { storage } from '../browser/storage'\nexport default () => storage()\n`, + 'src/uses/client-marked.ts': `import { clientMarked } from '../client-marked'\nexport default () => clientMarked()\n`, + 'src/entry.ts': `import db from './uses/db' +import privateDb from './uses/private' +import marked from './uses/marked' +import request from './uses/request' +import widget from './uses/widget' +import storage from './uses/storage' +import clientMarked from './uses/client-marked' +;(globalThis as any).uses = { db, privateDb, marked, request, widget, storage, clientMarked } +`, + // Start's router entry reaches the app's modules, as a router reaches its + // routes. + 'src/router.ts': `import './entry' +export const getRouter = () => undefined +`, +} + +/** The uses each environment calls (`getRequest` needs no server here). */ +const usesOf = { + client: ['db', 'privateDb'], + server: ['widget', 'storage'], +} as const + +/** + * A script (`describeValuePrelude`) giving what each use of `names` returns, + * described (`a safe mock`, or the value's text), and the modules that ran. + */ +const readScript = (names: ReadonlyArray<string>) => `${describeValuePrelude} +const values = {} +for (const name of ${JSON.stringify(names)}) { + try { + values[name] = describeValue(globalThis.uses[name](), 'MARK_') + } catch (error) { + values[name] = 'throws: ' + String(error) + } +} +return { values, loaded: globalThis.loaded ?? [] }` + +interface Read { + values: Record<string, string> + loaded: Array<string> +} + +/** + * What one environment's run shows: per use, its value and whether its + * module ran, and per denied edge whether it is reported. + */ +function outcome( + environment: 'client' | 'server', + read: Read, + recorded: Recorded, +) { + const reported = importersIn(recorded, environment) + const isReported = (importer: string, marked?: string) => + reported.includes(importer) || + (marked !== undefined && reported.includes(marked)) + if (environment === 'client') { + return { + 'db.server.ts (no longer denied)': { + value: read.values.db, + ran: read.loaded.includes('db'), + reported: isReported('src/uses/db.ts'), + }, + 'private/db.ts (denied by client.files)': { + value: read.values.privateDb, + ran: read.loaded.includes('privateDb'), + reported: isReported('src/uses/private.ts'), + }, + // A marker violation may be reported at the marked module (SPEC + // J6.5). + 'the server-only marker': { + reported: isReported('src/uses/marked.ts', 'src/marked.ts'), + }, + 'the server specifier': { reported: isReported('src/uses/request.ts') }, + } + } + return { + 'widget.client.ts (no longer denied)': { + value: read.values.widget, + ran: read.loaded.includes('widget'), + reported: isReported('src/uses/widget.ts'), + }, + 'browser/storage.ts (denied by server.files)': { + value: read.values.storage, + ran: read.loaded.includes('storage'), + reported: isReported('src/uses/storage.ts'), + }, + 'the client-only marker': { + reported: isReported('src/uses/client-marked.ts', 'src/client-marked.ts'), + }, + } +} + +const expected = { + client: { + 'db.server.ts (no longer denied)': { + value: 'MARK_DB', + ran: true, + reported: false, + }, + 'private/db.ts (denied by client.files)': { + value: 'a safe mock', + ran: false, + reported: true, + }, + 'the server-only marker': { reported: true }, + 'the server specifier': { reported: true }, + }, + server: { + 'widget.client.ts (no longer denied)': { + value: 'MARK_WIDGET', + ran: true, + reported: false, + }, + 'browser/storage.ts (denied by server.files)': { + value: 'a safe mock', + ran: false, + reported: true, + }, + 'the client-only marker': { reported: true }, + }, +} + +describe.each(startBundlers)('%s build (mock mode)', (bundler) => { + let built: Promise<StartBuild> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + const build = () => + (built ??= buildStart({ + bundler, + files: { + ...app, + // A real router (the server's requests need one; `request-probe.ts`) + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import './entry' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + }, + entry: 'src/entry.ts', + start: { importProtection: { ...importProtection, behavior: 'mock' } }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + + test( + 'client.files replaces the default file rule of the client', + async () => { + const built = await build() + const { result } = await built.client.run(readScript(usesOf.client)) + expect(outcome('client', result as Read, built)).toEqual(expected.client) + }, + timeout, + ) + + test( + 'server.files replaces the default file rule of the server', + async () => { + const built = await build() + const { result } = await built.ssr.run(readScript(usesOf.server)) + expect(outcome('server', result as Read, built)).toEqual(expected.server) + }, + timeout, + ) +}) + +describe('vite dev', () => { + afterEach(() => { + delete (globalThis as Record<string, unknown>).loaded + delete (globalThis as Record<string, unknown>).uses + }) + + // One dev server for both environments. + let started: ReturnType<typeof startDevServer> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + const recorder = violationRecorder(importProtection) + + /** Runs the app from Start's router entry in `environment`. */ + async function run(environment: 'client' | 'server') { + const server = await (started ??= startDevServer({ + browser: true, + start: { importProtection: recorder.importProtection }, + files: app, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + const { result } = + environment === 'client' + ? await runViteClient( + server, + '/src/router.ts', + readScript(usesOf.client), + ) + : await captureConsole(async () => { + await server.import('/src/router.ts', 'ssr') + const { uses, loaded = [] } = globalThis as unknown as { + uses: Record<string, () => unknown> + loaded?: Array<string> + } + return { + values: Object.fromEntries( + usesOf.server.map((name) => [ + name, + describeValue(uses[name]!(), 'MARK_'), + ]), + ), + loaded: [...loaded], + } + }) + await server.idle() + return outcome(environment, result as Read, { + root: server.root, + violations: recorder.violations, + }) + } + + test( + 'client.files replaces the default file rule of the client', + async () => { + expect(await run('client')).toEqual(expected.client) + }, + timeout, + ) + + test( + 'server.files replaces the default file rule of the server', + async () => { + expect(await run('server')).toEqual(expected.server) + }, + timeout, + ) +}) + +describe('rsbuild dev', () => { + // One dev server for both environments. + let started: ReturnType<typeof startRsbuildStartDevServer> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + const recorder = violationRecorder(importProtection) + const start = () => + (started ??= startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + config: ssrNodeOutput, + files: app, + start: { importProtection: recorder.importProtection }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + + test( + 'client.files replaces the default file rule of the client', + async () => { + const server = await start() + const ran = await runInClient(server, readScript(usesOf.client)) + expect(ran).toEqual({ result: expect.anything() }) + expect( + outcome('client', (ran as { result: Read }).result, { + root: server.root, + violations: recorder.violations, + }), + ).toEqual(expected.client) + }, + timeout, + ) + + test( + 'server.files replaces the default file rule of the server', + async () => { + const server = await start() + const ran = await runRsbuildSsr(server, readScript(usesOf.server)) + expect(ran).toEqual({ result: expect.anything() }) + expect( + outcome('server', (ran as { result: Read }).result, { + root: server.root, + violations: recorder.violations, + }), + ).toEqual(expected.server) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-hosts.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-hosts.ts new file mode 100644 index 0000000000..ee41a3f563 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-hosts.ts @@ -0,0 +1,179 @@ +/** + * Glue of the import-protection tests (`v2-*.test.ts`) that run an app on + * a real host: what a dev server or build reports through `onViolation`, + * and the Rsbuild dev server's SSR output run in Node. + */ +import path from 'node:path' +import { pathToFileURL } from 'node:url' +import { runNodeProgram } from '@tanstack/compiler-test-utils/run-node' +import { startServerEntryFiles } from '../../dev-server' +import { reportedImporters } from '../../importProtection/start-apps' +import type { Recorded } from '../../importProtection/start-apps' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +// --------------------------------------------------------------------------- +// The page app (v2-edits-page.test.ts on Vite, v2-edits-page-rsbuild +// .test.ts on Rsbuild): a Start app a browser opens (Start's default server +// and client entries, the real router over the generated route tree) whose +// index route renders `Widget` on the client only (`ssr: false`). + +export const secretServerModule = `export const secret = () => 'MARK_SECRET'\n` + +/** + * `src/widget.tsx` at `step`; `live`: also uses the denied import live + * (and gives it to the page, `window.liveSecret`). + */ +export const pageWidget = ( + step: number, + live: boolean, +) => `import { createIsomorphicFn } from '@tanstack/react-start' +import { secret } from './secret.server' +const read = createIsomorphicFn() + .server(() => secret()) + .client(() => 'MARK_CLIENT_BRANCH') +export function Widget() { +${ + live + ? ` ;(window as unknown as Record<string, unknown>).liveSecret = secret + return <p data-testid="widget">{read() + ' ' + String(secret()) + ' step-${step}'}</p>` + : ` return <p data-testid="widget">{read() + ' step-${step}'}</p>` +} +} +` + +export const pageApp = { + ...startServerEntryFiles, + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient)) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { Widget } from '../widget' +export const Route = createFileRoute('/')({ ssr: false, component: Widget }) +`, + 'src/secret.server.ts': secretServerModule, + 'src/widget.tsx': pageWidget(1, false), +} + +/** The steps of the page: allowed, denied (live use), allowed again. */ +export const pageSteps = [ + { step: 1, live: false }, + { step: 2, live: true }, + { step: 3, live: false }, +] as const + +/** + * The importers of the violations reported for `environment` (`client` or + * `server`) in `recorded` (what `onViolation` received), each once, sorted. + */ +export function importersIn( + recorded: Recorded, + environment: 'client' | 'server', +): Array<string> { + const prefix = `${environment} ` + return [ + ...new Set( + reportedImporters(recorded) + .filter((reported) => reported.startsWith(prefix)) + .map((reported) => reported.slice(prefix.length)), + ), + ].sort() +} + +/** What `recorded` received from the `since`th violation on. */ +export const recordedSince = (recorded: Recorded, since: number): Recorded => ({ + root: recorded.root, + violations: recorded.violations.slice(since), +}) + +/** + * `settle()` on both sides of a turn of the event loop. Rspack's + * MultiCompiler starts the compile of a dependent environment (Start's + * `ssr` after `client`) through its queue on the tick after its parent's + * compile ended, which `settle()` cannot see yet: a write landing while that + * compile runs is reported late, and a removal never (KNOWN-BUGS.md, + * upstream issues). Yielding a turn lets the queue start it; the second + * `settle()` waits for it. Not a timer. + */ +export async function settledAcrossTurn( + server: Pick<RsbuildDevServer, 'settle'>, +): Promise<void> { + await server.settle() + await new Promise<void>((resolve) => setImmediate(resolve)) + await server.settle() +} + +/** + * Explicit output contract of the Node fixture entry: the entry file is + * `ip-node-entry.cjs`, split chunks get names of their own. + */ +export const ssrNodeOutput = { + environments: { + ssr: { + output: { filename: { js: 'ip-node-entry.cjs' }, distPath: { js: '' } }, + tools: { + rspack: { output: { chunkFilename: 'ip-node-chunk-[id].cjs' } }, + }, + }, + }, +} + +/** + * Load the declared SSR entry from Rsbuild's writeToDisk output with Node. + * Node owns globals, dependencies, module identity and split chunk loading. + */ +export async function runRsbuildSsr( + server: Pick<RsbuildDevServer, 'rsbuild' | 'root'>, + script: string, +): Promise<{ result: unknown } | { error: string }> { + const config = server.rsbuild.getNormalizedConfig({ environment: 'ssr' }) + const entry = path.resolve( + server.root, + config.output.distPath.root, + 'ip-node-entry.cjs', + ) + const { stdout } = await runNodeProgram( + ` +let outcome +try { + await import(${JSON.stringify(pathToFileURL(entry).href)}) + outcome = { result: await (async () => {\n${script}\n})() } +} catch (error) { + outcome = { error: error instanceof Error ? error.message : String(error) } +} +console.log('IP_NODE_RESULT:' + JSON.stringify(outcome)) +`, + { cwd: server.root }, + ) + const result = stdout + .split('\n') + .reverse() + .find((line) => line.startsWith('IP_NODE_RESULT:')) + if (!result) { + throw new Error(`Node returned no SSR result: ${stdout}`) + } + return JSON.parse(result.slice('IP_NODE_RESULT:'.length)) as + | { result: unknown } + | { error: string } +} diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-policy.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-policy.test.ts new file mode 100644 index 0000000000..4f06d7b5d2 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-policy.test.ts @@ -0,0 +1,274 @@ +/** + * Policy branches of import protection on dev servers with Start's whole + * plugin (SPEC J6.6, J6.7, J6.9): per importer of the same + * denied file, an importer `ignoreImporters` exempts and one `onViolation` + * allows (returning `false`, or `Promise<false>`) get the real module and + * are not reported (SPEC J6.7; J6.6 "real module, + * no mock, no report"); any other importer gets a safe mock and is reported. + * Every entry counts: the app's own client entry `src/client.ts` and server + * entry `src/server.ts`. Rsbuild dev, and the `Promise<false>` row on Vite + * dev (its sync twin is pinned in dev.test.ts). + */ +import { afterAll, afterEach, describe, expect, test } from 'vitest' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { violationRecorder } from '../../importProtection/start-apps' +import { + runInClient, + runViteClient, + startBrowserStartDevServer as startDevServer, + startBrowserRsbuildStartDevServer as startRsbuildStartDevServer, +} from './client-pages' +import { importersIn, runRsbuildSsr, ssrNodeOutput } from './v2-hosts' +import type { + ImportProtectionOptions, + ViolationInfo, +} from '../../importProtection/public-types' + +const timeout = 60_000 +const compileTimeout = timeout + +/** A module using `name` of the denied file `target` (a default export). */ +const use = (target: string, name: string) => + `import { ${name} } from '${target}'\nexport default () => ${name}()\n` + +/** + * Importers of the denied file `src/secret.server.ts`, each in a module of + * its own, which the app's client entry gives to the page + * (`globalThis.uses`); the app's server entry answers with what + * `src/app/handler.ts` gets from the denied file `src/widget.client.ts`. + */ +const app = { + 'src/secret.server.ts': `;((globalThis as any).loaded ??= []).push('secret') +export const secret = () => 'MARK_SECRET' +`, + 'src/widget.client.ts': `;((globalThis as any).loaded ??= []).push('widget') +export const widget = () => 'MARK_WIDGET' +`, + 'src/exempt/a.ts': use('../secret.server', 'secret'), + 'src/app/plain.ts': use('../secret.server', 'secret'), + 'src/app/allowed-sync.ts': use('../secret.server', 'secret'), + 'src/app/allowed-async.ts': use('../secret.server', 'secret'), + 'src/app/handler.ts': use('../widget.client', 'widget'), + 'src/client.ts': `import exempt from './exempt/a' +import plain from './app/plain' +import allowedSync from './app/allowed-sync' +import allowedAsync from './app/allowed-async' +;(globalThis as any).uses = { exempt, plain, allowedSync, allowedAsync } +`, + 'src/server.ts': `import handler from './app/handler' +;(globalThis as any).uses = { handler } +export default { fetch: () => new Response(String(handler())) } +`, +} + +/** Whether a violation's importer is the app file `file`. */ +const importerIs = (info: unknown, file: string) => + (info as ViolationInfo).importer.split('?')[0]!.endsWith(`/${file}`) + +const importProtection: ImportProtectionOptions = { + mockAccess: 'off', + ignoreImporters: ['**/exempt/**'], + onViolation: (info) => { + if (importerIs(info, 'src/app/allowed-sync.ts')) { + return false + } + if (importerIs(info, 'src/app/allowed-async.ts')) { + return Promise.resolve(false) + } + return undefined + }, +} + +/** A script (`describeValuePrelude`): what each use returns, described. */ +const readScript = `${describeValuePrelude} +const values = {} +for (const [name, use] of Object.entries(globalThis.uses)) { + try { + values[name] = describeValue(use(), 'MARK_') + } catch (error) { + values[name] = 'throws: ' + String(error) + } +} +return values` + +const mocked = { value: 'a safe mock', reported: true } + +describe('rsbuild dev', () => { + // One dev server for every row. + let started: ReturnType<typeof startRsbuildStartDevServer> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + const recorder = violationRecorder(importProtection) + const start = () => + (started ??= startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + config: ssrNodeOutput, + files: app, + start: { importProtection: recorder.importProtection }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + + /** What a use of the client returns, and whether its importer is reported. */ + async function client(name: string, importer: string) { + const server = await start() + const ran = await runInClient(server, readScript) + expect(ran).toEqual({ result: expect.anything() }) + return { + value: (ran as { result: Record<string, string> }).result[name], + reported: importersIn( + { root: server.root, violations: recorder.violations }, + 'client', + ).includes(importer), + } + } + + test( + "an importer neither exempt nor allowed, reached from the app's client entry, gets a safe mock and is reported", + async () => { + expect(await client('plain', 'src/app/plain.ts')).toEqual(mocked) + }, + timeout, + ) + + /** The importers exempted or allowed, by how. */ + const permitted = [ + { how: 'ignoreImporters exempts', name: 'exempt', file: 'src/exempt/a.ts' }, + { + how: 'onViolation returns false for', + name: 'allowedSync', + file: 'src/app/allowed-sync.ts', + }, + { + how: 'onViolation returns Promise<false> for', + name: 'allowedAsync', + file: 'src/app/allowed-async.ts', + }, + ] + + // Control for the pins below (same server). + test.each(permitted)( + 'an importer $how is not reported', + async ({ name, file }) => { + expect((await client(name, file)).reported).toBe(false) + }, + timeout, + ) + + // Bug: Rsbuild dev replaces a denied file with its mock in the file's own + // transform, for every importer (rsbuild/import-protection-loader.ts: + // `checkFileDenial` matches, then `generateDevSelfDenialModule`), before an + // importer's exemption or the verdict of `onViolation` (`reportViolation`, + // rsbuild/import-protection.ts, at the end of the compile) counts. + // Exempting or allowing an importer only silences its report (the control + // above). The Rsbuild dev twin of the Vite dev and build pins + // (exemptions.test.ts; dev.test.ts and build.test.ts "onViolation returning + // false"). + // Impact: code a project exempts on purpose, or an import it allows with + // `onViolation` (documented: "Return false (or Promise<false>) to allow + // this specific import"), silently gets a mock whose calls return mocks. + test.fails.each(permitted)( + 'an importer $how gets the real module', + async ({ name, file }) => { + expect((await client(name, file)).value).toBe('MARK_SECRET') + }, + timeout, + ) + + test( + "an import of a .client file reached from the app's server entry is mocked on the server and reported", + async () => { + const server = await start() + const ran = await runRsbuildSsr(server, readScript) + expect({ + ran, + reported: importersIn( + { root: server.root, violations: recorder.violations }, + 'server', + ), + }).toEqual({ + ran: { result: { handler: 'a safe mock' } }, + reported: ['src/app/handler.ts'], + }) + }, + timeout, + ) +}) + +describe('vite dev: onViolation returning Promise<false>', () => { + afterEach(() => { + delete (globalThis as Record<string, unknown>).loaded + delete (globalThis as Record<string, unknown>).uses + }) + + /** + * `src/app/allowed-async.ts` uses the denied file; Start's router entry + * reaches it (as a router reaches its routes), and `onViolation` allows it + * with `Promise<false>`. + */ + const viteApp = { + 'src/secret.server.ts': app['src/secret.server.ts'], + 'src/app/allowed-async.ts': app['src/app/allowed-async.ts'], + 'src/router.ts': `import allowedAsync from './app/allowed-async' +;(globalThis as any).uses = { allowedAsync } +export const getRouter = () => undefined +`, + } + + let started: ReturnType<typeof startDevServer> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + const recorder = violationRecorder(importProtection) + + /** What the client gets, and the importers reported for the client. */ + async function outcome() { + const server = await (started ??= startDevServer({ + browser: true, + start: { importProtection: recorder.importProtection }, + files: viteApp, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + })) + const { result: value } = await runViteClient( + server, + '/src/router.ts', + `${describeValuePrelude}\nreturn describeValue(globalThis.uses.allowedAsync(), 'MARK_')`, + ) + await server.idle() + return { + value, + reported: importersIn( + { root: server.root, violations: recorder.violations }, + 'client', + ), + } + } + + // Control for the pin below (same server). + test( + 'the import is not reported', + async () => { + expect((await outcome()).reported).toEqual([]) + }, + timeout, + ) + + // Bug: the `Promise<false>` twin of the pin "returning false allows the + // import: the client gets the real module" (dev.test.ts): dev import + // protection replaces the denied file with its mock when it resolves the + // import, before `onViolation` decides; returning `Promise<false>` only + // silences the report (the control above). + // Impact: an import allowed by an async `onViolation` (the form the docs + // show) is a mock in the browser, without any warning. + test.fails( + 'the client gets the real module', + async () => { + expect((await outcome()).value).toBe('MARK_SECRET') + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/importProtection/v2-type-only.test.ts b/packages/start-plugin-core/tests/integration/importProtection/v2-type-only.test.ts new file mode 100644 index 0000000000..f01e00a5dc --- /dev/null +++ b/packages/start-plugin-core/tests/integration/importProtection/v2-type-only.test.ts @@ -0,0 +1,270 @@ +/** + * Type-only imports of a denied file through real hosts (SPEC + * J6.2): `import type`, `import { type X }`, `export type { X } from` + * and `export type * from` of the denied file `src/types.server.ts` are no + * violation: nothing is reported for their importers and the client never + * loads the file (it records that it ran). A mixed `import { type X, value }` + * of the denied file `src/mixed.server.ts` still uses a value: it is + * reported, and the client gets a safe mock. Client environment, mock mode + * (dev default; `behavior: 'mock'` in builds), Vite and Rsbuild, builds and + * dev servers with Start's whole plugin. + */ +import { + captureConsole, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { afterAll, afterEach, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../../build-harness' +import { describeValuePrelude } from '../../importProtection/mock-helpers' +import { violationRecorder } from '../../importProtection/start-apps' +import { + runInClient, + runViteClient, + startBrowserStartDevServer as startDevServer, + startBrowserRsbuildStartDevServer as startRsbuildStartDevServer, +} from './client-pages' +import { importersIn } from './v2-hosts' +import type { StartBuild } from '../../build-harness' + +const timeout = 60_000 +const compileTimeout = timeout + +afterEach(() => { + delete (globalThis as Record<string, unknown>).typesLoaded + delete (globalThis as Record<string, unknown>).mixedLoaded +}) + +/** Each type-only form, by the module that uses it. */ +const typeOnlyForms = { + 'src/forms/import-type.ts': `import type { Secret } from '../types.server' +export const importType = (value: Secret) => value.value +`, + 'src/forms/inline-type.ts': `import { type Secret } from '../types.server' +export const inlineType = (value: Secret) => value.value +`, + 'src/forms/export-type.ts': `export type { Secret } from '../types.server' +export const exportType = 1 +`, + 'src/forms/export-type-star.ts': `export type * from '../types.server' +export const exportTypeStar = 1 +`, +} + +const app = { + 'src/types.server.ts': `;(globalThis as any).typesLoaded = 'MARK_TYPES_LOADED' +export type Secret = { value: string } +export const secret = (): Secret => ({ value: 'MARK_SECRET' }) +`, + 'src/mixed.server.ts': `;(globalThis as any).mixedLoaded = 'MARK_MIXED_LOADED' +export type Mixed = { value: string } +export const mixed = (): Mixed => ({ value: 'MARK_MIXED' }) +`, + ...typeOnlyForms, + 'src/forms/mixed.ts': `import { type Mixed, mixed } from '../mixed.server' +export const readMixed = (): Mixed => mixed() +`, + 'src/entry.ts': `export * from './forms/import-type' +export * from './forms/inline-type' +export * from './forms/export-type' +export * from './forms/export-type-star' +import { readMixed } from './forms/mixed' +export { readMixed } +;(globalThis as any).readMixed = readMixed +`, + // Start's router entry reaches the app's modules, as a router reaches its + // routes. + 'src/router.ts': `import './entry' +export const getRouter = () => undefined +`, +} + +/** What the client got, and the importers reported for the client. */ +interface Outcome { + /** `readMixed()`, described (`a safe mock`, or the value's text). */ + mixed: string + typesLoaded: unknown + mixedLoaded: unknown + reported: Array<string> +} + +const expected: Outcome = { + mixed: 'a safe mock', + typesLoaded: null, + mixedLoaded: null, + reported: ['src/forms/mixed.ts'], +} + +/** A client script's view of the outcome (`describeValuePrelude`). */ +const outcomeScript = (readMixed: string) => `${describeValuePrelude} +return { + mixed: describeValue(${readMixed}(), 'MARK_'), + typesLoaded: globalThis.typesLoaded ?? null, + mixedLoaded: globalThis.mixedLoaded ?? null, +}` + +describe.each(startBundlers)('%s build (mock mode)', (bundler) => { + let built: Promise<StartBuild> | undefined + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + + test( + 'type-only forms are neither reported nor loaded; the mixed import is reported and mocked', + async () => { + built ??= buildStart({ + bundler, + files: app, + entry: 'src/entry.ts', + start: { importProtection: { behavior: 'mock', mockAccess: 'off' } }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + const build = await built + const { result } = await build.client.run( + outcomeScript('entry.readMixed'), + ) + expect({ + ...(result as Omit<Outcome, 'reported'>), + reported: importersIn(build, 'client'), + }).toEqual(expected) + }, + timeout, + ) +}) + +describe('vite dev', () => { + test( + 'type-only forms are neither reported nor loaded; the mixed import is reported and mocked', + async () => { + const recorder = violationRecorder() + const server = await startDevServer({ + browser: true, + start: { importProtection: recorder.importProtection }, + files: app, + }) + const { result } = await runViteClient( + server, + '/src/router.ts', + outcomeScript('globalThis.readMixed'), + ) + await server.idle() + expect({ + ...(result as Omit<Outcome, 'reported'>), + reported: importersIn({ root: server.root, ...recorder }, 'client'), + }).toEqual(expected) + }, + timeout, + ) +}) + +describe('rsbuild dev', () => { + test( + 'type-only forms are neither reported nor loaded; the mixed import is reported and mocked', + async () => { + const recorder = violationRecorder() + const server = await startRsbuildStartDevServer({ + compileTimeout, + browser: true, + hmr: false, + files: app, + start: { importProtection: recorder.importProtection }, + }) + // Nothing fails, on any channel + expect( + findDiagnostics(server.diagnostics, { severity: 'error' }), + ).toEqual([]) + const { result } = await captureConsole(() => + runInClient(server, outcomeScript('globalThis.readMixed')), + ) + expect({ + ...(result as { result: Omit<Outcome, 'reported'> }).result, + reported: importersIn({ root: server.root, ...recorder }, 'client'), + }).toEqual(expected) + }, + timeout, + ) +}) + +/** + * A mixed import whose value only a server fn handler uses, in an app with + * `verbatimModuleSyntax` (TypeScript then keeps an import left with type + * specifiers only, as a side-effect import): once the compiler removes the + * handler from the client, the import carries only a type, so it is no edge + * (SPEC J6.2, J6.4, J4.12, J2.5): the client neither loads the + * denied file nor reports it. + */ +const verbatimApp = { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + verbatimModuleSyntax: true, + }, + include: ['src'], + }), + 'src/types.server.ts': app['src/types.server.ts'], + 'src/forms/handler-only.ts': `import { createServerFn } from '@tanstack/react-start' +import { type Secret, secret } from '../types.server' +export const fetchSecret = createServerFn().handler( + async (): Promise<Secret> => secret(), +) +`, + 'src/entry.ts': `export { fetchSecret } from './forms/handler-only'\n`, + 'src/router.ts': `import './entry' +export const getRouter = () => undefined +`, +} + +const handlerOnly = { typesLoaded: null, reported: [] } + +describe.each(startBundlers)( + '%s build (mock mode), verbatimModuleSyntax', + (bundler) => { + test( + 'a mixed import whose value only a server fn handler uses is neither reported nor loaded', + async () => { + const build = await buildStart({ + bundler, + files: verbatimApp, + entry: 'src/entry.ts', + start: { importProtection: { behavior: 'mock', mockAccess: 'off' } }, + }) + const { result } = await build.client.run( + `return globalThis.typesLoaded ?? null`, + ) + expect({ + typesLoaded: result, + reported: importersIn(build, 'client'), + }).toEqual(handlerOnly) + }, + timeout, + ) + }, +) + +describe('vite dev, verbatimModuleSyntax', () => { + test( + 'a mixed import whose value only a server fn handler uses is neither reported nor loaded', + async () => { + const recorder = violationRecorder() + const server = await startDevServer({ + browser: true, + start: { importProtection: recorder.importProtection }, + files: verbatimApp, + }) + const { result: typesLoaded } = await runViteClient( + server, + '/src/router.ts', + 'return globalThis.typesLoaded ?? null', + ) + await server.idle() + expect({ + typesLoaded, + reported: importersIn({ root: server.root, ...recorder }, 'client'), + }).toEqual(handlerOnly) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-dev-server.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-dev-server.test.ts new file mode 100644 index 0000000000..4f59ed4b44 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-dev-server.test.ts @@ -0,0 +1,500 @@ +/** + * Known Start bugs that only show on a running dev server, after edits. Each + * pin asserts correct behaviour for a bug on main and is marked .fails; + * remove .fails when the bug is fixed. Each pin has a control test that runs + * the same harness on a case that works. The dev servers run Start's whole + * public Vite plugin; client code runs in a real browser page of the dev + * server (`runViteClient`). + */ +import { describe, expect, test } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { + callServerFn, + inDevRequest, + startDevServer, + startRequestFiles, +} from '../dev-server' +import { probeMockPrelude } from '../importProtection/mock-helpers' +import { starReexportApps } from '../importProtection/start-apps' +import { + runViteClient, + startBrowserStartDevServer, +} from './importProtection/client-pages' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' +import type { ImportProtectionOptions } from '../importProtection/start-apps' + +const timeout = 30_000 + +/** + * A module only a handler reads, whose code marks the modules it ends up in + * (no denied file: what the client gets of it is the compiler's doing, not + * import protection's mock). + */ +const dbModule = `export const db = { x: () => 'MARK_DB_SECRET' }\n` + +/** + * Runs `script` in a real page of `server` that loaded `entry` (as `entry`): + * what it returns, or `throws: <message>` when loading or running fails. + */ +async function inClient( + server: Pick<DevServer, 'url'>, + entry: string, + script: string, +): Promise<unknown> { + return runViteClient(server, entry, script).then( + ({ result }) => result, + (error: Error) => `throws: ${error.message.split('\n')[0]}`, + ) +} + +/** Modules of the client environment that contain `marker`. */ +function modulesContaining(modules: Record<string, string>, marker: string) { + return Object.keys(modules).filter((url) => modules[url]!.includes(marker)) +} + +describe('editing a server fn factory', () => { + /** + * `src/a.tsx` defines a server fn with the `base` builder of `src/b.ts`, + * imported from `importFrom` (`./b`, or `./c` and `./d`, which re-export it + * with `export *` and with an import and an export); `src/b.ts` starts as + * a plain object and becomes a `createServerFn()` builder. + */ + async function editFactory(importFrom: string) { + const server = await startBrowserStartDevServer({ + files: { + 'src/b.ts': `export const base = { handler: (fn: () => unknown) => fn }\n`, + 'src/c.ts': `export * from './b'\n`, + 'src/d.ts': `import { base } from './b'\nexport { base }\n`, + 'src/db.ts': dbModule, + 'src/a.tsx': `import { base } from '${importFrom}' +import { db } from './db' +export const fn = base.handler(async () => db.x()) +`, + }, + }) + // The page loads: `fn` is a plain function, its code runs in the browser + expect( + await inClient(server, '/src/a.tsx', 'return await entry.fn()'), + ).toBe('MARK_DB_SECRET') + + await server.edit({ + 'src/b.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + }) + return { server, client: await server.load('/src/a.tsx') } + } + + // Control for the pin below (same harness): a module importing the factory + // module directly is recompiled. + test( + 'client: a module importing an edited factory module directly loads no server code', + async () => { + const { client } = await editFactory('./b') + expect(modulesContaining(client, 'MARK_DB_SECRET')).toEqual([]) + }, + timeout, + ) + + // Control for the pin below (same harness): the compiler resolves the + // factory through the re-export on a server that starts after the edit. + test( + 'client: a module importing a factory module through a re-export loads no server code', + async () => { + const server = await startDevServer({ + files: { + 'src/b.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + 'src/c.ts': `export * from './b'\n`, + 'src/db.ts': dbModule, + 'src/a.tsx': `import { base } from './c' +import { db } from './db' +export const fn = base.handler(async () => db.x()) +`, + }, + }) + expect( + modulesContaining(await server.load('/src/a.tsx'), 'MARK_DB_SECRET'), + ).toEqual([]) + }, + timeout, + ) + + // Bug: on a factory module edit, the client environment of the Start + // compiler's Vite plugin invalidates only the direct importers of the + // module; the walk through transitive importers runs for server + // environments only (vite/start-compiler-plugin/plugin.ts + // `invalidateCompilerState`). Vite soft-invalidates the other importers and + // serves their previous transform. + // Impact: after a factory module (e.g. a `createServerFn()` builder) is + // edited, a module two or more imports away keeps the code compiled + // against the old factory until a restart: when the builder becomes a + // server fn, its handler and server-only imports still load in the browser + // (and when it stops being one, the client keeps an RPC stub). + test.fails.each([ + { name: 'export *', from: './c' }, + { name: 'an import and an export', from: './d' }, + ])( + 'client: a module importing an edited factory module through a re-export ($name) loads no server code', + async ({ from }) => { + const { client } = await editFactory(from) + expect(modulesContaining(client, 'MARK_DB_SECRET')).toEqual([]) + }, + timeout, + ) +}) + +describe('editing a server fn factory (SSR)', () => { + /** + * Like `editFactory` above, in the SSR environment: `src/a.tsx` runs in SSR + * while `fn` is a plain function, then `src/b.ts` becomes a + * `createServerFn()` builder. Returns what `fn` is in SSR afterwards: its + * server fn URL (its id), what calling it returns, and what a page's + * call of that id returns (`callServerFn`: Start's server entry handles + * it). + */ + async function editFactorySsr(importFrom: string) { + const server = await startDevServer({ + files: { + ...startRequestFiles, + 'src/b.ts': `export const base = { handler: (fn: () => unknown) => fn }\n`, + 'src/c.ts': `export * from './b'\n`, + 'src/d.ts': `import { base } from './b'\nexport { base }\n`, + 'src/db.server.ts': dbModule, + 'src/a.tsx': `import { base } from '${importFrom}' +import { db } from './db.server' +export const fn = base.handler(async () => db.x()) +`, + }, + }) + const before = (await server.import('/src/a.tsx')).fn + // (not a server fn: no server fn URL) + expect(before.url).toBeUndefined() + await server.edit({ + 'src/b.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + }) + const { fn } = await server.import('/src/a.tsx') + const settle = async (run: () => unknown) => { + try { + return await run() + } catch (error) { + return `throws: ${(error as Error).message}` + } + } + return { + url: typeof fn.url, + called: await settle(() => inDevRequest(server, () => fn())), + byId: await settle(() => callServerFn(server, fn)), + } + } + + /** + * `fn` is a server fn in SSR: it has a server fn URL (its id), and runs + * its handler both ways. + */ + const serverFn = { + url: 'string', + called: 'MARK_DB_SECRET', + byId: 'MARK_DB_SECRET', + } + + // Control for the pin below (same harness). + test( + 'SSR: a module importing an edited factory module directly gets a server fn', + async () => { + expect(await editFactorySsr('./b')).toEqual(serverFn) + }, + timeout, + ) + + // Bug: same as the client pin above, in the SSR environment: on a factory + // module edit, the server environments do walk the transitive importers + // (`getTransitiveImporters`), but only invalidate the compiler's state and + // the server-fn lookup modules of the importers it finds; Vite's module + // nodes of the importers two or more imports away are only + // soft-invalidated, and their previous transform is served. + // Impact: after a factory module is edited into a server fn builder, an + // SSR module importing it through a re-export keeps the code compiled + // against the old factory until a restart: its `fn` is no server fn (no + // id, so no HTTP endpoint, e.g. for a form action), and in the opposite + // edit it keeps a server fn that no longer exists. + // Replaces the former start-compiler-factories.test.ts test "dev: modules + // reaching a factory through imports and export * are its transitive + // importers", which only checked the walk. + test.fails.each([ + { name: 'export *', from: './c' }, + { name: 'an import and an export', from: './d' }, + ])( + 'SSR: a module importing an edited factory module through a re-export ($name) gets a server fn', + async ({ from }) => { + expect(await editFactorySsr(from)).toEqual(serverFn) + }, + timeout, + ) +}) + +describe('import protection', () => { + /** + * Start's options of an app with import protection's default rules, in + * its dev (mock) mode, whose router entry (Start's public `router.entry`) + * is `router` in `src` (the module the test loads first). + */ + const importProtection = (router: string) => ({ + importProtection: {}, + router: { entry: router }, + }) + + /** + * A client module with a server fn whose top-level code calls a function + * imported from a module denied to the client. + */ + const deniedCallFiles = (denied: string) => ({ + 'src/a.ts': `import { createServerFn } from '@tanstack/react-start' +import { getRequest } from '${denied}' +const request = getRequest() +export const fn = createServerFn().handler(async () => request) +`, + 'src/request.server.ts': `export const getRequest = () => ({ url: 'MARK_REQUEST_SECRET' })\n`, + }) + + /** + * Loads `src/a.ts` in the client: the served modules with the denied + * file's code, and, in a real page, the type of the id the client's server + * fn carries (or why the page could not load it). + */ + async function loadClient( + server: Awaited<ReturnType<typeof startDevServer>>, + ) { + const modules = await server.load('/src/a.ts', { skip: /^\/@vite\b/ }) + return { + secret: modulesContaining(modules, 'MARK_REQUEST_SECRET'), + functionId: await inClient( + server, + '/src/a.ts', + 'return typeof entry.fn.url', + ), + } + } + + // Control for the pin below (same harness): a denied file goes through the + // file rule, which mocks the file itself. + test( + 'client: a server fn module calling a function of a denied file at the top level loads, without the denied code', + async () => { + const server = await startBrowserStartDevServer({ + files: deniedCallFiles('./request.server'), + start: importProtection('a.ts'), + }) + expect(await loadClient(server)).toEqual({ + secret: [], + functionId: 'string', + }) + }, + timeout, + ) + + // Bug: when the Start compiler resolves an import of the module it is + // compiling (here the callee of a top-level call next to a server fn), import + // protection handles a denied specifier before the module's transform + // result exists, and falls back to `getModuleInfo(importer).code`, which + // Vite's dev server does not support: reading it throws + // (vite/import-protection-plugin/plugin.ts `resolveExportsForDeniedSpecifier`). + // Impact: in dev, the client transform of such a module fails (500), so the + // client entry never loads and the page does not hydrate. + // Source: issue #8554 (closed without a fix). + test.fails( + 'client: a server fn module calling a function of a denied specifier at the top level loads', + async () => { + const server = await startBrowserStartDevServer({ + files: deniedCallFiles('@tanstack/react-start/server'), + start: importProtection('a.ts'), + }) + expect(await loadClient(server)).toEqual({ + secret: [], + functionId: 'string', + }) + }, + timeout, + ) + + /** + * `src/a.ts` imports `src/b.ts`, which starts with a server-only marker: + * the client loads `src/b.ts` and then `src/a.ts` (which gets a mock of + * it), then the marker is removed, with `edits`. Returns what `read()` of + * `src/a.ts` gives in a real page afterwards: the module's value, or what + * it is not. + */ + async function removeMarker(edits: Record<string, string> = {}) { + const server = await startBrowserStartDevServer({ + files: { + 'src/b.ts': `import '@tanstack/react-start/server-only' +export const secret = () => 'MARK_B_CODE' +`, + 'src/a.ts': `import { secret } from './b' +export const read = () => secret() +`, + }, + start: importProtection('a.ts'), + }) + await server.load('/src/b.ts') + expect( + modulesContaining(await server.load('/src/a.ts'), 'MARK_B_CODE'), + ).toEqual([]) + + await server.edit({ + 'src/b.ts': `export const secret = () => 'MARK_B_CODE'\n`, + ...edits, + }) + return inClient( + server, + '/src/a.ts', + `const value = entry.read() +return typeof value === 'string' ? value : 'not the module value (' + typeof value + ')'`, + ) + } + + // Control for the pin below (same harness): an importer edited with the + // module is resolved again. + test( + 'client: an edited importer of a module whose server-only marker was removed loads the module', + async () => { + expect( + await removeMarker({ + 'src/a.ts': `import { secret } from './b' +export const read = () => secret() + '!' +`, + }), + ).toBe('MARK_B_CODE!') + }, + timeout, + ) + + // Bug: import protection replaces a client import of a module it knows is + // server-only-marked with a mock when it resolves the import. On an edit of + // the marked module it only clears its own caches + // (vite/import-protection-plugin `hotUpdate`); Vite soft-invalidates the + // importers, which keep their transform, and so the import of the mock. + // Impact: after removing a server-only marker from a module, the modules + // that imported it keep a mock in dev until they are edited or the server + // restarts: the client calls mocks and logs "Mocked import used in dev + // client" errors. + test.fails( + 'client: the importer of a module whose server-only marker was removed loads the module', + async () => { + expect(await removeMarker()).toBe('MARK_B_CODE') + }, + timeout, + ) + + /** + * Starts a dev server with import protection on an app of `files` and a + * denied file `src/request.server.ts` (more with `protection`), and runs + * `script` in a real page that loaded `src/c.ts` (`entry`; + * `probeMockPrelude` defines `isSafeMock`). Returns what the script + * returns (or why the page could not load `src/c.ts`), and the server. + */ + async function inClientOf( + files: Record<string, string>, + script: string, + protection: ImportProtectionOptions = {}, + ) { + const server = await startBrowserStartDevServer({ + files: { + 'src/request.server.ts': `export const getRequest = () => ({ url: '/' })\n`, + ...files, + }, + start: { ...importProtection('c.ts'), importProtection: protection }, + }) + return { + result: await inClient( + server, + '/src/c.ts', + `${probeMockPrelude}${script}`, + ), + server, + } + } + + const deniedModules = [ + { + name: 'a denied file', + denied: './request.server', + client: `import { getRequest } from './request.server' +import * as server from './request.server' +export const values = [getRequest, server.getRequest] +`, + }, + { + name: 'a denied specifier', + denied: '@tanstack/react-start/server', + client: `import { getRequest, getRequestHeader as getHeader } from '@tanstack/react-start/server' +import * as server from '@tanstack/react-start/server' +export const values = [getRequest, getHeader, server.setCookie] +`, + }, + ] + + // Control for the pin below (same harness): the names a client module + // imports from a denied module are mocks. + test.each(deniedModules)( + 'client: names imported from $name are mocks', + async ({ client }) => { + const { result } = await inClientOf( + { 'src/c.ts': client }, + `return { + values: entry.values.length, + safeMocks: entry.values.filter((value) => isSafeMock(value)).length, +}`, + ) + const { values } = result as { values: number } + expect(values).toBeGreaterThan(0) + expect(result).toEqual({ values, safeMocks: values }) + }, + timeout, + ) + + // SPEC J6.8: in dev, a name a client module re-exports with `export *` + // from a denied module is a safe mock, or the server warns at the `export *` + // (`src/b.ts`, line 1); either way the importer loads, and nothing the + // client gets holds the denied module's value. + // Bug: in dev, a client module's `export * from` a denied module re-exports + // nothing: the mock edge of a denied specifier exports only the names its + // importer uses, and `export *` uses none; a denied file's `export *` is + // removed from the importer. + // Impact: a client module importing a name that another module re-exports + // with `export *` from a denied module fails to load (missing export), so + // the page does not hydrate. + // The rewrite of the same form (Rsbuild) also only removes the + // `export *` (today's `rewriteDeniedImports`). + test.fails.each(starReexportApps)( + 'client: a name re-exported with `export *` from $name is a mock, or the server warns at the `export *`', + async ({ files, importProtection: protection }) => { + const { result, server } = await inClientOf( + files, + `const secretIn = [] +for (const { name } of performance.getEntriesByType('resource')) { + if ((await (await fetch(name)).text()).includes('MARK_SECRET')) { + secretIn.push(new URL(name).pathname) + } +} +return { mock: isSafeMock(entry.v), secretIn }`, + protection, + ) + // The importer loads (or the reason it did not), and nothing the page + // loaded holds the denied module's value + const run = result as { mock: boolean; secretIn: Array<string> } + expect(typeof result === 'string' ? result : run.secretIn).toEqual([]) + if (!run.mock) { + expectDiagnostic(server.diagnostics, { + file: 'src/b.ts', + root: server.root, + position: { line: 1 }, + }) + } + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-route-css-rsbuild.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-route-css-rsbuild.test.ts new file mode 100644 index 0000000000..75ca2b8e8b --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-route-css-rsbuild.test.ts @@ -0,0 +1,35 @@ +/** + * The route CSS rows (`route-css-cases.ts`, SPEC J2.22) on Rsbuild's dev + * server and in an Rsbuild production build. + */ +import { routeCssSuite } from './route-css-cases' + +// Bug: the code splitter keeps the bare CSS import in the route module, +// which the route tree imports eagerly, so the CSS is in the entry's CSS +// (see known-bugs-route-css.test.ts). +// Source: #4396; src/core/code-splitter/compilers.ts (router-plugin). +// Impact: a route's styles apply on every page of the app. +const routeModuleCss = [ + 'shows-component', + 'shows-error', + 'shows-not-found', + 'shows-pending', + 'shows-nothing', +] + +// Bug: Start's Rsbuild client manifest counts a chunk as available to a +// chunk when any one of its chunk groups has it, not every one: the chunk +// of the module both routes share gets the copy of the module it imports +// in each route's chunk as a dependency, so each route's manifest entry +// lists the other route's chunk and its CSS. +// Source: #8780; computeStaticDependencyChunks, +// src/rsbuild/normalized-client-build.ts. +// Impact: the page Start renders at /shares-module-a links the stylesheet +// of /shares-module-c (and preloads its chunk), whose styles apply there; +// in dev and in a build. +const siblingChunks = ['shares-module-a', 'shares-module-c'] + +routeCssSuite('rsbuild', { + dev: [...routeModuleCss, ...siblingChunks], + build: [...routeModuleCss, ...siblingChunks], +}) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-route-css.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-route-css.test.ts new file mode 100644 index 0000000000..e065e29aec --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-route-css.test.ts @@ -0,0 +1,21 @@ +/** + * The route CSS rows (`route-css-cases.ts`, SPEC J2.22) on Vite's dev server + * and in a Vite production build. + */ +import { routeCssSuite } from './route-css-cases' + +// Bug: the code splitter keeps the bare CSS import in the route module, +// which the route tree imports eagerly: in dev the CSS is injected on every +// page once the client runs, and in a build it is merged into the entry's +// CSS, which every page links. +// Source: #4396; src/core/code-splitter/compilers.ts (router-plugin). +// Impact: a route's styles apply on every page of the app. +const routeModuleCss = [ + 'shows-component', + 'shows-error', + 'shows-not-found', + 'shows-pending', + 'shows-nothing', +] + +routeCssSuite('vite', { dev: routeModuleCss, build: routeModuleCss }) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-route-options.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-route-options.test.ts new file mode 100644 index 0000000000..6ce4fead59 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-route-options.test.ts @@ -0,0 +1,202 @@ +/** + * Known bugs in how Start reads route options from route files. Each pin + * asserts correct behaviour for a bug on main and is marked .fails; remove + * .fails when the bug is fixed. Each pin has a control test that runs the + * same harness on a case that works. + * + * Start decides from the route generator's view of a route file which routes + * are server-only (pruned from the client route tree), and strips the server + * options (`server`, `headers`, `ssr`) of route modules from the client. + * Resolving every option key is best effort, but a missed key must never + * prune a route or leave server code in the client bundle. + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../build-harness' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const routeHead = `import { createFileRoute } from '@tanstack/react-router' +const Page = () => null +` + +/** + * Rows of route options that keep a route with server handlers a page, with + * the declarations they read. + */ +const pageOptions = [ + { + name: 'a spread', + head: `const clientOptions = { component: Page }\n`, + options: `...clientOptions`, + }, + { + name: 'a computed key', + head: `const key = 'component'\n`, + options: `[key]: Page`, + }, + { name: 'a method', head: '', options: `component() { return null }` }, + { + name: 'an async method', + head: '', + options: `async loader() { return null }`, + }, + { name: 'an accessor', head: '', options: `get component() { return Page }` }, +] + +/** Casts real route files wrap their options in. */ +const casts = [ + { name: 'as never', wrap: (options: string) => `(${options} as never)` }, + { name: 'as any', wrap: (options: string) => `(${options} as any)` }, + { + name: 'satisfies', + wrap: (options: string) => `(${options} satisfies Record<string, unknown>)`, + }, +] + +/** Route path (and file name) of a row. */ +const slug = (name: string) => name.replace(/\W+/g, '-') + +describe.each(startBundlers)('%s build: server-only routes', (bundler) => { + /** + * One app with a route file per row, each importing a module whose code + * carries the row's marker into its server handler. + */ + const files: Record<string, string> = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/page.tsx': `${routeHead}export const Route = createFileRoute('/page')({ server: { handlers: {} }, component: Page })\n`, + 'src/routes/api.tsx': `${routeHead}export const Route = createFileRoute('/api')({ server: { handlers: {} } })\n`, + // The same two routes with string option keys, and with an aliased + // Route export. + 'src/routes/string-keys.tsx': `${routeHead}export const Route = createFileRoute('/string-keys')({ 'server': { handlers: {} }, 'component': Page })\n`, + 'src/routes/string-keys-api.tsx': `${routeHead}export const Route = createFileRoute('/string-keys-api')({ 'server': { handlers: {} } })\n`, + 'src/routes/aliased.tsx': `${routeHead}const PageRoute = createFileRoute('/aliased')({ server: { handlers: {} }, component: Page })\nexport { PageRoute as Route }\n`, + 'src/routes/aliased-api.tsx': `${routeHead}const ApiRoute = createFileRoute('/aliased-api')({ server: { handlers: {} } })\nexport { ApiRoute as Route }\n`, + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router'\n`, + } + for (const { name, head, options } of pageOptions) { + files[`src/routes/${slug(name)}.tsx`] = + `${routeHead}${head}export const Route = createFileRoute('/${slug(name)}')({ server: { handlers: {} }, ${options} })\n` + } + for (const { name, wrap } of casts) { + const marker = `MARK_CAST_${slug(name).toUpperCase().replace(/-/g, '_')}` + files[`src/deps/${slug(name)}.ts`] = + `export const handle = () => '${marker}'\n` + files[`src/routes/cast-${slug(name)}.tsx`] = + `import { createFileRoute } from '@tanstack/react-router' +import { handle } from '../deps/${slug(name)}' +export const Route = createFileRoute('/cast-${slug(name)}')(${wrap( + `{ server: { handlers: { GET: () => handle() } } }`, + )}) +` + } + + let build: StartBuild + let dispose: (() => Promise<void>) | undefined + /** Ids of the routes of the client build's route tree. */ + let clientRoutes: Array<string> + beforeAll(async () => { + build = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + clientRoutes = ( + await build.client.run( + `return Object.values(entry.getRouter().routeTree.children ?? {}).map((route) => route.options.id)`, + ) + ).result as Array<string> + }, timeout) + afterAll(() => dispose?.()) + + // Control for the pins below (same build). + test('a route with server handlers and a component is in the client route tree', () => { + expect(clientRoutes).toContain('/page') + }) + + // Vite: control for the pins below (same build). + // Rsbuild bug: Start prunes server-only routes from the client route tree + // only in its Vite plugin; Rsbuild keeps them (their route modules have + // no server code left). + // Source: only vite/start-router-plugin/plugin.ts calls + // `pruneServerOnlySubtrees`; Rsbuild parity is the intended behaviour. + // Impact: Rsbuild client bundles ship the route tree entries and route + // modules of server-only routes, which Vite builds leave out. + ;(bundler === 'vite' ? test : test.fails)( + 'a route with only server handlers is not in the client route tree', + () => { + expect(clientRoutes).not.toContain('/api') + }, + ) + + // Option keys written as strings and a Route exported under an alias are + // read like the plain ones above (same build; moved from router-generator + // known-bugs.test.ts, which read the generator's internal option keys). + describe.each([ + { + name: 'string option keys', + page: '/string-keys', + api: '/string-keys-api', + }, + { name: 'an aliased Route export', page: '/aliased', api: '/aliased-api' }, + ])('$name', ({ page, api }) => { + test('a route with server handlers and a component is in the client route tree', () => { + expect(clientRoutes).toContain(page) + }) + + // Rsbuild does not prune the client route tree yet (pinned above). + ;(bundler === 'vite' ? test : test.fails)( + 'a route with only server handlers is not in the client route tree', + () => { + expect(clientRoutes).not.toContain(api) + }, + ) + }) + + // Bug: the route generator records only plain, non-computed, non-method + // property keys of the route options (`createFileRouteProps`), so a + // spread, a computed key, a method or an accessor is missed, and Start + // takes a route with server handlers and only such client options for a + // server-only route. + // Impact: the route is pruned from the client route tree: navigating to it + // in the browser finds no route. + // Source: #8504 router-generator transform.test.ts ("records + // method, async method and accessor option keys"), where the method and + // accessor rows pass. + describe.each(pageOptions)('$name', ({ name }) => { + // Rsbuild does not prune the client route tree yet (pinned above), so + // the route stays. + ;(bundler === 'vite' ? test.fails : test)( + 'a route with server handlers and these options is in the client route tree', + () => { + expect(clientRoutes).toContain(`/${slug(name)}`) + }, + ) + }) + + // Bug: route options wrapped in a cast (`as never`, `as any`, + // `satisfies`) are not recognised: the code splitter's `deleteNodes` + // (Start's list: `server`, `headers`, `ssr`) skips them, and the route + // generator records no option keys, so Start does not prune the route + // either. + // Impact: the route's server handlers and their server-only imports ship + // to the client bundle. + // Real apps wrap route options in `as never` / `as any`. + describe.each(casts)('options wrapped in $name', ({ name }) => { + test.fails( + 'the server handler code of the route is not in the client bundle', + () => { + const marker = `MARK_CAST_${slug(name).toUpperCase().replace(/-/g, '_')}` + expect(build.client.where(marker)).toBe('nowhere') + }, + ) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-dev.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-dev.test.ts new file mode 100644 index 0000000000..0f65925aa0 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-dev.test.ts @@ -0,0 +1,430 @@ +// Slow-tier part of known-bugs-start-compiler: the Vite dev server tests +// (its own file, so that they run beside the build tests). Builds: +// known-bugs-start-compiler.test.ts; in-process tests: +// ../known-bugs-start-compiler.test.ts. +/** + * Known Start compiler bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ +import { mkdir, rm, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { performance } from 'node:perf_hooks' +import { createServer, isRunnableDevEnvironment } from 'vite' +import { describe, expect, onTestFinished, test, vi } from 'vitest' +import { createAppDirectory } from '@tanstack/compiler-test-utils/app-directory' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { closeViteServer } from '@tanstack/compiler-test-utils/dev-server' +import { linkStartRuntime } from '../build-harness' +import { + callServerFn, + startDevServer, + startPlugin, + startPluginFiles, + startRequestFiles, +} from '../dev-server' +import { reactApp } from './hydrate-dev-edits' +import { + runViteClient, + startBrowserStartDevServer, +} from './importProtection/client-pages' + +const head = `import { createServerFn } from '@tanstack/react-start'\n` + +describe('Vite dev server', () => { + /** + * Resolves `'hang'` once `pending` has made no progress for `quietMs`: no + * plugin hook ran (`lastActivity()`) and the main thread stayed idle (a + * dependency optimizer bundling, or any other work the request waits for, + * keeps it busy). Resolves `'settled'` when `pending` settles first, and + * `'hang'` after `limitMs` at the latest. + */ + async function settledOrHung( + pending: Promise<unknown>, + lastActivity: () => number, + { quietMs = 1_500, limitMs = 15_000 } = {}, + ): Promise<'settled' | 'hang'> { + let settled = false + pending.then( + () => (settled = true), + () => (settled = true), + ) + // Read through a function: the callbacks above set it. + const isSettled = () => settled + const started = performance.now() + let busySince = started + let previous = performance.eventLoopUtilization() + while (!isSettled()) { + await new Promise((resolve) => setTimeout(resolve, 100)) + if (isSettled()) { + break + } + const current = performance.eventLoopUtilization() + if ( + performance.eventLoopUtilization(current, previous).utilization > 0.05 + ) { + busySince = performance.now() + } + previous = current + const now = performance.now() + const quietFor = now - Math.max(lastActivity(), busySince) + if (quietFor >= quietMs || now - started >= limitMs) { + return 'hang' + } + } + return 'settled' + } + + /** + * Creates a Vite dev server (empty dependency cache) on a temporary project + * with Start's whole Vite plugin, Start's real runtime (`linkStartRuntime`), + * `src/fn.ts` = `code` and `files` (in `src`), requests the client + * transform of `src/fn.ts`, and starts the server (`listen()`) once Vite + * loads that module. The transform is then in flight when Vite's dependency + * optimizer starts, so it is part of the optimizer's first crawl of static + * imports (the optimizer's first run waits for it), whatever the timing. A + * request made after the server started joins that crawl only when it + * reaches Vite within 50 ms of the optimizer's start, which a loaded machine + * can miss. Returns `'hang'` when the transform stops making progress + * before it finishes (`settledOrHung`); otherwise the code it served. + */ + async function transformClientModule( + code: string, + files: Record<string, string> = {}, + ) { + // A temporary project whose dependencies resolve as from this directory + const root = await createAppDirectory(__dirname, '.dev-transform-') + let server: Awaited<ReturnType<typeof createServer>> | undefined + let lastActivity = performance.now() + const active = () => { + lastActivity = performance.now() + return null + } + const fnFile = path.join(root, 'src/fn.ts') + let fnLoading!: () => void + // Vite calls the load hooks of a module once it tracks its request + const fnLoaded = new Promise<void>((resolve) => (fnLoading = resolve)) + let hung = false + try { + for (const [file, content] of Object.entries({ + ...startPluginFiles, + ...Object.fromEntries( + Object.entries({ 'fn.ts': code, ...files }).map(([name, source]) => [ + `src/${name}`, + source, + ]), + ), + })) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), content) + } + await linkStartRuntime(root) + server = await createServer({ + root, + configFile: false, + logLevel: 'silent', + cacheDir: path.join(root, '.vite'), + appType: 'custom', + // One address, as the harness's other servers: 127.0.0.1, because of + // Node's address-family selection + server: { host: '127.0.0.1', hmr: false, ws: false, watch: null }, + plugins: [ + { + name: 'record-activity', + enforce: 'pre', + resolveId: active, + load(id) { + if (id === fnFile) { + fnLoading() + } + return active() + }, + transform: active, + }, + startPlugin(root, {}), + ], + }) + // A server that is not listening yet has not started its dependency + // optimizer (Vite starts it in `listen()`) + const transformed = + server.environments.client.transformRequest('/src/fn.ts') + await Promise.race([fnLoaded, transformed.catch(() => {})]) + await server.listen() + if ((await settledOrHung(transformed, () => lastActivity)) === 'hang') { + hung = true + transformed.catch(() => {}) + return 'hang' as const + } + return { code: (await transformed)!.code } + } finally { + // A hung server's optimizer waits for the hung transform: it writes + // nothing more, and `close()` may wait for that transform + await (hung + ? Promise.race([ + server?.close(), + new Promise((resolve) => setTimeout(resolve, 3_000)), + ]) + : server && closeViteServer(server)) + await rm(root, { recursive: true, force: true }) + } + } + + /** + * The client got `fn` as an RPC carrying its id, without the handler body + * (`MARK_HANDLER`): the first request of a fresh dev server finishes + * (`transformClientModule`) without the handler, and a real page of a dev + * server of the same app runs `fn` as an RPC (its public `url`; the dev id + * is implementation-specific, J4.4). + */ + async function expectClientRpc( + code: string, + files: Record<string, string> = {}, + ) { + const result = await transformClientModule(code, files) + expect(result).not.toBe('hang') + expect((result as Exclude<typeof result, 'hang'>).code).not.toContain( + 'MARK_HANDLER', + ) + const server = await startBrowserStartDevServer({ + files: Object.fromEntries( + Object.entries({ 'fn.ts': code, ...files }).map(([name, source]) => [ + `src/${name}`, + source, + ]), + ), + }) + const { result: rpc } = await runViteClient( + server, + '/src/fn.ts', + `return { url: entry.fn.url }`, + ) + expect(rpc).toEqual({ url: expect.any(String) }) + } + + // Control for the pin below (same harness). + test('transforms a client module with a server fn and a top-level call of a project function', async () => { + await expectClientRpc( + `${head}import { define } from './define' +export const schema = define() +export const fn = createServerFn().handler(() => 'MARK_HANDLER')`, + { 'define.ts': `export const define = () => ({})` }, + ) + }, 30_000) + + // Regression (was a pin; fixed on main by #8758): a `z.object()` schema next + // to a server fn, with an empty dependency cache, used to never finish + // transforming in dev. The client compiler loaded `zod` through the client + // environment from inside the transform, and that load waited for the + // dependency optimizer, which waited for this transform. + test('transforms a client module with a server fn and a top-level member call of a pre-bundled dependency', async () => { + await expectClientRpc( + `${head}import { z } from 'zod' +export const schema = z.object({}) +export const fn = createServerFn().handler(() => 'MARK_HANDLER')`, + ) + }, 30_000) + + // Bug: next to a server fn, a top-level `const x = f()` may be a renamed or + // re-exported Start factory, so in dev the client compiler loads the module + // of `f` through the client environment, from inside the transform. For a + // pre-bundled dependency (here `zod`) with an empty dependency cache, that + // load waits for the dependency optimizer, which waits for this transform. + // (#8758 skips this load for `receiver.method()` calls on a named import, + // as in the regression test above, but not for a call of the import itself.) + // Source: the pin of the `z.object()` row above, before #8758. + // Impact: with an empty dependency cache, such a module (an `object()` + // schema from `import { object } from 'zod'` next to a server fn) never + // finishes transforming when its transform is part of Vite's first crawl of + // static imports: requested before the server listens, or within about + // 50 ms of the dependency optimizer's start (`server.warmup`, the first + // request of a middleware-mode server), and the page hangs. + test.fails( + 'transforms a client module with a server fn and a top-level call of a pre-bundled dependency', + async () => { + await expectClientRpc( + `${head}import { object } from 'zod' +export const schema = object({}) +export const fn = createServerFn().handler(() => 'MARK_HANDLER')`, + ) + }, + 30_000, + ) + + /** + * Starts a Vite dev server (middleware mode) with Start's Vite plugin on + * `root` (which links Start's real runtime and has `startAppFiles`), with + * SSR as the server fn provider. + */ + function startServerFnDevServer(root: string) { + return createServer({ + root, + configFile: false, + logLevel: 'silent', + cacheDir: path.join(root, '.vite'), + appType: 'custom', + server: { middlewareMode: true, hmr: false, ws: false, watch: null }, + plugins: [startPlugin(root, {})], + }) + } + + /** + * The files of Start's plugin (`startPluginFiles`), with Start's default + * server entry and what a request needs (`startRequestFiles`): Start's + * server entry handles server fn calls. + */ + const startAppFiles = { ...startPluginFiles, ...startRequestFiles } + + /** + * In a temporary project with `src/fns.ts` = a `greet` server fn, reads the + * id of `greet` through a first dev server, then calls the id the way a + * page does (`callServerFn`: Start's server entry handles it) on a dev + * server started with `fresh` (a new server, which has compiled nothing) + * or on the same server. Returns the result or the error message. + */ + async function callServerFnId(fresh: boolean) { + const root = await createAppDirectory(__dirname, '.dev-server-fn-') + const servers: Array<Awaited<ReturnType<typeof createServer>>> = [] + try { + for (const [file, code] of Object.entries({ + ...startAppFiles, + 'src/fns.ts': `${head}export const greet = createServerFn().handler(() => 'hello')\n`, + })) { + await mkdir(path.dirname(path.join(root, file)), { recursive: true }) + await writeFile(path.join(root, file), code) + } + await linkStartRuntime(root) + /** Imports a module in the SSR environment of a dev server. */ + const importSsr = ( + server: Awaited<ReturnType<typeof createServer>>, + id: string, + ) => { + const ssr = server.environments.ssr + if (!isRunnableDevEnvironment(ssr)) { + throw new Error('expected a runnable SSR environment') + } + return ssr.runner.import(id) + } + const first = await startServerFnDevServer(root) + servers.push(first) + const { greet } = await importSsr(first, '/src/fns.ts') + let server = first + if (fresh) { + await servers.pop()!.close() + server = await startServerFnDevServer(root) + servers.push(server) + } + const ssr = server + // Start's server logs the error of a failed call (a Vite plugin error + // here), which Vitest's console forwarding does not survive. + const logged = vi.spyOn(console, 'error').mockImplementation(() => {}) + try { + return await callServerFn({ import: (id) => importSsr(ssr, id) }, greet) + } catch (error) { + return `throws: ${(error as Error).message}` + } finally { + logged.mockRestore() + } + } finally { + for (const server of servers) { + await server.close() + } + await rm(root, { recursive: true, force: true }) + } + } + + // Control for the pin below (same harness). + test('calls a server fn id on the dev server that compiled its module', async () => { + expect(await callServerFnId(false)).toBe('hello') + }, 30_000) + + // Bug: when a server fn id is not registered yet, the dev validator + // (`validate-server-fn-id`) transforms the source file under + // `?server-fn-module-lookup`, the one id the compiling transform excludes, + // so the id is never registered and the validator rejects it. + // Impact: after a dev server restart, calling a server fn whose module the + // new server has not compiled yet (e.g. from a page loaded before the + // restart) fails with "Invalid server function ID" (500). + // Source: issue #8447. + test.fails( + 'calls a server fn id on a fresh dev server that has not compiled its module', + async () => { + expect(await callServerFnId(true)).toBe('hello') + }, + 30_000, + ) + + // SPEC J4.16, G13, G1: a library Start's discovery selects (a peer + // dependency on `@tanstack/react-start`) keeps working in dev as in a + // build, including what it imports from a CommonJS dependency. + // Bug: Start puts the libraries it discovers in the client's + // `optimizeDeps.exclude`, so Vite serves them as source and their + // CommonJS dependency reaches the browser untransformed ("does not provide + // an export named 'parse'"). + // Source: src/vite/plugin.ts (crawlFrameworkPkgs), src/vite/planning.ts + // (`optimizeDeps.exclude`); issues #5738, #6361. + // Impact: in dev, a client route using such a library does not run. + test.fails( + "a Start library's import of a CommonJS dependency works in a client route", + async () => { + const cwd = process.cwd() + let server: Awaited<ReturnType<typeof startDevServer>> + try { + server = await startDevServer({ + browser: true, + files: { + ...reactApp, + 'package.json': JSON.stringify({ + name: 'app', + private: true, + type: 'module', + dependencies: { 'start-lib': '*' }, + }), + 'node_modules/start-lib/package.json': JSON.stringify({ + name: 'start-lib', + type: 'module', + exports: './index.js', + peerDependencies: { '@tanstack/react-start': '*' }, + }), + 'node_modules/start-lib/index.js': `import { parse } from 'cjs-dep' +export const format = (value) => 'lib ' + parse(value) +`, + 'node_modules/cjs-dep/package.json': JSON.stringify({ + name: 'cjs-dep', + main: './index.js', + }), + 'node_modules/cjs-dep/index.js': `exports.parse = (value) => 'parsed:' + value\n`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +import { format } from 'start-lib' +export const Route = createFileRoute('/')({ component: Page }) +function Page() { + const [text, setText] = useState('') + return <button data-testid="lib" onClick={() => setText(format('x'))}>clicked {text}</button> +} +`, + }, + // `vite dev` runs in the app's directory, whose package.json + // Start reads to discover the libraries + plugins: ({ root }) => { + process.chdir(root) + return [] + }, + }) + } finally { + process.chdir(cwd) + } + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + await browser.page.locator('[data-testid=lib]').click() + await browser.waitForText('clicked lib parsed:x', { + selector: '[data-testid=lib]', + timeout: 5_000, + }) + expect(browser.errors).toEqual([]) + }, + 60_000, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-vue-sfc.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-vue-sfc.test.ts new file mode 100644 index 0000000000..36d5b5f1a8 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler-vue-sfc.test.ts @@ -0,0 +1,83 @@ +/** + * Known Start compiler bug in a Vue single-file component, through the + * public Start host (`createStartHost`): a Vue Start app with + * `tanstackStart()` of `@tanstack/vue-start/plugin/vite` and Vue's own Vite + * plugin (`@vitejs/plugin-vue`, which serves an SFC's `<script lang="ts">` + * block in builds as its own module, `Page.vue?vue&type=script&lang.ts`), + * built with `vite build` (`build()`). Formerly a pin on the internal + * compiler in known-bugs-start-compiler.test.ts, moved here once + * `@vitejs/plugin-vue` became a test-only devDependency. + */ +import { afterAll, expect, test } from 'vitest' +import { createStartHost } from '../regression-helpers' +import type { StartHost } from '../regression-helpers' + +const hosts: Array<StartHost> = [] +afterAll(async () => { + for (const host of hosts) { + await host.close() + } +}) + +/** + * Builds a Vue Start app whose case has an SFC `Page.vue` with `script` as + * its `<script lang="ts">` block (a server fn `fn` whose handler reads the + * server-only `./db.server`), re-exported by the case module, and checks + * that the build succeeds with the SFC in the client build and the + * server-only module not shipped there. + */ +async function expectSfcServerFnBuilds(script: string) { + const host = await createStartHost({ framework: 'vue', serve: false }) + hosts.push(host) + const startCase = await host.case({ + 'Page.vue': `<script lang="ts"> +${script} +export default {} +</script> + +<template> + <p>page</p> +</template> +`, + 'db.server.ts': `export const db = { x: (input: string) => 'MARK_DB_SERVER:' + input }\n`, + 'module.ts': `export { fn } from './Page.vue'\n`, + }) + const build = await host.build() + const client = build.environments.client!.chunks + // The SFC is in the client build (through the case module) + expect( + client.some((chunk) => + chunk.moduleIds.some((id) => id.startsWith(startCase.file('Page.vue'))), + ), + ).toBe(true) + for (const chunk of client) { + expect(chunk.code, chunk.fileName).not.toContain('MARK_DB_SERVER') + } +} + +const head = `import { createServerFn } from '@tanstack/vue-start' +import { db } from './db.server' +` + +// Control (same harness): the block without TypeScript-only syntax. +test('build: a server fn in a <script lang="ts"> block', async () => { + await expectSfcServerFnBuilds(`${head}const input = (globalThis as any).input as string +export const fn = createServerFn().handler(async () => db.x(input))`) +}) + +// Bug: the parser is chosen from the module id without its query, so the +// `<script lang="ts">` block of a Vue SFC, which @vitejs/plugin-vue 6 +// serves in builds as `Page.vue?vue&type=script&lang.ts` (genScriptCode, +// attrsToQuery), is parsed as TSX. (A `<script setup>` block cannot hold +// the exported server fn.) +// Impact: TypeScript-only syntax such as a `<string>value` assertion fails +// the build. +// Fix-agnostic: the build succeeds, the SFC is in the client build, and +// the server-only module the handler reads is not. +test.fails( + 'build: a server fn in a <script lang="ts"> block may use angle-bracket type assertions', + async () => { + await expectSfcServerFnBuilds(`${head}const input = <string>(globalThis as any).input +export const fn = createServerFn().handler(async () => db.x(input))`) + }, +) diff --git a/packages/start-plugin-core/tests/integration/known-bugs-start-compiler.test.ts b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler.test.ts new file mode 100644 index 0000000000..ffbb60d721 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/known-bugs-start-compiler.test.ts @@ -0,0 +1,662 @@ +// Slow-tier half of this suite: the tests that need a real build. Its +// in-process tests are in ../known-bugs-start-compiler.test.ts (fast tier), +// its Vite dev server tests in known-bugs-start-compiler-dev.test.ts. +/** + * Known Start compiler bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + */ +import { describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' +import { + clientPage, + runInClient, + startRsbuildStartDevServer, +} from '../rsbuild-dev-server' +import { expectSourceError } from './source-errors' + +const head = `import { createServerFn } from '@tanstack/react-start'\n` + +/** + * An installed CommonJS package (no `"type"`, so its `.js` file is a + * script, as in old npm packages) with a top-level `return`, which only a + * script may have, and the text `.handler(` but no Start API. + */ +const commonJsPackage = { + 'node_modules/legacy-lib/package.json': JSON.stringify({ + name: 'legacy-lib', + version: '1.0.0', + main: 'index.js', + }), + 'node_modules/legacy-lib/index.js': `if (typeof module !== 'object') return +module.exports = function (app) { + return app.handler(1) +} +`, +} + +/** App code that calls the package and keeps what it returned. */ +const commonJsImporter = `import legacy from 'legacy-lib' +export const result = legacy({ handler: (value: unknown) => ['handled', value] }) +;(globalThis as any).legacyResult = result +` + +describe.each(startBundlers)('%s build', (bundler) => { + const timeout = 60_000 + + /** A server-only module whose top-level code marks the bundle it is in. */ + const dbModule = `globalThis.MARK_DB_LOADED = true +export const db = { users: () => 'users' } +` + + // Control for the pin below (same harness). + test( + 'client: the server-only module of a function only server code uses is not bundled', + async () => { + const { client } = await buildStart({ + bundler, + files: { + 'db.server.ts': dbModule, + 'fns.ts': `${head}import { db } from './db.server' +function find() { return db.users() } +export const fn = createServerFn().handler(async () => find()) +`, + 'entry.ts': `export { fn } from './fns'\n`, + }, + }) + expect(client.where('MARK_DB_LOADED')).toBe('nowhere') + }, + timeout, + ) + + // Bug: the client output keeps a class only server code uses, with its + // server-only import (compiler pin "client: a class used by a server fn + // handler does not load its server-only import" in + // ../known-bugs-start-compiler.test.ts). Tree-shaking drops the unused + // class but keeps the import, so the server-only module's top-level code + // is bundled and runs in the browser. + // Impact: server-only modules (database clients, SDKs initialised with + // secrets) ship to the client and run their top-level code there. + // One bundler (Vite): the compiler decides, as the import it leaves in + // the client module loads the server-only module in any bundler; the + // in-process pin above decides it, and this cell is its build canary. + // (No Rsbuild cell: it was removed to save test time.) + if (bundler === 'vite') { + test.fails( + 'client: the server-only module of a class only server code uses is not bundled', + async () => { + const { client } = await buildStart({ + bundler, + files: { + 'db.server.ts': dbModule, + 'fns.ts': `${head}import { db } from './db.server' +class Repo { get() { return db.users() } } +export const fn = createServerFn().handler(async () => new Repo().get()) +`, + 'entry.ts': `export { fn } from './fns'\n`, + }, + }) + expect(client.where('MARK_DB_LOADED')).toBe('nowhere') + }, + timeout, + ) + } + + /** A server fn module whose `auth` import a type still mentions. */ + const typeofFiles = (verbatimModuleSyntax: boolean) => ({ + 'tsconfig.json': JSON.stringify({ + compilerOptions: { verbatimModuleSyntax }, + }), + 'auth.ts': `globalThis.MARK_AUTH_LOADED = true +export const auth = { get: () => 'session', session: 'session' } +`, + 'fns.ts': `${head}import { auth } from './auth' +type Session = typeof auth.session +export const fn = createServerFn().handler(async () => auth.get() as Session) +`, + 'entry.ts': `export { fn } from './fns'\n`, + }) + + // Control for the pin below (same harness): without verbatimModuleSyntax, + // TypeScript erases the import that only a type mentions. + test( + 'client: a server-only module a type mentions is not bundled', + async () => { + const { client } = await buildStart({ + bundler, + files: typeofFiles(false), + }) + expect(client.where('MARK_AUTH_LOADED')).toBe('nowhere') + }, + timeout, + ) + + // Bug (Vite): the client output keeps the server-only import that a + // `typeof` type query still mentions (compiler pin "client: a server-only + // import last mentioned by a type alias ..." above); with + // `verbatimModuleSyntax`, Vite's TypeScript transform keeps it. Rsbuild's + // transform of the same app drops it. + // Impact: the server-only module's top-level code is bundled and runs in + // the browser. + // A build canary of the in-process compiler pin. + ;(bundler === 'vite' ? test.fails : test)( + 'client: a server-only module a type mentions is not bundled with verbatimModuleSyntax', + async () => { + const { client } = await buildStart({ bundler, files: typeofFiles(true) }) + expect(client.where('MARK_AUTH_LOADED')).toBe('nowhere') + }, + timeout, + ) + + // Bug: with SSR as the server fn provider, the SSR caller module and the + // provider module (`?tss-serverfn-split`) are two module instances of the + // same file in the SSR bundle, and the provider repeats the file's + // top-level code (exports-and-directives.test.ts "side-effect imports and + // top-level statements stay in every output" asserts this). + // Impact: in one server process, the file's top-level side effects run + // twice, handlers and SSR code of the file see different module state, and + // `instanceof` fails for a class of the file passed to a server fn. + // Source: PR #8656 (class identity). + test.fails( + 'SSR: a server fn module is initialised once and shares its state with SSR code', + async () => { + const { ssr } = await buildStart({ + bundler, + files: { + 'fns.ts': `${head}globalThis.initialised = (globalThis.initialised ?? 0) + 1 +let count = 0 +export class Session {} +export const readCount = () => count +export const fn = createServerFn().handler(async ({ data }) => { + count++ + return data instanceof Session +}) +`, + 'entry.ts': `export { fn, readCount, Session } from './fns'\n`, + }, + }) + const { result } = + await ssr.run(`const isSession = await entry.fn({ data: new entry.Session() }) +return { initialised: globalThis.initialised, isSession, count: entry.readCount() }`) + expect(result).toEqual({ initialised: 1, isSession: true, count: 1 }) + }, + timeout, + ) + + /** + * An app whose client imports one server fn (`clientFn`) and whose server + * entry imports another one only server code uses (`serverOnlyFn`), and + * Start's server entry, whose server-fn HTTP handler finds server fns by + * id (`callByIdExports`). (Were `serverOnlyFn` missing from what the + * server knows, issue #7213, the SSR call below would fail too: the pin + * asserts it, so it cannot pass by a missing server fn.) + */ + const clientAccessFiles = { + 'client-fns.ts': `${head}export const clientFn = createServerFn().handler(async () => 'client fn') +`, + 'server-only-fns.ts': `${head}export const serverOnlyFn = createServerFn().handler(async () => 'server-only fn') +`, + 'client-entry.ts': `export { clientFn } from './client-fns' +`, + 'ssr-entry.ts': `export { serverOnlyFn } from './server-only-fns' +${callByIdExports}`, + } + + /** + * Builds `clientAccessFiles` and, in the SSR build, sends a request for + * each server fn id to Start's server entry, as a page does + * (`callByIdPrelude`), and calls the server-only one from SSR code. One + * build and run for the control and the pin below, which read the same + * results (`clientAccess`). + */ + async function buildAndCallClientAccess() { + const { client, ssr } = await buildStart({ + bundler, + files: clientAccessFiles, + entry: { client: 'client-entry.ts', ssr: 'ssr-entry.ts' }, + }) + // (the handler's text, however the bundle quotes it) + expect(client.where('server-only fn')).toBe('nowhere') + // (each server fn by its public URL: the server fn base, then its id; + // `serverFnId` throws outside `settle` for a value without one, so the + // pin cannot read a missing URL as a rejected call) + const clientFnUrl = (await client.run(`return entry.clientFn.url`)).result + const { result } = + await ssr.run(`${callByIdPrelude}const settle = async (run) => { + try { + return await run() + } catch { + return 'rejected' + } +} +const overHttp = (id) => + settle(async () => callById(id)) +const clientFnId = serverFnId(${JSON.stringify(clientFnUrl)}) +const serverOnlyFnId = serverFnId(entry.serverOnlyFn) +return { + clientFn: await overHttp(clientFnId), + serverOnlyFnOverHttp: await overHttp(serverOnlyFnId), + serverOnlyFnFromSsr: await settle(() => entry.serverOnlyFn()), +}`) + return result + } + let clientAccess: ReturnType<typeof buildAndCallClientAccess> | undefined + const callClientAccess = () => (clientAccess ??= buildAndCallClientAccess()) + + // Controls for the pin below (same harness). + test( + 'SSR: a server fn the client references is callable over HTTP', + async () => { + expect(await callClientAccess()).toMatchObject({ clientFn: 'client fn' }) + }, + timeout, + ) + // Not run on Vite: there, whether `serverOnlyFn` is in the production + // resolver is the #7213 race (below): the SSR build reaches its module + // and the resolver in parallel, and finds it first by about 12 ms on an + // idle machine. The row after it asserts this call on both bundlers in an + // order the app fixes, and the pin below asserts it too. + if (bundler !== 'vite') { + test( + 'SSR: a server fn only server code references is callable from SSR code', + async () => { + expect(await callClientAccess()).toMatchObject({ + serverOnlyFnFromSsr: 'server-only fn', + }) + }, + timeout, + ) + } + // The app's server entry (Start's documented `server.entry`, here the + // harness's) defines the server fn: the SSR build finds it when it + // compiles that entry, before it reaches any module the entry imports, + // Start's server fn resolver included, so on Vite too the order is fixed. + // (SPEC J4.2: a server fn only server code calls works for those callers; + // J4.6: a server fn declared at module top level works everywhere.) + test( + 'SSR: a server fn the server entry defines and only server code references is callable from SSR code', + async () => { + const { ssr } = await buildStart({ + bundler, + files: { + 'entry.ts': `export {}\n`, + 'harness/server-entry.ts': `${head}export const serverOnlyFn = createServerFn().handler(async () => 'server-only fn') +;(globalThis as any).__tssBuildHarnessEntry = { serverOnlyFn } +export { default } from '@tanstack/react-start/server-entry' +`, + }, + }) + const { result } = await ssr.run(`return await entry.serverOnlyFn()`) + expect(result).toBe('server-only fn') + }, + timeout, + ) + + // Bug: with SSR as the provider, the production resolver lists every + // server fn the builds found and never checks the caller's origin + // (`includeClientReferencedCheck` is off, and the flag it would check is + // true for every SSR-caller compile, handleCreateServerFn.ts + // `isClientReferenced`). + // Impact: a server fn only server code uses (an SSR loader helper, a + // server-only module) is callable over HTTP by anyone who learns its id, + // bypassing what the server code around it checks. + // SPEC J4.2: in a production build, only server fns client code + // references are HTTP-callable (dev may answer any). + // On Vite, when the SSR build loses the #7213 race (below), the server fn + // is missing from the resolver: the call from SSR code fails too, so the + // pin stays red (for #7213) and cannot pass by the missing server fn. + test.fails( + 'SSR: a server fn only server code references is not callable over HTTP', + async () => { + expect(await callClientAccess()).toEqual({ + clientFn: 'client fn', + serverOnlyFnOverHttp: 'rejected', + serverOnlyFnFromSsr: 'server-only fn', + }) + }, + timeout, + ) + + // Bug (Vite): the production server fn resolver is generated when the SSR + // build first loads it, from the server fns found so far. A server fn that + // only server code calls (another server fn's handler, a middleware + // `.server()`) is found when the SSR build compiles the module that calls + // it. When the SSR build reaches that module only through the resolver, + // the server fn is found after the resolver was generated and is missing + // from it. Only the resolver imports a server fn's handler (its provider + // module) and, when only client code imports a server fn, everything that + // server fn uses, its middleware included. Rsbuild rebuilds the resolver + // after the SSR compilation found every server fn. + // Impact: in production, calling it throws "Server function info not + // found" (works in dev), from SSR code and over HTTP alike. + // Source: issue #7213; SPEC J4.2 ("in any module processing order", G4). + // When SSR code imports the server fn, or its caller, from another module, + // the SSR build reaches the module that calls it and the resolver in + // parallel: then whether it is in the resolver is a race (see the + // controls above). + // Not run on Vite: the middleware caller (the one #7213 quotes) when SSR + // code imports the server fn that uses the middleware. The SSR build then + // reaches the middleware's module and the resolver in parallel, and + // whether it finds the server fn first is a race, which Vite usually wins + // by a few milliseconds and loses under heavy load; no app input orders + // the two. The rows where only client code imports that server fn pin + // this caller deterministically. + const innerFn = `${head}export const inner = createServerFn().handler(async () => 'inner') +` + const calledByServerCode = { + 'another server fn': { + 'inner.ts': innerFn, + 'outer.ts': `${head}import { inner } from './inner' +export const outer = createServerFn().handler(async () => 'outer:' + (await inner())) +`, + }, + 'a middleware .server() of another module': { + 'inner.ts': innerFn, + 'auth.ts': `import { createMiddleware } from '@tanstack/react-start' +import { inner } from './inner' +export const auth = createMiddleware({ type: 'function' }).server(async ({ next }) => + next({ context: { inner: await inner() } }), +) +`, + 'outer.ts': `${head}import { auth } from './auth' +export const outer = createServerFn() + .middleware([auth]) + .handler(async ({ context }) => 'outer:' + context.inner) +`, + }, + } + describe.each(Object.entries(calledByServerCode))( + 'SSR: a server fn that only %s calls', + (caller, modules) => { + const files = (order: 'as written' | 'reversed', ssrEntry: string) => { + const entries = Object.entries({ + ...modules, + 'client-entry.ts': `export { outer } from './outer'\n`, + 'ssr-entry.ts': ssrEntry, + }) + return Object.fromEntries( + order === 'reversed' ? entries.reverse() : entries, + ) + } + + if (bundler !== 'vite' || caller === 'another server fn') { + ;(bundler === 'vite' ? test.fails : test).each([ + 'as written', + 'reversed', + ] as const)( + 'is callable, the app files written %s', + async (order) => { + const { ssr } = await buildStart({ + bundler, + files: files( + order, + `export { outer } from './outer'\n${callByIdExports}`, + ), + entry: { client: 'client-entry.ts', ssr: 'ssr-entry.ts' }, + }) + const { result } = await ssr.run(`${callByIdPrelude}return { + fromSsr: await entry.outer(), + overHttp: await callById(serverFnId(entry.outer)), +}`) + expect(result).toEqual({ + fromSsr: 'outer:inner', + overHttp: 'outer:inner', + }) + }, + timeout, + ) + } + + ;(bundler === 'vite' ? test.fails : test).each([ + 'as written', + 'reversed', + ] as const)( + 'its caller only client code imports: the caller is callable over HTTP, the app files written %s', + async (order) => { + const { client, ssr } = await buildStart({ + bundler, + files: files(order, callByIdExports), + entry: { client: 'client-entry.ts', ssr: 'ssr-entry.ts' }, + }) + // (the caller by its public URL: the server fn base, then its id) + const url = (await client.run(`return entry.outer.url`)).result + const { result } = await ssr.run( + `${callByIdPrelude}return await callById(serverFnId(${JSON.stringify(url)}))`, + ) + expect(result).toBe('outer:inner') + }, + timeout, + ) + }, + ) + + // Control: start-build-env-separation.test.ts "a library's server fn" + // (a library exporting a top-level server fn). + // Bug: a library in node_modules that creates server fns for its users + // (`createLoggedServerFn(handler)` returning + // `createServerFn().handler(handler)`) is compiled like any module, but + // the user's module only calls the library's function, so the compiler + // never sees a server fn there, and nothing warns. + // Impact: the handler the user passes, and what it imports, ship to the + // client bundle and run there instead of on the server. + // SPEC J4.6: a server fn created inside a function is supported, or + // rejected clearly. + const wrapperLibrary = `import { createServerFn } from '@tanstack/react-start' +export function createLoggedServerFn(handler) { + return createServerFn().handler(handler) +} +` + const wrapperUser = `import { createLoggedServerFn } from 'wrapper-lib' +import { db } from './db' +export const fn = createLoggedServerFn(async () => db.secret()) +` + test.fails( + 'a server fn created by a library function: the handler is not in the client bundle, or the build fails clearly', + async () => { + const outcome = await buildStart({ + bundler, + // The app depends on the library, as an installed one. + packageJson: { + name: 'app', + private: true, + type: 'module', + dependencies: { 'wrapper-lib': '*' }, + }, + files: { + 'node_modules/wrapper-lib/package.json': JSON.stringify({ + name: 'wrapper-lib', + type: 'module', + exports: './index.js', + peerDependencies: { '@tanstack/react-start': '*' }, + }), + 'node_modules/wrapper-lib/index.js': wrapperLibrary, + 'src/db.ts': `export const db = { secret: () => 'MARK_WRAPPED_HANDLER' }\n`, + 'src/fns.ts': wrapperUser, + 'src/entry.ts': `export { fn } from './fns'\n`, + }, + entry: 'src/entry.ts', + }).then( + async ({ client, ssr }) => ({ + client: client.where('MARK_WRAPPED_HANDLER'), + ssr: (await ssr.run(`return await entry.fn()`)).result, + }), + (error: unknown) => ({ error }), + ) + if ('error' in outcome) { + // A clear build error at the server fn: in the library, or at the + // user's call of the library function (SPEC G5). + expectSourceError(outcome.error, { + sites: [ + { + file: 'node_modules/wrapper-lib/index.js', + source: wrapperLibrary, + at: 'createServerFn()', + }, + { + file: 'src/fns.ts', + source: wrapperUser, + at: 'createLoggedServerFn(async', + }, + ], + }) + } else { + expect(outcome).toEqual({ + client: 'nowhere', + ssr: 'MARK_WRAPPED_HANDLER', + }) + } + }, + timeout, + ) + + // Bug (Vite): Start's Vite plugin looks for the Start libraries it bundles + // in SSR (`crawlFrameworkPkgs`: dependencies with a peer dependency on + // Start) in the package.json of the working directory (`root: + // process.cwd()`), not of Vite's root, which the plugin uses for its own + // root a few lines above. + // Source: src/vite/plugin.ts:143 (Vite's root: :96); found when the build + // harness ran Start's real runtime (it ran Vite builds outside the app). + // Impact: `vite build <app>` run from another directory (a monorepo root, + // a script) leaves a Start library external in the SSR build: Node loads + // it uncompiled, and an SSR call of its server fn returns undefined + // instead of the handler's result. + // Control: start-build-env-separation.test.ts "a library's server fn" + // (the same library, built in the app's directory). + ;(bundler === 'vite' ? test.fails : test)( + "a build run from another directory: a library's server fn runs in the SSR build", + async () => { + const { ssr } = await buildStart({ + bundler, + // The directory of this test file, whose package.json is not the + // app's. + cwd: __dirname, + packageJson: { + name: 'app', + private: true, + type: 'module', + dependencies: { 'server-fn-lib': '*' }, + }, + files: { + 'node_modules/server-fn-lib/package.json': JSON.stringify({ + name: 'server-fn-lib', + type: 'module', + exports: './index.js', + peerDependencies: { '@tanstack/react-start': '*' }, + }), + 'node_modules/server-fn-lib/index.js': `import { createServerFn } from '@tanstack/react-start' +export const libFn = createServerFn().handler(async () => 'MARK_LIB_HANDLER') +`, + 'src/entry.ts': `export { libFn } from 'server-fn-lib'\n`, + }, + entry: 'src/entry.ts', + }) + expect((await ssr.run(`return await entry.libFn()`)).result).toBe( + 'MARK_LIB_HANDLER', + ) + }, + timeout, + ) + + // Bug (Rsbuild): in the SSR build, compiling a module with an isomorphic + // fn makes the Start compiler resolve the module's `createMiddleware` + // import (the server lookup does not know that factory). The Rsbuild + // compiler host resolves it through the loader context, whose resolver + // does not match the package's `import`-only exports (those of + // `@tanstack/react-start`): the build fails with + // `PackagePathNotExported(".")` (start-compiler-host.ts `resolveId`). + // Impact: an app with a middleware and an isomorphic fn in one module + // does not build with Rsbuild. + ;(bundler === 'rsbuild' ? test.fails : test)( + 'a module with a middleware and an isomorphic fn builds, and its middleware runs on the server', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: { + 'src/both.ts': `import { createIsomorphicFn, createMiddleware } from '@tanstack/react-start' +export const middleware = createMiddleware().server(({ next }) => + next({ context: { marker: 'MARK_MIDDLEWARE_SERVER' } }), +) +export const isomorphic = createIsomorphicFn() + .server(() => 'server') + .client(() => 'client') +`, + // The app's request middleware: a server fn's handler reads what + // it put into the context of a request + 'src/start.ts': `import { createStart } from '@tanstack/react-start' +import { middleware } from './both' +export const startInstance = createStart(() => ({ requestMiddleware: [middleware] })) +`, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const marker = createServerFn().handler( + async ({ context }) => (context as unknown as { marker?: string }).marker, +) +`, + 'src/entry.ts': `export { isomorphic } from './both' +export { marker } from './fns' +`, + 'src/ssr-entry.ts': `export * from './entry' +${callByIdExports}`, + }, + entry: { client: 'src/entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + expect(client.where('MARK_MIDDLEWARE_SERVER')).toBe('nowhere') + const { result } = await ssr.run(`${callByIdPrelude}return { + middleware: await callById(serverFnId(entry.marker)), + isomorphic: entry.isomorphic(), +}`) + expect(result).toEqual({ + middleware: 'MARK_MIDDLEWARE_SERVER', + isomorphic: 'server', + }) + }, + timeout, + ) + + // Bug: the bundler plugins hand every module whose text matches a + // detection pattern (here `.handler(`) to the Start compiler, which parses + // it as an ES module and fails on a CommonJS script's top-level `return`. + // The same package without that text builds and runs on both bundlers. + // Impact: an app with such a dependency does not build (Vite: when client + // code imports it, or SSR code with `noExternal`; Rsbuild: client or SSR). + // SPEC J4.16. These apps replace the in-process compiler pin of this + // name. + test.fails( + 'a CommonJS dependency with a top-level return builds and keeps its meaning', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: { ...commonJsPackage, 'entry.ts': commonJsImporter }, + }) + for (const output of [client, ssr]) { + const { result } = await output.run('return entry.result') + expect(result, output.env).toEqual(['handled', 1]) + } + }, + timeout, + ) +}) + +describe('rsbuild dev', () => { + // Bug: same as the build pin above; Rsbuild's dev server compiles the + // same package without the `.handler(` text, and the page runs it. + // Impact: the dev server fails to compile an app with such a dependency. + // Source: as the build pin above. + test.fails( + 'a CommonJS dependency with a top-level return compiles and keeps its meaning', + async () => { + const server = await startRsbuildStartDevServer({ + ...clientPage, + files: { ...commonJsPackage, 'src/entry.ts': commonJsImporter }, + }) + expect(server.errors).toEqual([]) + expect( + await runInClient(server, 'return globalThis.legacyResult'), + ).toEqual({ result: ['handled', 1] }) + }, + 60_000, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/pages/hydrate-boundary-forms.test.ts b/packages/start-plugin-core/tests/integration/pages/hydrate-boundary-forms.test.ts new file mode 100644 index 0000000000..18b9b047c1 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/hydrate-boundary-forms.test.ts @@ -0,0 +1,829 @@ +/** + * The forms a `<Hydrate>` boundary is written in, and what each environment + * makes of it: the server strips the client-only `fallback` however it is + * passed, `split={false}` keeps the children in place, children that cannot + * be split are rejected clearly, nested boundaries hydrate with the ids the + * server renders, and only the `Hydrate` of a `@tanstack/*-start` package is + * a boundary. + * + * Through the public Start plugin on a dev server (`render.ts`): the server + * render (React's server renderer in the SSR environment) is compared with + * the uncompiled source (a plain Vite host without the Start plugin), and a + * real page hydrates it with every gate opened. What only a whole app + * observes (the client receiving the fallback, `prefetch`, `onHydrated`) + * is checked by real pages (integration/hydrate-pages*.test.ts). + */ +import { describe, expect, test } from 'vitest' +import { + diagnosticPosition, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { compileError, expectCompileError } from '../../regression-helpers' +import { + editableFiles, + expectClientRendersLikeServer, + expectHydratedCleanly, + expectRendersLikeSource, + renderClient, + renderServer, + renderSource, + useEditHost, + useHydrateHost, + useSolidHost, + withoutHydrationIds, +} from '../../render' +import type { HydrateHost, RenderOptions } from '../../render' + +const hosts = useHydrateHost() +const solidHost = useSolidHost() +const editHost = useEditHost() + +const head = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +` + +/** + * The server output of `code` renders the markup the uncompiled source + * renders (hydration ids blanked, `withoutHydrationIds`). Returns the server + * render. + */ +async function expectServerRendersLikeSource( + code: string, + options: RenderOptions = {}, +) { + const started = await hosts() + const source = await renderSource(started, code, options) + const server = await renderServer(started, code, options) + expect(withoutHydrationIds(server.html)).toBe(source.html) + return server +} + +/** + * Everything an environment reported for a case it rejected: the error it + * threw (and, when the helper returns them, what it reported meanwhile). + */ +function reportedOf(failure: unknown): Array<unknown> { + const withReports = failure as { error?: unknown; reported?: Array<unknown> } + return failure instanceof Error && Array.isArray(withReports.reported) + ? [withReports.error, ...withReports.reported] + : [failure] +} + +describe('the server strips the client-only fallback, and only it', () => { + // Source: hydrate-when-transform.test.ts "strips Hydrate fallback from the + // server transform", "strips fallback from a parenthesized spread", + // "strips a statically computed fallback property from server output", + // "resolves spread props declared after their containing function"; + // hydrateWhen ObjectFallback and SplitFalse fixtures. + const forms = [ + { + name: 'a direct fallback', + code: `export function Page() { + return <Hydrate when={visible()} fallback={<p>fallback-marker</p>}><p>child</p></Hydrate> +}`, + }, + { + name: 'a direct fallback with split={false}', + code: `export function Page() { + return <Hydrate when={visible()} split={false} fallback={<p>fallback-marker</p>}><p>child</p></Hydrate> +}`, + }, + { + name: 'a direct fallback next to prefetch and onHydrated', + code: `export function Page() { + return <Hydrate when={visible()} prefetch={() => {}} fallback={<p>fallback-marker</p>} onHydrated={() => 'hydrated'}><p>child</p></Hydrate> +}`, + }, + { + name: 'an inline spread', + code: `export function Page() { + return <Hydrate {...{ when: visible(), fallback: <p>fallback-marker</p> }}><p>child</p></Hydrate> +}`, + }, + { + name: 'a parenthesized inline spread', + code: `export function Page() { + return <Hydrate {...({ when: visible(), fallback: <p>fallback-marker</p> })}><p>child</p></Hydrate> +}`, + }, + { + name: 'a spread used once, declared before the component', + code: `const props = { when: visible(), fallback: <p>fallback-marker</p> } +export function Page() { + return <Hydrate {...props}><p>child</p></Hydrate> +}`, + }, + { + name: 'a spread used once, declared after the component', + code: `export function Page() { + return <Hydrate {...props}><p>child</p></Hydrate> +} +const props = { when: visible(), fallback: <p>fallback-marker</p> }`, + }, + { + name: 'a parenthesized spread used once', + code: `const props = ({ when: visible(), fallback: <p>fallback-marker</p> }) +export function Page() { + return <Hydrate {...(props)}><p>child</p></Hydrate> +}`, + }, + { + // Source: hydrateWhenSplitFalse.tsx fixture (main) + name: 'a module-level element', + moduleLevel: true, + code: `const fallback = <p>fallback-marker</p> +export function Page() { + return <Hydrate when={visible()} fallback={fallback}><p>child</p></Hydrate> +}`, + }, + { + name: 'a module-level element with split={false}', + moduleLevel: true, + code: `const fallback = <p>fallback-marker</p> +export function Page() { + return <Hydrate when={visible()} split={false} fallback={fallback}><p>child</p></Hydrate> +}`, + }, + { + name: 'a computed fallback key', + code: `export function Page() { + return <Hydrate {...{ when: visible(), ['fallback']: <p>fallback-marker</p> }}><p>child</p></Hydrate> +}`, + }, + { + name: 'an inline spread with quoted keys', + code: `export function Page() { + return <Hydrate {...{ 'when': visible(), 'fallback': <p>fallback-marker</p> }}><p>child</p></Hydrate> +}`, + }, + { + name: 'a spread used once with split={false}', + code: `const props = { when: visible(), fallback: <p>fallback-marker</p> } +export function Page() { + return <Hydrate split={false} {...props}><p>child</p></Hydrate> +}`, + }, + ] + + /** Every row passes `when={visible()}`, through a prop or a spread. */ + const formsHead = `${head}import { visible } from '@tanstack/react-start/hydration' +` + + // A module-level element the boundary reads stays declared or not: the + // prop is removed, and what is left of the module is dead code (SPEC + // §5.9). + test.each(forms)( + 'server: $name is removed', + async ({ code, moduleLevel }) => { + const server = await expectServerRendersLikeSource(`${formsHead}${code}`) + expect(server.html).toContain('<p>child</p>') + if (!moduleLevel) { + expect(server.code).not.toContain('fallback-marker') + } + }, + ) + + // That the client boundary receives the fallback (and `prefetch`, + // `onHydrated`) is checked by real pages. + test.each(forms)( + 'client: a boundary with $name renders like the server', + async ({ code }) => { + const { client } = await expectClientRendersLikeServer( + await hosts(), + `${formsHead}${code}`, + { split: !code.includes('split={false}') }, + ) + expect(client.html).toContain('<p>child</p>') + }, + ) + + // A client-only module the fallback renders (e.g. a spinner reading browser + // APIs) is not loaded by the server module, however the fallback reaches + // it; module bindings the children read stay. + test.each([ + { + name: 'an imported component', + code: `import { Spinner } from './client-spinner' +export function Page() { return <Hydrate when={load()} fallback={<Spinner />}><p>child</p></Hydrate> }`, + }, + { + name: 'a const component rendering an import', + code: `import { Spinner } from './client-spinner' +const Fallback = () => <Spinner /> +export function Page() { return <Hydrate when={load()} fallback={<Fallback />}><p>child</p></Hydrate> }`, + }, + { + name: 'a function component rendering an import', + code: `import { Spinner } from './client-spinner' +function Fallback() { return <Spinner /> } +export function Page() { return <Hydrate when={load()} fallback={<Fallback />}><p>child</p></Hydrate> }`, + }, + { + name: 'a class rendering an import', + code: `import { Spinner } from './client-spinner' +class Fallback { render() { return <Spinner /> } } +export function Page() { return <Hydrate when={load()} fallback={new Fallback().render()}><p>child</p></Hydrate> }`, + }, + { + name: 'a binding in an inline spread', + code: `import { Spinner } from './client-spinner' +const spinner = <Spinner /> +export function Page() { return <Hydrate when={load()} {...{ fallback: spinner }}><p>child</p></Hydrate> }`, + }, + { + name: 'an element in an inline spread', + code: `import { Spinner } from './client-spinner' +export function Page() { return <Hydrate when={load()} {...{ fallback: <Spinner /> }}><p>child</p></Hydrate> }`, + }, + { + name: 'a destructured namespace import', + code: `import * as lib from './client-spinner' +const { Spinner } = lib +export function Page() { return <Hydrate when={load()} fallback={<Spinner />}><p>child</p></Hydrate> }`, + }, + { + name: 'a declarator next to one the children read', + code: `import { Spinner } from './client-spinner' +const label = 'child', spinner = <Spinner /> +export function Page() { return <Hydrate when={load()} fallback={spinner}><p>{label}</p></Hydrate> }`, + }, + { + name: 'a spread used once with split={false}', + code: `import { Spinner } from './client-spinner' +const opts = { fallback: <Spinner /> } +export function Page() { return <Hydrate when={load()} split={false} {...opts}><p>child</p></Hydrate> }`, + }, + ])( + 'server: a fallback through $name does not load its client-only module', + async ({ code }) => { + const server = await expectServerRendersLikeSource(`${head}${code}`, { + files: { + './client-spinner': `export const Spinner = () => <i>spinner</i>`, + }, + }) + expect(server.html).toContain('<p>child</p>') + // What the SSR environment's module graph reaches from the module. + expectNotLoaded(await server.case.serverLoads(), ['./client-spinner']) + }, + ) + + test('server: a module-level destructuring read by the fallback and the children keeps the children binding', async () => { + const server = await expectServerRendersLikeSource( + `${head}const { a, b } = { a: 'A', b: 'B' } +export function Page() { + return <Hydrate when={load()} fallback={<p>{a}{b}</p>}><p>{b}</p></Hydrate> +}`, + ) + expect(server.html).toContain('<p>B</p>') + }) + + // Whatever expression `when` is, both environments pass its value to the + // boundary (the server strips the fallback next to it): the outputs render + // the boundary the strategy renders in the source. That the function form + // runs on the client only is checked by real pages. + test.each([ + { name: 'a strategy call', when: 'idle()' }, + { + name: 'a strategy call with options', + when: `interaction({ events: 'focusin' })`, + }, + // The prop is a media strategy that does not match: the gate stays + // closed, and nothing loads on demand. + { name: 'a prop', when: 'props.when', closed: true }, + { + name: 'a local', + setup: `const strategy = media('(min-width: 1px)')\n `, + when: 'strategy', + }, + { + name: 'a conditional', + when: 'props.eager ? load() : visible()', + }, + { + name: 'a function', + when: `() => idle()`, + }, + ])( + 'when as $name reaches the boundary in both environments', + async ({ setup = '', when, closed = false }) => { + const code = `${head}import { idle, interaction, media, visible } from '@tanstack/react-start/hydration' +export function Page(props) { + ${setup}return <Hydrate when={${when}} fallback={<p>fallback-marker</p>}><p>child</p></Hydrate> +}` + const { server, client } = await expectRendersLikeSource( + await hosts(), + code, + { + // A strategy of the app's own hydration package, in each realm. + setup: `import { media } from '@tanstack/react-start/hydration' +globalThis.__propsWhen = media('(max-width: 2px)') +export const cleanup = ['__propsWhen']`, + render: 'h(m.Page, { when: globalThis.__propsWhen, eager: false })', + split: !closed, + }, + ) + if (closed) { + expect(client.lazy).toEqual([]) + } + expect(client.html).toContain('<p>child</p>') + expect(server.code).not.toContain('fallback-marker') + }, + ) +}) + +/** + * A page whose boundary, with the given `split` attribute (`''`: none), has + * `children`; `setup` comes before the component. + */ +const childrenPage = ( + children: string, + split = '', + setup = '', +) => `${head}import { idle } from '@tanstack/react-start/hydration' +import { useThing, use3D } from './hooks' +${setup}export function Page({ flag }: { flag?: boolean }) { + return <Hydrate when={idle()}${split}>${children}</Hydrate> +}` + +/** A class component whose boundary reads `this` or `super`. */ +const classPage = ( + read: 'this' | 'super', + split = '', +) => `${head}import { idle } from '@tanstack/react-start/hydration' +class Base { + get title() { + return 'super' + } +} +export class Page extends Base { + title2 = 'this' + render() { + return ( + <Hydrate when={idle()}${split}> + <p>{${read === 'this' ? 'this.title2' : 'super.title'}}</p> + </Hydrate> + ) + } +}` + +/** A real hook whose value depends on the component that calls it. */ +const hooks = { + './hooks': `import { useId } from 'react' +export const useThing = () => useId() +export const use3D = () => useId()`, +} + +/** + * The client environment, which extracts the children, rejects `code` with + * an error (SPEC J5.5) reporting a line of the boundary (the frame marks + * it, or a position). Wording and frame layout are free (SPEC §5.7). The + * server renders the children in place: rejecting them there is neither + * required nor forbidden. + */ +async function expectExtractionRejected(host: HydrateHost, code: string) { + const startCase = await host.start.case({ 'module.tsx': code, ...hookFiles }) + const failure = await compileError(startCase, 'client') + expect(failure, 'a client compile error').toBeInstanceOf(Error) + const reported = reportedOf(failure) + const first = diagnosticPosition(code, '<Hydrate').line + const last = diagnosticPosition(code, '</Hydrate>').line + const lines = Array.from( + { length: last - first + 1 }, + (_, index) => first + index, + ) + expect( + lines.filter( + (line) => + findDiagnostics(reported, { + severity: 'error', + position: { line }, + }).length > 0, + ), + `a line of the boundary (${first}-${last})`, + ).not.toEqual([]) +} + +const hookFiles = { 'hooks.ts': hooks['./hooks'] } + +/** The unsafe children of SPEC J5.5. */ +const unsafeChildren = [ + { + name: 'a function child (an arrow)', + code: (split = '') => childrenPage('{() => <p>child</p>}', split), + }, + { + name: 'a function child (a parenthesized arrow)', + code: (split = '') => childrenPage('{(() => <p>child</p>)}', split), + }, + { + name: 'a function child (a function expression)', + code: (split = '') => + childrenPage('{function () { return <p>child</p> }}', split), + }, + { + name: 'a hook call', + code: (split = '') => childrenPage('<p>{useThing()}</p>', split), + }, + { + // Digit-bearing hook names follow React's convention. + name: 'a hook call named use3D', + code: (split = '') => childrenPage('<p>{use3D()}</p>', split), + }, + { + name: 'a parenthesized hook call', + code: (split = '') => childrenPage('<p>{(useThing)()}</p>', split), + }, +] + +describe('children that cannot be split', () => { + // Source: hydrate-when-transform.test.ts "rejects function-as-children + // unless the boundary opts out of splitting", "rejects hook calls that + // would be moved into an extracted component", "rejects parenthesized + // unsafe extraction"; hydrateWhen FunctionChild and HookCall error + // fixtures. + test.each(unsafeChildren)( + 'client: $name is rejected at the boundary', + async ({ code }) => { + await expectExtractionRejected(await hosts(), code()) + }, + ) + + // Only the literal `split={false}` opts out (docs): a dynamic `split` + // extracts, so it rejects the same children. + test.each(unsafeChildren)( + 'client: $name with a dynamic split={flag} is rejected at the boundary', + async ({ code }) => { + await expectExtractionRejected(await hosts(), code(' split={flag}')) + }, + ) + + // With the literal `split={false}` the compiler neither extracts nor + // rejects the children (SPEC J5.5): every output renders like the + // uncompiled source (what React makes of a function child is the + // framework's business) and nothing loads on demand. + // Source: hydrate-when-transform.test.ts "respects parenthesized + // split={false}"; hydrateWhen SplitFalseFunctionChild fixture. + test.each([ + ...unsafeChildren.map(({ name, code }) => ({ + name, + code: code(' split={false}'), + render: undefined, + })), + { + name: 'a function child with a parenthesized false', + code: childrenPage('{() => <p>child</p>}', ' split={(false)}'), + render: undefined, + }, + { + name: 'a read of this', + code: classPage('this', ' split={false}'), + render: 'new m.Page().render()', + }, + { + name: 'a read of super', + code: classPage('super', ' split={false}'), + render: 'new m.Page().render()', + }, + ])( + '$name with split={false} stays in place in both environments', + async ({ code, render }) => { + const { client } = await expectRendersLikeSource(await hosts(), code, { + files: hooks, + render, + split: false, + }) + expect(client.lazy).toEqual([]) + }, + ) + + // The props of the boundary itself are not its children: they render in + // the parent on both sides, so a hook call there does not stop the split. + test('a hook call in the props of the boundary runs in the parent render, and the children still split', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { useThing } from './hooks' +export function Page() { + return <Hydrate when={useThing()}><p>child</p></Hydrate> +}`, + { + files: { + './hooks': `import { useId } from 'react' +import { idle } from '@tanstack/react-start/hydration' +export const useThing = () => (useId(), idle())`, + }, + }, + ) + expect(client.html).toContain('<p>child</p>') + }) + + // Only a literal opts out at compile time (docs): a dynamic value splits + // the children whatever its value, and they hydrate like the server + // renders them. + test.each([true, false])( + 'a dynamic split={flag} (%s) still splits the children', + async (flag) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page({ flag }) { + return <Hydrate when={load()} split={flag}><p>child</p></Hydrate> +}`, + { props: { flag } }, + ) + expect(client.html).toContain('<p>child</p>') + }, + ) + + // Bug: hook calls are only detected when the callee is a bare identifier, + // so `React.useId()` in the children moves into the split code instead of + // being rejected (SPEC J5.5). + // Impact: the hook runs in another component on the client than on the + // server (`useId` mismatches, hydration errors). + // Source: Qwik optimizer example_use_optimization. #8504 has no test for + // it and still moves `React.useId()` into the chunk. + test.fails( + 'client: a hook called through a namespace is rejected at the boundary', + async () => { + await expectExtractionRejected( + await hosts(), + `import * as React from 'react' +${childrenPage('<p id={React.useId()}>x</p>')}`, + ) + }, + ) + + // The client rejects children reading `this` or `super` at the boundary. + test.each([ + { name: 'this', code: classPage('this') }, + { name: 'super', code: classPage('super') }, + ])('client: children reading $name are rejected', async ({ code }) => { + const startCase = await (await hosts()).start.case({ 'module.tsx': code }) + expectCompileError(await compileError(startCase, 'client'), { + source: code, + at: diagnosticPosition(code, '<Hydrate').line, + }) + }) +}) + +describe('nested boundaries', () => { + // The outer boundary uses `idle()` (the original fixture: `visible()`), + // whose boundary renders an id: the outermost boundaries' ids are compared. + // Source: hydrate-when-transform.test.ts "supports nested Hydrate + // boundaries in extracted virtual modules", "keeps sibling boundary ids + // stable after nested boundaries"; hydrateWhen.test.ts "should extract + // virtual modules and keep nested ids stable" and the Nested fixture. + test('a nested boundary and a later sibling hydrate with the ids the server renders', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { idle, interaction } from '@tanstack/react-start/hydration' +import { NestedButton, Outer, Sibling } from './widgets' +export function Page() { + return ( + <> + <Hydrate when={idle()}> + <Outer /> + <Hydrate when={interaction()}> + <NestedButton /> + </Hydrate> + </Hydrate> + <Hydrate when={idle()}> + <Sibling /> + </Hydrate> + </> + ) +}`, + { + files: { + './widgets': `export const Outer = () => <section>Outer</section> +export const NestedButton = () => <button>Nested</button> +export const Sibling = () => <aside>Sibling</aside>`, + }, + }, + ) + expect(client.html).toContain('<section>Outer</section>') + expect(client.html).toContain('<button>Nested</button>') + expect(client.html).toContain('<aside>Sibling</aside>') + }) +}) + +describe('which elements are boundaries', () => { + // Source: hydrateWhen Renamed fixture. + test('a renamed import of Hydrate is a boundary', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `import { Hydrate as HW } from '@tanstack/react-start' +import { interaction } from '@tanstack/react-start/hydration' +import { SearchBox } from './search' +export function Page() { + return ( + <HW when={interaction({ events: 'focusin' })}> + <SearchBox /> + </HW> + ) +}`, + { files: { './search': `export const SearchBox = () => <input />` } }, + ) + expect(client.html).toContain('<input>') + // The children's module loads with the split code, not with the parent. + expect(client.loaded).not.toContain('./search') + expect(client.lazy).toContain('./search') + }) + + describe('elements that are not the Start Hydrate', () => { + /** + * A component of the app named `Hydrate`: renders the props it receives + * (functions as their type), its fallback and its children, with the + * app's React. + */ + const foreign = `import { createElement } from 'react' +export const Hydrate = ({ children, ...props }) => + createElement( + 'div', + { + 'data-props': JSON.stringify(props, (key, value) => + typeof value === 'function' + ? typeof value + : key === 'fallback' + ? 'rendered' + : value, + ), + }, + props.fallback, + children, + ) +` + /** `foreign` as a package of the app (`not-tanstack-start`). */ + const foreignPackage = { + 'node_modules/not-tanstack-start/package.json': JSON.stringify({ + name: 'not-tanstack-start', + type: 'module', + exports: './index.js', + }), + 'node_modules/not-tanstack-start/index.js': foreign, + } + + // Both environments leave the element as written: it receives the props + // the uncompiled source passes (the fallback included) and renders like + // it, and the client loads nothing on demand. + // Source: hydrateWhen NoImport, NotFromTanstack and WrongImportName + // fixtures. + test.each([ + { + name: 'a global Hydrate', + code: `export function Page() { + return ( + <Hydrate when={visible()} fallback={<p>fallback-marker</p>}> + <p>No transform</p> + </Hydrate> + ) +}`, + files: { './foreign': foreign }, + setup: `import { Hydrate } from './foreign' +Object.assign(globalThis, { Hydrate, visible: () => 'v' }) +export const cleanup = ['Hydrate', 'visible']`, + render: undefined, + }, + { + name: 'a Hydrate of another package', + code: `import { Hydrate } from 'not-tanstack-start' +import { visible } from '@tanstack/react-start/hydration' +export function Page() { + return ( + <Hydrate when={visible()} fallback={<p>fallback-marker</p>}> + <p>No transform</p> + </Hydrate> + ) +}`, + files: foreignPackage, + setup: undefined, + render: undefined, + }, + // A namespace of another package and a binding shadowing the Start + // namespace are look-alikes (SPEC J5.1, G15). + { + name: 'a Hydrate member of a namespace of another package', + code: `import * as Start from 'not-tanstack-start' +import { visible } from '@tanstack/react-start/hydration' +export function Page() { + return ( + <Start.Hydrate when={visible()} fallback={<p>fallback-marker</p>}> + <p>No transform</p> + </Start.Hydrate> + ) +}`, + files: foreignPackage, + setup: undefined, + render: undefined, + }, + { + name: 'a Hydrate member of a local shadowing the Start namespace', + code: `import * as Start from '@tanstack/react-start' +import { visible } from '@tanstack/react-start/hydration' +import type { ComponentType } from 'react' +export const startHydrate = Start.Hydrate +export function Page({ Start }: { Start: { Hydrate: ComponentType<any> } }) { + return ( + <Start.Hydrate when={visible()} fallback={<p>fallback-marker</p>}> + <p>No transform</p> + </Start.Hydrate> + ) +}`, + files: { './foreign': foreign }, + setup: `import { Hydrate } from './foreign' +globalThis.__foreign = { Hydrate } +export const cleanup = ['__foreign']`, + render: 'h(m.Page, { Start: globalThis.__foreign })', + }, + ])('$name is left alone', async ({ code, files, setup, render }) => { + const started = await hosts() + const options = { files, setup, render } + const source = await renderSource(started, code, options) + expect(source.html).toContain('<p>fallback-marker</p><p>No transform</p>') + expect((await renderServer(started, code, options)).html).toBe( + source.html, + ) + const client = await renderClient(started, code, options) + expectHydratedCleanly(client) + expect(client.html).toBe(source.html) + expect(client.lazy).toEqual([]) + }) + }) + + // A namespace-imported `<Start.Hydrate>` (React and Solid, Vite and + // Rsbuild) hydrates the server's HTML in real pages + // (integration/hydrate-pages-*.test.ts "namespace-imported Start.Hydrate + // boundaries"), where splitting it is pinned as a goal. + + // A Solid app (`vite-plugin-solid`): both environments serve and evaluate + // the module, the page mounts it and loads its split code, and nothing it + // loads, on either side, is a React package. + // Source: hydrate-when-transform.test.ts "uses the Solid Router import + // source for Solid Hydrate boundaries". + test('Solid: a Hydrate of @tanstack/solid-start splits with the Solid packages', async () => { + const solid = await solidHost() + const mounted = + await solid.mount(`import { Hydrate } from '@tanstack/solid-start' +import { visible } from '@tanstack/solid-start/hydration' +export function Page() { + return ( + <Hydrate when={visible()}> + <Widget title="Hello" /> + </Hydrate> + ) +} +function Widget(props: { title: string }) { + return <p>{props.title}</p> +}`) + expect(mounted.errors).toEqual([]) + expect(mounted.html).toContain('<p>Hello</p>') + expect(mounted.lazy).not.toEqual([]) + const isReact = (name: string) => + /^(?:\/node_modules\/\.vite\/deps\/)?(react|react-dom)(?:[_/.]|$)|@tanstack\/react-/.test( + name, + ) + expect(mounted.lazy.filter(isReact)).toEqual([]) + expect(mounted.loads.filter(isReact)).toEqual([]) + expect(mounted.serverLoads.filter(isReact)).toEqual([]) + }) +}) + +// When a module changes, the split code that loads afterwards renders the +// edited children, whichever module the dev server compiles first (Rsbuild +// loads split code with the code of its source file; dev servers of both in +// hydrate-build.test.ts). +// Source: hydrate-when-transform.test.ts "invalidates cached Hydrate source +// for virtual module loads" (the compiler half; the dev-server half is in +// hydrate-build-dev.test.ts). +test('client: a chunk loaded with the edited source before the parent is compiled again renders the new children', async () => { + const source = (text: string) => `${head}export function Page() { + return <Hydrate when={load()}><p>${text}</p></Hydrate> +}` + const started = await editHost() + const files = await editableFiles(started, source('Old')) + const render = async () => { + const rendered = await renderClient(started, '', { + target: files.target, + freshPage: true, + }) + expectHydratedCleanly(rendered) + return rendered.html + } + expect(await render()).toContain('<p>Old</p>') + await files.edit(source('New')) + expect(await render()).toContain('<p>New</p>') +}, 30_000) + +// A shared options object also renders outside +// the boundary: removing its fallback must not mutate that other consumer. +test('a fallback spread shared with an aside keeps the aside on server and client', async () => { + const { server, client } = await expectRendersLikeSource( + await hosts(), + `${head} +const opts = { when: load(), fallback: <b>wait</b> } +export function Page() { + return <><Hydrate {...opts}><p>ready</p></Hydrate><aside>{opts.fallback}</aside></> +}`, + ) + expect(server.html).toContain('<aside><b>wait</b></aside>') + expect(client.html).toContain('<aside><b>wait</b></aside>') +}) diff --git a/packages/start-plugin-core/tests/integration/pages/hydrate-captures.test.ts b/packages/start-plugin-core/tests/integration/pages/hydrate-captures.test.ts new file mode 100644 index 0000000000..76708f6cb8 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/hydrate-captures.test.ts @@ -0,0 +1,570 @@ +import { afterEach, describe, expect, test } from 'vitest' +import { expectRendersLikeSource, useHydrateHost } from '../../render' +import { generatedNames } from '../../hydrate-helpers' +import type { ClientOptions } from '../../render' + +const hosts = useHydrateHost() + +// `<Hydrate>` moves its children into a lazily loaded chunk on the client. +// Whatever the children read from the enclosing scopes and the module must +// still be the value the original reads: the client hydrates the server +// output in a real page and, once its split code has loaded, shows what the +// uncompiled source and the server output render (the public Start plugin +// on a dev server, `render.ts`). How the values reach the split code is left +// open. React keeps the `key` and `ref` props +// for itself, so no captured local here is named like them (pinned in +// known-bugs-hydrate.test.ts). + +const head = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +` + +/** + * Renders `<Page {...props} />` of `code` (after `head`) from the uncompiled + * source, the server output and the client output (every module valid, the + * children rendered through code loaded on demand): all three render the + * same markup, which is returned. + */ +async function renderPage( + code: string, + props?: Record<string, unknown>, + options: ClientOptions = {}, +) { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { ...options, props }, + ) + return client.html +} + +test.each<{ + name: string + children: string + expected: string +}>([ + { + // Source: @vitejs/plugin-rsc hoist/function-hoist-block.js + name: 'past a function declared in a nested block', + children: `{(() => { + const seen = value + { + function value() {} + } + return seen +})()}`, + expected: '<p>outer</p>', + }, + { + // Source: @vitejs/plugin-rsc scope/param-default-var-hoisting.js + name: 'from a parameter default next to a var of the same name', + children: `{((seen = value) => { + var value = 'inner' + return seen + ':' + value +})()}`, + expected: '<p>outer:inner</p>', + }, + { + // Source: @vitejs/plugin-rsc scope/label.js + name: 'next to a label of the same name', + children: `{(() => { + value: for (const item of [1]) { + if (item) { + break value + } + } + return value +})()}`, + expected: '<p>outer</p>', + }, + { + // Source: Qwik optimizer should_not_auto_export_var_shadowed_in_labeled_block + // (#8504 hydrate-captures.test.ts) + name: 'only through references, not through a label of the same name', + children: `{(() => { + field: { + break field + } + return 'after' +})()}`, + expected: '<p>after</p>', + }, + { + // Source: @vitejs/plugin-rsc hoist/computed-destructuring-key-captures-outer-binding.js + name: 'through a computed destructuring key', + children: `{(({ [field]: picked }) => picked)({ value })}`, + expected: '<p>outer</p>', + }, + { + // Source: @vitejs/plugin-rsc hoist/var-hoist-block.js, hoist/shadow-var-nested-block.js + name: 'unless a var in a nested block shadows them', + children: `{(() => { + if (field) { + var value = 'inner' + } + return value +})()}`, + expected: '<p>inner</p>', + }, + { + // Source: SolidStart compile.spec.ts "allows `this` and `arguments` in a + // function expression" + name: 'except the arguments of a function expression', + children: `{(function (..._args: Array<unknown>) { + return arguments.length +})(1, 2)}`, + expected: '<p>2</p>', + }, + { + // A let the component reassigns before it renders the boundary: the + // children read its latest value, not its initializer (a compiler that + // collects captures from constant bindings only fails here). + name: 'through a let reassigned before the boundary', + children: `{latest}`, + expected: '<p>second</p>', + }, +])( + 'client: the children read the locals of the component $name', + async ({ children, expected }) => { + expect( + await renderPage(`export function Page() { + const value = 'outer' + const field = 'value' + let latest = 'first' + if (field) { + latest = 'second' + } + return <Hydrate when={load()}><p>${children}</p></Hydrate> +}`), + ).toContain(expected) + }, +) + +// Source: @vitejs/plugin-rsc hoist/function-hoist-block.js (module-level binding) +test('client: the children read a module binding past a block-level function', async () => { + expect( + await renderPage(`const value = 'module' +export function Page() { + return <Hydrate when={load()}><p>{(() => { + const seen = value + { + function value() {} + } + return seen +})()}</p></Hydrate> +}`), + ).toContain('<p>module</p>') +}) + +// Source: Qwik optimizer should_not_auto_export_var_shadowed_in_catch +test('client: the children read a catch parameter', async () => { + expect( + await renderPage(`export function Page() { + try { + throw new Error('caught') + } catch (error) { + return <Hydrate when={load()}><p>{error.message}</p></Hydrate> + } +}`), + ).toContain('<p>caught</p>') +}) + +// Source: Qwik optimizer should_transform_handler_in_for_of_loop +test('client: the children read a destructured loop variable, a block-scoped local and a module helper', async () => { + expect( + await renderPage( + `function Row({ v }) { + return <li>{v}</li> +} +export function Page({ entries }) { + const out = [] + for (const [key, value] of entries) { + const label = key + '-' + out.push(<Hydrate when={load()} key={key}><Row v={label + value} /></Hydrate>) + } + return <ul>{out}</ul> +}`, + { entries: [['a', 1]] }, + ), + ).toContain('<li>a-1</li>') +}) + +// One test at a time: its tests set globals of this process (the server +// realm) +describe('a binding named like an intrinsic tag', { concurrent: false }, () => { + afterEach(() => { + delete (globalThis as { sideEffect?: unknown }).sideEffect + delete (globalThis as { __sideEffects?: unknown }).__sideEffects + }) + + // Source: Qwik optimizer jsx_tag_names_are_not_segment_uses, + // jsx_lowercase_tag_outside_segments, jsx_tag_named_like_inlined_const + test.each([ + { + scope: 'module', + code: `const div = sideEffect('div') +console.log(div) +export function Page() { + return <Hydrate when={load()}><div>x</div></Hydrate> +}`, + }, + { + scope: 'component', + code: `export function Page() { + const div = sideEffect('div') + console.log(div) + return <Hydrate when={load()}><div>x</div></Hydrate> +}`, + }, + ])( + 'client: a $scope binding named like the tag the children render runs once', + async ({ code }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { + setup: `globalThis.__sideEffects = 0 +globalThis.sideEffect = (value) => { + globalThis.__sideEffects++ + return value +} +export const cleanup = ['sideEffect', '__sideEffects']`, + // The client alone: the page's own count. + script: 'return globalThis.__sideEffects', + }, + ) + expect(client.html).toContain('<div>x</div>') + expect(client.result).toBe(1) + }, + ) +}) + +// Source: Qwik optimizer local_shadowing_destructured_prop, +// should_not_auto_export_var_shadowed_in_catch +test('client: names the children declare themselves shadow the locals of the component', async () => { + const html = await renderPage( + `export function Page({ value }) { + const x = 'outer' + console.log(x) + return <Hydrate when={load()}> + <input value={value} onChange={(e) => { const value = e.target.value; return value }} /> + <p>{(() => { try { throw new Error('e') } catch (err) { const x = 'catch:' + err.message; return x } })()}</p> + </Hydrate> +}`, + { value: 'v' }, + ) + expect(html).toContain('<input value="v"><p>catch:e</p>') +}) + +// Source: Qwik optimizer example_functional_component_capture_props, +// example_spread_jsx, should_convert_rest_props +test('client: the children read destructured params with defaults and rests, and spread props', async () => { + expect( + await renderPage( + `function Child(props) { return <b>{props.x + props.extra}</b> } +export function Page({ a: [b = 1], ...c }) { + const extra = '!' + return <Hydrate when={load()}><p>{b}</p><Child {...c} {...{ extra }} /></Hydrate> +}`, + { a: [], x: 'X' }, + ), + ).toContain('<p>1</p><b>X!</b>') +}) + +// Split children move to another module, so only runtime values may reach +// them. +// Source: Qwik optimizer should_wrap_type_asserted_variables_in_template; +// SolidStart compile.spec.ts "does not read type annotations as captured values" +test('client: the children use local types', async () => { + expect( + await renderPage( + `import type { Shape } from './types' +function format<T>(value: T) { return String(value) } +function List<T>(props: { items: Array<T> }) { return <ul>{props.items.length}</ul> } +export function Page({ v }: { v: unknown }) { + type Local = string + interface Box { value: Local } + return <Hydrate when={load()}><List<Box> items={[v] as Array<Shape>} /><p>{format<Local>(v as Local) + (v satisfies unknown as Box['value'] as Shape)}</p></Hydrate> +}`, + { v: 'x' }, + ), + ).toContain('<ul>1</ul><p>xx</p>') +}) + +// One test at a time: its tests set globals of this process (the server +// realm) +describe('names the compiler generates', { concurrent: false }, () => { + /** + * A page with a prefetched boundary and a nested one, whose children read + * `reads` (an array expression); `setup` runs first in the component. + */ + const page = ( + reads: string, + setup = '', + ) => `${head}import { idle } from '@tanstack/react-start/hydration' +export function Page() { + ${setup}return <><Hydrate when={load()} prefetch={idle()}><p>{${reads}.join('|')}</p></Hydrate><Hydrate when={load()}><section><Hydrate when={load()}><b>nested</b></Hydrate></section></Hydrate></> +}` + /** + * Names a compiler could give what it generates (the helpers and props of + * a lazy chunk component): always declared by the fixtures below, so they + * check something even when the compiler introduces no name at all (SPEC + * §5.1). + */ + const fixedNames = [ + 'lazy', + 'chunk', + 'Chunk', + 'HydrateChunk', + 'HydrateChildren', + 'captures', + 'props', + 'p', + 'h', + ] + /** + * The names the compiler introduces for `page` (in any output), and + * `fixedNames`, which the + * fixtures below declare themselves: no test depends on which names the + * compiler picks. The probe's children read a local, so the names the + * compiler introduces to pass captured values to a chunk are among them. + */ + const introducedNames = async () => [ + ...new Set([ + ...(await generatedNames( + await hosts(), + page('[captured]', `const captured = 'c'\n `), + )), + ...fixedNames, + ]), + ] + + let globals: Array<string> = [] + afterEach(() => { + for (const name of globals) { + delete (globalThis as Record<string, unknown>)[name] + } + globals = [] + }) + + // Source: Qwik optimizer example_qwik_conflict, import_collision_with_renaming; + // hydrateWhen.test.ts "generated lazy names do not shadow existing global + // references" + test('client: globals named like the generated bindings keep their values', async () => { + globals = await introducedNames() + // In every realm (the server, the reference and the page) + const { client } = await expectRendersLikeSource( + await hosts(), + `export const before = [${globals.join(', ')}] +${page(`['child']`)}`, + { + setup: `const names = ${JSON.stringify(globals)} +for (const name of names) { + globalThis[name] = 'global:' + name +} +export const cleanup = names`, + script: 'return m.before', + }, + ) + expect(client.result).toEqual(globals.map((name) => `global:${name}`)) + expect(client.html).toContain('<p>child</p>') + expect(client.html).toContain('<b>nested</b>') + }) + + // Module-level bindings with these names that the children read (or + // shadow) are pinned in known-bugs-hydrate.test.ts. + // Source: Qwik optimizer example_qwik_conflict, import_collision_with_renaming + test.each([ + { scope: 'module', reads: `['child']` }, + { scope: 'local', reads: 'names' }, + ])( + 'client: $scope bindings named like the generated bindings keep their values', + async ({ scope, reads }) => { + const names = await introducedNames() + const values = names.map((name) => `${scope}:${name}`).join('|') + const declare = names + .map((name) => `const ${name} = '${scope}:${name}'`) + .join('\n ') + const read = reads === 'names' ? `[${names.join(', ')}]` : reads + const { client } = await expectRendersLikeSource( + await hosts(), + `import { lazyRouteComponent } from '@tanstack/react-router' +${scope === 'module' ? declare : ''} +export const fromModule = ${scope === 'module' ? `[${names.join(', ')}].join('|')` : 'null'} +export const Lazy = lazyRouteComponent(() => import('./other')) +${page(read, scope === 'local' ? `${declare}\n ` : '')}`, + { + files: { './other': `export default () => <i>other</i>` }, + // The user's own lazy component still loads its module. + render: `[h(m.Page, { key: 'page' }), h(m.Lazy, { key: 'lazy' })]`, + script: 'return m.fromModule', + }, + ) + expect(client.result).toBe(scope === 'module' ? values : null) + expect(client.html).toContain( + `<p>${scope === 'local' ? values : 'child'}</p>`, + ) + expect(client.html).toContain('<b>nested</b>') + expect(client.html).toContain('<i>other</i>') + }, + ) +}) + +// Source: Qwik optimizer example_capture_imports, example_qwik_conflict +test('client: a local shadowing an import or module binding wins inside the children only', async () => { + expect( + await renderPage( + `import { label } from './labels' +import { Row } from './row' +const value = 'module' +function Show() { return <b>{value + ':' + label}</b> } +export function Page() { + const label = 'local' + const value = 'local-value' + return <Hydrate when={load()}><Row text={label} /><Show /><i>{value}</i></Hydrate> +}`, + {}, + { + files: { + './labels': `export const label = 'imported'`, + './row': `export const Row = ({ text }) => <r>{text}</r>`, + }, + }, + ), + ).toContain('<r>local</r><b>module:imported</b><i>local-value</i>') +}) + +// Source: Qwik optimizer nested_segment_param_does_not_collide_with_captured_props +test('client: a nested boundary reads the locals of the component around its enclosing boundary', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page({ isOpen, fee }) { + const label = 'fee' + return <Hydrate when={load()}><section><Hydrate when={load()}><p>{label + ':' + (isOpen ? fee : 0)}</p></Hydrate></section></Hydrate> +}`, + { props: { isOpen: true, fee: 5 } }, + ) + expect(client.html).toContain('<p>fee:5</p>') +}) + +// The local is not named `key`: React keeps a `key` prop for itself (pinned +// in known-bugs-hydrate.test.ts). +// Source: hydrate-when-transform.test.ts "captures identifiers used by +// shorthand objects and computed members" +test('client: the children read locals through a shorthand property and a computed member', async () => { + expect( + await renderPage(`import { visible } from '@tanstack/react-start/hydration' +export function Page() { + const field = 'name' + const items = { name: 'Ada' } + return ( + <Hydrate when={visible()}> + <Widget data={{ field, value: items[field] }} /> + </Hydrate> + ) +} +function Widget(props: { data: { field: string; value: string } }) { + return <p>{props.data.field + ':' + props.data.value}</p> +}`), + ).toContain('<p>name:Ada</p>') +}) + +// Like `style={{ color: color }}`. +test('client: the children read locals through a property value and a computed member alone', async () => { + expect( + await renderPage(`export function Page() { + const label = 'Ada' + const field = 'name' + const items = { name: 'Lovelace' } + return <Hydrate when={load()}><p>{({ text: label }).text + items[field]}</p></Hydrate> +}`), + ).toContain('<p>AdaLovelace</p>') +}) + +// Optional members, method keys and other property names are pinned in +// known-bugs-hydrate.test.ts. +test('client: member names and object keys are no reads of a local declared later', async () => { + expect( + await renderPage( + `export function Page({ obj }) { + const el = <Hydrate when={load()}><p>{obj.later + ({ later: '!' }).later}</p></Hydrate> + const later = 1 + console.log(later) + return el +}`, + { obj: { later: 'L' } }, + ), + ).toContain('<p>L!</p>') +}) + +// One test at a time: its tests set globals of this process (the server +// realm) +describe('globals', { concurrent: false }, () => { + afterEach(() => { + delete (globalThis as { GlobalWidget?: unknown }).GlobalWidget + delete (globalThis as { hydrateDefaults?: unknown }).hydrateDefaults + }) + + test('client: a boundary spreading a global splits children rendering a global component', async () => { + // The app's own hydration strategy, in every realm. + expect( + await renderPage( + `export function Page() { + return <Hydrate {...hydrateDefaults}><GlobalWidget /></Hydrate> +}`, + undefined, + { + setup: `import { load } from '@tanstack/react-start/hydration' +Object.assign(globalThis, { + GlobalWidget: () => 'global-widget', + hydrateDefaults: { when: load() }, +}) +export const cleanup = ['GlobalWidget', 'hydrateDefaults']`, + }, + ), + ).toContain('global-widget') + }) +}) + +// Source: hydrateWhen.test.ts "retains captured local components and values +// across extraction" +test('client: the children render a local component and read a local value', async () => { + expect( + await renderPage( + `export function Page({ name }) { + const count = 1 + const Local = (props) => <b>{name + (props.count === count ? '' : '!')}</b> + return <Hydrate when={load()}><Local count={count}/><span>{name}</span></Hydrate> +}`, + { name: 'n' }, + ), + ).toContain('<b>n</b><span>n</span>') +}) + +// Function declarations below the JSX are +// hoisted within this render, and can close over its current props. +test('client: rows.map captures a local function declared below the JSX', async () => { + expect( + await renderPage( + `export function Page({ rows, suffix }) { + return <Hydrate when={load()}><ul>{rows.map(renderRow)}</ul></Hydrate> + function renderRow(row) { + return <li key={row}>{row + suffix}</li> + } +}`, + { rows: ['a', 'b'], suffix: '!' }, + ), + ).toContain('<ul><li>a!</li><li>b!</li></ul>') +}) + +// The module object's computed key is the only +// reference to field; extracting its consumer must keep that dependency. +test('client: a computed object key keeps a module dependency', async () => { + expect( + await renderPage(`const field = 'value' +const record = { [field]: 'computed' } +export function Page() { + return <Hydrate when={load()}><p>{record.value}</p></Hydrate> +}`), + ).toContain('<p>computed</p>') +}) diff --git a/packages/start-plugin-core/tests/integration/pages/hydrate-dead-code-shapes.test.ts b/packages/start-plugin-core/tests/integration/pages/hydrate-dead-code-shapes.test.ts new file mode 100644 index 0000000000..3302fcfe6f --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/hydrate-dead-code-shapes.test.ts @@ -0,0 +1,74 @@ +import { expect, test } from 'vitest' +import { + deadCodeShapes, + depSource, + recordFile, + shapeSetup, +} from '@tanstack/compiler-test-utils/dead-code-shapes' +import { expectRendersLikeSource, useHydrateHost } from '../../render' + +// On the client `<Hydrate>` children move out of the parent module into +// split code the page loads on demand (SPEC J5.2). The move takes with it, +// in the parent, what only the children used, whatever the shape of the code +// in between (G16, J5.6): importing the parent does not load the module +// only the children import. Kept code keeps what it reads, and code already +// dead before the transform keeps running (G3). The server renders the +// children inline, like the uncompiled source, and the client hydrates it +// in a real page (`render.ts`). The same shapes run through every removal +// of the Start compiler in start-compiler-dead-code-shapes.test.ts. + +const hosts = useHydrateHost() + +/** + * Cells main gets wrong (KNOWN-BUGS J5, "The parent of a boundary keeps a + * declaration only the children use when another removed declaration reads + * it too"): the parent keeps the shared end of a diamond and both halves of + * a cycle, and their import. + */ +const failsToday = new Set([ + 'a diamond', + 'mutually recursive functions', + 'a class and a const that read each other', +]) + +for (const shape of deadCodeShapes) { + test( + `client: the parent drops what only the children use through ${shape.name}`, + { fails: failsToday.has(shape.name) }, + async () => { + const kept = shape.kept + ? `\nexport const kept = () => ${shape.kept.expression} +export { ${shape.kept.binding} as aliased }` + : '' + const recorded = shape.alreadyDead + ? `\nexport { calls as recorded } from './record'` + : '' + const { client } = await expectRendersLikeSource( + await hosts(), + `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +${shapeSetup(shape, './dep')} +export function Page() { + return <Hydrate when={load()}><p>{${shape.root}}</p></Hydrate> +}${kept}${recorded}`, + { + files: { 'dep.ts': depSource, ...recordFile }, + script: shape.kept + ? 'return [m.kept(), m.aliased()]' + : shape.alreadyDead + ? 'return [...m.recorded]' + : undefined, + }, + ) + expect(client.html).toContain(`<p>${shape.expected}</p>`) + if (shape.kept) { + expect(client.result).toEqual([shape.kept.expected, 'dep']) + } else { + expect(client.loaded).not.toContain('./dep') + } + if (shape.alreadyDead) { + expect(client.result).toContain('dead') + } + }, + ) +} diff --git a/packages/start-plugin-core/tests/integration/pages/hydrate-split-modules.test.ts b/packages/start-plugin-core/tests/integration/pages/hydrate-split-modules.test.ts new file mode 100644 index 0000000000..dd8d1b9f6c --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/hydrate-split-modules.test.ts @@ -0,0 +1,1113 @@ +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { parseSync } from 'vite' +import { + expectMapsTo, + positionAt, + tokenOffsets, +} from '@tanstack/compiler-test-utils/source-maps' +import { + compileError, + expectCompileError, + serverOnlyModule, +} from '../../regression-helpers' +import { + editableFiles, + expectHydratedCleanly, + expectRenderedThroughChunks, + expectRendersLikeSource, + lazyCode, + renderClient, + renderServer, + renderSource, + servedWithMap, + useEditHost, + useHydrateHost, + useSolidHost, + withoutHydrationIds, +} from '../../render' +import type { SourceMapInput } from '@tanstack/compiler-test-utils/source-maps' + +// On the client `<Hydrate>` children move into split code the page loads +// on demand, and the parent renders it in their place; on the server the +// children render inline and the client-only `fallback` is stripped. Both +// must stay valid and behave like the original source: through the public +// Start plugin on a dev server, the server render (React's server renderer +// in the SSR environment) is compared with the uncompiled source, and the +// client hydrates it in a real page (`render.ts`). Where the split code +// lives (how many modules, under which ids) is free (SPEC §5.3). + +const hosts = useHydrateHost() +const solidHost = useSolidHost() +const editHost = useEditHost() + +/** + * The directives a served module carries from the user's file: the string + * expression statements its code starts with, once what the dev server puts + * in front of every module it serves is skipped (its HMR client setup, the + * imports it hoists and the interop bindings of the dependencies it + * rewrites: Vite's own output, which breaks a served module's prologue in + * dev whatever the compilers do). + */ +function sourceDirectives(code: string) { + const { program } = parseSync('served.js', code, { sourceType: 'module' }) + const directives: Array<string> = [] + for (const statement of program.body) { + const text = code.slice(statement.start, statement.end) + if ( + statement.type === 'ImportDeclaration' || + (statement.type === 'ExpressionStatement' && + /^import\.meta\.hot\s*=/.test(text)) || + (statement.type === 'VariableDeclaration' && + text.includes('__vite__cjsImport')) + ) { + continue + } + if ( + statement.type === 'ExpressionStatement' && + statement.expression.type === 'Literal' && + typeof statement.expression.value === 'string' + ) { + directives.push(statement.expression.value) + continue + } + break + } + return directives +} + +const head = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +` + +describe('the parent module', () => { + const widgetPage = `${head}import { visible } from '@tanstack/react-start/hydration' +import { FallbackPane } from './widgets' +import { Chart } from './chart' +import { formatValue } from './format' +const chartTitle = formatValue('Revenue') +export function Page() { + return <Hydrate when={visible()} fallback={<FallbackPane />}><Chart title={chartTitle} /></Hydrate> +}` + const widgetFiles = { + './widgets': `export const FallbackPane = () => <aside>fallback</aside>`, + './chart': `export const Chart = ({ title }) => <figure>{title}</figure>`, + './format': `export function formatValue(value) { + globalThis.__formatCalls = (globalThis.__formatCalls ?? 0) + 1 + return value + '!' +}`, + } + + // Where the children's code ends up in the final bundle is the bundler's + // call (hydrate-build.test.ts); the parent must not need it before the + // split code loads. + test('client: modules and bindings only the split children use are not needed before the chunk loads', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + widgetPage, + { + files: widgetFiles, + setup: `globalThis.__formatCalls = 0 +export const cleanup = ['__formatCalls']`, + script: 'return globalThis.__formatCalls', + }, + ) + expect(client.html).toContain('<figure>Revenue!</figure>') + expect(client.loaded).not.toContain('./chart') + expect(client.lazy).toContain('./chart') + // When the parent's own module-level code (`formatValue('Revenue')`) runs + // is left open; it runs once. + expect(client.result).toBe(1) + }) + + // Source: #8504 hydrate-split-modules.test.ts + // Whether the client-only split chunk repeats 'use client' is free: the + // directive has no effect in a chunk only the client loads (SPEC J5.9). + test('client: the directives stay in the prologue of the parent module', async () => { + const client = await renderClient( + await hosts(), + `'use client' +'use strict' +${head}import { Chart } from './chart' +export function Page() { + return <Hydrate when={load()}><Chart /></Hydrate> +}`, + { files: { './chart': `export const Chart = () => <p>chart</p>` } }, + ) + expectHydratedCleanly(client) + // Both directives stay in the prologue (before any statement); their + // order is free (SPEC §5.5). + expect(sourceDirectives(await client.case.served())).toEqual( + expect.arrayContaining(['use client', 'use strict']), + ) + }) + + test('client: the split shorthand splits the children', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + return <Hydrate when={load()} split><p>child</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>child</p>') + }) + + // An object that may be observed elsewhere (shared, or returned by a call) + // may keep its fallback on the server (SPEC J5.3, deferred-hydration docs: + // "the compiler may keep them"); the boundaries still render their + // children. + test.each([ + { + name: 'shared by two boundaries', + code: `const opts = { fallback: <p>server-fallback</p> } +export function Page() { return <><Hydrate when={load()} {...opts}><p>a</p></Hydrate><Hydrate when={load()} {...opts}><p>b</p></Hydrate></> }`, + children: ['<p>a</p>', '<p>b</p>'], + }, + { + name: 'returned by a call', + code: `const makeOpts = () => ({ fallback: <p>server-fallback</p> }) +const opts = makeOpts() +export function Page() { return <Hydrate when={load()} {...opts}><p>child</p></Hydrate> }`, + children: ['<p>child</p>'], + }, + ])( + 'server: boundaries spreading an object $name render their children', + async ({ code, children }) => { + const server = await renderServer(await hosts(), `${head}${code}`) + const source = await renderSource(await hosts(), `${head}${code}`) + expect(withoutHydrationIds(server.html)).toBe(source.html) + for (const child of children) { + expect(server.html).toContain(child) + } + }, + ) + + test('server: a split={false} boundary loses a fallback passed through a spread too', async () => { + const code = `${head}export function Page() { + return <Hydrate when={load()} split={false} {...{ fallback: <p>server-fallback</p> }}><p>child</p></Hydrate> +}` + const server = await renderServer(await hosts(), code) + expect(server.code).not.toContain('server-fallback') + expect(withoutHydrationIds(server.html)).toBe( + (await renderSource(await hosts(), code)).html, + ) + expect(server.html).toContain('<p>child</p>') + }) + + // Source: Qwik optimizer example_functional_component_capture_props + test('server: params used only by the fallback keep later params in place', async () => { + const code = `${head}export function List({ items }) { + return <ul>{items.map((item, i) => <Hydrate when={load()} key={i} fallback={<p>{item}</p>}><li>{i}</li></Hydrate>)}</ul> +} +export function Card(label, body) { + return <Hydrate when={load()} fallback={<p>{label}</p>}><p>{body}</p></Hydrate> +}` + const options = { + render: `h('main', null, h(m.List, { items: ['a', 'b'] }), m.Card('L', 'B'))`, + } + const server = await renderServer(await hosts(), code, options) + expect(withoutHydrationIds(server.html)).toBe( + (await renderSource(await hosts(), code, options)).html, + ) + expect(server.html).toContain('<li>0</li>') + expect(server.html).toContain('<li>1</li>') + expect(server.html).toContain('<p>B</p>') + }) + + // Source: Qwik optimizer should_transform_handler_in_for_of_loop + test('server: a loop variable used only by the fallback keeps the module valid', async () => { + const code = `${head}export function List({ xs }) { + const out = [] + for (const x of xs) out.push(<Hydrate when={load()} fallback={<p>{x}</p>}><p>child</p></Hydrate>) + return out +}` + // The SSR environment serves and evaluates it, and it renders. + const server = await renderServer(await hosts(), code, { + render: `h(m.List, { xs: ['a', 'b'] })`, + }) + expect(server.html.match(/<p>child<\/p>/g)).toHaveLength(2) + }) + + // Source: Qwik optimizer should_keep_non_migrated_binding_from_shared_destructuring_declarator + test('server: a destructuring shared by the fallback and the children keeps the children binding', async () => { + const code = `${head}export function Page(props) { + const { a, b } = props + return <Hydrate when={load()} fallback={<p>{a}</p>}><p>{b}</p></Hydrate> +}` + const props = { a: 'A', b: 'B' } + const server = await renderServer(await hosts(), code, { props }) + expect(withoutHydrationIds(server.html)).toBe( + (await renderSource(await hosts(), code, { props })).html, + ) + expect(server.html).toContain('<p>B</p>') + }) + + // Every boundary renders a hydration id (`idle()`): the client hydrates + // the ids the server rendered. + // Source: Qwik optimizer example_mutable_children, issue_5008 + test.each([ + { name: 'Page', props: { flag: true, items: ['x'] } }, + { name: 'Page', props: { flag: false, items: ['x'] } }, + { name: 'Other', props: { early: true } }, + { name: 'Other', props: { early: false } }, + ])( + 'client: boundaries in conditionals and callbacks hydrate like the server renders them: $name $props', + async ({ name, props }) => { + const code = `${head}import { idle } from '@tanstack/react-start/hydration' +export function Page({ flag, items }) { + return <div> + {flag ? <Hydrate when={idle()}><p>yes</p></Hydrate> : <Hydrate when={idle()}><p>no</p></Hydrate>} + {flag && <Hydrate when={idle()}><p>and</p></Hydrate>} + {items.map(function (item, idx) { return <Hydrate when={idle()} key={idx}><p>{'fn' + item}</p></Hydrate> })} + {items.map((item) => <Hydrate when={idle()} key={item}><p>{'arrow' + item}</p></Hydrate>)} + </div> +} +export function Other({ early }) { + if (early) { return <Hydrate when={idle()}><p>early</p></Hydrate> } + return <Hydrate when={idle()}><p>late</p></Hydrate> +}` + const { server } = await expectRendersLikeSource(await hosts(), code, { + render: `h(m.${name}, props)`, + props, + }) + expect(server.html).toContain('data-ts-hydrate-id') + }, + ) + + // The route code splitter compiles a route's split component in its own + // module: the boundaries of a route component, split by the router plugin + // Start runs, keep the ids the server renders, and their split code loads. + test('client: a module compiled under an id with another query keeps the server boundary ids', async () => { + const started = await editHost() + const file = 'hydrate-split-route.tsx' + await started.start.edit({ + [`src/routes/${file}`]: `import { createFileRoute } from '@tanstack/react-router' +${head}import { idle } from '@tanstack/react-start/hydration' +export const Route = createFileRoute('/hydrate-split-route')({ + component: Page, +}) +function Page() { + return <div><Hydrate when={idle()}><p>one</p></Hydrate><Hydrate when={idle()}><p>two</p></Hydrate></div> +}`, + }) + const client = await renderClient(started, '', { + target: { + dir: 'src/routes', + setup: false, + ssr: (name: string) => + started.start.host.importServer(`/src/routes/${name}`), + served: (name: string, environment: 'client' | 'ssr') => + started.start.host.transform(`/src/routes/${name}`, environment), + }, + file, + render: 'h(m.Route.options.component)', + // The router loads a route's split component before it renders it: + // what loads once hydration starts is the boundaries' split code, not + // the route code splitter's module of the component + beforeRender: 'await m.Route.options.component.preload?.()', + freshPage: true, + }) + expectHydratedCleanly(client) + expect(client.html).toBe(client.server.html) + expectRenderedThroughChunks(client) + expect(client.html).toContain('<p>one</p>') + expect(client.html).toContain('<p>two</p>') + }, 30_000) + + test('client: a split={false} boundary nested in another does not shift the ids of later boundaries', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { idle } from '@tanstack/react-start/hydration' +export function Page() { + return <div><Hydrate when={idle()}><section><Hydrate when={idle()} split={false}><b>inline</b></Hydrate></section></Hydrate><Hydrate when={idle()}><p>second</p></Hydrate></div> +}`, + ) + expect(client.html).toContain('<b>inline</b>') + expect(client.html).toContain('<p>second</p>') + }) + + test('client: a call whose name only contains "use" is split', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { houseNumber } from './format' +export function Page() { + return <Hydrate when={load()}><p>{houseNumber()}</p></Hydrate> +}`, + { files: { './format.ts': `export const houseNumber = () => '12'` } }, + ) + expect(client.html).toContain('<p>12</p>') + }) + + // The client never receives the server fn's handler code, however the + // split children reach the server fn (its own caller, or the parent's). + // Calling it from the children by the id the server runs needs a page. + // Source: Qwik optimizer example_strip_exports_used + test.each([ + { + name: 'an exported server fn also called by the parent', + code: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { db } from '${serverOnlyModule}' +export const greet = createServerFn().handler(async () => db.read('greet-handler-marker')) +export function Page() { + return <><button onClick={() => greet()}>a</button><Hydrate when={load()}><button onClick={() => greet()}>b</button></Hydrate></> +}`, + }, + { + name: 'a private server fn only called by the children', + code: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { db } from '${serverOnlyModule}' +const greet = createServerFn().handler(async () => db.read('greet-handler-marker')) +export function Page() { + return <Hydrate when={load()}><button onClick={() => greet()}>b</button></Hydrate> +}`, + }, + ])( + 'client: $name keeps its handler out of the parent and the split chunk', + async ({ code }) => { + const client = await renderClient(await hosts(), code, { + files: { 'db.server.ts': `export const db = { read: (x) => x }` }, + }) + expectHydratedCleanly(client) + expectRenderedThroughChunks(client) + const shipped = { + parent: await client.case.served(), + ...(await lazyCode(await hosts(), client)), + } + for (const [url, output] of Object.entries(shipped)) { + expect(output, url).not.toContain('greet-handler-marker') + } + // Neither the parent nor what it imports, statically or on demand. + expectNotLoaded(await client.case.loads(), [serverOnlyModule]) + expect(client.lazy).not.toContain(serverOnlyModule) + }, + ) +}) + +describe('the split chunk', () => { + // The server renders the children as JSX text. Multi-line text is pinned + // in known-bugs-hydrate.test.ts. + // Source: #8504 hydrate-split-modules.test.ts (exact equality, numeric + // entities) + test.each([ + { + name: 'entities', + text: '& & &', + rendered: '& & &', + }, + { + name: 'numeric entities', + text: '© © ©', + rendered: '© © ©', + }, + ])( + 'client: a text-only child renders like JSX text: $name', + async ({ text, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + return <Hydrate when={load()}>${text}</Hydrate> +}`, + ) + expect(client.html).toContain(rendered) + }, + ) + + // A wrapper component forwarding its children through a boundary keeps + // them after hydration. + test.each([ + { + name: 'a captured prop', + code: `export function Page({ label }) { + return <Hydrate when={load()}>{label}</Hydrate> +}`, + props: { label: 'label-marker' }, + }, + { + name: 'the children of a wrapper', + code: `export function Page(props) { + return <Hydrate when={load()}>{props.children}</Hydrate> +}`, + props: { children: 'label-marker' }, + }, + ])( + 'client: a single expression child ($name) renders through the chunk', + async ({ code, props }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { props }, + ) + expect(client.html).toContain('label-marker') + }, + ) + + // Server code never reaches the client, the split code included. Where + // the split code lives and how many modules it takes is free (SPEC §5.3). + test('client: the chunk does not import what only a server fn handler uses', async () => { + const client = await renderClient( + await hosts(), + `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +import { db } from './db' +export const getUser = createServerFn().handler(async () => db.read()) +export function Page() { + return <Hydrate when={load()}><p>child</p></Hydrate> +}`, + { files: { './db.ts': `export const db = { read: () => 'db' }` } }, + ) + expectHydratedCleanly(client) + expectRenderedThroughChunks(client) + // The parent and everything it imports, statically or on demand. + expectNotLoaded(await client.case.loads(), ['./db']) + expect(client.lazy).not.toContain('./db') + }) + + // What the click handler returns needs a page. + // Source: #8504 hydrate-split-modules.test.ts (click handler and IIFE) + test('client: children may contain return statements', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}const letters = ['a', 'b'] +export function Page() { + return <Hydrate when={load()}><ul onClick={() => { return 'click' }}>{letters.map((letter) => { const upper = letter.toUpperCase(); return <li>{upper}</li> })}{(function () { return 'iife' })()}</ul></Hydrate> +}`, + ) + expect(client.html).toContain('<ul><li>A</li><li>B</li>iife</ul>') + }) + + // `null` children are valid (TypeScript accepts `children={null}` and + // `{null}`): both environments render the empty boundary the source + // renders. + test('client: boundaries with null children render like the source', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { idle } from '@tanstack/react-start/hydration' +export function Page() { + return <div><Hydrate when={idle()} children={null} /><Hydrate when={idle()}>{null}</Hydrate></div> +}`, + { split: false }, + ) + expect(client.server.html.match(/data-ts-hydrate-id=/g)).toHaveLength(2) + }) + + // Not a supported input (TypeScript rejects all three: `children` is a + // required prop), but a mistake a JavaScript user can make: a boundary + // without children renders nothing and keeps its props, or is rejected at + // its line. Leaving it unsplit is valid too. + // Source: #8504 hydrate-split-modules.test.ts (self-closing row, "a + // self-closing boundary without a children prop keeps its props") + test('client: empty, self-closing and comment-only boundaries render nothing and keep their props, or are rejected at their line', async () => { + const code = `${head}import { idle } from '@tanstack/react-start/hydration' +export function Page() { + return <div><Hydrate when={idle()}></Hydrate><Hydrate when={idle()} /><Hydrate when={idle()}>{/* nothing */}</Hydrate></div> +}` + const started = await hosts() + const startCase = await started.start.case({ 'module.tsx': code }) + let rejected = false + for (const environment of ['client', 'ssr'] as const) { + const error = await compileError(startCase, environment) + if (error !== undefined) { + // A rejection points at the boundaries' line + expectCompileError(error, { source: code, at: '<Hydrate' }) + rejected = true + } + } + if (rejected) { + return + } + // The strategy each boundary keeps shows in the markup it renders. + const { client } = await expectRendersLikeSource(started, code, { + split: false, + }) + expect(client.server.html.match(/data-ts-hydrate-id=/g)).toHaveLength(3) + }) + + // Goal: `<Hydrate children={…} />` defers its children like JSX children: + // the parent does not need their modules before the split code loads. + // Source: #8504 hydrate-split-modules.test.ts "a children prop moves into + // the chunk" + test.fails.each([ + { name: 'last', attributes: 'when={idle()} children={<Chart />}' }, + { name: 'first', attributes: 'children={<Chart />} when={idle()}' }, + ])( + 'client: the children prop ($name) of a self-closing boundary is deferred', + async ({ attributes }) => { + const client = await renderClient( + await hosts(), + `${head}import { idle } from '@tanstack/react-start/hydration' +import { Chart } from './chart' +export function Page() { + return <Hydrate ${attributes} /> +}`, + { files: { './chart': `export const Chart = () => 'chart'` } }, + ) + expect(client.loaded).not.toContain('./chart') + expect(client.lazy).toContain('./chart') + expect(client.html).toContain('chart') + }, + ) + + // Deferring them is the goal above; either way they render, like on the + // server. + test('client: the children prop of a self-closing boundary renders like on the server', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { idle } from '@tanstack/react-start/hydration' +import { Chart } from './chart' +export function Page() { + return <section><Hydrate when={idle()} children={<Chart />} /></section> +}`, + { + files: { './chart': `export const Chart = () => 'chart'` }, + split: false, + }, + ) + expect(client.html).toContain('chart') + expect(client.server.html).toContain('data-ts-hydrate-id') + }) + + // The dev server compiles a module again when it changes (here: written + // again with the same source): a fresh page then gets split code that + // renders the same children. + test('client: a chunk id renders the same children when the same source is compiled again', async () => { + const source = `${head}export function Page() { + return <Hydrate when={load()}><p>chunk-marker</p></Hydrate> +}` + const started = await editHost() + const files = await editableFiles(started, source) + const render = async () => { + const rendered = await renderClient(started, '', { + target: files.target, + freshPage: true, + }) + expectHydratedCleanly(rendered) + expectRenderedThroughChunks(rendered) + return rendered.html + } + const first = await render() + expect(first).toContain('<p>chunk-marker</p>') + await files.edit(`${source}\n`) + expect(await render()).toBe(first) + }, 30_000) + + // Code in the split code and in the parent maps back to where the user + // wrote it: the throws of a handler in the parent and of one in the + // children, located by their parsed string tokens (whatever the printing), + // resolve through each served module's map to their line and column in + // the source file. Real stack traces of a built page: hydrate-build.test.ts. + // Source: #8504 hydrate-split-modules.test.ts. + test('client: the source maps of the chunk and the parent point at the original code', async () => { + const source = `${head}import { visible } from '@tanstack/react-start/hydration' +export function Page() { + const fail = () => { + throw new Error('parent-throw') + } + return ( + <main onClick={fail}> + <Hydrate when={visible()}> + <button onClick={() => { throw new Error('child-throw') }}>x</button> + </Hydrate> + </main> + ) +}` + const started = await hosts() + const client = await renderClient(started, source) + expectRenderedThroughChunks(client) + const parent = await servedWithMap(started, client.case.url()) + // The case's split code, whatever its URLs (SPEC §5.3) + const chunks = await Promise.all( + client.chunks.map((url) => servedWithMap(started, url)), + ) + /** Asserts every occurrence of `marker` in `output` maps to the source's. */ + const expectMarkersMapped = ( + output: { code: string; map?: unknown }, + marker: string, + ) => { + const offsets = tokenOffsets(output.code, { string: marker }) + const original = positionAt(source, source.indexOf(`'${marker}'`)) + for (const offset of offsets) { + expectMapsTo( + output.map as SourceMapInput, + positionAt(output.code, offset), + { + file: client.case.file(), + line: original.line, + column: original.column, + }, + ) + } + return offsets.length + } + // The handler of the parent stays in the parent; the children's is in + // the split code (wherever else either is copied, it maps back too). + expect(expectMarkersMapped(parent, 'parent-throw')).toBeGreaterThan(0) + expectMarkersMapped(parent, 'child-throw') + let inChunks = 0 + for (const chunk of chunks) { + inChunks += expectMarkersMapped(chunk, 'child-throw') + expectMarkersMapped(chunk, 'parent-throw') + } + expect(inChunks).toBeGreaterThan(0) + }) + + test('client: the chunks of a module stay loadable after another module is compiled', async () => { + const started = await hosts() + const sources = { + A: `${head}export function A() { return <Hydrate when={load()}><p>first</p></Hydrate> }`, + B: `${head}export function B() { return <Hydrate when={load()}><p>second</p></Hydrate> }`, + } + const startCase = await started.start.case({ + 'setup.ts': 'export {}\n', + 'first.tsx': sources.A, + 'second.tsx': sources.B, + }) + // Both are compiled before either renders. + await startCase.served('first.tsx') + await startCase.served('second.tsx') + for (const [name, file, child] of [ + ['A', 'first.tsx', '<p>first</p>'], + ['B', 'second.tsx', '<p>second</p>'], + ] as const) { + const rendered = await renderClient(started, '', { + target: startCase, + file, + render: `h(m.${name})`, + }) + expectHydratedCleanly(rendered) + expectRenderedThroughChunks(rendered) + expect(rendered.html).toContain(child) + } + }) + + // SPEC J5.2: a boundary nested in another one has split code of its own, + // behind its own gate: once the outer gate opens, the outer children's + // modules load, and the nested children's modules wait for the nested + // gate (here `never()`, which stays shut). How many modules either split + // takes is free (SPEC §5.3). + test('client: the children of a nested boundary wait for its own gate', async () => { + const client = await renderClient( + await hosts(), + `${head}import { never } from '@tanstack/react-start/hydration' +import { Chart } from './chart' +import { Inner } from './inner' +export function Page() { + return <Hydrate when={load()}><section><Chart /><Hydrate when={never()}><Inner /></Hydrate></section></Hydrate> +}`, + { + files: { + './chart': `export const Chart = () => <figure>chart</figure>`, + './inner': `export const Inner = () => <p>inner</p>`, + }, + }, + ) + expectHydratedCleanly(client) + expect(client.html).toContain('<figure>chart</figure>') + expect(client.html).toContain('<p>inner</p>') + expect(client.loaded).not.toContain('./chart') + expect(client.lazy).toContain('./chart') + expect(client.loaded).not.toContain('./inner') + expect(client.lazy).not.toContain('./inner') + }) + + // SPEC J5.2: sibling boundaries have split code of their own, each behind + // its own gate: opening one gate loads that boundary's children only (how + // many modules either split takes is free, SPEC §5.3). + test('client: opening one of two sibling boundaries loads its children only', async () => { + const client = await renderClient( + await hosts(), + `${head}import { interaction } from '@tanstack/react-start/hydration' +import { Chart } from './chart' +import { Table } from './table' +export function Page() { + return <><Hydrate when={interaction()}><Chart /></Hydrate><Hydrate when={interaction()}><Table /></Hydrate></> +}`, + { + files: { + './chart': `export const Chart = () => <figure>chart</figure>`, + './table': `export const Table = () => <table><tbody><tr><td>table</td></tr></tbody></table>`, + }, + gates: `(boundary) => boundary.textContent.includes('chart')`, + }, + ) + expectHydratedCleanly(client) + expect(client.html).toContain('<figure>chart</figure>') + expect(client.html).toContain('<td>table</td>') + expect(client.loaded).not.toContain('./chart') + expect(client.loaded).not.toContain('./table') + expect(client.lazy).toContain('./chart') + expect(client.lazy).not.toContain('./table') + expectRenderedThroughChunks(client) + }) + + // The split code of a boundary, and of the nested boundary it contains, + // uses the packages of the module's framework only (a React module graph + // has no Solid packages, and the other way around). How many modules the + // split takes is free (SPEC §5.3). + test('client: react split code of a boundary and a nested one renders with its own packages', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +export function Page() { + return <Hydrate when={load()}><section><Hydrate when={load()}><p>react</p></Hydrate></section></Hydrate> +}`, + ) + expect(client.html).toContain('<p>react</p>') + expect(client.lazy.filter((url) => /solid/.test(url))).toEqual([]) + expect( + (await client.case.loads()).filter((name) => /solid/.test(name)), + ).toEqual([]) + }) + + // A Solid app (`vite-plugin-solid`) mounts the boundary in its page: the + // split code of the boundary and of the nested one loads and renders, + // and needs no React package. How many modules the split takes is free + // (SPEC §5.3). + test('client: solid split code of a boundary and a nested one is valid and uses the Solid packages only', async () => { + const solid = await solidHost() + const mounted = + await solid.mount(`import { Hydrate } from '@tanstack/solid-start' +import { load } from '@tanstack/solid-start/hydration' +export function Page() { + return <Hydrate when={load()}><section><Hydrate when={load()}><p>solid</p></Hydrate></section></Hydrate> +}`) + expect(mounted.errors).toEqual([]) + expect(mounted.html).toContain('<p>solid</p>') + expect(mounted.lazy).not.toEqual([]) + const isReact = (name: string) => + /^(?:\/node_modules\/\.vite\/deps\/)?(react|react-dom)(?:[_/.]|$)|@tanstack\/react-/.test( + name, + ) + expect(mounted.lazy.filter(isReact)).toEqual([]) + expect(mounted.loads.filter(isReact)).toEqual([]) + expect(mounted.serverLoads.filter(isReact)).toEqual([]) + }) + + // Source: Qwik optimizer example_capture_imports, + // jsx_member_tag_object_is_captured, example_jsx + test('client: default, namespace and aliased imports and namespaced names in the children', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import Chart from './chart' +import * as UI from './ui' +import { format as fmt, default as theme } from './format' +export function Page() { + return <Hydrate when={load()}><Chart /><UI.Button label={fmt(theme)} /><svg><use xlink:href="#icon" /></svg></Hydrate> +}`, + { + files: { + './chart': `export default () => <figure>chart</figure>`, + './ui': `export const Button = ({ label }) => <button>{label}</button>`, + './format.ts': `export const format = (value: string) => \`[\${value}]\` +export default 'dark'`, + }, + }, + ) + expect(client.html).toContain( + '<figure>chart</figure><button>[dark]</button>', + ) + expect(client.html).toContain('#icon') + }) + + // Source: Qwik optimizer should_handle_dangerously_set_inner_html + test('client: string attributes keep their value', async () => { + // The markup comparison covers every attribute value. + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + return <Hydrate when={load()}><span title="Fish & Chips ©" data-q='say "hi"' data-n="a +b" dangerouslySetInnerHTML={{ __html: "<h1>I'm an h1!</h1>" }} /></Hydrate> +}`, + ) + expect(client.html).toContain("<h1>I'm an h1!</h1>") + }) + + // Source: Qwik optimizer example_default_export + test('client: an anonymous default-exported component splits its boundary', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}const label = 'default' +export default () => <Hydrate when={load()}><p>{label}</p></Hydrate>`, + { render: 'h(m.default)' }, + ) + expect(client.html).toContain('<p>default</p>') + }) + + // Where the destructuring and the import end up is the bundler's call + // (hydrate-build.test.ts). + // Source: Qwik optimizer example_invalid_references, + // should_migrate_destructured_binding_with_imported_dependency + test('client: the children read a module-level destructuring of an import', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { source } from './lib' +const fallback = 'd' +const [a, { b = fallback, ...rest }] = source +export function Page() { + return <Hydrate when={load()}><p>{[a, b, JSON.stringify(rest)].join('|')}</p></Hydrate> +}`, + { files: { './lib.ts': `export const source = ['A', { extra: 'x' }]` } }, + ) + expect(client.html).toContain('<p>A|d|{"extra":"x"}</p>') + }) + + // A let the children only write is pinned in known-bugs-hydrate.test.ts. + // Source: Qwik optimizer should_preserve_let_when_migrated_into_segment + test('client: a module-level let only the children use stays mutable', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}let renders = 0 +export function Page() { + return <Hydrate when={load()}><p>{++renders}</p></Hydrate> +}`, + { + render: `[h(m.Page, { key: 'first' }), h(m.Page, { key: 'second' })]`, + }, + ) + expect(client.html).toContain('<p>1</p>') + expect(client.html).toContain('<p>2</p>') + }) + + // Source: Qwik optimizer should_keep_non_migrated_binding_from_shared_destructuring_declarator + // (+ _array_destructuring_declarator, _with_rest) + test.each([ + { name: 'object', declaration: `const { a, b } = { a: 'A', b: 'B' }` }, + { name: 'array', declaration: `const [a, b] = ['A', 'B']` }, + { name: 'rest', declaration: `const { a, ...b } = { a: 'A', c: 'B' }` }, + ])( + 'client: an $name destructuring shared by the parent and the children keeps both bindings', + async ({ declaration }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${declaration} +export const fromRoot = () => JSON.stringify(b) +export function Page() { + return <Hydrate when={load()}><p>{a}</p></Hydrate> +}`, + { script: 'return m.fromRoot()' }, + ) + expect(client.result).toContain('B') + expect(client.html).toContain('<p>A</p>') + }, + ) + + // Source: Qwik optimizer should_keep_root_var_used_by_export_decl_and_qrl, + // example_segment_variable_migration, + // variable_migration_transitive_dep_used_by_other_segment + test('client: helpers shared by two boundaries and an export stay available to each', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}const scrollState = (el) => ({ x: el.x, y: el.y }) +const saveScroll = (s) => s.x + s.y +const bigHelper = (el) => saveScroll(scrollState(el)) +export const direct = saveScroll(scrollState({ x: 1, y: 1 })) +export function App() { + return <><Hydrate when={load()}><p>{bigHelper({ x: 1, y: 2 })}</p></Hydrate><Hydrate when={load()}><p>{scrollState({ x: 3, y: 4 }).y}</p></Hydrate></> +}`, + { render: 'h(m.App)', script: 'return m.direct' }, + ) + expect(client.result).toBe(2) + expect(client.html).toContain('<p>3</p>') + expect(client.html).toContain('<p>4</p>') + }) + + // Whether the split code shares the parent's instance of these + // declarations or declares its own is pinned in known-bugs-hydrate.test.ts + // (module state initialized once), like a default-exported function, enums + // and namespaces; only the output is asserted here. + // Source: Qwik optimizer example_exports (#8504 + // hydrate-split-modules.test.ts) + test('client: exported declarations of every form used by the children render', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export const [a, { b }] = ['a', { b: 'b' }] +const exp1 = 'e1' +const internal = 'i' +export { exp1, internal as expr2 } +export function foo() { return 'foo' } +export class Bar { static id = 'bar' } +export function Page() { + return <Hydrate when={load()}><p>{[a, b, exp1, internal, foo(), Bar.id].join('|')}</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>a|b|e1|i|foo|bar</p>') + }) + + describe('a route file', () => { + // The children render a component the route file exports; the route is + // created once (`track` counts the creations). + // Source: hydrate-when-transform.test.ts "unwraps exported declarations + // needed by extracted virtual modules" + test('client: an exported component of a route file renders in the chunk, and the route is created once', async () => { + const code = `import { createFileRoute } from '@tanstack/react-router' +${head}import { visible } from '@tanstack/react-start/hydration' +import { track } from './track' +export const Route = track(createFileRoute('/test')({ + component: Page, +})) +export const label = 'Ada' +export const Widget = () => { + return <p>{label}</p> +} +function Page() { + return <Hydrate when={visible()}><Widget /></Hydrate> +}` + const { client } = await expectRendersLikeSource(await hosts(), code, { + files: { + './track': `export function track(route) { + globalThis.__routes = (globalThis.__routes ?? 0) + 1 + return route +}`, + }, + setup: `globalThis.__routes = 0 +export const cleanup = ['__routes']`, + render: 'h(m.Route.options.component)', + script: 'return globalThis.__routes', + }) + expect(client.html).toContain('<p>Ada</p>') + expect(client.result).toBe(1) + }) + }) + + // Source: Qwik optimizer example_ts_enums (TypeScript-only declaration forms) + test('client: an overloaded function used by the children keeps its implementation', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}function label(value: string): string +function label(value: number): string +function label(value: unknown) { return 'label:' + String(value) } +export function Page() { + return <Hydrate when={load()}><p>{label(1)}</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>label:1</p>') + }) + + /** A page whose split child renders `Widget`, declared by `body`. */ + const widgetPage = (body: string) => `${head}${body} +export function Page(props) { + return <Hydrate when={load()}><Widget {...props} /></Hydrate> +}` + + // A component the children render moves into the split code with the + // module bindings it reads. + // Source: React Compiler fixtures (per row) + test.each([ + { + // try-catch-* fixtures + name: 'a catch parameter shadowing a module binding', + body: `const error = 'module' +function Widget() { + let caught + try { + throw 'thrown' + } catch (error) { + caught = error + } + return <p>{caught}-{error}</p> +}`, + expected: '<p>thrown-module</p>', + }, + { + // fn-name-no-leak-to-nested-arrow.js + name: 'a named function expression shadowing a module binding', + body: `const helper = () => 'module' +function Widget() { + const local = function helper(n) { + return n > 0 ? helper(n - 1) : 'local' + } + return <p>{local(2)}/{helper()}</p> +}`, + expected: '<p>local/module</p>', + }, + { + // destructure-*-default fixtures + name: 'parameter defaults reading module bindings', + body: `const fallback = 'fb' +function Widget({ title = fallback, items: [first = fallback.toUpperCase()] = [] }) { + return <p>{title}{first}</p> +}`, + expected: '<p>fbFB</p>', + }, + { + // hoisting-simple-function-declaration.js + name: 'a hoisted local function reading a module binding declared later', + body: `function Widget() { + const x = format() + function format() { + return prefix + 'x' + } + return <p>{x}</p> +} +const prefix = 'p-'`, + expected: '<p>p-x</p>', + }, + { + // class fixtures (static blocks, private fields) + name: 'a local class with a static block and a private field', + body: `const base = 2 +function Widget() { + class Counter { + static start + static { + Counter.start = base * 2 + } + #n = Counter.start + get n() { + return this.#n + } + } + return <p>{new Counter().n}</p> +}`, + expected: '<p>4</p>', + }, + ])( + 'client: the chunk renders like the original with $name', + async ({ body, expected }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + widgetPage(body), + ) + expect(client.html).toContain(expected) + }, + ) + + describe('side effects of the component bodies it moves', () => { + // An unused local initialized by a hook call or another side effect must + // still run when the split code renders: once on the client. + // Source: React Compiler fixtures react-namespace.js, + // unused-optional-method-assigned-to-variable.js, error.todo-reassign-const.js + // One row at a time: each resets a global of this process (the server + // realm) + test.each([ + { name: 'a call', initializer: `useTracked('call')` }, + { name: 'an optional call', initializer: `useTracked?.('optional')` }, + { + name: 'a member read of a call', + initializer: `useTracked('member').length`, + }, + ])( + 'client: an unused local initialized by $name still runs', + { concurrent: false }, + async ({ initializer }) => { + const code = widgetPage(`function useTracked(label) { + globalThis.__hydrateCalls.push(label) + return label +} +function Widget() { + const unused = ${initializer} + return <p>widget</p> +}`) + const { client } = await expectRendersLikeSource(await hosts(), code, { + setup: `globalThis.__hydrateCalls = [] +export const cleanup = ['__hydrateCalls']`, + script: 'return globalThis.__hydrateCalls.length', + }) + expect(client.html).toContain('<p>widget</p>') + expect(client.result).toBe(1) + }, + ) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate-module-level.test.ts b/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate-module-level.test.ts new file mode 100644 index 0000000000..3d34ac281e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate-module-level.test.ts @@ -0,0 +1,430 @@ +/** + * Known `<Hydrate>` split bugs of module-level code the split children use + * (the other pins are in known-bugs-hydrate.test.ts; two files, to keep + * each within the per-file time budget). Each test asserts correct + * behaviour for a bug on main and is marked .fails; remove .fails when the + * bug is fixed. + * + * The modules are compiled by the public Start plugin on a dev server and + * rendered through it (`render.ts`): the server render (React's server + * renderer in the SSR environment) is compared with the uncompiled source + * (a plain Vite host), and a real page hydrates it with every gate opened; + * the hydrated page must show the markup the server rendered, without a + * hydration error. + */ +import { describe, expect, test } from 'vitest' +import { + expectRendersLikeSource, + renderServer, + renderSource, + useHydrateHost, +} from '../../render' +import { generatedNames } from '../../hydrate-helpers' + +const hosts = useHydrateHost() + +const head = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +` + +describe('module-level code used by the children', () => { + // (First: its failure takes the page run bound, and the other tests run + // meanwhile.) + // Bug: the chunk keeps the module-level bindings the children name (by + // name, even when a local shadows them) under their own names, so a + // binding named like one the compiler generates in the chunk (its export) + // collides with it. + // Impact: compiling the chunk fails ("Duplicate declaration"), so the + // build fails. + test.fails.each([ + { + name: 'helpers the children call', + module: (name: string) => + `function ${name}() { return 'module:${name}' }`, + local: () => '', + read: (name: string) => `${name}()`, + value: (name: string) => `module:${name}`, + }, + { + name: 'bindings the children shadow with locals', + module: (name: string) => `const ${name} = 'module:${name}'`, + local: (name: string) => `const ${name} = 'local:${name}'`, + read: (name: string) => name, + value: (name: string) => `local:${name}`, + }, + ])( + 'client: module-level $name, named like the generated bindings, do not collide', + async ({ module: declare, local, read, value }) => { + /** The page; the `probe` page's children also read a local. */ + const page = ( + names: Array<string>, + probe = false, + ) => `${head}import { idle } from '@tanstack/react-start/hydration' +${names.map(declare).join('\n')} +export function Page() { + ${probe ? `const captured = 'c'\n ` : ''}${names.map(local).join('\n ')} + return <><Hydrate when={load()} prefetch={idle()}><p>{[${[...(probe ? ['captured'] : []), ...names.map(read)].join(', ')}].join('|')}</p></Hydrate><Hydrate when={load()}><section><Hydrate when={load()}><b>nested</b></Hydrate></section></Hydrate></> +}` + // Whichever names the compiler picks for this page, including the + // names it passes captured values under (none is a valid choice: then + // nothing can collide). + const names = await generatedNames(await hosts(), page([], true)) + const { client } = await expectRendersLikeSource( + await hosts(), + page(names), + ) + expect(client.html).toContain(`<p>${names.map(value).join('|')}</p>`) + expect(client.html).toContain('<b>nested</b>') + }, + // A failed split module makes the dev server reload the page (runs again) + 20_000, + ) + + // Bug: the chunk re-declares the module-level bindings the children use + // instead of using the parent module's instance. + // Impact: children read another context than the parent provides, or the + // initial value of a `let` the parent reassigns. + // Source: Qwik optimizer should_keep_module_level_var_used_in_both_main_and_qrl, + // should_auto_export_shared_let_kept_in_parent + test.fails.each([ + { + name: 'context', + code: `import { createContext, useContext } from 'react' +const Theme = createContext('light') +function Label() { return <span>{useContext(Theme)}</span> } +export function Page() { + return <Theme.Provider value="dark"><Hydrate when={load()}><Label /></Hydrate></Theme.Provider> +}`, + // The value the parent provides. + rendered: '<span>dark</span>', + }, + { + name: 'let reassigned by the parent', + code: `let clicks = 0 +export function bump() { clicks++ } +export function Page() { + return <Hydrate when={load()}><p>{clicks}</p></Hydrate> +}`, + rendered: '<p>1</p>', + }, + ])( + 'client: the children use the module-level $name of the parent module', + async ({ code, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { + // App code runs before the boundary hydrates. + beforeRender: 'm.bump?.()', + }, + ) + expect(client.html).toContain(rendered) + }, + ) + + // Bug (same root cause): an exported declaration the children use is + // copied into the chunk, so its initializer runs again there. + // Impact: the children use another instance than the module exports + // (e.g. another store), and the initializer's side effects run twice. + // Goal of hydrate-when-transform.test.ts "unwraps exported declarations + // needed by extracted virtual modules" (the copy is not required). + test.fails( + 'client: an exported declaration the children use has one instance, initialized once', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { makeStore } from './store' +export const store = makeStore() +export function Page() { + return <Hydrate when={load()}><p>{store.id}</p></Hydrate> +}`, + { + // Each store gets the next id: a second instance renders 2. + files: { + './store': `let stores = 0 +export const makeStore = () => ({ id: ++stores })`, + }, + script: 'return m.store.id', + }, + ) + expect(client.result).toBe(1) + expect(client.html).toContain('<p>1</p>') + }, + ) + + // Bug: the client chunk removes the module's `Route` + // (`removeModuleLevelBindings(ast, new Set(['Route']))`) without importing + // it from the parent module, so split children reading it reference an + // undeclared binding. + // Impact: the boundary throws "Route is not defined" when it hydrates. + // Source: #8504 hydrate-split-modules.test.ts (rows directly, through a + // module helper and exported under a specifier; red on main) + test.fails.each([ + { + name: 'directly', + code: `export const Route = createFileRoute('/posts')({ component: Page }) +export function Page() { + return <Hydrate when={load()}><p>{Route.options.id}</p></Hydrate> +}`, + rendered: '<p>/posts</p>', + }, + { + name: 'through a module helper', + code: `export const Route = createFileRoute('/posts')({ + loader: () => 'data', + component: Page, +}) +function Comments() { + return <p>{Route.options.loader() + ':' + Route.options.id}</p> +} +export function Page() { + return <Hydrate when={load()}><Comments /></Hydrate> +}`, + rendered: '<p>data:/posts</p>', + }, + { + name: 'exported under a specifier', + code: `const Route = createFileRoute('/posts')({ component: Page }) +export { Route } +export function Page() { + return <Hydrate when={load()}><p>{Route.options.id}</p></Hydrate> +}`, + rendered: '<p>/posts</p>', + }, + ])( + 'client: split children reading Route $name use the one route', + async ({ code, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { createFileRoute } from '@tanstack/react-router' +${code}`, + { + // The route tree updates the module's route (routeTree.gen.ts): + // the children read the route the module exports. + beforeRender: `m.Route.update({ id: '/posts' })`, + }, + ) + expect(client.html).toContain(rendered) + }, + ) + + // Bug: the client chunk takes any module-level binding named `Route` for + // the route and removes it (the removal of the pins above), even when the + // module does not export it and it is a plain component. + // Impact: the boundary throws "Route is not defined" when it hydrates. + test.fails( + 'client: an unexported component named Route that the children render reaches the chunk', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}function Route() { + return <p>local</p> +} +export function Page() { + return <Hydrate when={load()}><Route /></Hydrate> +}`, + ) + expect(client.html).toContain('<p>local</p>') + }, + ) + + // Bug: only declarations move into the chunk; the top-level statements that + // complete them (member assignments, registrations) are dropped. + // Impact: compound components such as `<Card.Title />` are undefined in + // the chunk ("Element type is invalid") and registries are empty. + // Source: Qwik optimizer should_not_move_over_side_effects, + // example_drop_side_effects + test.fails.each([ + { + name: 'a compound component member assignment', + setup: `function Card({ children }) { return <div>{children}</div> } +Card.Title = function Title() { return <h1>t</h1> }`, + children: '<Card><Card.Title /></Card>', + rendered: '<div><h1>t</h1></div>', + }, + { + name: 'Object.assign on a component', + setup: `function Tabs({ children }) { return <ul>{children}</ul> } +Object.assign(Tabs, { Tab: () => <li>tab</li> })`, + children: '<Tabs><Tabs.Tab /></Tabs>', + rendered: '<ul><li>tab</li></ul>', + }, + { + name: 'a registry filled by a top-level call', + setup: `const registry = new Map() +registry.set('a', 'A')`, + children: `<p>{registry.get('a')}</p>`, + rendered: '<p>A</p>', + }, + ])( + 'client: $name that the children rely on reaches the chunk', + async ({ setup, children, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${setup} +export function Page() { + return <Hydrate when={load()}>${children}</Hydrate> +}`, + ) + expect(client.html).toContain(rendered) + }, + ) + + // Bug: module bindings are collected from top-level declarations only + // (`collectLocalBindingsFromStatement`), so a module-level `var` declared + // in a nested block is dropped from the chunk. Same root cause as the + // nested `var` pins in router-plugin/tests/known-bugs-code-splitter.test.ts. + // Impact: the boundary throws "label is not defined" when it hydrates. + test.fails( + 'client: a var declared in a nested block that the children read reaches the chunk', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}try { + var label = JSON.parse('"nested"') +} catch {} +export function Page() { + return <Hydrate when={load()}><p>{label}</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>nested</p>') + }, + ) + + // Bug: a TypeScript import alias (`import Card = ui.Card`) used only by the + // split children is not declared in the client chunk. + // Impact: the chunk throws "Card is not defined" when the boundary + // hydrates. + // Source: React Compiler fixture ts-import-equals-declaration.ts + test.fails( + 'client: a TypeScript import alias used by the split children is declared in the chunk', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { visible } from '@tanstack/react-start/hydration' +import * as ui from './ui' +import Card = ui.Card +function Panel() { + return <Card title="hi" /> +} +export function Page() { + return <Hydrate when={visible()}><Panel /></Hydrate> +}`, + { + files: { + './ui': `export const Card = (props: { title: string }) => <b>{props.title}</b>`, + }, + }, + ) + expect(client.html).toContain('<b>hi</b>') + }, + ) + + // Bug: module-level declarations the children use are only moved into the + // chunk for some declaration forms and uses: a default-exported function, + // TypeScript enums and namespaces, and a `let` the children only assign + // are neither declared in the chunk nor imported from the parent. + // Impact: the boundary throws "DefaultFn is not defined" (or `Tone`, + // `Labels`, `renders`) when it hydrates. + // Source: Qwik optimizer example_exports, example_ts_enums, + // should_preserve_let_when_migrated_into_segment; React Compiler fixture + // should-bailout-without-compilation-annotation-mode.js (#8504 + // hydrate-split-modules.test.ts, red on main) + test.fails.each([ + { + name: 'a default-exported function', + code: `export default function DefaultFn() { return 'default' } +export function Page() { + return <Hydrate when={load()}><p>{DefaultFn()}</p></Hydrate> +}`, + rendered: '<p>default</p>', + }, + { + name: 'TypeScript enums and namespaces', + code: `export enum Tone { Loud = 'LOUD' } +namespace Labels { export const quiet = 'quiet' } +export function Page() { + return <Hydrate when={load()}><p>{Tone.Loud + ':' + Labels.quiet}</p></Hydrate> +}`, + rendered: '<p>LOUD:quiet</p>', + }, + { + name: 'a let the children only assign', + code: `let renders = 0 +export function Page() { + return <Hydrate when={load()}><p>{(() => { renders = 1 })()}</p></Hydrate> +}`, + rendered: '<p></p>', + }, + ])( + 'client: $name used by the children reaches the chunk', + async ({ code, rendered }) => { + // Rendered twice. + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { + render: '[h(m.Page, { key: 1 }), h(m.Page, { key: 2 })]', + }, + ) + expect(client.html).toContain(rendered) + }, + ) + + /** + * A module rendering through a classic JSX pragma naming a factory of the + * app (`./h`, which marks every element it creates with `data-h`), like + * Emotion's `jsx`; the children also call the factory directly. + */ + const pragmaModule = `/** @jsxRuntime classic */ +/** @jsx h */ +import { h } from './h' +${head}export function Page() { + return <div><Hydrate when={load()}><p>{h('i', null)}</p></Hydrate></div> +}` + const pragmaFiles = { + './h': `import { createElement } from 'react' +export function h(type, props, ...children) { + return createElement(type, { ...props, 'data-h': '' }, ...children) +}`, + } + + // Control for the JSX pragma pin below (same rendering). + test('server: a module with a classic JSX pragma renders through its factory', async () => { + const source = await renderSource(await hosts(), pragmaModule, { + files: pragmaFiles, + }) + expect(source.html).toContain('<div data-h="">') + expect(source.html).toContain('<p data-h=""><i data-h=""></i></p>') + expect( + (await renderServer(await hosts(), pragmaModule, { files: pragmaFiles })) + .html, + ).toBe(source.html) + }) + + // Bug: dead-code elimination does not count a classic JSX pragma + // (`/** @jsx jsx */`) as a use of the factory it names, so the client parent + // drops the factory import once the children that call it are split (the + // generated code also lands above the pragma comment, where Oxc no longer + // reads it). Same root cause as the JSX pragma pins in + // known-bugs-start-compiler.test.ts and + // router-plugin/tests/known-bugs-code-splitter.test.ts. + // Impact: the client renders the parent's JSX through another factory than + // the server (a hydration mismatch), or throws "h is not defined". In a + // project whose default JSX runtime is classic, Oxc then compiles the + // parent's JSX to `React.createElement` without `React` in scope. + test.fails( + 'client: a module with a classic JSX pragma renders through its factory', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + pragmaModule, + { + files: pragmaFiles, + }, + ) + expect(client.html).toContain('<div data-h="">') + }, + 20_000, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate.test.ts b/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate.test.ts new file mode 100644 index 0000000000..9dabbb9e93 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/known-bugs-hydrate.test.ts @@ -0,0 +1,827 @@ +/** + * Known `<Hydrate>` split bugs. Each test asserts correct behaviour for a bug + * on main and is marked .fails; remove .fails when the bug is fixed. + * + * The modules are compiled by the public Start plugin on a dev server and + * rendered through it (`render.ts`): the server render (React's server + * renderer in the SSR environment) is compared with the uncompiled source + * (a plain Vite host), and a real page hydrates it with every gate opened; + * the hydrated page must show the markup the server rendered, without a + * hydration error. + */ +import { describe, expect, test } from 'vitest' +import { + expectMapsTo, + positionAt, + tokenOffsets, +} from '@tanstack/compiler-test-utils/source-maps' +import { compileError, expectCompileError } from '../../regression-helpers' +import { + caseCode, + expectHydratedCleanly, + expectRenderedThroughChunks, + expectRendersLikeSource, + renderClient, + servedWithMap, + useHydrateHost, +} from '../../render' +import type { ClientRender } from '../../render' +import type { SourceMapInput } from '@tanstack/compiler-test-utils/source-maps' + +const hosts = useHydrateHost() + +const head = `import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' +` + +/** + * Like `head`, with the `idle()` strategy, whose boundaries render their + * hydration id (`load()` boundaries render none): fixtures about which id a + * boundary hydrates with use it. + */ +const idleHead = `import { Hydrate } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +` + +/** + * Asserts that `error` is a compile error about `source` at the line of its + * boundary (`expectCompileError`; the fixtures read the value on that line + * too, so the boundary and the read are both there). + */ +function expectRejection(error: unknown, source: string) { + expectCompileError(error, { source, at: '<Hydrate' }) +} + +/** + * Every module of the case's own code that the page can load from the + * client module (Vite's client module graph from it, static and lazy + * imports: `load()`, up to packages and Vite's client; the case's code by + * provenance among them, `caseCode`) is + * requested while the page imports the module and hydrates it with every + * gate open (every boundary of the fixtures renders): no split code ships + * that the page never loads. How many modules the split takes, their ids + * and how the client imports them are free (SPEC §5.3). + */ +async function expectNoUnusedChunks(client: ClientRender) { + const host = await hosts() + // Packages (installed, linked from outside the app: served under + // `/@fs/`, or named by their bare id in the graph) and Vite's client are + // not the case's code; the dev server serves them as they are + const reachable = Object.keys( + await host.start.host.dev.load(client.case.url(), { + skip: /^[^/]|(^|\/)node_modules\/|^\/@fs\/|^\/@vite\/|^\/@react-refresh/, + }), + ) + const own = await caseCode(host, client.case.dir, 'module.tsx', reachable) + const normalized = (url: string) => { + const parsed = new URL(url, 'http://localhost') + return decodeURIComponent(parsed.pathname + parsed.search) + } + const requested = new Set( + [...client.importedUrls, ...client.lazyUrls].map(normalized), + ) + const unloaded = own.filter((url) => !requested.has(normalized(url))) + expect(unloaded, 'split code the page never loaded').toEqual([]) +} + +/** + * The markup of the boundary element (the one the runtime renders with a + * hydration id) whose whole content is `children`, if the (normalized) + * markup `html` has one: its element and id, whatever else the page has. + */ +function boundaryRendering(html: string, children: string) { + return html.match( + new RegExp( + `<([a-z]+) data-ts-hydrate-id="[^"]*">${children.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&')}</\\1>`, + ), + )?.[0] +} + +describe('boundaries and ids', () => { + // Bug: the server and the client number boundaries without the Hydrate + // inside a `fallback`, but the chunk loader counts it. + // Impact: the boundary after it hydrates with the fallback's children. + test.fails( + 'a Hydrate inside a fallback does not shift the chunks of later boundaries', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${idleHead}export function Page() { + return <div> + <Hydrate when={idle()} fallback={<Hydrate when={idle()}><p>inner</p></Hydrate>}><p>outer</p></Hydrate> + <Hydrate when={idle()}><p>second</p></Hydrate> + </div> +}`, + ) + expect(client.html).toContain('<p>outer</p>') + expect(client.html).toContain('<p>second</p>') + }, + ) + + // Bug: a component that declares a boundary and is rendered inside a + // boundary (its own, or another one) is copied into the chunk, and + // compiling the chunk numbers the copy's boundary after the chunk's own + // index. + // Impact: nested boundaries of recursive components (trees, threads) and + // of components with their own boundary render ids the server never + // emitted and lazy-load boundaries that do not exist. + // Source: Qwik optimizer root_level_self_referential_qrl, + // example_self_referential_component_migration + test.fails.each([ + { + name: 'a self-recursive component', + code: `export function Tree({ node }) { + return <li>{node.label}<Hydrate when={idle()}><ul>{node.children.map((child) => <Tree node={child} />)}</ul></Hydrate></li> +}`, + component: 'Tree', + props: { node: { label: 'a', children: [{ label: 'b', children: [] }] } }, + rendered: 'b', + }, + { + name: 'mutually recursive components', + code: `function Branch({ depth }) { return depth ? <Leaf depth={depth - 1} /> : null } +export function Leaf({ depth }) { + return <Hydrate when={idle()}><Branch depth={depth} /></Hydrate> +}`, + component: 'Leaf', + props: { depth: 2 }, + rendered: 'data-ts-hydrate-id', + }, + { + name: 'a component with its own boundary inside another boundary', + code: `function Widget() { return <Hydrate when={idle()}><b>widget</b></Hydrate> } +export function Page() { + return <Hydrate when={idle()}><section><Widget /></section></Hydrate> +}`, + component: 'Page', + props: {}, + rendered: '<b>widget</b>', + }, + ])( + 'client: $name hydrates like the server renders it', + async ({ code, component, props, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${idleHead}${code}`, + { + render: `h(m.${component}, props)`, + props, + }, + ) + expect(client.html).toContain(rendered) + }, + // The page may keep loading boundaries that do not exist (the impact) + 20_000, + ) + + // Bug: Hydrate elements are matched by name instead of by binding. + // Impact: a local component named `Hydrate` is split into a lazy chunk. + test.fails( + 'client: a local component named Hydrate is left alone', + async () => { + const code = `${head}export function Page() { + return <Hydrate when={load()}><p>real</p></Hydrate> +} +export function Local() { + const Hydrate = (props: { children: unknown }) => props.children + return <Hydrate><p>local</p></Hydrate> +}` + const { client: page } = await expectRendersLikeSource( + await hosts(), + code, + ) + expect(page.html).toContain('<p>real</p>') + // The local component renders its children in place: nothing loads. + const { client: local } = await expectRendersLikeSource( + await hosts(), + code, + { + render: 'h(m.Local)', + split: false, + }, + ) + expect(local.html).toBe('<p>local</p>') + expect(local.lazy).toEqual([]) + }, + ) + + // The goal that a namespace-imported `<Start.Hydrate>` is split like a + // named import (SPEC J5.1) is pinned on real hydration: + // integration/hydrate-pages-react.ts and hydrate-pages-solid.test.ts "a + // namespace-imported Start.Hydrate loads its children when it hydrates". + + // Control of the pins below (the same check): a boundary with JSX + // children loads every split module it ships once it hydrates. + test('client: children passed as JSX children render without unused chunks', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { Chart } from './chart' +export function Page() { + return <Hydrate when={load()}><Chart /></Hydrate> +}`, + { files: { './chart': `export const Chart = () => 'chart'` } }, + ) + expect(client.html).toContain('chart') + expect(client.chunks.length).toBeGreaterThan(0) + await expectNoUnusedChunks(client) + }) + + // Bug: the boundary's children are only read from JSX children, never from + // a `children` prop or spread. + // Impact: a self-closing boundary whose children come from a spread or a + // `children` prop ships an unused empty chunk (and the JSX of a `children` + // prop is not deferred). + // `split`: JSX passed as the `children` prop is split like JSX children. + // Children that only exist at run time (a spread) or plain text have no + // code to load lazily, so leaving them in place is accepted. + test.fails.each([ + { + name: 'a spread on a self-closing element', + code: `export function Page(props) { + return <Hydrate {...props} /> +}`, + spread: true, + rendered: 'spread', + split: false, + }, + { + name: 'a children prop of a self-closing element', + code: `import { idle } from '@tanstack/react-start/hydration' +import { Chart } from './chart' +export function Page() { + return <Hydrate when={idle()} children={<Chart />} /> +}`, + spread: false, + rendered: 'chart', + split: true, + }, + { + // Plain text has nothing to hydrate: splitting it or leaving it in + // place both render it once. + // Source: #8504 hydrate-split-modules.test.ts (red on main) + name: 'a string children prop', + code: `export function Page() { + return <Hydrate when={load()} children="text" /> +}`, + spread: false, + rendered: 'text', + split: false, + }, + ])( + 'client: children passed through $name render without unused chunks', + async ({ code, spread, rendered, split }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { + // A strategy of the app's own hydration package, in each realm. + setup: `import { load } from '@tanstack/react-start/hydration' +globalThis.__spreadWhen = load() +export const cleanup = ['__spreadWhen']`, + render: spread + ? `h(m.Page, { when: globalThis.__spreadWhen, children: 'spread' })` + : 'h(m.Page, {})', + files: { './chart': `export const Chart = () => 'chart'` }, + split, + }, + ) + expect(client.html).toContain(rendered) + await expectNoUnusedChunks(client) + }, + ) + + // Bug: same root cause as above, for a `children` prop that holds another + // boundary: the client does not compile the JSX of the prop, so the nested + // boundary hydrates without the id the server renders it with. + // Source: fuzzing (mutants of the repository's + // e2e/react-start/deferred-hydration EnhancedNestedWidget.tsx). + // Impact: the nested boundary hydrates without its id (a hydration + // mismatch). + test.fails( + 'client: a boundary nested in a children prop hydrates with the id the server renders', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${idleHead}export function Page() { + return <Hydrate when={idle()} children={<section><Hydrate when={idle()}><p>inner</p></Hydrate></section>} /> +}`, + ) + expect(client.html).toContain('<p>inner</p>') + }, + ) + + // Bug: a multi-line text-only child moves into the chunk as a string + // literal of the raw text, without the line collapsing of JSX text. + // Impact: the client renders other text than the server (a hydration + // mismatch). + // Plain text has nothing to hydrate: splitting it or leaving it in place + // are both accepted, so the chunks are not asserted. + // Source: #8504 hydrate-split-modules.test.ts (exact JSX-text equality, red + // on main) + test.fails.each([ + { + name: 'multi-line text with entities', + text: '\n Fish &\n Chips ©\n ', + rendered: 'Fish & Chips ©', + }, + { + name: 'lines with trailing whitespace', + text: '\n first line \n second line\n ', + rendered: 'first line second line', + }, + ])( + 'client: a text-only child renders like JSX text: $name', + async ({ text, rendered }) => { + const { source } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + return <Hydrate when={load()}>${text}</Hydrate> +}`, + { split: false }, + ) + // The reference renders the text alone in the boundary. + expect(boundaryRendering(source.html, rendered)).toBeDefined() + }, + ) + + // Bug: whitespace-only text around a single child is dropped when the + // children move into the chunk, although JSX keeps whitespace on the line + // of the child as text (the server renders it). + // Impact: the client renders other text than the server (a hydration + // mismatch). + // Source: hydrate-when-transform.ts getMeaningfulChildren (mutation + // testing). + test.fails( + 'client: spaces around a single child on one line render like on the server', + async () => { + const { source } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + return <Hydrate when={load()}> <p>x</p> </Hydrate> +}`, + { split: false }, + ) + expect(boundaryRendering(source.html, ' <p>x</p> ')).toBeDefined() + }, + ) + + // Bug: the Hydrate plugin numbers boundaries after the other Start + // transforms removed environment-specific code (`<ClientOnly>` children on + // the server; server fn handlers, `createServerOnlyFn` bodies and + // isomorphic `.server()` implementations on the client), while the client + // chunk loader counts the boundaries of the original module. + // Impact: a boundary after such code hydrates with an id the server did + // not render it with, or loads the chunk of the removed boundary and + // renders its children instead of its own. + // Source: start-compiler/compiler.ts + // (built-in handlers, `<ClientOnly>` removal and dead-code elimination run + // before the AST plugins) vs hydrate-when-transform.ts + // `loadHydrateVirtualModule`. + test.fails.each([ + { + // `<ClientOnly>` renders its fallback on the server and, before + // hydration, on the client. + name: 'a boundary in <ClientOnly> children (removed on the server)', + code: `import { Hydrate } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +import { ClientOnly } from '@tanstack/react-router' +export function Page() { + return <div> + <ClientOnly fallback={<i>fallback</i>}><Hydrate when={idle()}><p>a</p></Hydrate></ClientOnly> + <Hydrate when={idle()}><p>b</p></Hydrate> + </div> +}`, + }, + { + name: 'a boundary in an isomorphic .server() (removed on the client)', + code: `import { Hydrate, createIsomorphicFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +const panel = createIsomorphicFn() + .server(() => <Hydrate when={idle()}><p>a</p></Hydrate>) + .client(() => <i>client</i>) +export function Page() { + return <div>{panel()}<Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + { + name: 'a boundary in a createServerOnlyFn (removed on the client)', + code: `import { Hydrate, createServerOnlyFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +export const panel = createServerOnlyFn(() => <Hydrate when={idle()}><p>a</p></Hydrate>) +export function Page() { + return <div><Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + { + name: 'a boundary in a server fn handler (removed on the client)', + code: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +export const panel = createServerFn().handler(async () => <Hydrate when={idle()}><p>a</p></Hydrate>) +export function Page() { + return <div><Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + { + name: 'a boundary in an isomorphic .client() (removed on the server)', + code: `import { Hydrate, createIsomorphicFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +const panel = createIsomorphicFn() + .server(() => <i>server</i>) + .client(() => <Hydrate when={idle()}><p>a</p></Hydrate>) +export function Page() { + return <div>{panel()}<Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + { + // The component is only referenced from the removed handler, so the + // client drops it too. + name: 'a component with a boundary that only a server fn handler renders (removed on the client)', + code: `import { Hydrate, createServerFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +function ServerPanel() { + return <Hydrate when={idle()}><p>a</p></Hydrate> +} +export const panel = createServerFn().handler(async () => <ServerPanel />) +export function Page() { + return <div><Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + { + name: 'a boundary in a createClientOnlyFn (a stub on the server)', + code: `import { Hydrate, createClientOnlyFn } from '@tanstack/react-start' +import { idle } from '@tanstack/react-start/hydration' +export const panel = createClientOnlyFn(() => <Hydrate when={idle()}><p>a</p></Hydrate>) +export function Page() { + return <div><Hydrate when={idle()}><p>b</p></Hydrate></div> +}`, + }, + ])( + 'a later boundary keeps its id and its children next to $name', + async ({ code }) => { + // The rest of the page may differ between the environments (that is + // the code they remove): the later boundary renders the same markup, + // id included, through split code on the client. + const client = await renderClient(await hosts(), code) + expectHydratedCleanly(client) + const later = boundaryRendering(client.server.html, '<p>b</p>') + expect(later).toBeDefined() + expect(boundaryRendering(client.html, '<p>b</p>')).toBe(later) + expectRenderedThroughChunks(client) + }, + ) +}) + +describe('values captured by the children', () => { + // Bug: captured locals are passed to the lazy chunk component as props of + // the same name, so locals named `key` or `ref` become React's `key`/`ref`. + // Impact: the split children render without those values. + test.fails( + 'client: captured locals named key and ref reach the split children', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + const key = 'k' + const ref = 'r' + return <Hydrate when={load()}><p>{key}{ref}</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>kr</p>') + }, + ) + + // Bug: a JSX tag is only taken for a read of a local when its name starts + // with an ASCII capital letter, so a local component named `_Local`, + // `$Local` or with a non-ASCII first letter is not passed to the chunk. + // Impact: the boundary throws "_Local is not defined" when it hydrates. + // Source: Qwik optimizer jsx_underscore_component_tag; React Compiler + // fixture jsx-underscore-prefix-component.js (#8504 + // hydrate-captures.test.ts, red on main) + test.fails.each(['_Local', '$Local', 'ÉLocal', '组件'])( + 'client: the split children render a local component named %s', + async (name) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page({ label }) { + const ${name} = () => <b>{label}</b> + return <Hydrate when={load()}><${name} /><i>{label}</i></Hydrate> +}`, + { props: { label: 'l' } }, + ) + expect(client.html).toContain('<b>l</b><i>l</i>') + }, + ) + + // Bug: the object of a member-expression tag (`<ui.Home />`, + // `<Model.Item />`) is not taken for a read of a local. + // Impact: the boundary throws "ui is not defined" when it hydrates. + // Source: Qwik optimizer jsx_member_tag_object_is_captured, + // destructured_prop_used_as_member_tag (#8504 hydrate-captures.test.ts, red + // on main); hydrate-when-transform.ts captureVisitors.JSXIdentifier + test.fails.each([ + { + name: 'a lowercase local object', + code: `function Home() { return <i>home</i> } +export function Page() { + const ui = { Home } + return <Hydrate when={load()}><ui.Home /></Hydrate> +}`, + rendered: '<i>home</i>', + }, + { + name: 'a capitalized destructured prop', + code: `export function Page({ Model }) { + return <Hydrate when={load()}><Model.Item /></Hydrate> +}`, + rendered: '<b>item</b>', + }, + ])( + 'client: the split children render member-expression tags of $name', + async ({ code, rendered }) => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}${code}`, + { + render: `h(m.Page, { Model: { Item: () => h('b', null, 'item') } })`, + }, + ) + expect(client.html).toContain(rendered) + }, + ) + + /** `icons` maps ids to components. */ + const iconFiles = { + './icons': `export const icons = { a: () => <i>a</i>, b: () => <i>b</i> }`, + } + const renderIcons = { + files: iconFiles, + render: `h(m.Icons, { ids: ['a', 'b'] })`, + } + + // Control for the pin below (same rendering): a component the component + // body binds outside the boundary is a capture, passed to the chunk. + test('client: the split children render a component bound outside the boundary', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { icons } from './icons' +export function Icons({ ids }) { + const Icon = icons[ids[0]] + return ( + <Hydrate when={load()}> + <ul>{ids.map((id) => <li key={id}><Icon /></li>)}</ul> + </Hydrate> + ) +}`, + renderIcons, + ) + expect(client.html).toContain('<ul><li><i>a</i></li><li><i>a</i></li></ul>') + }) + + // Bug: a JSX tag naming a binding declared inside the children (`const Icon + // = icons[id]` in a `.map()` callback) is taken for a capture of the + // component: the client parent passes `Icon={Icon}` to the chunk, where no + // `Icon` exists. The identifier visitor checks where a binding is declared, + // the JSX tag visitor does not. + // Source: hydrate-when-transform.ts:439-447 (JSXIdentifier, without the + // declared-inside check of :426-434); fuzzing. + // Impact: the parent throws "Icon is not defined" when it renders, so the + // page fails on the client. + test.fails( + 'client: the split children render a component bound inside them', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}import { icons } from './icons' +export function Icons({ ids }) { + return ( + <Hydrate when={load()}> + <ul> + {ids.map((id) => { + const Icon = icons[id] + return <li key={id}><Icon /></li> + })} + </ul> + </Hydrate> + ) +}`, + renderIcons, + ) + expect(client.html).toContain( + '<ul><li><i>a</i></li><li><i>b</i></li></ul>', + ) + }, + ) + + // Bug: property names, method keys and optional member names in the + // children are taken for reads of the local of the same name, which the + // parent then reads where the boundary renders. + // Impact: a boundary rendered before such a local is declared throws + // "Cannot access 'later' before initialization". + // Source: Qwik optimizer jsx_tag_names_are_not_segment_uses (non-reference + // identifiers) (#8504 hydrate-captures.test.ts, red on main) + test.fails( + 'client: property names, method keys and optional members are no reads of a local', + async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page({ obj }) { + const el = <Hydrate when={load()}><p>{obj?.later + ({ later() { return '!' } }).later()}</p></Hydrate> + const later = 1 + console.log(later) + return el +}`, + { props: { obj: { later: 'L' } } }, + ) + expect(client.html).toContain('<p>L!</p>') + }, + ) + + // Bug: a TypeScript enum declared in the component is not passed to the + // chunk. + // Impact: the boundary throws "Color is not defined" when it hydrates. + // Source: Qwik optimizer example_ts_enums (component-local enum) (#8504 + // hydrate-captures.test.ts, red on main) + test.fails('client: the split children read a local enum', async () => { + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page() { + enum Color { + Red = 'red', + } + return <Hydrate when={load()}><p>{Color.Red}</p></Hydrate> +}`, + ) + expect(client.html).toContain('<p>red</p>') + }) + + // Bug: split children reading the component's `arguments` are moved into + // the chunk component unchanged, where `arguments` are the chunk's own + // props (`this` and `super` are rejected instead). + // Impact: the boundary silently hydrates with other values than the server + // rendered. Rejecting it at compile time is a valid fix. + // Source: SolidStart compile.spec.ts "rejects `arguments` in an arrow + // inside a function" + test.fails( + "client: split children reading the component's arguments render its props", + async () => { + const code = `${head}export function Page() { + return <Hydrate when={load()}><p>{arguments[0].title}</p></Hydrate> +}` + const startCase = await ( + await hosts() + ).start.case({ + 'module.tsx': code, + }) + const failure = await compileError(startCase, 'client') + if (failure !== undefined) { + expectRejection(failure, code) + return + } + const { client } = await expectRendersLikeSource(await hosts(), code, { + props: { title: 'Hello' }, + }) + expect(client.html).toContain('<p>Hello</p>') + }, + ) + + // Bug: a `this` owned by a function, class or method in the children is + // rejected, on the client and the server. + // Impact: valid code fails to build. + // Source: SolidStart compile.spec.ts "allows `this` and `arguments` in a + // function expression" + test.fails.each([ + { + name: 'a function expression', + children: `<ul>{items.map(function (this: { prefix: string }, item: string) { return <li>{this.prefix + item}</li> }, { prefix: '>' })}</ul>`, + rendered: '<ul><li>>a</li><li>>b</li></ul>', + }, + { + name: 'a class', + children: `<p>{new (class { label = 'inner'; read() { return this.label } })().read()}</p>`, + rendered: '<p>inner</p>', + }, + { + name: 'an object method', + children: `<p>{({ label: 'inner', read() { return this.label } }).read()}</p>`, + rendered: '<p>inner</p>', + }, + ])( + 'client: split children may use the own `this` of $name', + async ({ children, rendered }) => { + // Both environments compile, and the client renders like the server. + const { client } = await expectRendersLikeSource( + await hosts(), + `${head}export function Page({ items }) { + return <Hydrate when={load()}>${children}</Hydrate> +}`, + { props: { items: ['a', 'b'] } }, + ) + expect(client.html).toContain(rendered) + }, + ) + + // Bug: split children containing `await` (async server components) are + // moved as is into the synchronous chunk component the client compile + // emits, while the server renders them inline. + // Impact: the chunk does not parse (`await` outside an async function) and + // the client build fails without saying why. A clear compile-time error is + // a valid fix (React client components cannot be async), and so is valid + // output that renders the awaited value. + test.fails( + 'client: await in split children is rejected at the boundary or renders', + async () => { + const code = `${head}import { loadData } from './data' +export async function Page() { + return <Hydrate when={load()}><p>{await loadData()}</p></Hydrate> +}` + const startCase = await ( + await hosts() + ).start.case({ + 'module.tsx': code, + 'data.ts': `export const loadData = async () => 'data'`, + }) + const failure = await compileError(startCase, 'client') + if (failure !== undefined) { + expectRejection(failure, code) + return + } + // Every emitted module is valid, and the client renders like the + // server. + const { client } = await expectRendersLikeSource(await hosts(), code, { + files: { './data': `export const loadData = async () => 'data'` }, + }) + expect(client.html).toContain('<p>data</p>') + }, + ) +}) + +describe('source maps of the split code', () => { + /** + * Asserts that the case's split code holds `marker` (a string token) and + * that every occurrence maps, through the map the dev server serves with + * it, to the marker's line and column in `source` (SPEC G6: Hydrate + * chunks map to the user's original line and column). + */ + async function expectSplitTextMapped(source: string, marker: string) { + const started = await hosts() + const client = await renderClient(started, source) + expectRenderedThroughChunks(client) + const original = positionAt(source, source.indexOf(marker)) + let held = 0 + for (const url of client.chunks) { + const served = await servedWithMap(started, url) + for (const offset of tokenOffsets(served.code, { string: marker })) { + held++ + expectMapsTo( + served.map as SourceMapInput, + positionAt(served.code, offset), + { + file: client.case.file(), + line: original.line, + column: original.column, + }, + ) + } + } + expect(held, `the split code holds ${marker}`).toBeGreaterThan(0) + } + + // Control for the pin below: the text of an element child maps to where + // the user wrote it. + test('client: the split text of an element child maps to its line and column', async () => { + await expectSplitTextMapped( + `${head}export function Page() { + return ( + <main> + <Hydrate when={load()}><p>MARK_SPLIT_TEXT</p></Hydrate> + </main> + ) +}`, + 'MARK_SPLIT_TEXT', + ) + }) + + // Bug: a boundary whose only child is text is split into code whose text + // is a new string the compiler creates without the text's position, and + // nothing else in that code comes from the user's file: the dev server + // serves it with an empty source map (no mappings, no sources). Found in + // review. + // Impact: the split code of such a boundary maps to nothing (SPEC G6): + // devtools show it as generated code, not as the user's file, and its + // component's frames in stacks resolve nowhere. + test.fails( + 'client: the split text of a text-only boundary maps to its line and column', + async () => { + await expectSplitTextMapped( + `${head}export function Page() { + return ( + <main> + <Hydrate when={load()}>MARK_SPLIT_TEXT</Hydrate> + </main> + ) +}`, + 'MARK_SPLIT_TEXT', + ) + }, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/pages/start-compiler-import-forms.test.ts b/packages/start-plugin-core/tests/integration/pages/start-compiler-import-forms.test.ts new file mode 100644 index 0000000000..f4f95e97eb --- /dev/null +++ b/packages/start-plugin-core/tests/integration/pages/start-compiler-import-forms.test.ts @@ -0,0 +1,380 @@ +/** + * Every Start construct is recognised however its factory is imported (a + * renamed import, a member of a namespace import) or its result wrapped (a + * TypeScript `as` or `satisfies`), in each framework: the client keeps no + * server code or import, and each environment follows the runtime contract + * of its environment (a server fn the client calls through the server, an + * environment branch, a throwing env-only fn, a fallback), observed through + * the public Start host (`./start-host`): the client in a real page, the + * server in the SSR environment and in a real request. + * Replaces the Rename / StarImport snapshot fixtures of the createServerFn, + * createMiddleware, createIsomorphicFn, envOnly and ClientOnly suites and + * envOnlyExportedAlias. + */ +import { beforeAll, describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + callFromClient, + callOnServer, + fromPage, + inPage, + serveCase, + settle, + throwsError, + useStartHosts, +} from '../../regression-helpers' +import { + forms, + moduleFiles, + moduleImports, + serverFnConstruct, +} from '../../compiler-inputs' +import { clientMiddleware, clientMiddlewareOf } from '../../page-values' +import type { Form } from '../../compiler-inputs' +import type { + Framework, + PageSettled, + ServedCase, + StartCase, +} from '../../regression-helpers' + +const frameworks: Array<Framework> = ['react', 'solid', 'vue'] + +// The hosts' defaults (`./start-host`): no import protection (its dev mock +// would hide a leaked server import from the client's loads) and an app +// tsconfig with `verbatimModuleSyntax` (without it, Vite's TypeScript +// transform drops unreferenced imports after the compiler and hides leaks); +// a Vue app's JSX is Vue's own runtime. +const hosts = useStartHosts() + +/** The client does not load the server-only module. */ +async function expectClientFree(served: StartCase) { + expectNotLoaded(await served.loads(), ['./db.server']) +} + +/** The SSR environment does not load the client-only module. */ +async function expectServerFree(served: StartCase) { + expectNotLoaded(await served.serverLoads(), ['./chart.client']) +} + +/** What calling the function `fn` (a page expression) in the page gives (`settle`). */ +async function settleInPage(served: StartCase, fn: string) { + return fromPage(await inPage<PageSettled>(served, `return settle(${fn})`)) +} + +/** A Start construct: the module creating it and the checks of each env. */ +interface Construct { + name: string + /** The export `fn` (or `mw`), created by calling `callee`. */ + code: (callee: string, wrap: Form['wrap']) => string + check: (served: ServedCase) => Promise<void> +} + +const constructs: Array<Construct> = [ + { + name: 'createServerFn', + code: serverFnConstruct, + check: async (served) => { + await expectClientFree(served) + // The callers keep the builder options (Start exposes `method`), and + // the client's server fn is Start's fetcher (its public `url`). + expect( + await inPage( + served, + `return { url: typeof module.fn.url, method: module.fn.method }`, + ), + ).toEqual({ url: 'string', method: 'POST' }) + expect((await served.ssr()).fn.method, 'ssr').toBe('POST') + // Called from server code, and from the client through the server. + expect(await callOnServer(served, 'module.fn')).toBe('x') + expect(await callFromClient(served, 'module.fn')).toBe('x') + }, + }, + { + name: 'createMiddleware', + code: (callee, wrap) => + `export const mw = ${wrap(`${callee}({ type: 'function' }).server(async ({ next }) => { + db.x() + return next() +})`)}`, + check: async (served) => { + await expectClientFree(served) + // The client drops `.server()`; the server keeps it. + expect( + await inPage(served, `return ${clientMiddlewareOf('module.mw')}`), + ).toEqual(clientMiddleware('function')) + expect((await served.ssr()).mw.options.server).toBeTypeOf('function') + }, + }, + { + name: 'createIsomorphicFn', + code: (callee, wrap) => + `export const fn = ${wrap(`${callee}().server(() => db.x()).client(() => chart())`)}`, + check: async (served) => { + await expectClientFree(served) + await expectServerFree(served) + expect(await inPage(served, 'return module.fn()')).toBe('chart') + expect((await served.ssr()).fn()).toBe('x') + }, + }, + { + name: 'createServerOnlyFn', + code: (callee, wrap) => + `export const fn = ${wrap(`${callee}(() => db.x())`)}`, + check: async (served) => { + await expectClientFree(served) + expect(await settleInPage(served, 'module.fn')).toEqual(throwsError) + expect((await served.ssr()).fn()).toBe('x') + }, + }, + { + name: 'createClientOnlyFn', + code: (callee, wrap) => + `export const fn = ${wrap(`${callee}(() => chart())`)}`, + check: async (served) => { + await expectServerFree(served) + expect(await inPage(served, 'return module.fn()')).toBe('chart') + const ssr = await served.ssr() + expect(settle(ssr.fn)).toEqual(throwsError) + }, + }, +] + +/** + * What renders a module's `Page` with the framework's real renderers: on + * the server to HTML (`html()`, in the SSR environment), and mounted in the + * page (`mount()`, giving the container). The Vue app's JSX is + * `@vitejs/plugin-vue-jsx`'s, as in a Vue Start app (the host's plugins). + */ +const renderFiles: Record<Framework, Record<string, string>> = { + react: { + 'render.server.tsx': `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { Page } from './module' +export const html = () => renderToString(createElement(Page)) +`, + 'render.client.tsx': `import { createElement } from 'react' +import { createRoot } from 'react-dom/client' +import { Page } from './module' +export function mount() { + const container = document.createElement('div') + document.body.append(container) + createRoot(container).render(createElement(Page)) + return container +} +`, + }, + vue: { + 'render.server.tsx': `import { createSSRApp, h } from 'vue' +import { renderToString } from 'vue/server-renderer' +import { Page } from './module' +export const html = () => renderToString(createSSRApp({ render: () => h(Page) })) +`, + 'render.client.tsx': `import { createApp, h } from 'vue' +import { Page } from './module' +export function mount() { + const container = document.createElement('div') + document.body.append(container) + createApp({ render: () => h(Page) }).mount(container) + return container +} +`, + }, + solid: { + 'render.server.tsx': `import { renderToString } from 'solid-js/web' +import { Page } from './module' +export const html = () => renderToString(() => <Page />) +`, + 'render.client.tsx': `import { render } from 'solid-js/web' +import { Page } from './module' +export function mount() { + const container = document.createElement('div') + document.body.append(container) + render(() => <Page />, container) + return container +} +`, + }, +} + +describe.each(frameworks)('%s', (framework) => { + const pkg = `@tanstack/${framework}-start` + const host = () => hosts(framework) + // The framework's host (dev server and page) starts before its tests. + beforeAll(async () => { + await (await host()).page() + }, 60_000) + + describe.each(constructs)('$name', (construct) => { + test.each(Object.keys(forms))('through %s', async (formName) => { + const form = forms[formName]! + const code = `${form.imports(pkg, construct.name)} +${moduleImports} +${construct.code(form.callee(construct.name), form.wrap)}` + const served = await serveCase(await host(), { + 'module.tsx': code, + ...moduleFiles, + }) + await construct.check(served) + }) + }) + + // A factory a project module re-exports under a new name, called as a + // member of a namespace import of that module: renamed imports, namespace + // members and re-exports are all recognised forms (SPEC J4.5, §2.1). Each + // env-only factory, next to a server fn and alone in its module. + describe('a renamed env-only factory read through a namespace import of a project module', () => { + const files = { + 'factory.ts': `export { createServerOnlyFn as serverOnly, createClientOnlyFn as clientOnly } from '${pkg}'\n`, + 'db.server.ts': `export const db = { x: () => 'server-only-value' }\n`, + 'chart.client.ts': `export const chart = () => 'client-only-value'\n`, + } + + /** A call of the namespace member `factory.<member>`, and its checks. */ + interface EnvOnlyCall { + name: string + code: string + check: (served: StartCase) => Promise<void> + } + + const calls: Array<EnvOnlyCall> = [ + { + name: 'createServerOnlyFn', + code: `import * as factory from './factory' +import { db } from './db.server' +export const impl = factory.serverOnly(() => db.x())`, + check: async (served) => { + expectNotLoaded(await served.loads(), ['./db.server']) + expect(await settleInPage(served, 'module.impl')).toEqual(throwsError) + expect((await served.ssr()).impl()).toBe('server-only-value') + }, + }, + { + name: 'createClientOnlyFn', + code: `import * as factory from './factory' +import { chart } from './chart.client' +export const impl = factory.clientOnly(() => chart())`, + check: async (served) => { + expectNotLoaded(await served.serverLoads(), ['./chart.client']) + const ssr = await served.ssr() + expect(settle(ssr.impl)).toEqual(throwsError) + expect(await inPage(served, 'return module.impl()')).toBe( + 'client-only-value', + ) + }, + }, + ] + + /** Serves `code` (both environments evaluate it) and checks `call`. */ + async function expectEnvOnly(call: EnvOnlyCall, code: string) { + const served = await serveCase(await host(), { + 'module.tsx': code, + ...files, + }) + await call.check(served) + } + + test.each(calls)( + '$name next to a server fn: the other environment neither loads nor runs the implementation', + async (call) => { + await expectEnvOnly( + call, + `import { createServerFn } from '${pkg}' +${call.code} +export const fn = createServerFn().handler(async () => 'fn')`, + ) + }, + ) + + // Bug: the bundler plugins choose the modules the Start compiler + // transforms by their text (a factory name such as + // `createServerOnlyFn`, or `.handler(`). A module whose only Start call + // is `factory.serverOnly(...)` names none, so it is left untransformed; + // the same module next to a server fn is compiled (rows above). Same + // cause as the renamed re-export pin "client builds compile a renamed + // createServerOnlyFn re-export ..." in known-bugs-start-compiler.test.ts. + // Impact: the client bundle gets the server-only implementation and the + // modules it imports, and runs it; the client-only mirror runs during + // SSR. + // Source: start-compiler/compiler.ts `KindDetectionPatterns` and + // `detectKindsInCode` (used by vite/start-compiler-plugin/plugin.ts and + // rsbuild/start-compiler-host.ts). Outcome twin of main's printed-code + // test of #8758 (compiler.test.ts). + test.fails.each(calls)( + '$name alone in its module: the other environment neither loads nor runs the implementation', + async (call) => { + await expectEnvOnly(call, call.code) + }, + ) + }) + + // `<ClientOnly>` comes from the router package (SPEC J4.11): the server + // renders the fallback only, without loading the modules only the + // children use; the client keeps the children and renders them. + describe('<ClientOnly>', () => { + const router = `@tanstack/${framework}-router` + const chartFile = { + 'chart.client.tsx': `export const Chart = () => '<chart>'\n`, + } + + /** Checks a `<ClientOnly>` boundary written as `tag`, imported by `imports`. */ + async function checkBoundary(imports: string, tag: string) { + const code = `${imports} +import { Chart } from './chart.client' +export const Page = () => ( + <div> + <${tag} fallback={<p>loading</p>}> + <Chart /> + </${tag}> + </div> +)` + const served = await serveCase(await host(), { + 'module.tsx': code, + ...chartFile, + ...renderFiles[framework], + }) + expectNotLoaded(await served.serverLoads(), ['./chart.client']) + // The client keeps the children's module. + expect(await served.loads()).toContain('./chart.client') + // The real renderers: the server renders the fallback, the client the + // children. + const { html } = await served.ssr('render.server.tsx') + const ssrHtml = (await html()) as string + expect(ssrHtml).toContain('loading') + expect(ssrHtml).not.toContain('chart') + expect( + await inPage( + served, + `const container = module.mount() +for (let i = 0; i < 200 && !container.textContent.includes('<chart>'); i++) { + await new Promise((resolve) => setTimeout(resolve, 10)) +} +const text = container.textContent +container.remove() +return text`, + { file: 'render.client.tsx' }, + ), + ).toContain('<chart>') + } + + test.each([ + `import { ClientOnly as CO } from '${router}'`, + `import { Link, ClientOnly as CO } from '${router}'`, + `import{ClientOnly as CO}from '${router}'`, + ])('through a renamed import: %s', async (imports) => { + await checkBoundary(imports, 'CO') + }) + + // Bug: `<ClientOnly>` is detected by the `<ClientOnly` / imported + // `ClientOnly` text, so a boundary written as a member of a namespace + // import (`<Router.ClientOnly>`) is never compiled. + // Impact: the SSR environment keeps the children and the client-only + // modules they import: browser-only code runs during SSR. + test.fails('through a namespace member', async () => { + await checkBoundary( + `import * as Router from '${router}'`, + 'Router.ClientOnly', + ) + }) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/route-css-cases.ts b/packages/start-plugin-core/tests/integration/route-css-cases.ts new file mode 100644 index 0000000000..5451327d81 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/route-css-cases.ts @@ -0,0 +1,306 @@ +/** + * The CSS a route imports in a real page of a React Start app, run for each + * bundler by its own test file (`known-bugs-route-css.test.ts`: Vite, + * `known-bugs-route-css-rsbuild.test.ts`: Rsbuild), on the bundler's dev + * server (Vite: `startDevServer`; Rsbuild: `startRsbuildStartDevServer`) + * and in a production build served as the bundler's preview serves it, + * Start's server entry rendering the pages (Vite: `createStartHost({ + * serve: false })` + `preview()`; Rsbuild: `buildStart` + `preview()`). The + * root route renders a probe element with each route's class on every + * page; the page is read at `/`, then after a client-side navigation to the + * route, and, for two routes that share a module, after a reload there (the + * page the server renders at the route). + */ +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { buildStart } from '../build-harness' +import { startDevServer } from '../dev-server' +import { startRsbuildStartDevServer } from '../rsbuild-dev-server' +import { createStartHost } from '../start-host' +import { reactApp } from './hydrate-dev-edits' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { RsbuildConfig } from '@rsbuild/core' +import type { StartBundler } from '../build-harness' + +const timeout = 60_000 + +const head = `import { createFileRoute, notFound } from '@tanstack/react-router'\n` + +/** The component module of a route whose component imports its CSS. */ +const pageModule = (name: string) => `import './${name}.css' +import { Shared } from './shared' +export function Page() { + return <p>${name} page <Shared /></p> +} +` + +/** + * Each route, by path: its options, what the page shows once it matched + * (`shows-nothing` mounts no component) and who imports its CSS: the route + * module (`./<name>.css` next to it), or, with `sharesWith`, its component + * module (`src/pages/<name>.tsx`), which shares a module with the component + * module of the route `sharesWith`. + */ +const routes: Record< + string, + { options: string; shows?: string; sharesWith?: string } +> = { + 'shows-component': { + options: `component: () => <p>component page</p>`, + shows: 'component page', + }, + 'shows-error': { + options: `loader: () => { + throw new Error('MARK_LOADER_ERROR') + }, + errorComponent: () => <p>error page</p>`, + shows: 'error page', + }, + 'shows-not-found': { + options: `loader: () => { + throw notFound() + }, + notFoundComponent: () => <p>not found page</p>`, + shows: 'not found page', + }, + 'shows-pending': { + options: `loader: () => new Promise(() => {}), + pendingMs: 0, + pendingComponent: () => <p>pending page</p>`, + shows: 'pending page', + }, + 'shows-nothing': { options: '' }, + 'shares-module-a': { + options: `component: Page`, + shows: 'shares-module-a page', + sharesWith: 'shares-module-c', + }, + 'shares-module-c': { + options: `component: Page`, + shows: 'shares-module-c page', + sharesWith: 'shares-module-a', + }, +} + +const color = 'rgb(1, 2, 3)' + +const files: Record<string, string> = { + 'src/routes/__root.tsx': `import { HeadContent, Link, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +const names = ${JSON.stringify(Object.keys(routes))} +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <nav>{names.map((name) => <Link key={name} to={'/' + name}>{name}</Link>)}</nav> + <div id="app"><Outlet /></div> + {names.map((name) => <span key={name} data-probe={name} className={name + '-marker'}>probe</span>)} + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ component: () => <p>home</p> })\n`, + // The module the component modules share, and a module it imports + 'src/pages/shared.tsx': `import { Widget } from './widget' +export function Shared() { + return <Widget /> +} +`, + 'src/pages/widget.tsx': `export function Widget() { + return <em>widget</em> +} +`, + ...Object.fromEntries( + Object.entries(routes).flatMap(([name, { options, sharesWith }]) => { + const css = `.${name}-marker { color: ${color}; }\n` + return sharesWith + ? [ + [ + `src/routes/${name}.tsx`, + `${head}import { Page } from '../pages/${name}' +export const Route = createFileRoute('/${name}')({ + ${options} +}) +`, + ], + [`src/pages/${name}.tsx`, pageModule(name)], + [`src/pages/${name}.css`, css], + ] + : [ + [ + `src/routes/${name}.tsx`, + `${head}import './${name}.css' +export const Route = createFileRoute('/${name}')({ + ${options} +}) +`, + ], + [`src/routes/${name}.css`, css], + ] + }), + ), +} + +/** + * Rsbuild: the app's own client and server entries (Start's defaults, as an + * app writes them; the Rsbuild harnesses' test entries render nothing) and + * its router. + */ +const rsbuildEntries = { + 'src/client.tsx': `import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, <StartClient />) +`, + 'src/server.ts': `export { default } from '@tanstack/react-start/server-entry'\n`, + 'src/router.ts': reactApp['src/router.ts'], +} + +/** + * Rsbuild: the module the component modules share is in a chunk of its + * own, as an app's chunk splitting may put it (`splitChunks`); the module it + * imports stays in each component's chunk. + */ +const rsbuildConfig = { + splitChunks: { + cacheGroups: { + shared: { + name: 'shared', + test: /[\\/]src[\\/]pages[\\/]shared\./, + chunks: 'async', + enforce: true, + }, + }, + }, +} satisfies RsbuildConfig + +/** The computed color of the probe element of route `name`. */ +const probeColor = (page: BrowserPage, name: string) => + page.page + .locator(`[data-probe="${name}"]`) + .evaluate((element) => getComputedStyle(element).color) + +const bundlerName = { vite: 'Vite', rsbuild: 'Rsbuild' } as const + +/** The rows of `bundler`, in its dev server and in its production build. */ +export function routeCssSuite( + bundler: StartBundler, + /** The rows each mode fails today, by name. */ + failsOn: Record<'dev' | 'build', Array<string>>, +) { + describe.each(['dev', 'build'] as const)( + `${bundlerName[bundler]} %s`, + (mode) => { + const cleanups: Array<() => Promise<void>> = [] + const registerCleanup = (cleanup: () => Promise<void>) => { + cleanups.push(cleanup) + } + let url: string + beforeAll(async () => { + if (bundler === 'vite') { + if (mode === 'dev') { + const server = await startDevServer({ + browser: true, + registerCleanup, + files: { ...reactApp, ...files }, + }) + url = server.url! + } else { + const host = await createStartHost({ serve: false, files }) + registerCleanup(() => host.close()) + url = (await host.preview()).url + } + } else if (mode === 'dev') { + const server = await startRsbuildStartDevServer({ + browser: true, + registerCleanup, + config: { + ...rsbuildConfig, + // Start serves the pages, not an HTML template + tools: { htmlPlugin: false }, + }, + files: { ...rsbuildEntries, ...files }, + }) + url = server.url! + } else { + const build = await buildStart({ + bundler, + registerCleanup, + rsbuildConfig, + files: { ...rsbuildEntries, ...files }, + }) + url = (await build.preview(registerCleanup)).url + } + }, timeout) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + // SPEC J2.22: a route's CSS loads only when the route matches, whatever + // it mounts. + for (const name of Object.keys(routes)) { + ;(failsOn[mode].includes(name) ? test.fails : test)( + `the CSS of the /${name} route applies only once the route matches`, + async () => { + const page = await openPage(new URL('/', url).href, { + registerCleanup: onTestFinished, + }) + await page.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + await page.page.waitForLoadState('networkidle') + expect(await probeColor(page, name), 'at /').not.toBe(color) + await page.page.locator(`nav a[href="/${name}"]`).click() + await page.page.waitForURL(new URL(`/${name}`, url).href) + const { shows, sharesWith } = routes[name]! + /** + * The route's CSS applies; the CSS of the route it shares a + * module with does not. + */ + const expectRouteCss = async (at: string) => { + if (shows !== undefined) { + await page.waitForText(shows, { selector: '#app' }) + } + await expect + .poll(() => probeColor(page, name), { timeout: 5_000 }) + .toBe(color) + if (sharesWith !== undefined) { + expect( + await probeColor(page, sharesWith), + `/${sharesWith} ${at}`, + ).not.toBe(color) + } + } + if (sharesWith !== undefined) { + // (everything the navigation loads) + await page.page.waitForLoadState('networkidle') + } + await expectRouteCss('after the navigation') + if (sharesWith !== undefined) { + // The page the server renders at the route, whose stylesheets + // load before its `load` event + await page.page.reload() + await expectRouteCss('after a reload') + } + }, + timeout, + ) + } + }, + ) +} diff --git a/packages/start-plugin-core/tests/integration/rsbuild/dev-server.test.ts b/packages/start-plugin-core/tests/integration/rsbuild/dev-server.test.ts new file mode 100644 index 0000000000..ea7a534667 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/rsbuild/dev-server.test.ts @@ -0,0 +1,345 @@ +/** + * The Start compiler on a running Rsbuild dev server: editing a factory + * module rebuilds every client module compiled against it. + */ +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { pluginReact } from '@rsbuild/plugin-react' +import { startRsbuildStartDevServer } from '../../rsbuild-dev-server' +import { + rootDocument, + routerFile, + startPageEntries, +} from '../start-compose-app' + +const timeout = 30_000 + +describe('Rsbuild dev: editing a server fn factory', () => { + /** + * `src/a1.ts` and `src/a2.ts` define server fns with the `base` builder of + * `src/b.ts`, imported from `importFrom`; `src/b.ts` starts as a + * `createServerFn()` builder and becomes a plain object, or the other way + * around (`toFactory`). The dev server runs Start's whole Rsbuild plugin + * (client and SSR environments, import protection). + * Returns the client output afterwards, and what calling both fns in the + * client gives (their results, or the error). + */ + async function editFactory(importFrom: string, toFactory: boolean) { + const factory = `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +` + const plain = `export const base = { handler: (fn: () => unknown) => fn }\n` + const importer = (name: string) => `import { base } from '${importFrom}' +import { db } from './db' +export const ${name} = base.handler(async () => db.x()) +` + const server = await startRsbuildStartDevServer({ + browser: true, + hmr: false, + config: { plugins: [pluginReact()] }, + files: { + ...startPageEntries, + 'src/ssr-entry.ts': `export { getRouter } from './router'`, + 'src/router.ts': routerFile, + 'src/routes/__root.tsx': rootDocument(), + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => null })`, + 'src/client-entry.ts': `import './entry'`, + 'src/b.ts': toFactory ? plain : factory, + 'src/c.ts': `export * from './b'\n`, + // Not a `.server` file: import protection would mock it in the + // client, which is not what this test is about. + 'src/db.ts': `export const db = { x: () => 'MARK_DB_SECRET' }\n`, + 'src/a1.ts': importer('fn1'), + 'src/a2.ts': importer('fn2'), + 'src/entry.ts': `import { fn1 } from './a1' +import { fn2 } from './a2' +;(globalThis as Record<string, unknown>).fns = [fn1, fn2] +`, + }, + }) + const output = async () => + Object.values(await server.outputs('client')).join('\n') + expect((await output()).includes('MARK_DB_SECRET')).toBe(toFactory) + + await server.edit({ 'src/b.ts': toFactory ? factory : plain }) + expect(server.errors).toEqual([]) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + const sent: Array<{ url: string; method: string }> = [] + page.page.on('request', (request) => { + const url = new URL(request.url()) + if (url.pathname.startsWith('/_serverFn/')) { + sent.push({ url: url.pathname + url.search, method: request.method() }) + } + }) + const result = await page.page.evaluate(async () => { + const fns = (globalThis as any).fns + return { + values: await Promise.all(fns.map((fn: any) => fn())), + urls: fns.map((fn: any) => fn.url), + } + }) + expect(page.errors).toEqual([]) + return { + output: await output(), + called: { result: result.values }, + requests: { + result: result.urls.map((url: string) => ({ + url, + sent: sent.filter((request) => request.url === url), + })), + }, + } + } + + // The compiler registers `src/b.ts` as a dependency (`addDependency`) only + // of the module it first loads it for; the other importers depend on it in + // Rspack because the compiler resolves the whole import chain from each + // importer (the loader's `resolve()` records the files it resolves). + // Source: review, suspected bug not reproduced. + test.each(['./b', './c'])( + 'client: every module importing a factory from %s that becomes one loads no server code, and calls the server', + async (importFrom) => { + const { output, requests } = await editFactory(importFrom, true) + expect(output).not.toContain('MARK_DB_SECRET') + const url = expect.stringMatching(/^\/_serverFn\/./) + const call = { url, sent: [{ url, method: 'GET' }] } + expect(requests).toEqual({ result: [call, call] }) + const { result } = requests as { + result: Array<{ url: string; sent: Array<{ url: string }> }> + } + expect(result.map(({ url, sent }) => sent[0]!.url === url)).toEqual([ + true, + true, + ]) + }, + timeout, + ) + + test.each(['./b', './c'])( + 'client: every module importing a factory from %s that stops being one keeps its handler', + async (importFrom) => { + expect((await editFactory(importFrom, false)).called).toEqual({ + result: ['MARK_DB_SECRET', 'MARK_DB_SECRET'], + }) + }, + timeout, + ) +}) + +describe('Rsbuild dev with HMR: editing a server fn module', () => { + /** + * `src/routes/index.tsx` declares a server fn whose handler returns + * `MARK_HANDLER_*`, a loader calling it, and a page showing the loader's + * result, its label, the result of its last call from the browser and a + * counter (its state). + */ + const route = ( + version: string, + ) => `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +const greet = createServerFn().handler(async () => 'MARK_HANDLER_${version}') +export const Route = createFileRoute('/')({ + loader: () => greet(), + component: Page, +}) +function Page() { + const label = Route.useLoaderData() + const [called, setCalled] = useState('') + const [count, setCount] = useState(0) + return ( + <main> + <p data-testid="label">MARK_LABEL_${version} {label}</p> + <p data-testid="called">called {called}</p> + <button data-testid="call" onClick={() => greet().then(setCalled)}>call</button> + <button data-testid="count" onClick={() => setCount(count + 1)}>count {count}</button> + </main> + ) +} +` + + // A real page runs Start's Rsbuild dev server with its HMR client + // (Rsbuild's default, `dev.hmr`): after an edit of a route module with a + // server fn, the page applies the hot update (its loader runs the new + // handler) and the next call from the page runs the new handler, without + // a full reload; the client's hot update carries the edited client code + // and never the handler. (What the edited component shows is route HMR's + // business, router-plugin's page tests with React Refresh.) + // Source: review (the Rsbuild hot-update path never ran in tests). + test( + 'the page applies the hot update of an edited server fn module and the next call runs the edited handler, without a full reload', + async () => { + const server = await startRsbuildStartDevServer({ + hmr: true, + browser: true, + config: { + tools: { + // Start serves the pages, not an HTML template + htmlPlugin: false, + }, + }, + files: { + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient)) +`, + 'harness/server-entry.ts': `export { default } from '@tanstack/react-start/server-entry'\n`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': route('V1'), + }, + }) + expect(server.errors).toEqual([]) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_LABEL_V1 MARK_HANDLER_V1', { + selector: '[data-testid=label]', + }) + await page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + await page.page.locator('[data-testid=count]').click() + await page.waitForText('count 1', { selector: '[data-testid=count]' }) + await page.page.locator('[data-testid=call]').click() + await page.waitForText('called MARK_HANDLER_V1', { + selector: '[data-testid=called]', + }) + + await server.edit({ 'src/routes/index.tsx': route('V2') }) + expect(server.errors).toEqual([]) + await page.waitForText('MARK_HANDLER_V2', { + selector: '[data-testid=label]', + }) + await page.page.locator('[data-testid=call]').click() + await page.waitForText('called MARK_HANDLER_V2', { + selector: '[data-testid=called]', + }) + expect(page.loads()).toBe(1) + // The client's hot update has the client code and not the handler + const update = Object.values(await server.hotUpdates('client')).join('\n') + expect({ + label: update.includes('MARK_LABEL_V2'), + handler: update.includes('MARK_HANDLER_V2'), + }).toEqual({ label: true, handler: false }) + expect(page.errors).toEqual([]) + }, + timeout, + ) +}) + +describe('Rsbuild dev: removing a server fn module', () => { + // The generated server fn resolver lists every server fn by id; a module + // the app no longer has must leave it, or the next compile of the server + // never completes. + // Source: mutation testing, with Start's whole Rsbuild plugin. + test( + 'deleting a module with a server fn keeps the dev server compiling', + async () => { + const fn = ( + name: string, + ) => `import { createServerFn } from '@tanstack/react-start' +export const ${name} = createServerFn().handler(async () => 'MARK_${name}') +` + const server = await startRsbuildStartDevServer({ + compileTimeout: 10_000, + files: { + 'src/a.ts': fn('a'), + 'src/b.ts': fn('b'), + 'src/entry.ts': `export { a } from './a'\nexport { b } from './b'\n`, + }, + }) + // The deletion in its own edit, before the entry's: a write landing + // while Rspack compiles the deletion can be lost (watchpack 2.5.2 + // vendored by Rspack; KNOWN-BUGS.md, upstream issues). Merge the two + // edits back once Rspack bundles watchpack >= 2.6. + await server.edit({ 'src/b.ts': null }) + await server.edit({ 'src/entry.ts': `export { a } from './a'\n` }) + expect(server.errors).toEqual([]) + const ssr = Object.values(await server.outputs('ssr')).join('\n') + expect(ssr).toContain('MARK_a') + }, + timeout, + ) +}) + +describe('Rsbuild dev: server fn ids', () => { + // Server fns are called by id: two server fns sharing an id would run + // each other's handler. + // Source: mutation testing. + test( + 'same-named server fns of two modules get different ids', + async () => { + const fn = ( + value: string, + ) => `import { createServerFn } from '@tanstack/react-start' +export const getData = createServerFn().handler(async () => ${JSON.stringify(value)}) +` + const server = await startRsbuildStartDevServer({ + browser: true, + hmr: false, + config: { plugins: [pluginReact()] }, + files: { + ...startPageEntries, + 'src/ssr-entry.ts': `export { getRouter } from './router'`, + 'src/router.ts': routerFile, + 'src/routes/__root.tsx': rootDocument(), + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => null })`, + 'src/a.ts': fn('from a'), + 'src/b.ts': fn('from b'), + 'src/client-entry.ts': `export { getData as a } from './a' +export { getData as b } from './b' +`, + }, + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + // A server fn's identity is the URL its calls fetch (`fn.url`, which + // carries its id; the metadata object holding the id is Start's own) + const { urls, values } = await page.page.evaluate(async () => { + const { a, b } = (globalThis as any).__app + return { + urls: [a.url, b.url], + values: [await a(), await b()], + } + }) + expect(urls).toEqual([expect.any(String), expect.any(String)]) + expect(urls[0]).not.toBe(urls[1]) + expect(values).toEqual(['from a', 'from b']) + expect(page.errors).toEqual([]) + }, + timeout, + ) + + // Whether dev ids use `serverFns.generateFunctionId` is + // free: it is a production-build contract (SPEC J4.4), covered by + // start-build-options.test.ts "serverFns.generateFunctionId returning an + // id"; dev caller/provider agreement by the page calls of "Rsbuild dev: + // with HMR: editing a server fn module" above. +}) diff --git a/packages/start-plugin-core/tests/integration/rsbuild/import-protection.test.ts b/packages/start-plugin-core/tests/integration/rsbuild/import-protection.test.ts new file mode 100644 index 0000000000..7873c77fe4 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/rsbuild/import-protection.test.ts @@ -0,0 +1,736 @@ +import path from 'node:path' +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + diagnosticsOf, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + runRsbuildClient, + startBrowserRsbuildDevServer as startRsbuildDevServer, +} from '../importProtection/client-pages' +import { runRsbuildSsr, ssrNodeOutput } from '../importProtection/v2-hosts' +import { buildStart } from '../../build-harness' +import { + describeValuePrelude, + expectMockAccess, +} from '../../importProtection/mock-helpers' +import { + distinct, + expectMarkerViolation, + expectPrinted, + expectViolationsAt, + isAt, + locationIn, + receivedViolations, + rejection, + relevantViolations, + reportedViolations, + violationLabel, + violationRecorder, + violationsOf, +} from '../../importProtection/start-apps' +import { startRsbuildStartDevServer } from '../../rsbuild-dev-server' +import { originalLocation } from '../../importProtection/original-location' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import type { StartBuildError } from '../../build-harness' +import type { ExpectedViolation } from '../../importProtection/start-apps' +import type { + ImportProtectionOptions, + ViolationInfo, +} from '../../importProtection/public-types' + +/** + * Each test's timeout, and the time an Rsbuild dev server may take to + * compile: only a guard against a compile that never comes, never shorter + * than the test's own timeout (a slow compile on a loaded machine fails the + * test by its timeout, not by a shorter deadline of the harness). + */ + +const timeout = 60_000 +const compileTimeout = timeout + +// One dev server for every importer: a client module of each JavaScript and +// TypeScript type imports the same `.server` file. +describe('Rsbuild dev: a client module importing a .server file', () => { + const esm = `import { secret } from './secret.server.js' +export const page = () => secret +` + const commonJs = `const { secret } = require('./secret.server.js') +exports.page = () => secret +` + const importers = [ + { extension: 'ts', page: esm }, + { extension: 'js', page: esm }, + { extension: 'jsx', page: esm }, + { extension: 'mjs', page: esm }, + { extension: 'cjs', page: commonJs }, + { extension: 'mts', page: esm }, + { extension: 'cts', page: commonJs }, + ] + + let violations: Array<ViolationInfo> + let server: RsbuildDevServer + let dispose: (() => Promise<void>) | undefined + afterAll(() => dispose?.()) + beforeAll(async () => { + violations = [] + server = await startRsbuildDevServer({ + registerCleanup: (cleanup) => { + dispose = cleanup + }, + compileTimeout, + importProtection: { + onViolation: (info) => { + violations.push(info as ViolationInfo) + }, + }, + files: { + 'src/secret.server.js': `export const secret = 'MARK_SERVER_SECRET'\n`, + ...Object.fromEntries( + importers.map(({ extension, page }) => [ + `src/page.${extension}`, + page, + ]), + ), + 'src/entry.ts': importers + .map( + ({ extension }) => + `import { page as ${extension} } from './page.${extension}'\nconsole.log(${extension}())\n`, + ) + .join(''), + }, + }) + }, timeout) + + test('the compile succeeds, without the real module', async () => { + expect(server.errors).toEqual([]) + expect(Object.values(await server.outputs()).join('\n')).not.toContain( + 'MARK_SERVER_SECRET', + ) + }) + + test.each(importers)( + 'is reported when it is a .$extension file', + ({ extension }) => { + expect( + violations + .filter((info) => info.importer.endsWith(`/src/page.${extension}`)) + .map((info) => ({ + type: info.type, + importer: path.relative(server.root, info.importer), + specifier: info.specifier, + })), + ).toEqual([ + { + type: 'file', + importer: `src/page.${extension}`, + specifier: './secret.server.js', + }, + ]) + }, + ) +}) + +// With Start's whole Rsbuild plugin, import protection runs in the server +// environment too: Start's default rules deny `*.client.*` files to it. +// Source: review (the other Rsbuild dev tests run import protection on the +// client environment only). +test( + 'Rsbuild dev with Start: a server import of a .client file is mocked on the server and reported', + async () => { + const recorder = violationRecorder() + const server = await startRsbuildStartDevServer({ + compileTimeout, + start: { importProtection: recorder.importProtection }, + files: { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/entry.ts': `import { widget } from './widget.client' +export const read = () => widget() +console.log(read()) +`, + }, + }) + expect(server.errors).toEqual([]) + expect(receivedViolations(recorder.violations, server.root)).toEqual([ + originalLocation('server src/entry.ts:2:27', 1), + ]) + // Printed as a warning at the importer's line of the import or of its + // use (SPEC J6.3, J6.12) + expect( + [1, 2].some( + (line) => + findDiagnostics(server.diagnostics, { + severity: 'warning', + file: 'src/entry.ts', + root: server.root, + position: { line }, + }).length > 0, + ), + 'a printed warning at src/entry.ts:1 or :2', + ).toBe(true) + const code = async (environment: string) => + Object.values(await server.outputs(environment)).join('\n') + expect(await code('ssr')).not.toContain('MARK_CLIENT') + expect(await code('client')).toContain('MARK_CLIENT') + }, + timeout, +) + +// `mockAccess` applies wherever a mock is served, the server environments of +// a dev server included (SPEC J6.3: mock mode always +// logs): the SSR mock of a `.client` file reports its use in the server +// console as configured. +describe('Rsbuild dev with Start: an SSR import of a .client file: mockAccess', () => { + /** + * Runs the SSR output of a dev server with `mockAccess` in a child Node + * process and calls the mocked `widget`: what it is, and what the call + * logged, as warnings and errors. + */ + async function useOnTheServer( + mockAccess: NonNullable<ImportProtectionOptions>['mockAccess'], + ) { + const recorder = violationRecorder({ mockAccess }) + const server = await startRsbuildStartDevServer({ + compileTimeout, + config: ssrNodeOutput, + start: { importProtection: recorder.importProtection }, + files: { + 'src/widget.client.ts': `export const widget = () => 'MARK_CLIENT'\n`, + 'src/entry.ts': `import { widget } from './widget.client' +export const read = () => widget() +;(globalThis as Record<string, unknown>).read = read +`, + }, + }) + expect(server.errors).toEqual([]) + expect(reportedViolations({ root: server.root, ...recorder })).toEqual([ + expect.objectContaining({ environment: 'server' }), + ]) + const ran = await runRsbuildSsr( + server, + `${describeValuePrelude} +const logged = [] +for (const level of ['warn', 'error']) { + console[level] = (...args) => logged.push({ + severity: level === 'warn' ? 'warning' : 'error', + raw: args.map(String), + text: args.map((arg) => arg instanceof Error ? arg.message : String(arg)).join(' '), + }) +} +return { read: describeValue(globalThis.read(), 'MARK_'), logged }`, + ) + expect(ran).toEqual({ result: expect.anything() }) + return (ran as { result: { read: string; logged: Array<Diagnostic> } }) + .result + } + + test.each([ + { mockAccess: undefined, severity: 'error' }, + { mockAccess: 'error', severity: 'error' }, + { mockAccess: 'warn', severity: 'warning' }, + ] as const)( + '$mockAccess: the server gets a safe mock, and using it is reported as an $severity naming the import', + async ({ mockAccess, severity }) => { + const { read, logged } = await useOnTheServer(mockAccess) + expect(read).toBe('a safe mock') + expect(distinct(logged.map((diagnostic) => diagnostic.severity))).toEqual( + [severity], + ) + expectMockAccess(logged, { + severity, + specifier: './widget.client', + file: 'src/widget.client.ts', + }) + }, + timeout, + ) + + test( + 'off: the server gets a safe mock, and using it is not reported', + async () => { + expect(await useOnTheServer('off')).toEqual({ + read: 'a safe mock', + logged: [], + }) + }, + timeout, + ) +}) + +// Source: mutation testing (Rsbuild host, `behavior` in dev). +describe('Rsbuild dev: behavior', () => { + test.each<{ + behavior: NonNullable<ImportProtectionOptions>['behavior'] + reportedAs: 'warnings' | 'errors' + }>([ + { behavior: undefined, reportedAs: 'warnings' }, + { behavior: { build: 'mock' }, reportedAs: 'warnings' }, + { behavior: { dev: 'error' }, reportedAs: 'errors' }, + ])( + '$behavior: a violation is reported in the compile $reportedAs', + async ({ behavior, reportedAs }) => { + const entry = `import { secret } from './secret.server' +console.log(secret()) +` + const recorder = violationRecorder({ behavior }) + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: recorder.importProtection, + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/entry.ts': entry, + }, + }) + const recorded = { root: server.root, ...recorder } + const [violation, ...others] = violationsOf(recorded) + expect(others).toEqual([]) + expectViolationsAt(recorded, [ + { + environment: 'client', + use: locationIn('src/entry.ts', entry, 2, 'secret()'), + also: ['src/entry.ts:1'], + }, + ]) + // Printed with the severity, naming the importer at its position + const severityOf = { warnings: 'warning', errors: 'error' } as const + const other = reportedAs === 'errors' ? 'warnings' : 'errors' + expectPrinted( + server.diagnostics, + server.root, + violation!, + severityOf[reportedAs], + ) + expect( + findDiagnostics(server.diagnostics, { + severity: severityOf[other], + file: 'src/entry.ts', + root: server.root, + }), + ).toEqual([]) + }, + timeout, + ) +}) + +describe('Rsbuild dev: reports across rebuilds', () => { + /** An entry using the denied file `src/secret.server.ts` and `src/other.ts`. */ + const app = { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/other.ts': `export const other = 1\n`, + 'src/entry.ts': `import { secret } from './secret.server' +import { other } from './other' +console.log(secret(), other) +`, + } + + // Source: mutation testing; a control of the harness running + // an Rsbuild dev rebuild with import protection on (the warnings of each + // compile). + /** The violation: the use of `secret` in the entry (or its import). */ + const violation: ExpectedViolation = { + environment: 'client', + use: locationIn('src/entry.ts', app['src/entry.ts'], 3, 'secret()'), + also: ['src/entry.ts:1'], + } + + test.each([ + { log: 'once' as const, afterRebuild: [] }, + { log: 'always' as const, afterRebuild: [violationLabel(violation)] }, + ])( + "log '$log': a rebuild for an unrelated edit reports $afterRebuild", + async ({ log, afterRebuild }) => { + const recorder = violationRecorder({ log }) + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: recorder.importProtection, + files: app, + }) + // Which violations the compiles since `since` report (a dev server + // may compile more than once for one edit; the same violation in each + // counts once). + const reported = (since: number) => + relevantViolations( + { + root: server.root, + violations: recorder.violations.slice(since), + }, + [violation], + ) + expect(reported(0)).toEqual([violationLabel(violation)]) + const since = recorder.violations.length + await server.edit({ 'src/other.ts': `export const other = 2\n` }) + expect(server.rebuilt).toContain('src/other.ts') + expect(reported(since)).toEqual(afterRebuild) + }, + timeout, + ) + + // The compile ends (import protection does not hang on a module that is + // gone) with an error (SPEC G5; the module-not-found error names the + // importer's directory and the specifier, no file and position SPEC §5.7 + // checks). + // Source: mutation testing (Rsbuild host, entries without a module). + test.each([ + { module: 'the entry module', file: 'src/entry.ts' }, + { module: 'an imported module', file: 'src/other.ts' }, + ])( + 'a compile in which $module is missing fails', + async ({ file }) => { + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: {}, + files: app, + }) + const since = server.diagnostics.length + await server.edit({ [file]: null }) + const errors = findDiagnostics(server.diagnostics.slice(since), { + severity: 'error', + }) + expect(errors).not.toEqual([]) + }, + timeout, + ) + + // Source: mutation testing (the resolve cache of a previous compile). + test( + 'a denied specifier that an edit makes resolve elsewhere is reported again, never with its old target', + async () => { + const resolved: Array<string | undefined> = [] + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: { + client: { specifiers: [/^\.\/lib$/] }, + onViolation: (info) => { + // relative to the app root (src/...) + resolved.push( + (info as ViolationInfo).resolved?.replace(/^.*\/(?=src\/)/, ''), + ) + }, + }, + files: { + 'src/lib.ts': `export const lib = 1\n`, + 'src/entry.ts': `import { lib } from './lib'\nconsole.log(lib)\n`, + }, + }) + // `resolved` is optional for a specifier violation (SPEC J6.5, + // §5.14): what is checked is a resolved path when one is given. + expect(resolved).toHaveLength(1) + expect([undefined, 'src/lib.ts']).toContain(resolved[0]) + await server.edit({ + 'src/lib.ts': null, + 'src/lib/index.ts': `export const lib = 2\n`, + 'src/entry.ts': `import { lib } from './lib'\nconsole.log(lib, 2)\n`, + }) + // The edit passes through states the dev server may compile and + // report: `./lib` resolving nowhere (`undefined`) once `src/lib.ts` is + // gone and before `src/lib/index.ts` exists (SPEC §8). The violation is reported + // again; every resolved path given since the edit is the new target, + // never the old one, and a compiler that gave one before the edit + // reports the new target last. + const sinceEdit = resolved.slice(1) + expect(sinceEdit).not.toEqual([]) + const given = sinceEdit.filter((target) => target !== undefined) + expect(given).toEqual(given.map(() => 'src/lib/index.ts')) + if (resolved[0] !== undefined) { + expect(sinceEdit.at(-1)).toBe('src/lib/index.ts') + } + }, + timeout, + ) +}) + +// Rsbuild's `source.transformImport` rewrites a library's named imports +// into imports of its submodules (`import { button } from 'ui-lib'` -> +// `import { button } from 'ui-lib/button'`) before import protection sees +// the module. A specifier rule matches the specifier the user wrote; the +// file and marker rules apply to the module the rewritten import resolves +// to (SPEC J6.1). The report names the importer at the original import or +// at the use of its binding (J6.5). +// Source: mutation testing (Rsbuild host); review (a rule on the rewritten +// specifier `ui-lib/button` is no rule the user writes). +describe('Rsbuild build: an import source.transformImport rewrites', () => { + /** The app's entry: it uses `button` of `ui-lib`. */ + const uiLibEntry = `import { button } from 'ui-lib' +export const read = () => button() +` + /** + * Builds an entry using `button` of `ui-lib` with Start's + * `importProtection` options. `ui-lib/button.js` starts with `head` (e.g. + * a marker import). The library is a dependency, or, with `local`, a + * directory of the project the app aliases `ui-lib` to (a monorepo + * package, say), whose files import protection checks by default. + */ + const build = ( + importProtection: ImportProtectionOptions, + { head = '', local = false } = {}, + ) => { + const dir = local ? 'src/ui-lib' : 'node_modules/ui-lib' + return buildStart({ + bundler: 'rsbuild', + files: { + 'node_modules/ui-lib/package.json': JSON.stringify({ + name: 'ui-lib', + type: 'module', + exports: { '.': './index.js', './*': './*.js' }, + }), + [`${dir}/index.js`]: `export { button } from './button.js'\n`, + [`${dir}/button.js`]: `${head}export const button = () => 'MARK_SECRET'\n`, + 'src/entry.ts': uiLibEntry, + }, + entry: 'src/entry.ts', + start: { importProtection }, + rsbuildConfig: { + resolve: local ? { alias: { 'ui-lib': `./${dir}` } } : {}, + source: { + transformImport: [ + { + libraryName: 'ui-lib', + customName: 'ui-lib/{{ member }}', + transformToDefaultImport: false, + }, + ], + }, + }, + }) + } + + /** + * The import of `ui-lib` (any column of line 1) or the use `button()`, or + * the entry without coordinates: a tool rewrote the import, so its + * location may be unavailable (SPEC §5.14). + */ + const atImportOrUse = expect.toSatisfy( + (importer: string) => + ['src/entry.ts:2:27', 'src/entry.ts:1', 'src/entry.ts'].some((place) => + isAt(importer, place), + ), + 'the import of ui-lib or the use button() in src/entry.ts', + ) + + let fileRuleError: Promise<StartBuildError> | undefined + /** The build error when the file rule denies `ui-lib/button.js`, built once. */ + const fileRuleDenied = () => + // `excludeFiles: []`: the checks see dependencies (J6.10). + (fileRuleError ??= rejection( + build({ client: { files: ['**/ui-lib/button.js'], excludeFiles: [] } }), + )) + + // (where it is reported is pinned below: the location is wrong) + test('the file rule denies the module it resolves to: the build fails, naming the importer', async () => { + expect(reportedViolations(await fileRuleDenied())).toEqual([ + { + environment: 'client', + importer: expect.stringMatching(/^src\/entry\.ts\b/), + }, + ]) + }, 60_000) + + // Bug: the report of a denied import `source.transformImport` rewrote + // points at neither the import nor the use of its binding + // (`src/entry.ts:2:25`, the arrow of `read`; the use `button()` is at + // 2:27): the location is only found in the rewritten code (through the + // mock module's path), whose positions do not map back to the source. + // Source: rsbuild/import-protection.ts resolveImporterLocation + // (transformedSources lookup); mutation testing. + // Impact: low; the code frame's caret points at the wrong column. + test.fails( + 'the file rule denies the module it resolves to: the importer is reported at the import or the use', + async () => { + expect(reportedViolations(await fileRuleDenied())).toEqual([ + { environment: 'client', importer: atImportOrUse }, + ]) + }, + 60_000, + ) + + test('the module it resolves to is marked server-only: the build fails, naming the module and the importer', async () => { + const error = await rejection( + build( + {}, + { + head: `import '@tanstack/react-start/server-only'\n`, + local: true, + }, + ), + ) + const [report, ...others] = violationsOf(error) + expect(others).toEqual([]) + expect(report!.environment).toBe('client') + expectMarkerViolation(report!, { + marker: 'src/ui-lib/button.js:1', + use: 'src/entry.ts:2:27', + imports: ['src/entry.ts:1'], + }) + }, 60_000) + + // Bug: a specifier denied as the user wrote it is not denied once + // `source.transformImport` rewrote it: the loader matches the specifiers + // of the code SWC already transformed (`ui-lib/button`), so `'ui-lib'` + // never matches, and the build ships the library to the client without + // any error or warning. + // Source: rsbuild/import-protection-loader.ts transformImportProtection + // (`matchesAny(source, matchers.specifiers)` on the post-SWC imports). + // Impact: a client.specifiers rule on a library the app also lists in + // source.transformImport is silently bypassed. + test.fails( + 'denied as written, the build fails on it, reporting the importer at the import or the use', + async () => { + expect( + reportedViolations( + await rejection(build({ client: { specifiers: ['ui-lib'] } })), + ), + ).toEqual([{ environment: 'client', importer: atImportOrUse }]) + }, + 60_000, + ) +}) + +// `rsbuild build --watch`: each build reports the violations it bundles, +// whatever an earlier build reported. +// Source: mutation testing (Rsbuild host, the state of a previous build). +test('Rsbuild build --watch: a rebuild for an unrelated edit fails on the violation again', async () => { + const entry = `import { secret } from './secret.server' +import { other } from './other' +export const read = () => secret() + other +` + const error = await rejection( + buildStart({ + bundler: 'rsbuild', + files: { + 'src/secret.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/other.ts': `export const other = 1\n`, + 'src/entry.ts': entry, + }, + entry: 'src/entry.ts', + watchEdits: { 'src/other.ts': `export const other = 2\n` }, + }), + ) + // Rspack may compile the client more than once for the edit (each + // distinct report counts once). + expectViolationsAt(error, [ + { + environment: 'client', + use: locationIn('src/entry.ts', entry, 3, 'secret()'), + also: ['src/entry.ts:1'], + }, + ]) +}, 60_000) + +// Source: mutation testing. +test( + 'Rsbuild dev: the client mock of each denied import reports its own use in the browser console', + async () => { + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: { client: { specifiers: ['db-lib'] } }, + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const query = () => 'MARK_LIB'\n`, + 'src/a.server.ts': `export const a = () => 'MARK_A'\n`, + 'src/b.server.ts': `export const b = () => 'MARK_B'\n`, + 'src/entry.ts': `import { a } from './a.server' +import { b } from './b.server' +import { query } from 'db-lib' +console.log(a(), b(), query()) +`, + }, + }) + expect(server.errors).toEqual([]) + const messages = await runRsbuildClient(server, { levels: true }) + expect(messages.filter((message) => message.includes('MARK_'))).toEqual([]) + const logged = consoleDiagnostics(messages) + for (const denied of [ + { specifier: './a.server', file: 'src/a.server.ts' }, + { specifier: './b.server', file: 'src/b.server.ts' }, + { specifier: 'db-lib' }, + ]) { + expectMockAccess(logged, { + severity: 'error', + ...denied, + }) + } + }, + timeout, +) + +/** + * What a client run logged (`runRsbuildClient` with `levels`), as + * diagnostics of the shared oracle, by console method. + */ +function consoleDiagnostics(messages: Array<string>): Array<Diagnostic> { + return messages.flatMap((message) => { + const [, level, text] = /^(\w+): ([\s\S]*)$/.exec(message)! + return diagnosticsOf( + text!, + level === 'error' ? 'error' : level === 'warn' ? 'warning' : 'info', + ) + }) +} + +// Source: mutation testing (Rsbuild host, `mockAccess`). +describe('Rsbuild dev: mockAccess', () => { + test.each<{ + mockAccess: NonNullable<ImportProtectionOptions>['mockAccess'] + reports: Array<'error' | 'warning'> + }>([ + { mockAccess: undefined, reports: ['error'] }, + { mockAccess: 'error', reports: ['error'] }, + { mockAccess: 'warn', reports: ['warning'] }, + { mockAccess: 'off', reports: [] }, + ])( + '$mockAccess: the use of a mocked import is reported as $reports', + async ({ mockAccess, reports }) => { + const server = await startRsbuildDevServer({ + compileTimeout, + importProtection: { + mockAccess, + client: { specifiers: ['db-lib'] }, + }, + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const query = () => 'MARK_LIB'\n`, + 'src/a.server.ts': `export const a = () => 'MARK_A'\n`, + 'src/entry.ts': `import { a } from './a.server' +import { query } from 'db-lib' +console.log(a(), query()) +`, + }, + }) + expect(server.errors).toEqual([]) + const messages = await runRsbuildClient(server, { levels: true }) + expect(messages.filter((message) => message.includes('MARK_'))).toEqual( + [], + ) + // The severities logged, and each denied import (the file and the + // specifier) named by a diagnostic of that severity. + const logged = consoleDiagnostics(messages).filter( + ({ severity }) => severity !== 'info', + ) + expect( + distinct(logged.map(({ severity }) => severity)), + messages.join('\n'), + ).toEqual(reports) + for (const severity of reports) { + for (const denied of [ + { specifier: './a.server', file: 'src/a.server.ts' }, + { specifier: 'db-lib' }, + ]) { + expectMockAccess(logged, { + severity, + ...denied, + }) + } + } + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/rsc-warning-app.ts b/packages/start-plugin-core/tests/integration/rsc-warning-app.ts new file mode 100644 index 0000000000..a47875a440 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/rsc-warning-app.ts @@ -0,0 +1,132 @@ +/** + * A React Start app with RSC enabled on a dev server, configured the way an + * app's `vite.config.ts` / `rsbuild.config.ts` configures it, through public + * entry points only: + * - Vite: `tanstackStart({ rsc: { enabled: true } })` of the built + * `@tanstack/react-start/plugin/vite`, Vite's RSC plugin + * (`@vitejs/plugin-rsc`) and `@vitejs/plugin-react`; + * - Rsbuild: `@rsbuild/plugin-react` and + * `tanstackStart({ rsc: { enabled: true } })` of the built + * `@tanstack/react-start/plugin/rsbuild`, run in the app's directory as + * `rsbuild dev` is. + * The packages an RSC app installs (`@tanstack/react-start`, + * `@tanstack/react-start-rsc`, and from the latter's own dependencies + * `@vitejs/plugin-rsc` and `react-server-dom-rspack`) are linked into the + * app's `node_modules`, as an installation puts them there. Both servers + * listen on a port: Start's own dev middleware answers the app's requests + * (SSR, server functions). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import { pluginReact } from '@rsbuild/plugin-react' +import { createDevServer } from '@tanstack/compiler-test-utils/dev-server' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { onTestFinished } from 'vitest' +import { + rscDependency, + rscPluginFactory, + startPluginFactory, + startRsbuildPluginFactory, +} from '../start-plugins' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +/** The temporary apps stand in for apps in `tests/`, like the other harnesses'. */ +const appsDir = path.dirname(path.dirname(fileURLToPath(import.meta.url))) + +/** The router entry and a root route rendering the document. */ +export const rscAppFiles = { + 'src/router.tsx': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export function getRouter() { + return createRouter({ routeTree }) +} +`, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <Scripts /> + </body> + </html> + ) +} +`, +} + +const appLinks = () => ({ + ...workspacePackageLinks([ + '@tanstack/react-start', + '@tanstack/react-start-rsc', + ]), + 'node_modules/@vitejs/plugin-rsc': rscDependency('@vitejs/plugin-rsc'), + 'node_modules/react-server-dom-rspack': rscDependency( + 'react-server-dom-rspack', + ), +}) + +/** A Vite dev server on the RSC app of `files` (over `rscAppFiles`). */ +export async function startViteRscApp( + files: Record<string, string>, +): Promise<DevServer> { + const start = await startPluginFactory('react') + const rsc = await rscPluginFactory() + return createDevServer({ + dir: appsDir, + prefix: '.start-rsc-warnings-vite-', + registerCleanup: onTestFinished, + listen: true, + files: { ...rscAppFiles, ...files }, + symlinks: appLinks(), + // Start serves the pages (SSR through its dev middleware) + config: { appType: 'custom' }, + plugins: [start({ rsc: { enabled: true } }), rsc(), react()], + }) +} + +/** An Rsbuild dev server on the RSC app of `files` (over `rscAppFiles`). */ +export async function startRsbuildRscApp( + files: Record<string, string>, +): Promise<RsbuildDevServer> { + const start = await startRsbuildPluginFactory('react') + const cwd = process.cwd() + try { + return await createRsbuildDevServer({ + dir: appsDir, + prefix: '.start-rsc-warnings-rsbuild-', + registerCleanup: onTestFinished, + browser: true, + // Start's plugin defines the entries of its environments + entry: 'src/router.tsx', + files: { ...rscAppFiles, ...files }, + symlinks: appLinks(), + config: { + tools: { + // Start serves the pages, not an HTML template + htmlPlugin: false, + }, + }, + plugins: [ + pluginReact(), + { + name: 'rsc-warning-app:working-directory', + setup(api) { + // `rsbuild dev` runs in the app's directory + process.chdir(api.context.rootPath) + }, + }, + start({ rsc: { enabled: true } }), + ], + }) + } finally { + process.chdir(cwd) + } +} diff --git a/packages/start-plugin-core/tests/integration/source-errors.ts b/packages/start-plugin-core/tests/integration/source-errors.ts new file mode 100644 index 0000000000..7afc3b18ba --- /dev/null +++ b/packages/start-plugin-core/tests/integration/source-errors.ts @@ -0,0 +1,55 @@ +/** + * Judges a failed build's diagnostic (SPEC G5, §5.7: file and position + * only): it names one of the user's sources and, where the test gives + * one, a line of the call. Pure: only the shared diagnostics reader, no module of the + * implementation. + * + * Every channel is read: pass the `StartBuildError` of `buildStart` (its + * `diagnostics` hold the bundler's errors and what the build printed, so a + * compiler that prints the details and fails with a short error is read + * whole), or any value `diagnosticsOf` reads. + */ +import { expect } from 'vitest' +import { + diagnosticPosition, + diagnosticsOf, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import type { Diagnostic } from '@tanstack/compiler-test-utils/diagnostics' + +/** The diagnostics of `error`: every channel when it carries them. */ +function diagnosticsOfFailure(error: unknown): Array<Diagnostic> { + const carried = (error as { diagnostics?: unknown } | null)?.diagnostics + if (Array.isArray(carried)) { + return (carried as Array<Diagnostic>).filter( + ({ severity }) => severity !== 'info', + ) + } + return diagnosticsOf(error) +} + +/** + * Fails unless one diagnostic of `error` reports one of `sites`: its file, + * and the line of `at` in its `source` (any position without `at`). + */ +export function expectSourceError( + error: unknown, + expected: { + sites: Array<{ file: string; source: string; at: string | undefined }> + }, +) { + const diagnostics = diagnosticsOfFailure(error) + const reported = expected.sites.some( + (site) => + findDiagnostics(diagnostics, { + file: site.file, + ...(site.at !== undefined && { + position: { line: diagnosticPosition(site.source, site.at).line }, + }), + }).length > 0, + ) + expect( + reported, + `a diagnostic at ${expected.sites.map((site) => `${site.file} (${site.at ?? 'any position'})`).join(' or ')}:\n${diagnostics.map((diagnostic) => diagnostic.text).join('\n---\n')}`, + ).toBe(true) +} diff --git a/packages/start-plugin-core/tests/integration/start-app.ts b/packages/start-plugin-core/tests/integration/start-app.ts deleted file mode 100644 index ca5603ac2c..0000000000 --- a/packages/start-plugin-core/tests/integration/start-app.ts +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Real Start apps for the integration tests: a temporary app directory, built - * or served the way `vite build`, `vite dev` and `rsbuild build` do, with - * `tanstackStart()` of the built `@tanstack/react-start` package (its - * `plugin/vite` and `plugin/rsbuild` entries, which run this package's built - * `dist`). The `test:integration` target builds both packages first. - * - * The app links the workspace's `@tanstack/react-start` and the - * `@tanstack/react-router`, `react` and `react-dom` it uses, as an installed - * app would. - */ -import { realpathSync } from 'node:fs' -import { - mkdir, - mkdtemp, - readFile, - readdir, - rm, - symlink, - writeFile, -} from 'node:fs/promises' -import os from 'node:os' -import path from 'node:path' -import { fileURLToPath, pathToFileURL } from 'node:url' -import { createRsbuild } from '@rsbuild/core' -import { createBuilder, createLogger, createServer } from 'vite' -import { onTestFinished } from 'vitest' -import type { ViteDevServer } from 'vite' - -/** The options of `tanstackStart()`. */ -export type StartOptions = Record<string, unknown> - -const reactStartDir = fileURLToPath( - new URL('../../../react-start', import.meta.url), -) - -const routerEntry = `import { createRouter } from '@tanstack/react-router' -import { routeTree } from './routeTree.gen' -export const getRouter = () => createRouter({ routeTree }) -` - -const rootRoute = `import { createRootRoute } from '@tanstack/react-router' -export const Route = createRootRoute() -` - -/** The files of an app with only a root route; `files` adds or replaces. */ -export function appFiles(files: Record<string, string> = {}) { - return { - 'src/router.ts': routerEntry, - 'src/routes/__root.tsx': rootRoute, - ...files, - } -} - -export interface StartApp { - root: string - read: (file: string) => Promise<string> - write: (files: Record<string, string>) => Promise<void> -} - -/** - * Creates an app directory under the system's temporary directory, its name - * starting with `prefix`, and makes it the working directory, as running - * `vite` or `rsbuild` in the app's directory does (the generator and - * Rsbuild's virtual modules write under it). Both are undone when the test - * finishes. - */ -export async function createStartApp( - files: Record<string, string>, - prefix = 'start-app-', -): Promise<StartApp> { - const root = realpathSync(await mkdtemp(path.join(os.tmpdir(), prefix))) - const cwd = process.cwd() - process.chdir(root) - onTestFinished(async () => { - process.chdir(cwd) - await rm(root, { recursive: true, force: true }) - }) - const links: Record<string, string> = { - '@tanstack/react-start': reactStartDir, - } - for (const name of ['@tanstack/react-router', 'react', 'react-dom']) { - links[name] = realpathSync(path.join(reactStartDir, 'node_modules', name)) - } - for (const [name, target] of Object.entries(links)) { - const link = path.join(root, 'node_modules', name) - await mkdir(path.dirname(link), { recursive: true }) - // (a junction on Windows, which needs no privilege; a symlink elsewhere) - await symlink(target, link, 'junction') - } - const write = async (next: Record<string, string>) => { - for (const [file, code] of Object.entries(next)) { - const target = path.join(root, file) - await mkdir(path.dirname(target), { recursive: true }) - await writeFile(target, code) - } - } - await write({ - 'package.json': JSON.stringify({ name: 'app', type: 'module' }), - ...files, - }) - return { - root, - read: (file) => readFile(path.join(root, file), 'utf8'), - write, - } -} - -async function startPlugin(bundler: 'vite' | 'rsbuild', options: StartOptions) { - const entry = path.join(reactStartDir, 'dist/esm/plugin', `${bundler}.js`) - const { tanstackStart } = await import(pathToFileURL(entry).href) - return tanstackStart(options) -} - -/** The JavaScript a build emitted under `dir` (of the app), concatenated. */ -async function emittedCode(dir: string) { - const entries = await readdir(dir, { recursive: true, withFileTypes: true }) - const code: Array<string> = [] - for (const entry of entries) { - if (entry.isFile() && /\.m?js$/.test(entry.name)) { - code.push(await readFile(path.join(entry.parentPath, entry.name), 'utf8')) - } - } - return code.join('\n') -} - -export interface StartBuild { - /** The client build's JavaScript. */ - client: string - /** The server build's JavaScript. */ - server: string - /** The warnings a Vite build logged (not collected for Rsbuild). */ - warnings: Array<string> -} - -/** Builds the app as `vite build` or `rsbuild build` does. */ -export async function buildStartApp( - app: StartApp, - bundler: 'vite' | 'rsbuild', - options: StartOptions = {}, -): Promise<StartBuild> { - const plugin = await startPlugin(bundler, options) - const warnings: Array<string> = [] - if (bundler === 'vite') { - const customLogger = createLogger('error') - customLogger.warn = (message) => warnings.push(message) - customLogger.warnOnce = customLogger.warn - const builder = await createBuilder({ - root: app.root, - configFile: false, - customLogger, - plugins: [plugin], - }) - await builder.buildApp() - } else { - const rsbuild = await createRsbuild({ - cwd: app.root, - loadEnv: false, - rsbuildConfig: { logLevel: 'error', plugins: [plugin] }, - }) - await rsbuild.build() - } - return { - client: await emittedCode(path.join(app.root, 'dist/client')), - server: await emittedCode(path.join(app.root, 'dist/server')), - warnings, - } -} - -/** Starts the app's Vite dev server (middleware mode); closed when the test finishes. */ -export async function startViteDevServer( - app: StartApp, - options: StartOptions = {}, -): Promise<ViteDevServer> { - const server = await createServer({ - root: app.root, - configFile: false, - logLevel: 'error', - server: { middlewareMode: true }, - plugins: [await startPlugin('vite', options)], - }) - onTestFinished(() => server.close()) - return server -} - -/** - * Waits until the dev server's file watcher reports changes in `dir` (of the - * app). The generator prints the first route tree before the watcher exists - * (`configResolved`), and the watcher's initial scan takes a file written - * before it ends for one that was already there (no `add`). So the test - * writes a file the generator ignores (`-` prefix) until the watcher - * reports it, and only then makes the edit it checks. - */ -export async function watcherReady( - app: StartApp, - server: ViteDevServer, - dir: string, -) { - const probe = path.join(app.root, dir, '-watch-probe.ts') - let seen = false - const onEvent = (_event: string, file: string) => { - if (path.resolve(file) === probe) { - seen = true - } - } - server.watcher.on('all', onEvent) - try { - let writes = 0 - await until(async () => { - if (!seen) { - await writeFile(probe, `export {}\n// ${writes++}\n`) - await new Promise((resolve) => setTimeout(resolve, 200)) - } - return seen - }, `the file watcher of ${dir}`) - } finally { - server.watcher.off('all', onEvent) - } -} - -/** Waits for `check`, bounded. */ -export async function until(check: () => Promise<boolean>, what: string) { - const deadline = Date.now() + 20_000 - while (!(await check())) { - if (Date.now() > deadline) { - throw new Error(`timed out waiting for ${what}`) - } - await new Promise((resolve) => setTimeout(resolve, 50)) - } -} diff --git a/packages/start-plugin-core/tests/integration/start-build-call-shapes.test.ts b/packages/start-plugin-core/tests/integration/start-build-call-shapes.test.ts new file mode 100644 index 0000000000..2c70a46352 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-call-shapes.test.ts @@ -0,0 +1,596 @@ +/** + * Server code written in shapes the Start compiler may not recognise, in + * real builds through Start's Vite and Rsbuild plugins (build-harness.ts): + * a builder method called through a computed member, a server-only fn whose + * result is bound, a server fn declared in a top-level block, builders + * imported under string export names, renamed env-only factories read + * through a namespace import of a project module. SPEC J4.5 ("unrecognised + * shapes must not silently leak"), J4.6 ("block … work or error clearly"), + * J4.12. + * + * Either outcome passes, shape by shape: the shape works (the client bundle + * holds none of its server-only module, the client's function does what the + * client side does, a server fn's client calls the server, and the SSR + * build runs the server code, by id through Start's server entry for a + * server fn), or the build fails with an error that names the shape's file + * and the line of the call (`expectSourceError`). A silent leak, a broken + * function or a build error elsewhere fails. String export names, renamed + * re-exports and namespace members are forms SPEC J4.5 lists as recognised: + * those shapes must work. + * + * The compile-level twins: ../known-bugs-start-compiler.test.ts ("the + * client holds no server code, or the module is rejected at the call", and + * the placement "a block at the module top level"), + * ../start-compiler-factories.test.ts (string export names), + * ../start-compiler-import-forms.test.ts (the namespace factory). + * + * The shapes share one build per bundler. When that build (or a run of it) + * fails, each shape is built on its own, so the rejection of one shape never + * decides the outcome of another. A server fn whose handler is an env + * function call (#8446) is built on its own: today its SSR build does not + * load. + */ +import { afterAll, describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import { expectSourceError } from './source-errors' +import type { StartBuild, StartBundler } from '../build-harness' + +const timeout = 60_000 + +/** What the client and SSR runs of a shape gave. */ +interface Observed { + /** Where the shape's server-only module is in the client bundle. */ + where: string + client: unknown + ssr: unknown +} + +interface Shape { + name: string + /** Its module is `src/<slug>.ts`, exported as `entry.<slug>`. */ + slug: string + /** The module's source (`src/<slug>.ts`). */ + source: (db: string) => string + /** + * The text of the call a build error points at, in `source` (`undefined`: + * an error naming the file is enough). + */ + at: string | undefined + /** Other modules of the shape, by path relative to the app root. */ + files?: Record<string, string> + /** Client script body: `shape` is the module's exports. */ + client: string + /** SSR script body: `shape` is the module's exports, `client` what the client run gave. */ + ssr: string + /** Checks a working shape's runs. */ + expectWorks: (observed: Observed, result: string) => void +} + +/** + * A server-only module (`src/<slug>-db.ts`): its top-level code sets the + * shape's marker, which is also in its code, so the marker is in the client + * bundle as soon as the module is; its functions return `result` (and record + * the call). + */ +const dbModule = ( + marker: string, + result: string, +) => `;(globalThis as Record<string, unknown>).${marker} = 'loaded' +export const db = { + x: () => { + ;(globalThis as Record<string, unknown>).${marker}_CALLED = true + return '${result}' + }, +} +` + +/** + * Client script of a server fn `fn`: its public URL (the server fn base, + * then its id) and the requests calling it sends (none reach a server in a + * client run). + */ +const clientServerFn = (fn: string) => `const fn = ${fn} +return { url: fn?.url ?? null, requests: await requestsOf(fn) }` + +/** + * SSR script of a server fn `fn`: called in place and by the id of the + * client's URL. + */ +const ssrServerFn = (fn: string) => `return { + called: await ${fn}(), + byId: client && client.url ? await callById(serverFnId(client.url)) : null, +}` + +/** A working server fn: the client calls the server, the SSR build runs it. */ +function expectServerFnWorks(client: unknown, ssr: unknown, result: string) { + const { url, requests } = client as { + url: unknown + requests: unknown + } + expect(url, 'client server fn url').toMatch(/^\/_serverFn\/./) + expect(requests, 'requests of a client call').toEqual([ + { url, method: 'GET' }, + ]) + expect(ssr).toEqual({ called: result, byId: result }) +} + +/** The re-exports of the string export names shape. */ +const stringNamesStart = `export { createServerFn as 'create server fn', createServerOnlyFn as 'server only' } from '@tanstack/react-start' +` +const stringNamesSource = ( + db: string, +) => `import { 'create server fn' as createServerFn, 'server only' as createServerOnlyFn } from './stringNames-start' +import { db } from './${db}' +export const fn = createServerFn().handler(async () => db.x()) +export const serverOnly = createServerOnlyFn(() => 'server-only') +` + +/** The re-exports of the namespace factory shapes: both env-only factories, renamed. */ +const namespaceFactoryStart = `export { createServerOnlyFn as serverOnly, createClientOnlyFn as clientOnly } from '@tanstack/react-start' +` + +/** Client and SSR script of the namespace factory shapes: both calls, each settled. */ +const envOnlyCalls = `const run = (fn) => { + try { + return { value: fn() } + } catch (error) { + return { thrown: { name: error.name, message: error.message } } + } +} +return { serverOnly: run(shape.impl), clientOnly: run(shape.clientImpl) }` + +/** + * A working namespace factory shape: each environment runs its own + * implementation and throws for the other. + */ +function expectEnvOnlyWorks(client: unknown, ssr: unknown, result: string) { + type Calls = Record< + 'serverOnly' | 'clientOnly', + { value?: unknown; thrown?: unknown } + > + const onClient = client as Calls + const onServer = ssr as Calls + expect( + onClient.serverOnly.thrown, + JSON.stringify(onClient.serverOnly), + ).toBeDefined() + expect(onClient.clientOnly).toEqual({ value: 'client-only-value' }) + expect(onServer.serverOnly).toEqual({ value: result }) + expect( + onServer.clientOnly.thrown, + JSON.stringify(onServer.clientOnly), + ).toBeDefined() +} + +/** A module calling both renamed factories through a namespace import, after `head`. */ +const namespaceFactorySource = + (slug: string, head = '') => + (db: string) => `${head}import * as factory from './${slug}-start' +import { db } from './${db}' +export const impl = factory.serverOnly(() => db.x()) +export const clientImpl = factory.clientOnly(() => 'client-only-value') +` + +const shapes: Array<Shape> = [ + { + name: 'a server fn handler called through a computed member', + slug: 'computedHandler', + source: (db) => `import { createServerFn } from '@tanstack/react-start' +import { db } from './${db}' +export const fn = createServerFn()['handler'](async () => db.x()) +`, + at: `createServerFn()['handler']`, + client: clientServerFn('shape.fn'), + ssr: ssrServerFn('shape.fn'), + expectWorks: ({ client, ssr }, result) => + expectServerFnWorks(client, ssr, result), + }, + { + name: 'a request middleware server implementation called through a computed member', + slug: 'computedMiddleware', + source: (db) => `import { createMiddleware } from '@tanstack/react-start' +import { db } from './${db}' +export const mw = createMiddleware()['server'](async ({ next }) => { + db.x() + return next() +}) +`, + at: `createMiddleware()['server']`, + // The app's request middleware: Start runs it for every request of the + // app, so for the one the SSR script runs in (whose route handler runs + // only once the middleware called `next()`) + files: { + 'src/start.ts': `import { createStart } from '@tanstack/react-start' +import { mw } from './computedMiddleware' +export const startInstance = createStart(() => ({ requestMiddleware: [mw] })) +`, + }, + client: `return typeof shape.mw`, + ssr: `return { called: globalThis.MARK_COMPUTEDMIDDLEWARE_DB_CALLED ?? false }`, + expectWorks: ({ client, ssr }) => { + expect(client).toBe('object') + expect(ssr).toEqual({ called: true }) + }, + }, + { + name: 'an isomorphic server implementation called through a computed member', + slug: 'computedIsomorphic', + source: (db) => `import { createIsomorphicFn } from '@tanstack/react-start' +import { db } from './${db}' +export const fn = createIsomorphicFn()['server'](() => db.x()).client(() => 'client') +`, + at: `createIsomorphicFn()['server']`, + client: `return shape.fn()`, + ssr: `return shape.fn()`, + expectWorks: ({ client, ssr }, result) => { + expect({ client, ssr }).toEqual({ client: 'client', ssr: result }) + }, + }, + { + name: 'a createServerOnlyFn whose result is bound', + slug: 'boundServerOnly', + source: (db) => `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './${db}' +export const read = createServerOnlyFn(() => db.x()).bind(null) +`, + at: 'createServerOnlyFn(', + client: `return { value: shape.read() }`, + ssr: `return shape.read()`, + expectWorks: ({ client, ssr }, result) => { + expect( + (client as { thrown?: unknown }).thrown, + JSON.stringify(client), + ).toBeDefined() + expect(ssr).toBe(result) + }, + }, + { + name: 'a server fn declared in a top-level block', + slug: 'topLevelBlock', + source: (db) => `import { createServerFn } from '@tanstack/react-start' +import { db } from './${db}' +export const registry: Array<unknown> = [] +{ + const inner = createServerFn().handler(async () => db.x()) + registry.push(inner) +} +`, + at: 'createServerFn()', + client: clientServerFn('shape.registry[0]'), + ssr: ssrServerFn('shape.registry[0]'), + expectWorks: ({ client, ssr }, result) => + expectServerFnWorks(client, ssr, result), + }, + { + name: 'a server fn whose handler is a createServerOnlyFn call', + slug: 'serverOnlyHandler', + source: ( + db, + ) => `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' +import { db } from './${db}' +export const fn = createServerFn().handler(createServerOnlyFn(async () => db.x())) +`, + at: undefined, + client: clientServerFn('shape.fn'), + ssr: ssrServerFn('shape.fn'), + expectWorks: ({ client, ssr }, result) => + expectServerFnWorks(client, ssr, result), + }, + { + name: 'a server fn whose handler is a createIsomorphicFn chain', + slug: 'isomorphicHandler', + source: ( + db, + ) => `import { createServerFn, createIsomorphicFn } from '@tanstack/react-start' +import { db } from './${db}' +export const fn = createServerFn().handler( + createIsomorphicFn() + .server(async () => db.x()) + .client(() => 'client'), +) +`, + at: undefined, + client: clientServerFn('shape.fn'), + ssr: ssrServerFn('shape.fn'), + expectWorks: ({ client, ssr }, result) => + expectServerFnWorks(client, ssr, result), + }, + { + name: 'builders imported under string export names', + slug: 'stringNames', + source: stringNamesSource, + at: 'createServerFn()', + files: { 'src/stringNames-start.ts': stringNamesStart }, + client: `${clientServerFn('shape.fn').replace( + /^return \{/m, + `let serverOnly +try { + serverOnly = { value: shape.serverOnly() } +} catch (error) { + serverOnly = { thrown: { name: error.name, message: error.message } } +} +return { serverOnly,`, + )}`, + ssr: ssrServerFn('shape.fn').replace( + /^return \{/, + `return { + serverOnly: shape.serverOnly(),`, + ), + expectWorks: ({ client, ssr }, result) => { + const { serverOnly, ...fn } = client as { + serverOnly: { thrown?: unknown } + } + expect(serverOnly.thrown, JSON.stringify(serverOnly)).toBeDefined() + const { serverOnly: ssrServerOnly, ...ssrFn } = ssr as { + serverOnly: unknown + } + expect(ssrServerOnly).toBe('server-only') + expectServerFnWorks(fn, ssrFn, result) + }, + }, + { + name: 'renamed env-only factories read through a namespace import, next to a server fn', + slug: 'namespaceFactoryNextToServerFn', + source: namespaceFactorySource( + 'namespaceFactoryNextToServerFn', + `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 'fn') +`, + ), + at: 'factory.serverOnly(', + files: { + 'src/namespaceFactoryNextToServerFn-start.ts': namespaceFactoryStart, + }, + client: envOnlyCalls, + ssr: envOnlyCalls, + expectWorks: ({ client, ssr }, result) => + expectEnvOnlyWorks(client, ssr, result), + }, + { + name: 'renamed env-only factories read through a namespace import', + slug: 'namespaceFactory', + source: namespaceFactorySource('namespaceFactory'), + at: 'factory.serverOnly(', + files: { 'src/namespaceFactory-start.ts': namespaceFactoryStart }, + client: envOnlyCalls, + ssr: envOnlyCalls, + expectWorks: ({ client, ssr }, result) => + expectEnvOnlyWorks(client, ssr, result), + }, +] + +const marker = (shape: Shape) => `MARK_${shape.slug.toUpperCase()}_DB` +const result = (shape: Shape) => `MARK_${shape.slug.toUpperCase()}_RESULT` + +/** + * Re-export forms SPEC J4.5 lists as recognised: these shapes must work, + * with no rejection branch. + */ +const recognisedForms = [ + 'stringNames', + 'namespaceFactoryNextToServerFn', + 'namespaceFactory', +] +/** Recognised forms main leaves untransformed (pinned below). */ +const pinnedForms = ['namespaceFactory'] + +/** + * Server fns whose handler is an env function call: they work, or the + * build fails naming the file (pinned below). + */ +const envFnHandlers = ['serverOnlyHandler', 'isomorphicHandler'] + +/** The app files of `list`, each shape exported from the entry. */ +function appFiles(list: Array<Shape>) { + const files: Record<string, string> = {} + for (const shape of list) { + files[`src/${shape.slug}.ts`] = shape.source(`${shape.slug}-db`) + files[`src/${shape.slug}-db.ts`] = dbModule(marker(shape), result(shape)) + Object.assign(files, shape.files) + } + files['src/entry.ts'] = list + .map((shape) => `export * as ${shape.slug} from './${shape.slug}'\n`) + .join('') + files['src/ssr-entry.ts'] = `export * from './entry'\n${callByIdExports}` + return files +} + +/** Runs each shape's script in one run, each in its own `try`. */ +const script = (list: Array<Shape>, part: 'client' | 'ssr') => + `const results = {} +${list + .map( + (shape) => `results[${JSON.stringify(shape.slug)}] = await (async () => { + const shape = entry.${shape.slug} + const client = clientResults[${JSON.stringify(shape.slug)}] + try { + ${shape[part]} + } catch (error) { + return { thrown: { name: error?.name, message: String(error?.message ?? error) } } + } +})()`, + ) + .join('\n')} +return results` + +/** Builds `list` in one app and observes each shape. */ +async function observe( + bundler: StartBundler, + list: Array<Shape>, + registerCleanup?: (cleanup: () => Promise<void>) => void, +): Promise<Record<string, Observed>> { + const build: StartBuild = await buildStart({ + bundler, + files: appFiles(list), + entry: { client: 'src/entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup, + }) + const client = ( + await build.client.run( + `${requestsOfPrelude}const clientResults = {}\n${script(list, 'client')}`, + ) + ).result as Record<string, unknown> + const ssr = ( + await build.ssr.run( + `${callByIdPrelude}const clientResults = ${JSON.stringify(client)}\n${script(list, 'ssr')}`, + ) + ).result as Record<string, unknown> + return Object.fromEntries( + list.map((shape) => [ + shape.slug, + { + where: build.client.where(marker(shape)), + client: client[shape.slug], + ssr: ssr[shape.slug], + }, + ]), + ) +} + +describe.each(startBundlers)('%s build', (bundler) => { + const cleanups: Array<() => Promise<void>> = [] + let shared: Promise<Record<string, Observed> | undefined> | undefined + + /** What building `shape` gave: its observation, or the build's error. */ + async function outcomeOf( + shape: Shape, + ): Promise<{ observed: Observed } | { error: unknown }> { + shared ??= observe( + bundler, + shapes.filter((other) => !envFnHandlers.includes(other.slug)), + (cleanup) => cleanups.push(cleanup), + ).catch(() => undefined) + const together = envFnHandlers.includes(shape.slug) + ? undefined + : await shared + if (together) { + return { observed: together[shape.slug]! } + } + return observe(bundler, [shape]).then( + (alone) => ({ observed: alone[shape.slug]! }), + (error: unknown) => ({ error }), + ) + } + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + /** The shape works: nothing of its server-only module in the client. */ + function expectWorks(shape: Shape, observed: Observed) { + expect(observed.where, 'the server-only module in the client bundle').toBe( + 'nowhere', + ) + shape.expectWorks(observed, result(shape)) + } + + async function expectWorksOrRejected(shape: Shape) { + const outcome = await outcomeOf(shape) + if ('error' in outcome) { + expectSourceError(outcome.error, { + sites: [ + { + file: `src/${shape.slug}.ts`, + source: shape.source(`${shape.slug}-db`), + at: shape.at, + }, + ], + }) + return + } + expectWorks(shape, outcome.observed) + } + + // Bug: chain methods called through a computed member + // (`builder['handler'](...)`, `['server'](...)`), a server-only fn whose + // result is member-called (`.bind(null)`), and a server fn in a top-level + // block (with createServerFn the only factory imported) are left + // untransformed by the client compiler (in-process pins in + // ../known-bugs-start-compiler.test.ts), and the build succeeds. + // Source: #8630 pins; SPEC J4.5, J4.6, J4.12. + // Impact: the server implementation and its server-only module ship in + // the client bundle and run in the browser. + test.fails.each( + shapes.filter( + (shape) => + !recognisedForms.includes(shape.slug) && + !envFnHandlers.includes(shape.slug), + ), + )( + '$name: the client bundle holds no server code and the shape works, or the build fails at the call', + async (shape) => { + await expectWorksOrRejected(shape) + }, + timeout, + ) + + /** A recognised form: the shape must work (no rejection). */ + async function expectRecognised(shape: Shape) { + const outcome = await outcomeOf(shape) + if ('error' in outcome) { + throw outcome.error + } + expectWorks(shape, outcome.observed) + } + + test.each( + shapes.filter( + (shape) => + recognisedForms.includes(shape.slug) && + !pinnedForms.includes(shape.slug), + ), + )( + '$name are recognised: the client bundle holds no server code and the shape works', + async (shape) => { + await expectRecognised(shape) + }, + timeout, + ) + + // Bug: the bundler plugins choose the modules the Start compiler + // transforms by their text (a factory name, or `.handler(`). A module + // whose only Start calls are `factory.serverOnly(...)` and + // `factory.clientOnly(...)` names none, so it is left untransformed and + // the build succeeds; next to a server fn the same calls are compiled + // (shape above). In-process twin: + // ../start-compiler-import-forms.test.ts "... alone in its module". + // Source: start-compiler/compiler.ts `KindDetectionPatterns` and + // `detectKindsInCode` (used by vite/start-compiler-plugin/plugin.ts and + // rsbuild/start-compiler-host.ts); SPEC J4.5, J4.10, J4.12. + // Impact: the server-only implementation and its server-only module ship + // in the client bundle and run in the browser; the client-only one runs + // during SSR. + test.fails.each(shapes.filter((shape) => pinnedForms.includes(shape.slug)))( + '$name are recognised: the client bundle holds no server code and the shape works', + async (shape) => { + await expectRecognised(shape) + }, + timeout, + ) + + // Bug: when the handler passed to `.handler()` is a createServerOnlyFn + // call or a createIsomorphicFn chain, that call is compiled first and the + // caller is never rewritten into an RPC, and the build succeeds without a + // report (the dev twins: ../createServerFn/handler-scope.test.ts and + // ../known-bugs-start-compiler.test.ts). + // Impact: the server fn cannot be called, and the SSR build's server + // entry throws while it loads ("Cannot create property 'method' on + // string"), so the production server does not start. (Built on their + // own, outside the shared build.) + // Source: TanStack/router#8446. The outcome (SPEC J4.1, J4.2, G5): the + // server fn works, or the build fails with an error naming the file (a + // warning alone does not count in a build). + test.fails.each(shapes.filter((shape) => envFnHandlers.includes(shape.slug)))( + '$name: the server fn works, or the build fails naming the file', + async (shape) => { + await expectWorksOrRejected(shape) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-client-only-imports.test.ts b/packages/start-plugin-core/tests/integration/start-build-client-only-imports.test.ts new file mode 100644 index 0000000000..456e8d1bf1 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-client-only-imports.test.ts @@ -0,0 +1,120 @@ +/** + * Modules import protection denies on the server (by default `**\/*.client.*` + * files and modules marked `@tanstack/react-start/client-only`), used only by + * client-only code, are eliminated from the server build: a default-config + * Start build reports no import-protection violation, the server bundle + * holds none of their code, and each environment runs its implementation + * (SPEC J4.11). So is an installed browser-only package (it reads + * `window` when it loads) that only client-only code reads, through a + * diamond and a cycle of helpers: the server build neither bundles nor + * imports it, and reports nothing about it (G16). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { buildStart, startBundlers } from '../build-harness' +import { reportedViolations } from '../importProtection/start-apps' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const files = { + 'node_modules/browser-lib/package.json': JSON.stringify({ + name: 'browser-lib', + type: 'module', + exports: './index.js', + }), + 'node_modules/browser-lib/index.js': `const width = window.innerWidth +export const measure = () => 'MARK_BROWSER_LIB:' + typeof width +`, + 'src/chart.client.ts': `export const draw = () => 'MARK_CHART'\n`, + 'src/paint.ts': `import '@tanstack/react-start/client-only' +export const paint = () => 'MARK_PAINT' +`, + 'src/entry.ts': `import { createClientOnlyFn, createIsomorphicFn } from '@tanstack/react-start' +import { draw } from './chart.client' +import { paint } from './paint' +import { measure } from 'browser-lib' +const measured = () => measure() +const left = () => measured() +const right = () => measured() +function ping(n: number): string { return n > 0 ? pong(n - 1) : left() + right() } +function pong(n: number): string { return n > 0 ? ping(n - 1) : '' } +export const render = createClientOnlyFn(() => draw()) +export const repaint = createIsomorphicFn() + .server(() => 'server') + .client(() => paint()) +export const size = createClientOnlyFn(() => measure()) +export const resize = createIsomorphicFn() + .server(() => 'server') + .client(() => ping(2)) +`, +} + +/** What `render()` and `repaint()` give in an environment of the build. */ +const run = `const settle = (fn) => { + if (typeof fn !== 'function') { + return fn + } + try { + return fn() + } catch (error) { + return { thrown: { name: error.name, message: error.message } } + } +} +return [settle(entry.render), settle(entry.repaint), settle(entry.size), settle(entry.resize)]` + +describe.each(startBundlers)('%s build', (bundler) => { + let build: StartBuild + const cleanups: Array<() => Promise<void>> = [] + + beforeAll(async () => { + build = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + }, timeout) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + test('reports no import-protection violation', () => { + expect( + // (everything the build reported, on every channel) + reportedViolations(build), + ).toEqual([]) + }) + + test('the server bundle holds none of the client-only modules', () => { + expect([ + build.ssr.where('MARK_CHART'), + build.ssr.where('MARK_PAINT'), + build.ssr.where('MARK_BROWSER_LIB'), + ]).toEqual(['nowhere', 'nowhere', 'nowhere']) + // (nothing about the module that imports them either) + expect( + findDiagnostics(build.ssr.warnings, { + file: 'src/entry.ts', + root: build.root, + }), + ).toEqual([]) + }) + + test('each environment runs its implementation', async () => { + expect((await build.client.run(run)).result).toEqual([ + 'MARK_CHART', + 'MARK_PAINT', + 'MARK_BROWSER_LIB:number', + 'MARK_BROWSER_LIB:numberMARK_BROWSER_LIB:number', + ]) + // The server build loads (and would crash on) no browser-only package. + expect((await build.ssr.run(run)).result).toEqual([ + { thrown: expect.anything() }, + 'server', + { thrown: expect.anything() }, + 'server', + ]) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-determinism.test.ts b/packages/start-plugin-core/tests/integration/start-build-determinism.test.ts new file mode 100644 index 0000000000..9fca525430 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-determinism.test.ts @@ -0,0 +1,237 @@ +/** + * Start builds are deterministic (SPEC G4, J4.4): the same app at the same + * root gives the same output and server fn ids when it is built again, and + * the same ids and results whatever order the build discovers its modules + * in; within each build the client's ids reach the same handlers in the + * SSR build. The same app at another root builds correctly too, but its + * opaque ids and bytes need not equal the first root's (relocation is + * correctness, not equality). Builds go through Start's Vite and Rsbuild + * plugins (build-harness.ts). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + expectDeterministic, + expectRelocatable, +} from '@tanstack/compiler-test-utils/determinism' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +/** An app with server fns in two modules, a route and a lazy module. */ +const appFiles: Record<string, string> = { + 'src/a.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(async () => 'MARK_A') +`, + 'src/b.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(async () => 'MARK_B') +export const lazy = () => import('./lazy') +`, + 'src/lazy.ts': `export const lazy = () => 'MARK_LAZY'\n`, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + component: () => 'MARK_COMPONENT', +}) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, +} + +/** + * A test entry: re-exports the server fns of `order`'s modules, in that + * order (the order the build discovers them in); the SSR one also what + * calls by id need. + */ +function entryModule(order: Array<'a' | 'b'>, env: 'client' | 'ssr') { + return `${order + .map( + (name) => + `export { greet as greet${name.toUpperCase()}${name === 'b' ? ', lazy' : ''} } from './${name}'`, + ) + .join('\n')} +export { getRouter } from './router' +${env === 'ssr' ? callByIdExports : ''}` +} + +/** The app's entries, importing the modules in `order`. */ +const entries = (order: Array<'a' | 'b'>, ssrOrder = order) => ({ + 'src/client-entry.ts': entryModule(order, 'client'), + 'src/ssr-entry.ts': entryModule(ssrOrder, 'ssr'), +}) + +// Re-export barrels are real user inputs. The secondary module is reached +// through a chain in both environments, so the first compiler encounter is +// driven by graph discovery rather than two concurrent reads of siblings. +const collisionBarrels = Object.fromEntries( + (['a', 'b'] as const).flatMap((name) => + Array.from({ length: 8 }, (_, index) => [ + `src/discover-${name}-${index}.ts`, + `export * from './${index === 7 ? name : `discover-${name}-${index + 1}`}'`, + ]), + ), +) +const collisionEntries = (order: Array<'a' | 'b'>) => + Object.fromEntries( + Object.entries(entries(order)).map(([file, code]) => [ + file, + code.replace(`from './${order[1]}'`, `from './discover-${order[1]}-0'`), + ]), + ) + +const entry = { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' } + +/** + * What a build does: the id the client gives each server fn, the id the SSR + * caller gives it, and what an HTTP call of each client id runs. + */ +async function observe(build: StartBuild) { + // (each server fn by its public URL: the server fn base, then its id) + const urls = ( + await build.client.run( + `return { a: entry.greetA.url, b: entry.greetB.url }`, + ) + ).result as { a: string; b: string } + const { result } = await build.ssr.run(`${callByIdPrelude} +const ids = { + a: serverFnId(${JSON.stringify(urls.a)}), + b: serverFnId(${JSON.stringify(urls.b)}), +} +return { + ids, + ssrIds: { a: serverFnId(entry.greetA), b: serverFnId(entry.greetB) }, + results: { a: await callById(ids.a), b: await callById(ids.b) }, +}`) + return result as { + ids: { a: string; b: string } + ssrIds: unknown + results: unknown + } +} + +/** Each build's own agreement: ids are set, SSR agrees, each runs its handler. */ +function expectAgreement(observation: Awaited<ReturnType<typeof observe>>) { + expect(observation.ids.a).not.toBe(observation.ids.b) + expect(observation.ssrIds).toEqual(observation.ids) + expect(observation.results).toEqual({ a: 'MARK_A', b: 'MARK_B' }) +} + +describe.each(startBundlers)('%s build', (bundler) => { + test( + 'the same app built again at the same root gives the same ids and results, and the same ids in another discovery order', + async () => { + const first = await buildStart({ + bundler, + files: { ...appFiles, ...entries(['a', 'b']) }, + entry, + }) + const firstObservation = await observe(first) + expectAgreement(firstObservation) + // Built again, unchanged: the same ids and results. (Equal bytes and + // chunk names are not required, SPEC §8.) + const again = await first.rebuild() + expect(await observe(again)).toEqual(firstObservation) + // The entry imports the modules in the opposite order: same ids. + await expectDeterministic( + [ + firstObservation, + await observe(await again.rebuild(entries(['b', 'a']))), + ], + (observation) => observation, + ) + }, + timeout, + ) + + // Relocation (SPEC G4) requires correctness at each root, not equal ids. + test( + 'the same app at another root builds correctly: within each build the client ids run their handlers', + async () => { + const builds: Record<string, StartBuild> = {} + await expectRelocatable( + ['first', 'second'], + async (name) => { + builds[name] = await buildStart({ + bundler, + files: { ...appFiles, ...entries(['a', 'b']) }, + entry, + }) + return observe(builds[name]) + }, + { + check: expectAgreement, + portable: (observation) => observation.results, + }, + ) + expect(builds.first!.client.root).not.toBe(builds.second!.client.root) + }, + timeout, + ) + + // A `generateFunctionId` giving two server fns the same id: the build + // de-duplicates them with a suffix (`same-id`, `same-id_1`; docs + // server-functions.md:417-430, SPEC J4.4), each client id reaches its own + // handler, and the SSR build, which compiles the two modules in the + // opposite order, agrees (the suffix can depend on compile order). Built + // again with the other discovery order, the pairing still holds. + describe('colliding custom ids', () => { + let oppositeEnvironments: Awaited<ReturnType<typeof observe>> + let first: Awaited<ReturnType<typeof observe>> + let reordered: Awaited<ReturnType<typeof observe>> + let cleanup: (() => Promise<void>) | undefined + beforeAll(async () => { + const build = await buildStart({ + bundler, + files: { + 'src/a.ts': appFiles['src/a.ts']!, + 'src/b.ts': appFiles['src/b.ts']!, + 'src/lazy.ts': appFiles['src/lazy.ts']!, + ...collisionBarrels, + ...entries(['a', 'b'], ['b', 'a']), + }, + entry, + start: { serverFns: { generateFunctionId: () => 'same-id' } }, + registerCleanup: (dispose) => { + cleanup = dispose + }, + }) + oppositeEnvironments = await observe(build) + first = await observe(await build.rebuild(collisionEntries(['a', 'b']))) + reordered = await observe( + await build.rebuild(collisionEntries(['b', 'a'])), + ) + }, timeout) + afterAll(() => cleanup?.()) + + test('each client id runs its own handler in the SSR build in either discovery order', () => { + for (const observation of [oppositeEnvironments, first, reordered]) { + expectAgreement(observation) + expect(new Set(Object.values(observation.ids))).toEqual( + new Set(['same-id', 'same-id_1']), + ) + } + }) + + // Bug: collision suffixes follow discovery order across fresh + // builds: at the same root, with the server function modules unchanged, + // the function-to-id mapping changes. + // Impact: reordering the imports of an entry file, with no server + // function changed, swaps which function each id calls: a client of the + // previous build (an open tab during a deploy) runs the other function. + test.fails( + 'fresh builds keep the function-to-id mapping when discovery order reverses', + () => { + expect(reordered.ids).toEqual(first.ids) + }, + ) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-env-separation.test.ts b/packages/start-plugin-core/tests/integration/start-build-env-separation.test.ts new file mode 100644 index 0000000000..ab721f86fa --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-env-separation.test.ts @@ -0,0 +1,755 @@ +/** + * Start's environment separation in real builds, through Start's Vite and + * Rsbuild plugins (build-harness.ts): server code never reaches the client + * bundle, and the server build still runs it. "Server code" is each + * construct whose server side the client must not get; each one imports a + * module whose code carries a marker (and whose top-level code sets it), so + * the marker is in the client bundle as soon as the module is. + * Route options go through Start's own router plugin wiring (its list of + * options deleted from client route modules). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import { solidAppConfig } from './hydrate-pages' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +/** + * The client's `entry.greet()` sends one request to the server, to the + * server fn's URL. + */ +async function expectCallsTheServer(client: StartBuild['client']) { + const called = ( + await client.run(`${requestsOfPrelude} +return { url: entry.greet.url, requests: await requestsOf(entry.greet) }`) + ).result as { url: string; requests: Array<unknown> } + expect(called.url).toMatch(/^\/_serverFn\/./) + expect(called.requests).toEqual([{ url: called.url, method: 'GET' }]) +} + +describe.each(startBundlers)('%s build', (bundler) => { + // React and Solid apps: J4 recognises the factories of each framework's + // Start package (SPEC J4.5), whose bundler wiring differs (Solid apps + // build with the framework's own plugin, `solidAppConfig`). + describe.each(['react', 'solid'] as const)('%s app', (framework) => { + const appConfig = framework === 'solid' ? solidAppConfig : {} + + // Whether the SSR build loads the handler eagerly or on demand is left + // open. + test( + 'a server function handler is only in the SSR build, and runs there', + async () => { + const { client, ssr } = await buildStart({ + bundler, + framework, + ...appConfig, + files: { + 'fns.ts': `import { createServerFn } from '@tanstack/${framework}-start' +export const greet = createServerFn().handler(() => 'MARK_HANDLER') +`, + 'entry.ts': `export { greet } from './fns' +`, + }, + }) + expect(client.where('MARK_HANDLER')).toBe('nowhere') + expect(ssr.where('MARK_HANDLER')).not.toBe('nowhere') + expect((await ssr.run(`return await entry.greet()`)).result).toBe( + 'MARK_HANDLER', + ) + await expectCallsTheServer(client) + }, + timeout, + ) + + test( + 'an isomorphic function keeps the branch of each build', + async () => { + const { client, ssr } = await buildStart({ + bundler, + framework, + ...appConfig, + files: { + 'entry.ts': `import { createIsomorphicFn } from '@tanstack/${framework}-start' +export const where = createIsomorphicFn() + .server(() => 'MARK_SERVER') + .client(() => 'MARK_CLIENT') +`, + }, + }) + expect({ + client: [client.where('MARK_CLIENT'), client.where('MARK_SERVER')], + ssr: [ssr.where('MARK_CLIENT'), ssr.where('MARK_SERVER')], + }).toEqual({ client: ['eager', 'nowhere'], ssr: ['nowhere', 'eager'] }) + expect([ + (await client.run(`return entry.where()`)).result, + (await ssr.run(`return entry.where()`)).result, + ]).toEqual(['MARK_CLIENT', 'MARK_SERVER']) + }, + timeout, + ) + }) + + /** A library in `node_modules` whose module is `code`, built for Start. */ + const library = (name: string, code: string) => ({ + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: './index.js', + peerDependencies: { '@tanstack/react-start': '*' }, + }), + [`node_modules/${name}/index.js`]: code, + }) + + // Source: review (no test built a server fn defined in node_modules + // through Start's plugin). + test( + "a library's server fn: the client gets an RPC without the handler, and the SSR build runs it by that id", + async () => { + const { client, ssr } = await buildStart({ + bundler, + // The app depends on the library, as an installed one. + packageJson: { + name: 'app', + private: true, + type: 'module', + dependencies: { 'server-fn-lib': '*' }, + }, + files: { + ...library( + 'server-fn-lib', + `import { createServerFn } from '@tanstack/react-start' +export const libFn = createServerFn().handler(async () => 'MARK_LIB_HANDLER') +`, + ), + 'src/client-entry.ts': `export { libFn } from 'server-fn-lib'\n`, + 'src/ssr-entry.ts': `export { libFn } from 'server-fn-lib' +${callByIdExports}`, + }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + expect(client.where('MARK_LIB_HANDLER')).toBe('nowhere') + const url = (await client.run(`return entry.libFn.url`)).result + const { result } = await ssr.run(`${callByIdPrelude}return { + called: await entry.libFn(), + byId: await callById(serverFnId(${JSON.stringify(url)})), +}`) + expect(result).toEqual({ + called: 'MARK_LIB_HANDLER', + byId: 'MARK_LIB_HANDLER', + }) + }, + timeout, + ) + + // Concurrent: the rows share one build and run it in Node processes and + // browser pages. The last test builds: runs give their working directory + // and environment explicitly, so the build's process-global state does not + // reach them. + describe.concurrent('server code of each construct', () => { + /** + * `src/deps/<name>.ts`: an export returning `marker`, in a module whose + * top-level code also sets it. + */ + const dependency = (name: string, marker: string) => ({ + [`src/deps/${name}.ts`]: `;(globalThis as Record<string, unknown>).${marker} = 'loaded' +export const ${name} = (..._args: Array<unknown>) => '${marker}' +`, + }) + + /** + * One app with every construct; the client and SSR entries export them + * (`src/entry.ts`), and import `src/start.ts` and the router + * (`src/router.ts`) like Start's entries. + */ + const files = { + ...dependency('handlerDep', 'MARK_HANDLER_DEP'), + ...dependency('baseHandlerDep', 'MARK_BASE_HANDLER_DEP'), + ...dependency('middlewareServer', 'MARK_MIDDLEWARE_SERVER'), + ...dependency('middlewareValidator', 'MARK_MIDDLEWARE_VALIDATOR'), + ...dependency('isomorphicServer', 'MARK_ISOMORPHIC_SERVER'), + ...dependency('serverOnlyDep', 'MARK_SERVER_ONLY'), + ...dependency('routeHandler', 'MARK_ROUTE_HANDLER'), + ...dependency('routeHeaders', 'MARK_ROUTE_HEADERS'), + ...dependency('routeSsr', 'MARK_ROUTE_SSR'), + ...dependency('routeServerFn', 'MARK_ROUTE_SERVER_FN'), + ...dependency('serverRouteHandler', 'MARK_SERVER_ROUTE'), + ...dependency('startMiddleware', 'MARK_START_MIDDLEWARE'), + ...dependency('builderValidator', 'MARK_BUILDER_VALIDATOR'), + ...dependency( + 'builderMiddlewareValidator', + 'MARK_BUILDER_MIDDLEWARE_VALIDATOR', + ), + ...dependency( + 'builderMiddlewareServer', + 'MARK_BUILDER_MIDDLEWARE_SERVER', + ), + // A validator factory: the validator it returns returns the marker. + 'src/deps/typedSchema.ts': `;(globalThis as Record<string, unknown>).MARK_TYPED_VALIDATOR = 'loaded' +export const typedSchema = (_name: string) => (_data: unknown) => + 'MARK_TYPED_VALIDATOR' +`, + // Builders stored in variables, and a validator schema that a type + // alias reads. The middleware module imports no server fn factory: + // with one, the Rsbuild SSR build fails to resolve its + // `createMiddleware` import (pin "a module with a middleware and an + // isomorphic fn builds ..." in known-bugs-start-compiler.test.ts). + 'src/builder-middleware.ts': `import { createMiddleware } from '@tanstack/react-start' +import { builderMiddlewareValidator } from './deps/builderMiddlewareValidator' +import { builderMiddlewareServer } from './deps/builderMiddlewareServer' +const validatedBase = createMiddleware({ type: 'function' }).validator( + (data: unknown) => builderMiddlewareValidator(data), +) +export const validatedMiddleware = validatedBase.server(({ next }) => next()) +const serverBase = createMiddleware({ type: 'function' }).server(({ next }) => + next({ context: { marker: builderMiddlewareServer() } }), +) +export const serverMiddleware = serverBase.client(({ next }) => next()) +`, + 'src/builders.ts': `import { createServerFn } from '@tanstack/react-start' +import { builderValidator } from './deps/builderValidator' +import { typedSchema } from './deps/typedSchema' +const withValidator = createServerFn({ method: 'POST' }).validator( + (data: unknown) => builderValidator(data), +) +export const validatedFn = withValidator.handler(async ({ data }) => data) +const themeValidator = typedSchema('theme') +type Theme = ReturnType<typeof themeValidator> +export const setTheme = createServerFn({ method: 'POST' }) + .validator(themeValidator) + .handler(async ({ data }): Promise<Theme> => data) +`, + // Isomorphic fns whose first link is stored in a variable. + 'src/iso-builders.ts': `import { createIsomorphicFn } from '@tanstack/react-start' +const serverBase = createIsomorphicFn().server(() => 'iso-var-server') +export const isoServerVar = serverBase.client(() => 'iso-var-client') +const clientBase = createIsomorphicFn().client(() => 'iso-var-client') +export const isoClientVar = clientBase.server(() => 'iso-var-server') +`, + 'src/middleware.ts': `import { createMiddleware } from '@tanstack/react-start' +import { middlewareServer } from './deps/middlewareServer' +import { middlewareValidator } from './deps/middlewareValidator' +export const fnMiddleware = createMiddleware({ type: 'function' }) + .validator((data: unknown) => middlewareValidator(data)) + .server(({ next }) => next({ context: { marker: middlewareServer() } })) +`, + 'src/base.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + 'src/fns.ts': `import { + createIsomorphicFn, + createServerFn, + createServerOnlyFn, +} from '@tanstack/react-start' +import { base } from './base' +import { fnMiddleware } from './middleware' +import { handlerDep } from './deps/handlerDep' +import { baseHandlerDep } from './deps/baseHandlerDep' +import { isomorphicServer } from './deps/isomorphicServer' +import { serverOnlyDep } from './deps/serverOnlyDep' +export const fn = createServerFn() + .middleware([fnMiddleware]) + .handler(async () => handlerDep()) +export const fromBase = base.handler(async () => baseHandlerDep()) +export const isomorphic = createIsomorphicFn() + .server(() => isomorphicServer()) + .client(() => 'MARK_ISOMORPHIC_CLIENT') +export const serverOnly = createServerOnlyFn(() => serverOnlyDep()) +`, + // Server fns whose handlers return what the middleware put into + // their context (the request middleware of src/start.ts runs first, + // then the server fn's own) and the data its validator gave: a call + // over HTTP runs Start's own middleware chain. + 'src/middleware-fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { serverMiddleware, validatedMiddleware } from './builder-middleware' +import { fnMiddleware } from './middleware' +type Context = { marker?: string } +export const viaFnMiddleware = createServerFn() + .middleware([fnMiddleware]) + .handler(async ({ context, data }) => ({ + marker: (context as Context).marker, + data, + })) +export const viaBuilderMiddleware = createServerFn() + .middleware([serverMiddleware]) + .handler(async ({ context }) => (context as Context).marker) +export const viaBuilderValidator = createServerFn() + .middleware([validatedMiddleware]) + .handler(async ({ data }) => data) +export const viaStartMiddleware = createServerFn().handler( + async ({ context }) => (context as unknown as Context).marker, +) +`, + 'src/start.ts': `import { createMiddleware, createStart } from '@tanstack/react-start' +import { startMiddleware } from './deps/startMiddleware' +const marker = createMiddleware().server(({ next }) => + next({ context: { marker: startMiddleware() } }), +) +export const startInstance = createStart(() => ({ requestMiddleware: [marker] })) +`, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { routeHandler } from '../deps/routeHandler' +import { routeHeaders } from '../deps/routeHeaders' +import { routeSsr } from '../deps/routeSsr' +import { routeServerFn } from '../deps/routeServerFn' +const getData = createServerFn().handler(async () => routeServerFn()) +export const Route = createFileRoute('/')({ + server: { handlers: { GET: () => new Response(routeHandler()) } }, + headers: () => ({ 'x-marker': routeHeaders() }), + ssr: () => routeSsr() === 'MARK_ROUTE_SSR', + loader: () => getData(), + component: () => 'MARK_ROUTE_COMPONENT', +}) +`, + 'src/routes/api.ts': `import { createFileRoute } from '@tanstack/react-router' +import { serverRouteHandler } from '../deps/serverRouteHandler' +export const Route = createFileRoute('/api')({ + server: { handlers: { GET: () => new Response(serverRouteHandler()) } }, +}) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/entry.ts': `export { fn, fromBase, isomorphic, serverOnly } from './fns' +export { setTheme, validatedFn } from './builders' +export { isoClientVar, isoServerVar } from './iso-builders' +export { serverMiddleware, validatedMiddleware } from './builder-middleware' +export { fnMiddleware } from './middleware' +export { + viaBuilderMiddleware, + viaBuilderValidator, + viaFnMiddleware, + viaStartMiddleware, +} from './middleware-fns' +export { startInstance } from './start' +export { getRouter } from './router' +`, + // Start's server entry: its server-fn HTTP handler finds the server + // fns by id, as in an app. + 'src/ssr-entry.ts': `export * from './entry' +${callByIdExports}`, + } + + /** + * SSR script prelude: `route(id)` is the route with that id; `get(path)` + * is the text of Start's server entry's response to a GET request for + * `path`; `callById` (`callByIdPrelude`) calls a server fn over HTTP. + */ + const routes = `${callByIdPrelude}const route = (id) => + Object.values(entry.getRouter().routeTree.children).find( + (candidate) => candidate.options.id === id, + ) +const get = async (path) => + (await entry.startServerEntry.fetch(new Request(new URL(path, 'http://localhost')))).text() +` + + // One build for every row. + let build: StartBuild + let dispose: (() => Promise<void>) | undefined + beforeAll(async () => { + build = await buildStart({ + bundler, + files, + entry: { client: 'src/entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + }, timeout) + afterAll(() => dispose?.()) + + // The markers are searchable: the client keeps the client side of the + // same modules. + test('the client keeps the client code of these modules', () => { + expect({ + isomorphic: build.client.where('MARK_ISOMORPHIC_CLIENT'), + component: build.client.where('MARK_ROUTE_COMPONENT'), + }).toEqual({ isomorphic: 'eager', component: 'lazy' }) + }) + + // Source: review (Rsbuild, Start's plugin wiring and each construct were + // not covered). + test.each([ + { + construct: 'a server fn handler', + marker: 'MARK_HANDLER_DEP', + run: `return await entry.fn()`, + expected: 'MARK_HANDLER_DEP', + }, + { + construct: + 'a server fn handler of a builder imported from another module', + marker: 'MARK_BASE_HANDLER_DEP', + run: `return await entry.fromBase()`, + expected: 'MARK_BASE_HANDLER_DEP', + }, + { + construct: 'a function middleware .server()', + marker: 'MARK_MIDDLEWARE_SERVER', + run: `return (await callById(serverFnId(entry.viaFnMiddleware))).marker`, + expected: 'MARK_MIDDLEWARE_SERVER', + }, + { + construct: 'a function middleware validator', + marker: 'MARK_MIDDLEWARE_VALIDATOR', + run: `return (await callById(serverFnId(entry.viaFnMiddleware))).data`, + expected: 'MARK_MIDDLEWARE_VALIDATOR', + }, + { + construct: 'an isomorphic fn .server()', + marker: 'MARK_ISOMORPHIC_SERVER', + run: `return entry.isomorphic()`, + expected: 'MARK_ISOMORPHIC_SERVER', + }, + { + construct: 'a server-only fn', + marker: 'MARK_SERVER_ONLY', + run: `return entry.serverOnly()`, + expected: 'MARK_SERVER_ONLY', + }, + { + construct: 'route server.handlers', + marker: 'MARK_ROUTE_HANDLER', + run: `return await get('/')`, + expected: 'MARK_ROUTE_HANDLER', + }, + { + construct: 'route headers', + marker: 'MARK_ROUTE_HEADERS', + run: `return route('/').options.headers()['x-marker']`, + expected: 'MARK_ROUTE_HEADERS', + }, + { + construct: 'route ssr', + marker: 'MARK_ROUTE_SSR', + run: `return route('/').options.ssr()`, + expected: true, + }, + { + construct: 'a server fn of a route file the loader calls', + marker: 'MARK_ROUTE_SERVER_FN', + run: `return await route('/').options.loader()`, + expected: 'MARK_ROUTE_SERVER_FN', + }, + { + construct: 'a server route', + marker: 'MARK_SERVER_ROUTE', + run: `return await get('/api')`, + expected: 'MARK_SERVER_ROUTE', + }, + { + construct: 'a request middleware of src/start.ts', + marker: 'MARK_START_MIDDLEWARE', + run: `return await callById(serverFnId(entry.viaStartMiddleware))`, + expected: 'MARK_START_MIDDLEWARE', + }, + { + construct: 'a function middleware .server() on a builder variable', + marker: 'MARK_BUILDER_MIDDLEWARE_SERVER', + run: `return await callById(serverFnId(entry.viaBuilderMiddleware))`, + expected: 'MARK_BUILDER_MIDDLEWARE_SERVER', + }, + ])( + '$construct: its server code is not in the client bundle, and runs in the SSR build', + async ({ marker, run, expected }) => { + expect(build.client.where(marker)).toBe('nowhere') + expect((await build.ssr.run(`${routes}${run}`)).result).toEqual( + expected, + ) + }, + ) + + // Bug: a `.validator()` link on a builder stored in a variable is not + // stripped from the client (server fn and middleware): the chain walk + // stops at the identifier. Pinned at compiler level in + // createServerFn/caller-dead-code.test.ts and + // start-compiler-factories.test.ts. + // Source: start-compiler/compiler.ts:1296-1330; fuzzing. + // Bug: a validator schema that a type alias reads with `typeof` stays in + // the client output with its initializer. The root cause is upstream + // (babel-dead-code-elimination 1.0.12 counts a `typeof` type query as a + // reference; no workaround here). Pinned at compiler level in + // known-bugs-start-compiler.test.ts. + // Source: router-utils/src/ast.ts:190; fuzzing. + // Impact: the validators and what they import load eagerly in the + // client, which never runs them. + test.fails.each([ + { + construct: 'a server fn validator on a builder variable', + marker: 'MARK_BUILDER_VALIDATOR', + run: `return await entry.validatedFn({ data: 'input' })`, + expected: 'MARK_BUILDER_VALIDATOR', + }, + { + construct: 'a function middleware validator on a builder variable', + marker: 'MARK_BUILDER_MIDDLEWARE_VALIDATOR', + run: `return await callById(serverFnId(entry.viaBuilderValidator))`, + expected: 'MARK_BUILDER_MIDDLEWARE_VALIDATOR', + }, + { + construct: 'a server fn validator schema that a type alias reads', + marker: 'MARK_TYPED_VALIDATOR', + run: `return await entry.setTheme({ data: 'light' })`, + expected: 'MARK_TYPED_VALIDATOR', + }, + ])( + '$construct: its server code is not in the client bundle, and runs in the SSR build', + async ({ marker, run, expected }) => { + expect(build.client.where(marker)).toBe('nowhere') + expect((await build.ssr.run(`${routes}${run}`)).result).toEqual( + expected, + ) + }, + ) + + /** What `run` returns in the client and in the SSR build. */ + const callInBoth = async (run: string) => { + // Independent runs: a browser page and a Node process, side by side. + const [client, ssr] = await Promise.all([ + build.client.run(run), + build.ssr.run(run), + ]) + return { client: client.result, ssr: ssr.result } + } + + // Control for the pin below (same build): the inline chain. + test('an isomorphic fn written as one chain runs its implementation in each build', async () => { + expect(await callInBoth(`return entry.isomorphic()`)).toEqual({ + client: 'MARK_ISOMORPHIC_CLIENT', + ssr: 'MARK_ISOMORPHIC_SERVER', + }) + }) + + // Bug: an isomorphic fn whose first link is stored in a variable loses + // that link's implementation in its environment's build (no-op, returns + // undefined). Pinned at compiler level in + // start-compiler-factories.test.ts. + // Source: start-compiler/handleCreateIsomorphicFn.ts:17-25, + // start-compiler/compiler.ts:1296-1330; fuzzing. + // Impact: the server (or client) call silently returns undefined. + test.fails.each([ + { name: '.server() link', run: `return entry.isoServerVar()` }, + { name: '.client() link', run: `return entry.isoClientVar()` }, + ])( + 'an isomorphic fn whose $name is stored in a variable runs its implementation in each build', + async ({ run }) => { + expect(await callInBoth(run)).toEqual({ + client: 'iso-var-client', + ssr: 'iso-var-server', + }) + }, + ) + + // An HTTP call of a client RPC runs the server fn of its id. Its own + // build of the server fns: Start's server entry, which handles the + // call, renders with the real `@tanstack/react-router`, not the shared + // build's stand-in. + // Source: mutation testing (no Rsbuild build made the + // compiler load another module, here the builder's). + test( + 'each server fn of the client runs by its id in the SSR build', + async ({ onTestFinished }) => { + const fnFiles = [ + 'src/deps/handlerDep.ts', + 'src/deps/baseHandlerDep.ts', + 'src/deps/middlewareServer.ts', + 'src/deps/middlewareValidator.ts', + 'src/deps/isomorphicServer.ts', + 'src/deps/serverOnlyDep.ts', + 'src/deps/startMiddleware.ts', + 'src/middleware.ts', + 'src/base.ts', + 'src/fns.ts', + 'src/start.ts', + ] + const { client, ssr } = await buildStart({ + bundler, + files: { + ...Object.fromEntries( + fnFiles.map((file) => [ + file, + (files as Record<string, string>)[file]!, + ]), + ), + 'src/ssr-entry.ts': `export * from './fns' +${callByIdExports}`, + }, + entry: { client: 'src/fns.ts', ssr: 'src/ssr-entry.ts' }, + // This test's own hook: the tests of the block run concurrently. + registerCleanup: onTestFinished, + }) + const urls = ( + await client.run(`return [entry.fn.url, entry.fromBase.url]`) + ).result + const { result } = await ssr.run(`${callByIdPrelude}const results = [] +for (const url of ${JSON.stringify(urls)}) { + results.push(await callById(serverFnId(url))) +} +return results`) + expect(result).toEqual(['MARK_HANDLER_DEP', 'MARK_BASE_HANDLER_DEP']) + }, + timeout, + ) + }) +}) + +describe("Vite build with Vite's default client target", () => { + // The harness builds for `esnext`; Vite's default client target + // (`baseline-widely-available`) lowers newer syntax after Start compiled + // the module. + // Source: review. + test( + 'a server function handler is only in the SSR build, and the client calls the server', + async () => { + const { client, ssr } = await buildStart({ + files: { + 'fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { secret } from './secret' +export const greet = createServerFn().handler(async () => secret?.() ?? 'MARK_NONE') +export const label = () => 'MARK_CLIENT_LABEL' +`, + 'secret.ts': `export const secret = () => 'MARK_HANDLER'\n`, + 'entry.ts': `export { greet, label } from './fns'\n`, + }, + viteConfig: { + environments: { + client: { build: { target: 'baseline-widely-available' } }, + }, + }, + }) + expect({ + handler: client.where('MARK_HANDLER'), + label: client.where('MARK_CLIENT_LABEL'), + }).toEqual({ handler: 'nowhere', label: 'eager' }) + expect((await ssr.run(`return await entry.greet()`)).result).toBe( + 'MARK_HANDLER', + ) + await expectCallsTheServer(client) + }, + timeout, + ) +}) + +describe('Vite: an environment built twice by one builder', () => { + // `@vitejs/plugin-rsc` runs a scan build of an environment besides its + // real build, with the same plugins: the build after the first compiles + // server fns again, including ones whose builder the compiler loads from + // another module. Here an app plugin builds the SSR environment once more + // after Start's builds (Vite's public `buildApp` hook), and the SSR + // output of that last build serves the client's calls. + // Source: mutation testing. + test( + 'the second build compiles the server fns of its modules', + async () => { + let ssrBuilds = 0 + const { client, ssr } = await buildStart({ + bundler: 'vite', + files: { + 'src/direct.ts': `import { createServerFn } from '@tanstack/react-start' +export const direct = createServerFn().handler(async () => 'MARK_DIRECT') +`, + 'src/base.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + 'src/fns.ts': `import { base } from './base' +export const greet = base.handler(async () => 'MARK_HANDLER') +`, + 'src/client-entry.ts': `export { direct } from './direct' +export { greet } from './fns' +`, + 'src/ssr-entry.ts': `export { direct } from './direct' +export { greet } from './fns' +${callByIdExports}`, + }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + viteConfig: { + plugins: [ + { + name: 'build-ssr-again', + buildApp: { + order: 'post', + handler: async (builder) => { + await builder.build(builder.environments.ssr!) + }, + }, + writeBundle() { + if (this.environment.name === 'ssr') { + ssrBuilds++ + } + }, + }, + ], + }, + }) + expect(ssrBuilds).toBe(2) + expect(client.where('MARK_HANDLER')).toBe('nowhere') + const urls = ( + await client.run(`return [entry.direct.url, entry.greet.url]`) + ).result + const { result } = await ssr.run(`${callByIdPrelude}const results = [] +for (const url of ${JSON.stringify(urls)}) { + results.push(await callById(serverFnId(url))) +} +return { byId: results, direct: await entry.greet() }`) + expect(result).toEqual({ + byId: ['MARK_DIRECT', 'MARK_HANDLER'], + direct: 'MARK_HANDLER', + }) + }, + timeout, + ) +}) + +describe('Rsbuild: a build restored from the persistent cache', () => { + // With `performance.buildCache`, Rspack restores unchanged modules from + // its cache without running Start's compiler on them again; Start must + // still know their server fns. + // Source: mutation testing (e2e apps custom-server-rsbuild and + // server-functions build with buildCache). + test( + 'each server fn of the client runs by its id in the SSR build', + async () => { + const { client, ssr } = await buildStart({ + bundler: 'rsbuild', + builds: 2, + rsbuildConfig: { performance: { buildCache: true } }, + files: { + 'src/base.ts': `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +`, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { base } from './base' +export const greet = createServerFn().handler(async () => 'MARK_GREET') +export const fromBase = base.handler(async () => 'MARK_FROM_BASE') +`, + 'src/client-entry.ts': `export { greet, fromBase } from './fns'\n`, + 'src/ssr-entry.ts': `export { greet, fromBase } from './fns' +${callByIdExports}`, + }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + expect(client.where(/MARK_GREET|MARK_FROM_BASE/)).toBe('nowhere') + const urls = ( + await client.run(`return [entry.greet.url, entry.fromBase.url]`) + ).result + const { result } = await ssr.run(`${callByIdPrelude}const results = [] +for (const url of ${JSON.stringify(urls)}) { + results.push(await callById(serverFnId(url))) +} +return results`) + expect(result).toEqual(['MARK_GREET', 'MARK_FROM_BASE']) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-function-id-url.test.ts b/packages/start-plugin-core/tests/integration/start-build-function-id-url.test.ts deleted file mode 100644 index a5a2b229fc..0000000000 --- a/packages/start-plugin-core/tests/integration/start-build-function-id-url.test.ts +++ /dev/null @@ -1,130 +0,0 @@ -/** - * The client puts a server function's id in its URL unencoded, as one path - * segment, and the server reads that segment back. An id a custom - * `serverFns.generateFunctionId` returns with an ASCII character outside - * RFC 3986's unreserved set and `$` (`'`, `:`, `%`…) reaches its handler, - * but proxies and servers may encode or normalise it: it builds, with a - * deprecation warning naming the file. An id of unreserved characters and - * `$` builds without one. (Ids that never reached their handler fail the - * build: `tests/createServerFn/createServerFn.test.ts`.) - */ -import { execFile } from 'node:child_process' -import { readdir } from 'node:fs/promises' -import path from 'node:path' -import { pathToFileURL } from 'node:url' -import { promisify } from 'node:util' -import { describe, expect, test } from 'vitest' -import { appFiles, buildStartApp, createStartApp } from './start-app' - -const timeout = 60_000 - -const execFileAsync = promisify(execFile) - -/** Ids that reach their handler, deprecated, by file. */ -const deprecated: Record<string, string> = { - 'src/fns/apostrophe.ts': "users'get", - 'src/fns/colon.ts': 'users:get', - 'src/fns/percent.ts': 'users%2Fget', - 'src/fns/brackets.ts': 'users[get]', -} - -const fine: Record<string, string> = { 'src/fns/fine.ts': 'Users-get.v1_~$' } - -const ids = { ...deprecated, ...fine } - -/** A route whose component references a server function of each file, which returns the file's name. */ -function app() { - const files: Record<string, string> = {} - const imports: Array<string> = [] - Object.keys(ids).forEach((file, index) => { - files[file] = `import { createServerFn } from '@tanstack/react-start' -export const fn = createServerFn().handler(async () => new Response(${JSON.stringify(file)})) -` - imports.push( - `import { fn as fn${index} } from '${file.replace(/^src\/(.*)\.ts$/, '../$1')}'`, - ) - }) - files['src/routes/index.tsx'] = - `import { createFileRoute } from '@tanstack/react-router' -${imports.join('\n')} -export const Route = createFileRoute('/')({ - component: () => <button onClick={() => [${Object.keys(ids).map((_, index) => `fn${index}()`)}]}>call</button>, -}) -` - return appFiles(files) -} - -/** - * Sends a request for each id (`/_serverFn/<id>`, as a page of the same - * origin does) to the server build's entry, in a Node process of its own, - * and gives each response's text. - */ -async function callServer(root: string, ids: Array<string>) { - const dir = path.join(root, 'dist/server') - const entry = (await readdir(dir)).find((file) => - /^(server|index)\.m?js$/.test(file), - ) - if (entry === undefined) { - throw new Error(`no server entry in ${dir}`) - } - const script = `const { default: server } = await import(${JSON.stringify(pathToFileURL(path.join(dir, entry)).href)}) -const texts = [] -for (const id of ${JSON.stringify(ids)}) { - const response = await server.fetch( - new Request(new URL('/_serverFn/' + id, 'http://localhost'), { - headers: { 'sec-fetch-site': 'same-origin' }, - }), - ) - texts.push(await response.text()) -} -process.stdout.write(JSON.stringify(texts)) -` - const { stdout } = await execFileAsync( - process.execPath, - ['--input-type=module', '-e', script], - { cwd: root, env: { ...process.env, NODE_ENV: 'production' } }, - ) - return JSON.parse(stdout) as Array<string> -} - -const options = { - serverFns: { - generateFunctionId: ({ filename }: { filename: string }) => ids[filename], - }, -} - -describe.each(['vite', 'rsbuild'] as const)('%s build', (bundler) => { - // `'` broke the server bundle: the resolver's manifest key was quoted with it - test( - 'a custom id with characters outside the unreserved set builds and reaches its handler', - async () => { - const start = await createStartApp(app()) - await buildStartApp(start, bundler, options) - expect(await callServer(start.root, Object.values(ids))).toEqual( - Object.keys(ids), - ) - }, - timeout, - ) -}) - -// (Rsbuild's transform context has no channel for the compiler's warnings) -describe('vite build', () => { - test( - 'a custom id with characters outside the unreserved set warns, naming the file and the id', - async () => { - const start = await createStartApp(app()) - const build = await buildStartApp(start, 'vite', options) - for (const [file, id] of Object.entries(ids)) { - expect( - build.warnings.some( - (warning) => - warning.includes(file) && warning.includes(JSON.stringify(id)), - ), - `a warning naming ${file}`, - ).toBe(file in deprecated) - } - }, - timeout, - ) -}) diff --git a/packages/start-plugin-core/tests/integration/start-build-manifest.test.ts b/packages/start-plugin-core/tests/integration/start-build-manifest.test.ts new file mode 100644 index 0000000000..6ed5b0c37a --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-manifest.test.ts @@ -0,0 +1,93 @@ +/** + * The client route tree of a real build, through Start's Vite and Rsbuild + * plugins (build-harness.ts): it leaves out server-only routes. + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../build-harness' +import { probeRoutePath } from '../request-probe' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const head = `import { createFileRoute } from '@tanstack/react-router'\n` +const handlers = `server: { handlers: { GET: () => new Response('x') } }` + +/** + * Pages (`/`, and `/users/profile` under the server-only `/users`) and a + * server-only subtree (`/api`, `/api/inner`). + */ +const files = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ component: () => 'MARK_INDEX' })\n`, + 'src/routes/users.tsx': `${head}export const Route = createFileRoute('/users')({ ${handlers} })\n`, + 'src/routes/users/profile.tsx': `${head}import { Profile } from '../../components/Profile' +export const Route = createFileRoute('/users/profile')({ component: Profile }) +`, + 'src/components/Profile.tsx': `export const Profile = () => 'MARK_PROFILE'\n`, + 'src/routes/api.tsx': `${head}export const Route = createFileRoute('/api')({ ${handlers} })\n`, + 'src/routes/api/inner.tsx': `${head}export const Route = createFileRoute('/api/inner')({ ${handlers} })\n`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, +} + +/** + * Script returning the route tree of the build: whether the root is a root + * (the generated tree gives it no parent) and the paths of its routes, + * depth first. + */ +const routeTree = `const tree = entry.getRouter().routeTree +const paths = (route) => Object.values(route.children ?? {}).flatMap((child) => [ + child.options.path, + ...paths(child), +]) +return { rootIsRoot: !('getParentRoute' in tree.options), paths: paths(tree) }` + +describe.each(startBundlers)('%s build', (bundler) => { + let build: StartBuild + let dispose: (() => Promise<void>) | undefined + beforeAll(async () => { + build = await buildStart({ + bundler, + files, + entry: 'src/router.ts', + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + }, timeout) + afterAll(() => dispose?.()) + + // Source: mutation testing. + test('a server-only route with a page under it stays in the client route tree, under the root', async () => { + const { result } = await build.client.run(routeTree) + expect(result).toEqual({ + rootIsRoot: true, + paths: expect.arrayContaining(['/', '/users', '/profile']), + }) + }) + + // Vite: Start prunes server-only subtrees from the client route tree. + // Rsbuild: same bug as known-bugs-route-options.test.ts "a route with only + // server handlers is not in the client route tree" (only the Vite plugin + // prunes). + ;(bundler === 'vite' ? test : test.fails)( + 'the client route tree is the SSR route tree without the server-only subtree', + async () => { + const ssr = (await build.ssr.run(routeTree)).result as { + paths: Array<string> + } + expect(ssr.paths).toEqual(expect.arrayContaining(['/api', '/inner'])) + // (the harness's probe route, which serves the requests SSR scripts + // run in, is a server-only route too) + const serverOnly = ['/api', '/inner', probeRoutePath] + expect((await build.client.run(routeTree)).result).toEqual({ + rootIsRoot: true, + paths: ssr.paths.filter((path) => !serverOnly.includes(path)), + }) + }, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-options.test.ts b/packages/start-plugin-core/tests/integration/start-build-options.test.ts new file mode 100644 index 0000000000..170824efff --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-options.test.ts @@ -0,0 +1,323 @@ +/** + * Documented Start plugin options that reach the compilers (server fn ids, + * the code splitter, the route tree) have their effect in real builds, + * through Start's Vite and Rsbuild plugins (build-harness.ts). + */ +import { writeFile } from 'node:fs/promises' +import path from 'node:path' +import ts from 'typescript' +import { describe, expect, test } from 'vitest' +import { + loadMarker, + loadedModulesExpression, +} from '@tanstack/compiler-test-utils/importers' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' +import { solidAppConfig } from './hydrate-pages' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const greetFiles = { + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(async () => 'MARK_HANDLER') +`, + 'src/client-entry.ts': `export { greet } from './fns'\n`, + 'src/ssr-entry.ts': `export { greet } from './fns' +${callByIdExports}`, +} + +/** Type-checks `files` (relative to `root`); returns the diagnostics. */ +function typeCheck(root: string, files: Array<string>) { + const program = ts.createProgram( + files.map((file) => path.join(root, file)), + { + strict: true, + noEmit: true, + target: ts.ScriptTarget.ESNext, + module: ts.ModuleKind.ESNext, + moduleResolution: ts.ModuleResolutionKind.Bundler, + allowImportingTsExtensions: true, + jsx: ts.JsxEmit.Preserve, + skipLibCheck: true, + types: [], + }, + ) + return ts.getPreEmitDiagnostics(program).map((diagnostic) => { + const where = diagnostic.file + ? `${path.relative(root, diagnostic.file.fileName)}:${diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start ?? 0).line + 1}` + : '' + return `${where} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}` + }) +} + +/** + * Type assertions on the `Register` interface the route tree declares: + * the app's router, and its Start config (`withConfig`) or none. (The + * generated route tree is not type-checked itself, `@ts-nocheck`, so a + * broken import there would only make these types `any`.) + */ +const registerChecks = ( + withConfig: boolean, + framework: 'react' | 'solid', +) => `import type { Register } from '@tanstack/${framework}-start' +type Equal<A, B> = + (<T>() => T extends A ? 1 : 2) extends <T>() => T extends B ? 1 : 2 + ? true + : false +type Expect<T extends true> = T +export type Checks = [ + Expect<Equal<Register['ssr'], true>>, + Expect<Equal<Register['router']['brand'], 'ROUTER'>>, + ${withConfig ? `Expect<Equal<Register['config'], { brand: 'CONFIG' }>>,` : `Expect<Equal<'config' extends keyof Register ? true : false, false>>,`} +] +// @ts-expect-error the registered router is the app's +export const router: Register['router'] = { brand: 'OTHER' } +${ + withConfig + ? `// @ts-expect-error the registered config is the app's +export const config: Register['config'] = { brand: 'OTHER' }` + : '' +} +` + +describe.each(startBundlers)('%s build', (bundler) => { + // Source: review (serverFns.generateFunctionId returning undefined was + // never exercised). + test( + 'serverFns.generateFunctionId returning undefined: the default id, which the SSR build resolves', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: greetFiles, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + start: { serverFns: { generateFunctionId: () => undefined } }, + }) + // (the client's server fn, by its public URL: base, then id) + const url = (await client.run(`return entry.greet.url`)).result + expect( + ( + await ssr.run( + `${callByIdPrelude}const id = serverFnId(${JSON.stringify(url)}) +return { id, value: await callById(id) }`, + ) + ).result, + ).toEqual({ id: expect.stringMatching(/./), value: 'MARK_HANDLER' }) + }, + timeout, + ) + + // Source: mutation testing (a generator returning an id was + // never built). + test( + 'serverFns.generateFunctionId returning an id: the client calls that id, which the SSR build resolves', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: greetFiles, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + start: { serverFns: { generateFunctionId: () => 'my-custom-id' } }, + }) + const url = (await client.run(`return entry.greet.url`)).result + expect( + ( + await ssr.run( + `${callByIdPrelude}return { + id: serverFnId(${JSON.stringify(url)}), + value: await callById('my-custom-id'), +}`, + ) + ).result, + ).toEqual({ id: 'my-custom-id', value: 'MARK_HANDLER' }) + }, + timeout, + ) + + /** + * A route whose loader and component each read a module of their own + * that records when it loads (`loadMarker`): what loads, and when, is + * observed at run time, not through chunk names. + */ + const routeFiles = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/loader-data.ts': `${loadMarker('loader')}export const loaderData = 'MARK_LOADER'\n`, + 'src/component-label.ts': `${loadMarker('component')}export const componentLabel = 'MARK_COMPONENT'\n`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { loaderData } from '../loader-data' +import { componentLabel } from '../component-label' +export const Route = createFileRoute('/')({ + loader: () => loaderData, + component: () => componentLabel, +}) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +`, + } + + // Start passes the router options through to the code splitter of each + // build (only replacing the options it owns: the route options it deletes + // from client builds, and HMR). By default the loader stays with the + // route. + // Source: review (router.codeSplittingOptions through Start was never + // exercised). + test.each([ + { + name: 'by default', + router: {}, + expected: { + loader: 'eager', + component: 'lazy', + loaderBringsComponent: false, + componentBringsLoader: false, + }, + }, + { + name: 'with a defaultBehavior grouping the loader with the component', + router: { + codeSplittingOptions: { + defaultBehavior: [['loader', 'component']] as Array< + Array<'loader' | 'component'> + >, + }, + }, + expected: { + loader: 'lazy', + component: 'lazy', + loaderBringsComponent: true, + componentBringsLoader: true, + }, + }, + ])( + 'router.codeSplittingOptions: the client build loads the route loader and component $name, and both builds run them', + async ({ router, expected }) => { + const { client, ssr } = await buildStart({ + bundler, + files: routeFiles, + entry: 'src/entry.ts', + start: { router }, + }) + /** + * What loads with the app (eager) or later (lazy), and whether loading + * one option (running the loader, preloading the component) loads the + * other's code too (one group). Each direction gets a fresh run. + */ + const placementScript = (load: string, other: string, key: string) => + `const loaded = () => [...${loadedModulesExpression}] +const atStart = loaded() +const route = Object.values(entry.getRouter().routeTree.children).find( + (candidate) => candidate.options.id === '/', +) +await ${load} +return { + loader: atStart.includes('loader') ? 'eager' : 'lazy', + component: atStart.includes('component') ? 'eager' : 'lazy', + ${key}: !atStart.includes('${other}') && loaded().includes('${other}'), +}` + const placement = async (build: StartBuild['client']) => ({ + ...(( + await build.run( + placementScript( + 'route.options.loader()', + 'component', + 'loaderBringsComponent', + ), + ) + ).result as object), + ...(( + await build.run( + placementScript( + 'route.options.component.preload()', + 'loader', + 'componentBringsLoader', + ), + ) + ).result as object), + }) + // The SSR build need not split route options like the client: it is + // not required for correctness, an eventual optimisation (SPEC §5.3). + expect(await placement(client)).toEqual(expected) + // Wherever they are, the route's loader and component still run: the + // real router renders the page at `/`. + const script = `const route = Object.values(entry.getRouter().routeTree.children).find( + (candidate) => candidate.options.id === '/', +) +return { + loader: await route.options.loader(), + page: await entry.renderPath(entry.getRouter().routeTree, '/'), +}` + const runs = { + loader: 'MARK_LOADER', + page: expect.stringContaining('MARK_COMPONENT'), + } + expect({ + client: (await client.run(script)).result, + ssr: (await ssr.run(script)).result, + }).toEqual({ client: runs, ssr: runs }) + }, + timeout, + ) + + // Source: mutation testing (the footer Start adds to the + // route tree was never type-checked). + // The footer augments the Start package of the app's framework. + test.each([ + { name: 'with', withStart: true, framework: 'react' }, + { name: 'without', withStart: false, framework: 'react' }, + { name: 'with', withStart: true, framework: 'solid' }, + ] as const)( + 'the route tree registers the router and Start config ($framework, $name src/start.ts) for TypeScript, and keeps the router.routeTreeFileFooter', + async ({ withStart, framework }) => { + const { ssr } = await buildStart({ + bundler, + framework, + ...(framework === 'solid' && solidAppConfig), + files: { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/${framework}-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/${framework}-router' +export const Route = createFileRoute('/')({ component: () => null }) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/${framework}-router' +import { routeTree } from './routeTree.gen' +export const getRouter = async () => + Object.assign(createRouter({ routeTree }), { brand: 'ROUTER' as const }) +`, + ...(withStart && { + 'src/start.ts': `export const startInstance = { getOptions: async () => ({ brand: 'CONFIG' as const }) } +`, + }), + 'src/entry.ts': `export { FOOTER } from './routeTree.gen'\n`, + }, + entry: { client: 'src/router.ts', ssr: 'src/entry.ts' }, + start: { + router: { + routeTreeFileFooter: [`export const FOOTER = 'MARK_USER_FOOTER'`], + }, + }, + }) + expect((await ssr.run(`return entry.FOOTER`)).result).toBe( + 'MARK_USER_FOOTER', + ) + await writeFile( + path.join(ssr.root, 'src/check.ts'), + registerChecks(withStart, framework), + ) + expect( + typeCheck(ssr.root, ['src/routeTree.gen.ts', 'src/check.ts']), + ).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-route-hmr.test.ts b/packages/start-plugin-core/tests/integration/start-build-route-hmr.test.ts new file mode 100644 index 0000000000..112ab7b208 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-route-hmr.test.ts @@ -0,0 +1,230 @@ +/** + * Route HMR in Start: Start forces route HMR on in its client code + * splitting (`addHmr: true`, vite/start-router-plugin/plugin.ts, + * rsbuild/start-router-plugin.ts), so in development an edit of a route + * file updates the page in place (controls on a real page, with the same + * route file); production builds, through Start's Vite and Rsbuild plugins + * (build-harness.ts), carry nothing of it, in the client and in the server + * output (SPEC J3.7), and the page still renders. + * + * What production output must not carry is looked for by the names of the + * bundlers' HMR APIs only (a partial check: how route HMR is written is the + * compiler's business). Start offers no way to turn route HMR off (its + * client code splitting forces `addHmr: true`), so no build without it can + * be compared with these, as router-plugin's production-bundle.ts does with + * its control build; the dev controls show the route file does get route HMR + * where it belongs. + */ +import react from '@vitejs/plugin-react' +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { buildStart, startBundlers } from '../build-harness' +import { startDevServer } from '../dev-server' +import { + reportedErrors, + startRsbuildStartDevServer, +} from '../rsbuild-dev-server' + +const timeout = 60_000 + +/** The bundlers' HMR APIs (Vite's SSR transform spells `import.meta` its way). */ +const hmrApi = + /\b(?:import\.meta|__vite_ssr_import_meta__)\.(?:hot|webpackHot)\b|\bmodule\.hot\b/ + +/** The HMR APIs some module of `modules` uses. */ +function hmrApisIn(modules: Array<string>) { + return modules.flatMap((code) => + [...code.matchAll(new RegExp(hmrApi, 'g'))].map((match) => match[0]), + ) +} + +/** A page route whose loader and component carry markers of `version`. */ +const pageRoute = ( + version = '', +) => `import { createFileRoute } from '@tanstack/react-router' +function Page() { + return <p>{'MARK_PAGE ' + Route.useLoaderData()}</p> +} +export const Route = createFileRoute('/')({ + loader: () => 'MARK_LOADER${version}', + component: Page, +}) +` + +/** The app of the production builds. */ +const files = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': pageRoute(), + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +`, +} + +/** The router of the dev pages, over the generated route tree. */ +const routerFile = `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +` + +// Controls: in development, the same route file gets route HMR. An edit of +// its loader shows the new data in place: without route HMR the bundler +// finds no module accepting the edit, and the page reloads. +describe("dev servers with Start's plugin hot-update the route (controls)", () => { + // A real Vite dev server with Start's whole Vite plugin and + // `@vitejs/plugin-react` serves the app (rendered on the client from + // `index.html`; Start's own page middleware is off) to a real page. The + // server environment's route module has no route HMR code. + test( + 'Vite dev: an edit of the route loader shows in place, and the server environment gets no route HMR code', + async () => { + const server = await startDevServer({ + start: { vite: { installDevServerMiddleware: false } }, + browser: true, + // Pre-bundled up front, as Vite does for an app that installed them + // (the router is a linked workspace package here) + config: { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + }, + }, + plugins: [react()], + files: { + 'index.html': `<!doctype html> +<html> + <body> + <div id="app"></div> + <script type="module" src="/src/main.tsx"></script> + </body> +</html> +`, + 'src/main.tsx': `import { createRoot } from 'react-dom/client' +import { RouterProvider } from '@tanstack/react-router' +import { getRouter } from './router' +createRoot(document.getElementById('app')!).render(<RouterProvider router={getRouter()} />) +`, + 'src/router.ts': routerFile, + 'src/routes/__root.tsx': files['src/routes/__root.tsx'], + 'src/routes/index.tsx': pageRoute(), + }, + }) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_PAGE MARK_LOADER', { selector: '#app' }) + await server.edit({ 'src/routes/index.tsx': pageRoute('_V2') }) + await page.waitForText('MARK_PAGE MARK_LOADER_V2', { selector: '#app' }) + expect(page.loads()).toBe(1) + expect(page.errors).toEqual([]) + // Every module the server environment serves from the route module, + // the router's packages and any support module the compiler imports + // included; left out: Vite's own client, and packages the environment + // externalizes (bare ids: Node loads the installed package itself). + const ssr = await server.load('/src/routes/index.tsx', { + environment: 'ssr', + skip: /^\/@(?:vite|react-refresh)\b|^[^./]/, + }) + expect(hmrApisIn(Object.values(ssr))).toEqual([]) + }, + timeout, + ) + + // A real Rsbuild dev server with Start's Rsbuild plugin and HMR serves + // the app's pages (Start's server entry renders them, the client entry + // hydrates) to a real page. + test( + 'Rsbuild dev: an edit of the route loader shows in place', + async () => { + const server = await startRsbuildStartDevServer({ + hmr: true, + browser: true, + config: { + tools: { + // Start serves the pages, not an HTML template + htmlPlugin: false, + }, + }, + files: { + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient)) +`, + 'harness/server-entry.ts': `export { default } from '@tanstack/react-start/server-entry'\n`, + 'src/router.ts': routerFile, + 'src/routes/__root.tsx': `import { HeadContent, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ component: Root }) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/index.tsx': pageRoute(), + }, + }) + expect(reportedErrors(server)).toEqual([]) + const page = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_PAGE MARK_LOADER', { selector: '#app' }) + await page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + await server.write({ 'src/routes/index.tsx': pageRoute('_V2') }) + await server.settle() + expect(reportedErrors(server)).toEqual([]) + await page.waitForText('MARK_PAGE MARK_LOADER_V2', { selector: '#app' }) + expect(page.loads()).toBe(1) + expect(page.errors).toEqual([]) + }, + timeout, + ) +}) + +describe.each(startBundlers)('%s production build', (bundler) => { + // Source: review (only router-plugin's + // build-production.test.ts checked R7, without Start's forced `addHmr`). + test( + 'the client and server outputs use no HMR API, and the page renders', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + }) + expect(hmrApisIn(client.chunks.map((chunk) => chunk.code))).toEqual([]) + expect(hmrApisIn(ssr.chunks.map((chunk) => chunk.code))).toEqual([]) + const { result } = await client.run(`const route = Object.values( + entry.getRouter().routeTree.children, +).find((candidate) => candidate.options.id === '/') +return { + loader: await route.options.loader(), + page: await entry.renderPath(entry.getRouter().routeTree, '/'), +}`) + expect(result).toEqual({ + loader: 'MARK_LOADER', + page: expect.stringContaining('MARK_PAGE MARK_LOADER'), + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-rpc-and-routes.test.ts b/packages/start-plugin-core/tests/integration/start-build-rpc-and-routes.test.ts new file mode 100644 index 0000000000..3bb298fcd5 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-rpc-and-routes.test.ts @@ -0,0 +1,121 @@ +/** + * A Start build through Start's public plugin, with each bundler: a server + * fn is Start's RPC on the client and runs on the server, directly and by + * the id the client calls (SPEC J4.1, J4.4); the router generator and code + * splitter run, so the route tree links a route whose component loads on + * demand (J1.4, J2.2, J2.6). + */ +import { describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import { probeRoutePath } from '../request-probe' + +const timeout = 60_000 + +describe.each(startBundlers)('%s', (bundler) => { + test( + "a server fn is Start's RPC on the client: calling it fetches its URL, which carries its id; the SSR build runs the handler, directly and for a request of that id, and rejects an unknown id", + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: { + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(async () => 'hello') +`, + 'src/client-entry.ts': `export { greet } from './fns'\n`, + 'src/ssr-entry.ts': `export { greet } from './fns' +${callByIdExports}`, + }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + // The client run has no server: `requestsOf` records the requests + // the call sends. + const clientRpc = ( + await client.run(`${requestsOfPrelude} +return { + url: entry.greet.url, + requests: await requestsOf(entry.greet), +}`) + ).result as { + url: string + requests: Array<{ url: string; method: string }> + } + expect(clientRpc).toEqual({ + url: expect.stringMatching(/^\/_serverFn\/./), + requests: [{ url: clientRpc.url, method: 'GET' }], + }) + const { result } = await ssr.run(`${callByIdPrelude} +const settle = async (run) => { + try { + return { value: await run() } + } catch (error) { + return { rejected: true } + } +} +const id = serverFnId(${JSON.stringify(clientRpc.url)}) +return { + sameId: serverFnId(entry.greet) === id, + called: await settle(() => entry.greet()), + byId: await settle(() => callById(id)), + unknown: await settle(() => callById('unknown-id')), +}`) + // (what the server entry says about an unknown id is free; that it is + // rejected, not answered, is not) + expect(result).toEqual({ + sameId: true, + called: { value: 'hello' }, + byId: { value: 'hello' }, + unknown: { rejected: true }, + }) + }, + timeout, + ) + + test( + 'the route generator and code splitter run: the route tree links a route whose component loads on demand', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files: { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ + component: () => 'MARK_COMPONENT', +}) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +`, + }, + entry: 'src/entry.ts', + }) + expect(client.where('MARK_COMPONENT')).toBe('lazy') + // The real router over the generated tree renders the page at `/` + // (loading the route's component chunk). (The harness's probe route, + // which serves the requests SSR scripts run in, is left out.) + const { result } = await ssr.run(`const { routeTree } = entry.getRouter() +return { + ids: Object.values(routeTree.children) + .map((route) => route.options.id) + .filter((id) => id !== ${JSON.stringify(probeRoutePath)}), + rendered: await entry.renderPath(routeTree, '/'), +}`) + expect(result).toEqual({ + ids: ['/'], + rendered: expect.stringContaining('MARK_COMPONENT'), + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-runtime-outcomes.test.ts b/packages/start-plugin-core/tests/integration/start-build-runtime-outcomes.test.ts new file mode 100644 index 0000000000..f30db64f8d --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-runtime-outcomes.test.ts @@ -0,0 +1,145 @@ +/** Observable Start runtime contracts that mutation testing found unchecked. */ +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { buildStart, startBundlers } from '../build-harness' +import { + openAppPage, + pageEntries, + rootDocument, + routerFile, + serveStartBuild, + startPageEntries, +} from './start-compose-app' + +const files = { + ...startPageEntries, + ...pageEntries, + 'src/router.ts': routerFile, + 'src/routes/__root.tsx': rootDocument(), + // SPEC J4.2/J4.14. Importing the RPC + // provider must preserve a default-export expression's observable effect. + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +let ready = false +let released = false +let complete: (() => void) | undefined +export default (ready = true) +export const readReady = createServerFn().handler(() => ready) +export const slow = createServerFn().handler(async () => { + if (!released) { + await new Promise<void>((resolve) => { complete = resolve }) + } + return 'completed' +}) +export const release = createServerFn().handler(() => { + released = true + complete?.() + return 'released' +}) +`, + 'src/client-entry.ts': `export { readReady, slow, release } from './fns' +export { getRouter } from './router' +`, + // SPEC J4.1/G8. The same real Zod schema + // validates server input and is consumed by a live browser component. + 'src/routes/index.tsx': `import { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { z } from 'zod' +const postSchema = z.object({ title: z.string().min(1) }) +export const createPost = createServerFn({ method: 'POST' }).validator(postSchema).handler(({ data }) => data.title) +export const Route = createFileRoute('/')({ component: PostForm }) +function PostForm() { + const [result, setResult] = useState('') + function submit() { + const form = { title: 'browser title' } + const parsed = postSchema.safeParse(form) + if (parsed.success) { + void createPost({ data: parsed.data }).then(setResult) + } + } + return <><button data-testid="submit" onClick={submit}>submit</button><p data-testid="result">{result}</p></> +} +`, +} + +describe.each(startBundlers)('%s build runtime outcomes', (bundler) => { + const cleanups: Array<() => Promise<void>> = [] + let served: Awaited<ReturnType<typeof serveStartBuild>> + beforeAll(async () => { + const build = await buildStart({ + bundler, + files, + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + }) + served = await serveStartBuild(build, { + registerCleanup: (cleanup) => { + cleanups.push(cleanup) + }, + }) + }, 60_000) + afterAll(async () => { + for (const cleanup of cleanups.reverse()) { + await cleanup() + } + }) + + test('a provider keeps the effect of a default-export expression over HTTP', async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + expect( + await page.page.evaluate(() => (globalThis as any).__app.readReady()), + ).toBe(true) + expect(page.errors).toEqual([]) + }) + + test('a validator schema also used by a component works after hydration', async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.page.locator('[data-testid=submit]').click() + await page.waitForText('browser title', { + selector: '[data-testid=result]', + }) + + expect(page.errors).toEqual([]) + }) + + test('aborting a browser RPC cancels the in-flight HTTP request', async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + // SPEC J4.1. Abort an actual in-flight + // browser HTTP call, after the request has left the page. No fake fetch. + const request = page.page.waitForRequest((req) => + req.url().includes('/_serverFn/'), + ) + await page.page.evaluate(() => { + const app = globalThis as any + app.abortController = new AbortController() + app.pendingCall = app.__app + .slow({ signal: app.abortController.signal }) + .then( + () => 'completed', + (error: Error) => error.name, + ) + }) + await request + const outcome = await page.page.evaluate(async () => { + const app = globalThis as any + app.abortController.abort() + await app.__app.release() + return await app.pendingCall + }) + expect(outcome).toBe('AbortError') + expect(page.errors).toEqual([]) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-source-maps.test.ts b/packages/start-plugin-core/tests/integration/start-build-source-maps.test.ts new file mode 100644 index 0000000000..e303a6a967 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-source-maps.test.ts @@ -0,0 +1,209 @@ +/** + * Source maps of real Start builds point at the code the user wrote: an + * error thrown in a server fn handler (called during SSR) or in a split + * route component (client) maps, through the emitted source map of the chunk + * it runs in, to the line of the throw in the user's file. The column is + * left out: minifiers map the throw to different tokens of the statement. + * (`<Hydrate>` children: hydrate-build.test.ts.) + */ +import { describe, expect, test } from 'vitest' +import { originalFrameOf } from '@tanstack/compiler-test-utils/build-harness' +import { buildStart, startBundlers } from '../build-harness' +import type { StartBundler } from '../build-harness' +import type { InlineConfig } from 'vite' + +const timeout = 60_000 + +/** 1-based line of the first occurrence of `needle` in `code`. */ +function lineOf(code: string, needle: string) { + return code.slice(0, code.indexOf(needle)).split('\n').length +} + +/** Vite's default build target for the client (the harness builds for `esnext`). */ +const viteDefaultClientTarget: InlineConfig = { + environments: { + client: { build: { target: 'baseline-widely-available' } }, + }, +} + +const builds = [ + { name: 'minified', minify: true }, + { name: 'unminified', minify: false }, +] + +const fns = `import { createServerFn } from '@tanstack/react-start' +import { prefix } from './prefix' +const suffix = '_THROW' +export const fail = createServerFn().handler(async () => { + throw new Error(prefix + '_HANDLER' + suffix) +}) +` + +describe.each(startBundlers)('%s build', (bundler) => { + test.each(builds)( + 'ssr: a throw in a server fn handler maps to its line in the source file ($name)', + async ({ minify }) => { + const { ssr } = await buildStart({ + bundler, + minify, + sourcemap: true, + files: { + 'src/fns.ts': fns, + 'src/prefix.ts': `export const prefix = 'MARK'\n`, + 'entry.ts': `export { fail } from './src/fns'\n`, + }, + }) + const { result: stack } = await ssr.run( + `try { await entry.fail() } catch (error) { return error.stack }`, + ) + expect(stack).toMatch(/MARK_HANDLER_THROW/) + const { file, line } = originalFrameOf(ssr, stack as string) ?? {} + expect({ file, line }).toEqual({ + file: 'src/fns.ts', + line: lineOf(fns, 'throw new Error'), + }) + }, + timeout, + ) + + // Import protection rewrites the denied import of the module (mock mode), + // and compiling drops the type-only lines before the throw. + test( + 'client, mock mode: a throw in a module whose denied import is mocked maps to its line in the source file (minified)', + async () => { + const { client } = await buildStart({ + bundler, + minify: true, + sourcemap: true, + files: { + 'node_modules/db-lib/package.json': JSON.stringify({ + name: 'db-lib', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/db-lib/index.js': `export const secret = 1\n`, + 'src/fail.ts': mockedImporter, + 'src/entry.ts': `export { fail } from './fail'\n`, + }, + entry: 'src/entry.ts', + start: { + importProtection: { + behavior: 'mock', + client: { specifiers: ['db-lib'] }, + }, + }, + }) + const { result: stack } = await client.run( + `try { entry.fail() } catch (error) { return error.stack }`, + ) + expect(stack).toMatch(/MARK_THROW/) + const { file, line } = originalFrameOf(client, stack as string) ?? {} + expect({ file, line }).toEqual({ + file: 'src/fail.ts', + line: lineOf(mockedImporter, 'throw new Error'), + }) + }, + timeout, + ) +}) + +const mockedImporter = `import { secret } from 'db-lib' +interface Options { + a: string + b: number +} +type Unused = Options +export function fail(options?: Options): string { + if (!options) { + throw new Error('MARK_THROW' + String(secret)) + } + return options.a +} +` + +const route = `import { createFileRoute } from '@tanstack/react-router' +import { prefix } from '../prefix' +export const Route = createFileRoute('/')({ component: Page }) +function Page(): never { + throw new Error(prefix + '_PAGE_THROW') +} +` + +/** + * Builds a Start app whose index route component throws, renders the + * component in the client build once its chunk loaded and maps the error's + * stack frame through the emitted source map. + */ +async function expectRouteThrowMapsToRouteFile( + bundler: StartBundler, + { minify, viteConfig }: { minify: boolean; viteConfig?: InlineConfig }, +) { + const { client } = await buildStart({ + bundler, + minify, + viteConfig, + sourcemap: true, + files: { + 'src/routes/index.tsx': route, + 'src/prefix.ts': `export const prefix = 'MARK'\n`, + 'src/router.ts': `import { routeTree } from './routeTree.gen' +export const getRouter = () => ({ routeTree }) +`, + 'entry.ts': `export { getRouter } from './src/router' +export { createElement, renderToString } from './harness/render' +`, + }, + }) + expect(client.where('_PAGE_THROW')).toBe('lazy') + // React renders the loaded split component; its throw is the render's. + const { result: stack } = await client.run(`const route = Object.values( + entry.getRouter().routeTree.children, +).find((candidate) => candidate.options.id === '/') +await route.options.component.preload() +try { + entry.renderToString(entry.createElement(route.options.component)) +} catch (error) { + return error.stack +}`) + expect(stack).toMatch(/MARK_PAGE_THROW/) + const { file, line } = originalFrameOf(client, stack as string) ?? {} + expect({ file, line }).toEqual({ + file: 'src/routes/index.tsx', + line: lineOf(route, 'throw new Error'), + }) +} + +// Control for the pin below. +test.each(builds)( + 'vite build: client: a throw in a split route component maps to its line in the route file ($name)', + (options) => expectRouteThrowMapsToRouteFile('vite', options), + timeout, +) + +// The harness builds for `esnext`; Vite's default client target lowers +// newer syntax, which moves code around once more. +// Source: review. +test( + "vite build with Vite's default client target: client: a throw in a split route component maps to its line in the route file (minified)", + () => + expectRouteThrowMapsToRouteFile('vite', { + minify: true, + viteConfig: viteDefaultClientTarget, + }), + timeout, +) + +// Bug: the router plugin's code splitter returns a source map of each route +// file it compiles, but unplugin's Rspack transform loader drops it when no +// earlier loader passed one in (`map == null ? map : res.map || map` in +// unplugin/dist/rspack/loaders/transform.mjs), so Rsbuild maps the chunk to +// the code splitter's output. Same cause as the router plugin's Rspack and +// webpack pins (router-plugin build-source-maps.test.ts). +// Source: upstream (unplugin). +// Impact: stack traces, devtools and error trackers of Rsbuild Start apps +// point at lines of generated code for every route file. +test.fails.each(builds)( + 'rsbuild build: client: a throw in a split route component maps to its line in the route file ($name)', + (options) => expectRouteThrowMapsToRouteFile('rsbuild', options), + timeout, +) diff --git a/packages/start-plugin-core/tests/integration/start-build-user-code.test.ts b/packages/start-plugin-core/tests/integration/start-build-user-code.test.ts new file mode 100644 index 0000000000..9ceeb75e27 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-user-code.test.ts @@ -0,0 +1,282 @@ +/** + * User code the Start compiler does not own keeps working in real + * production builds (SPEC J4.14, J4.17, G3, G12), through Start's Vite and + * Rsbuild plugins (build-harness.ts): + * - the `__NO_SIDE_EFFECTS__` annotations bundlers read still make an + * unused call disappear and a consumed one return its value; + * - decorators and import attributes written `assert`; + * - browser-only code inside the component of an `ssr: false` route next to + * a server fn: SSR and the server fn work without running it. + */ +import { describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' + +const timeout = 60_000 + +/** Records each call it gets, an effect a bundler cannot see through. */ +const trackModule = `export const track = (label) => { + ;(globalThis.__tracked ??= []).push(label) +} +` + +describe.each(startBundlers)('%s build', (bundler) => { + // Bundlers drop an unused call of a function annotated + // `__NO_SIDE_EFFECTS__` (Rolldown, Rspack): wherever the Start compiler + // moves or keeps the declaration (the provider of a server fn, the client + // caller), its annotation still reaches the bundler. The control module + // has no Start API: whatever the bundler drops there it must drop next to + // a server fn too. Each label is tracked when its call runs. + // Source: #8504 start-compiler-preserves-user-code.test.ts. + test.each([ + { + name: 'a function', + declaration: (name: string) => `/* #__NO_SIDE_EFFECTS__ */ +export function ${name}(label: string) { + track(label) + return 'label:' + label +}`, + }, + { + name: 'an arrow function', + declaration: (name: string) => `/* @__NO_SIDE_EFFECTS__ */ +export const ${name} = (label: string) => { + track(label) + return 'label:' + label +}`, + }, + ])( + 'an unused call of $name annotated __NO_SIDE_EFFECTS__ is dropped, a consumed one runs', + async ({ declaration }) => { + const files = { + 'src/track.ts': trackModule, + 'src/plain.ts': `import { track } from './track' +${declaration('plainLabel')} +plainLabel('plain-unused') +export const plainUsed = () => plainLabel('plain-used') +`, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { track } from './track' +${declaration('makeLabel')} +makeLabel('unused') +export const fn = createServerFn().handler(async () => makeLabel('handler')) +export const clientLabel = () => makeLabel('client') +`, + 'src/client-entry.ts': `export { fn, clientLabel } from './fns' +export { plainUsed } from './plain' +`, + 'src/ssr-entry.ts': `export { fn } from './fns' +export { plainUsed } from './plain' +${callByIdExports}`, + } + const { client, ssr } = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + const tracked = `[...(globalThis.__tracked ?? [])]` + const clientRun = + await client.run(`const values = [entry.clientLabel(), entry.plainUsed()] +return { values, tracked: ${tracked} }`) + const ssrRun = await ssr.run(`${callByIdPrelude}const values = [ + await callById(serverFnId(entry.fn)), + entry.plainUsed(), +] +return { values, tracked: ${tracked} }`) + // The control: the bundler drops the plain module's unused call. + for (const run of [clientRun, ssrRun]) { + expect( + (run.result as { tracked: Array<string> }).tracked, + ).not.toContain('plain-unused') + } + expect({ client: clientRun.result, ssr: ssrRun.result }).toEqual({ + client: { + values: ['label:client', 'label:plain-used'], + tracked: expect.not.arrayContaining(['unused']), + }, + ssr: { + values: ['label:handler', 'label:plain-used'], + tracked: expect.not.arrayContaining(['unused']), + }, + }) + }, + timeout, + ) + + /** + * Builds a module with a server fn, decorated classes (TypeScript + * `experimentalDecorators`, the form of the decorator-using libraries; the + * handler's `Repository`, the client's `Widget`) and a JSON import written + * with the deprecated `assert` keyword. + */ + const decoratedApp = () => { + const decorators = `export const tagged: Array<string> = [] +export function tag(name: string) { + return (target: unknown) => { + tagged.push(name) + return target + } +} +` + return buildStart({ + bundler, + files: { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { experimentalDecorators: true }, + }), + 'src/decorators.ts': decorators, + 'src/config.json': `{ "theme": "dark" }`, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { tag, tagged } from './decorators' +import config from './config.json' assert { type: 'json' } + +@tag('MARK_REPOSITORY') +class Repository { + read() { + return 'MARK_FROM_REPOSITORY' + } +} + +@tag('widget') +export class Widget { + label() { + return 'widget:' + config.theme + } +} + +export const fn = createServerFn().handler(async () => [ + new Repository().read(), + config.theme, + [...tagged].sort(), +]) +`, + 'src/client-entry.ts': `export { fn, Widget } from './fns' +export { tagged } from './decorators' +`, + 'src/ssr-entry.ts': `export { fn } from './fns' +${callByIdExports}`, + }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + } + + // Every output parses and runs: the decorators run, the JSON import + // works (`assert` reaches the bundler as `with`; `assert` stays supported, + // SPEC J2.17), the handler runs. + test( + 'a server fn module with decorated classes and an assert import attribute builds and runs', + async () => { + const { client, ssr } = await decoratedApp() + expect( + ( + await client.run( + `return { label: new entry.Widget().label(), tagged: entry.tagged }`, + ) + ).result, + ).toEqual({ + label: 'widget:dark', + // (`Repository`'s decorator may run on the client too: pinned below.) + tagged: expect.arrayContaining(['widget']), + }) + expect( + ( + await ssr.run( + `${callByIdPrelude}return await callById(serverFnId(entry.fn))`, + ) + ).result, + ).toEqual([ + 'MARK_FROM_REPOSITORY', + 'dark', + // The handler's class was decorated (how often a module's top-level + // code runs on the server is pinned elsewhere; `Widget` may go). + expect.arrayContaining(['MARK_REPOSITORY']), + ]) + }, + timeout, + ) + + // Bug: a class only a server fn handler uses stays in the client output + // (dead-code elimination never removes class declarations; same root + // cause as the pins "client: a class used by a server fn handler does + // not load its server-only import" and "client: the server-only module of + // a class only server code uses is not bundled"). A decorated class + // cannot even be dropped by the bundler (its decorators run when it is + // defined). + // Impact: the handler's class, and what its decorators and methods + // reference, ship to the client and run their decorators there. + test.fails( + 'the decorated class only a server fn handler uses is not in the client bundle', + async () => { + const { client } = await decoratedApp() + expect(client.where('MARK_FROM_REPOSITORY')).toBe('nowhere') + }, + timeout, + ) + + // A route with `ssr: false` whose component reads browser globals, in a + // module that also defines a server fn: SSR renders the route without + // running the component, the server fn answers its HTTP call, and the + // client renders the component. (That the route module's top-level code + // runs once per environment is the goal pinned in + // known-bugs-start-compiler.test.ts "SSR: a server fn module is + // initialised once ...". An unconditional top-level `window` read is no + // requirement, SPEC J4.14.) + test( + 'an ssr: false route with browser-only code in its component and a server fn', + async () => { + const files = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/canvas.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +export const getMessage = createServerFn().handler(async () => 'MARK_SERVER_MESSAGE') +export const Route = createFileRoute('/canvas')({ + ssr: false, + component: CanvasPage, +}) +function CanvasPage() { + const canvas = window.document.createElement('canvas') + return 'MARK_CANVAS_' + canvas.tagName +} +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/client-entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +`, + 'src/ssr-entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +export { getMessage } from './routes/canvas' +${callByIdExports}`, + } + const { client, ssr } = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + }) + const { result } = await ssr.run(`${callByIdPrelude}return { + page: await entry.renderPath(entry.getRouter().routeTree, '/canvas'), + message: await callById(serverFnId(entry.getMessage)), +}`) + expect(result).toEqual({ + page: expect.not.stringContaining('MARK_CANVAS'), + message: 'MARK_SERVER_MESSAGE', + }) + expect( + ( + await client.run( + `return await entry.renderPath(entry.getRouter().routeTree, '/canvas')`, + ) + ).result, + ).toContain('MARK_CANVAS_CANVAS') + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-dev-source-maps.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-dev-source-maps.test.ts new file mode 100644 index 0000000000..df984e8510 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-dev-source-maps.test.ts @@ -0,0 +1,208 @@ +/** + * Source maps in development of a server fn module (SPEC G6, dev as in + * build): Start's dev servers (Vite and Rsbuild, with Start's whole plugin) + * serve a map for the client module in which the server fn became an RPC + * stub and for every server module derived from the file (the SSR caller, + * the provider the server fn resolver loads), and a throw's position in + * each resolves to the user's file and line. The derived modules are found + * by what they hold, whatever they are (Vite: every module the SSR + * environment served for a call by id; Rsbuild: the emitted files), never + * by their ids or by the file a module graph attaches them to (SPEC §5.3). + * Maps are + * read with the standard consumer (`@tanstack/compiler-test-utils/ + * source-maps`). + * Source: #6667, #3828. + */ +import { readFile } from 'node:fs/promises' +import path from 'node:path' +import { describe, expect, test } from 'vitest' +import { + expectMapsTo, + inlineSourceMap, + positionAt, + tokenOffsets, +} from '@tanstack/compiler-test-utils/source-maps' +import { callServerFn, startDevServer, startRequestFiles } from '../dev-server' +import { + reportedErrors, + startRsbuildStartDevServer, +} from '../rsbuild-dev-server' +import type { AnySourceMap } from '@tanstack/compiler-test-utils/source-maps' +import type { RsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +const timeout = 60_000 + +/** A server fn whose handler throws, next to a client function that throws. */ +const fail = `import { createServerFn } from '@tanstack/react-start' +import { secret } from './secret' +export const getSecret = createServerFn().handler(async () => { + throw new Error('MARK_HANDLER_THROW ' + secret()) +}) +export function fail(): never { + throw new Error('MARK_CLIENT_THROW') +} +` +const files = { + 'src/fail.ts': fail, + 'src/secret.ts': `export const secret = () => 'MARK_SECRET'\n`, +} +const markers = ['MARK_HANDLER_THROW ', 'MARK_CLIENT_THROW'] + +/** The 1-based line of `marker` in the user's file: the line of its throw. */ +function lineOf(marker: string) { + return positionAt(fail, tokenOffsets(fail, { string: marker })[0]!).line +} + +/** + * Asserts that every marker `code` holds maps, through `map`, to the user's + * file at the marker's line. Returns the markers found. + */ +function expectMarkersMapToFile( + id: string, + code: string, + map: AnySourceMap | undefined, + root: string, + mapUrl?: string, +) { + const held = markers.filter((marker) => code.includes(marker)) + if (held.length === 0) { + return held + } + expect( + map, + `${id} holds ${held.join(', ')} and has a source map`, + ).toBeDefined() + for (const marker of held) { + const [offset] = tokenOffsets(code, { string: marker }, { filename: id }) + expect(offset, `the string ${marker} in ${id}`).toBeDefined() + expectMapsTo(map!, positionAt(code, offset!), { + file: 'src/fail.ts', + root, + mapUrl, + line: lineOf(marker), + }) + } + return held +} + +describe('vite dev server', () => { + test( + 'the client stub module and every server module of the file map a throw to its line in the file', + async () => { + const server = await startDevServer({ + start: {}, + listen: true, + files: { ...startRequestFiles, ...files }, + }) + // The client module, as the browser gets it (an inline map). + const { status, body } = await server.fetch('/src/fail.ts') + expect(status).toBe(200) + expect( + expectMarkersMapToFile( + '/src/fail.ts', + body, + inlineSourceMap(body), + server.root, + // (the module's URL path is relative to the app root) + path.join(server.root, 'src/fail.ts'), + ), + ).toEqual(['MARK_CLIENT_THROW']) + // A call by id loads the server modules of the file: the SSR caller + // and whatever module the resolver runs the handler from. Every module + // the SSR environment served is checked. + const { getSecret } = await server.import('/src/fail.ts') + await expect(callServerFn(server, getSecret)).rejects.toThrow( + /MARK_HANDLER_THROW/, + ) + const ssr = server.vite.environments.ssr + const modules = [...ssr.moduleGraph.idToModuleMap.values()] + const checked: Array<string> = [] + for (const module of modules) { + const result = module.transformResult + if (!result) { + continue + } + const held = expectMarkersMapToFile( + module.id ?? module.url, + result.code, + result.map ? (result.map as AnySourceMap) : undefined, + server.root, + // (the module's id is its file, with its query) + module.id ?? path.join(server.root, module.url), + ) + if (held.length > 0) { + checked.push(module.url) + } + } + // The handler's throw lives in at least one server module. + expect(checked.length, checked.join(', ')).toBeGreaterThanOrEqual(1) + expect( + modules.some((module) => + module.transformResult?.code.includes('MARK_HANDLER_THROW '), + ), + ).toBe(true) + }, + timeout, + ) +}) + +/** + * The map of the emitted file `file` of `environment` (relative to the + * environment's output directory, which Rsbuild's normalized config names): + * the `.map` next to it. + */ +async function emittedMap( + server: RsbuildDevServer, + environment: string, + file: string, +) { + const config = await server.rsbuild.getNormalizedConfig({ environment }) + const mapFile = path.resolve( + server.root, + config.output.distPath.root, + `${file}.map`, + ) + return readFile(mapFile, 'utf8').then( + (json) => JSON.parse(json) as AnySourceMap, + () => undefined, + ) +} + +describe('rsbuild dev server', () => { + test( + 'the client stub module and every server module of the file map a throw to its line in the file', + async () => { + const server = await startRsbuildStartDevServer({ + files: { + ...files, + 'src/entry.ts': `export { getSecret, fail } from './fail'\n`, + }, + config: { output: { sourceMap: { js: 'source-map' } } }, + }) + await server.settle() + expect(reportedErrors(server)).toEqual([]) + const checked: Record<string, Array<string>> = {} + for (const environment of ['client', 'ssr']) { + for (const [file, code] of Object.entries( + await server.outputs(environment), + )) { + const held = expectMarkersMapToFile( + `${environment}:${file}`, + code, + await emittedMap(server, environment, file), + server.root, + ) + if (held.length > 0) { + checked[`${environment}:${file}`] = held + } + } + } + const held = Object.values(checked).flat() + expect(held, Object.keys(checked).join(', ')).toContain( + 'MARK_CLIENT_THROW', + ) + expect(held).toContain('MARK_HANDLER_THROW ') + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-global-middleware.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-global-middleware.test.ts new file mode 100644 index 0000000000..0be6d333ee --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-global-middleware.test.ts @@ -0,0 +1,145 @@ +/** + * Global middleware of `createStart` in real production builds through + * Start's Vite and Rsbuild plugins (build-harness.ts): `src/start.ts` lists + * a function middleware with a `.client()` and a `.server()` that reads a + * server-only module, and a request middleware reading another one. The + * client bundle has no server code of either (SPEC J4.8, J4.12); a client + * call of a server fn without middleware of its own runs the global + * `.client()` once; the server runs the global `.server()` for an HTTP call + * by id; the request middleware runs for the SSR page (rendered by Start's + * own server entry) and for the HTTP call. + */ +import { describe, expect, onTestFinished, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' +import { + openAppPage, + rootDocument, + serveStartBuild, + startPageEntries, +} from './start-compose-app' + +const timeout = 60_000 + +const files = { + ...startPageEntries, + 'src/routes/__root.tsx': rootDocument(), + 'src/audit.server.ts': `export const audit = () => 'MARK_AUDIT_SERVER'\n`, + 'src/auth.server.ts': `export const authenticate = (_request: Request) => 'MARK_AUTH_USER'\n`, + 'src/middleware.ts': `import { createMiddleware } from '@tanstack/react-start' +import { audit } from './audit.server' +import { authenticate } from './auth.server' +export const log = createMiddleware({ type: 'function' }) + .client(({ next }) => { + ;(((globalThis as Record<string, unknown>).__clientLog ??= []) as Array<string>).push('log') + return next() + }) + .server(({ next }) => next({ context: { audited: audit() } })) +export const auth = createMiddleware({ type: 'request' }).server( + ({ next, request }) => next({ context: { user: authenticate(request) } }), +) +`, + 'src/start.ts': `import { createStart } from '@tanstack/react-start' +import { auth, log } from './middleware' +export const startInstance = createStart(() => ({ + requestMiddleware: [auth], + functionMiddleware: [log], +})) +`, + // A server fn with no middleware of its own. (Its handler's `context` + // type does not carry the global middleware's context: the e2e apps cast + // it the same way.) + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const whoAmI = createServerFn().handler(async ({ context }) => { + const globalContext = context as unknown as { audited: string; user: string } + return [globalContext.audited, globalContext.user] +}) +`, + 'src/routes/index.tsx': `import { useState } from 'react' +import { createFileRoute } from '@tanstack/react-router' +import { whoAmI } from '../fns' +export const Route = createFileRoute('/')({ + loader: () => whoAmI(), + component: Page, +}) +function Page() { + const [called, setCalled] = useState('') + return <><p>{Route.useLoaderData().join(' ')}</p><button data-testid="call" onClick={() => whoAmI().then((value) => setCalled(value.join(' ')))}>call</button><p data-testid="called">{called}</p></> +} +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/client-entry.ts': `export { whoAmI } from './fns'\n`, + 'src/ssr-entry.ts': `export { whoAmI } from './fns' +${callByIdExports}`, +} + +describe.each(startBundlers)('%s build', (bundler) => { + test( + 'global function and request middleware: no server code in the client, .client() runs on a client call, .server() and the request middleware run on the server', + async () => { + const build = await buildStart({ + bundler, + files, + registerCleanup: onTestFinished, + }) + const { client, ssr } = build + expect({ + audit: client.where('MARK_AUDIT_SERVER'), + auth: client.where('MARK_AUTH_USER'), + modules: client.where(/audit\.server|auth\.server/), + }).toEqual({ audit: 'nowhere', auth: 'nowhere', modules: 'nowhere' }) + const served = await serveStartBuild(build, { + registerCleanup: onTestFinished, + }) + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + const requests: Array<{ url: string; method: string }> = [] + page.page.on('request', (request) => { + const url = new URL(request.url()) + if (url.pathname.startsWith('/_serverFn/')) { + requests.push({ + url: url.pathname + url.search, + method: request.method(), + }) + } + }) + await page.page.locator('[data-testid=call]').click() + await page.waitForText('MARK_AUDIT_SERVER MARK_AUTH_USER', { + selector: '[data-testid=called]', + }) + expect( + await page.page.evaluate(() => (globalThis as any).__clientLog), + ).toEqual(['log']) + expect(page.serverFnRequests).toHaveLength(1) + expect(page.errors).toEqual([]) + const url = await page.page.evaluate( + () => (globalThis as any).__app.whoAmI.url as string, + ) + expect(requests).toEqual([{ url, method: 'GET' }]) + const { result } = + await ssr.run(`${callByIdPrelude}const response = await entry.startServerEntry.fetch( + new Request('http://localhost/'), +) +return { + byId: await callById(serverFnId(${JSON.stringify(url)})), + page: { status: response.status, html: await response.text() }, +}`) + const { byId, page: renderedPage } = result as { + byId: unknown + page: { status: number; html: string } + } + expect(byId).toEqual(['MARK_AUDIT_SERVER', 'MARK_AUTH_USER']) + expect(renderedPage.status).toBe(200) + expect(renderedPage.html).toContain('MARK_AUDIT_SERVER MARK_AUTH_USER') + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-jsx-and-builders.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-jsx-and-builders.test.ts new file mode 100644 index 0000000000..8cb3af117e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-jsx-and-builders.test.ts @@ -0,0 +1,141 @@ +/** + * Two inputs a review found untested, in one real Vite production build through + * Start's plugin (build-harness.ts), next to their compiler-level rows in + * start-compiler-v2-inputs.test.ts: + * - `.jsx` modules (SPEC §2.1, J4.1, J2.1): a `.jsx` server fn module with + * JSX, and a `.jsx` route file whose component is split; + * - a server fn builder reused as middleware (J4.5, J4.8): + * `createServerFn().middleware([auth])` passed in another server fn's + * `.middleware([...])`. + */ +import { afterAll, beforeAll, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, +} from '../build-harness' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const files = { + 'src/db.server.js': `export const db = { user: () => 'MARK_USER' }\n`, + 'src/fns.jsx': `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +export const getUser = createServerFn().handler(async () => db.user()) +export function Badge({ name }) { + return <span className="badge">{name}</span> +} +`, + 'src/routes/index.jsx': `import { createFileRoute } from '@tanstack/react-router' +import { Badge } from '../fns' +export const Route = createFileRoute('/')({ component: Page }) +function Page() { + return <main>MARK_JSX_PAGE <Badge name="Ada" /></main> +} +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/audit.server.ts': `export const audit = () => 'MARK_AUDIT_USER'\n`, + 'src/builders.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { audit } from './audit.server' +export const auth = createMiddleware({ type: 'function' }) + .client(({ next }) => { + ;(((globalThis as Record<string, unknown>).__clientCalls ??= []) as Array<string>).push('auth') + return next() + }) + .server(({ next }) => next({ context: { user: audit() } })) +const authed = createServerFn().middleware([auth]) +export const whoAmI = createServerFn() + .middleware([authed]) + .handler(async ({ context }) => context.user) +`, + 'src/client-entry.ts': `export { getUser, Badge } from './fns' +export { whoAmI } from './builders' +export { getRouter } from './router' +export { createElement, renderPath, renderToString } from '../harness/render' +`, + 'src/ssr-entry.ts': `export * from './client-entry' +${callByIdExports}`, +} + +// One build for both rows. +let build: StartBuild +let dispose: (() => Promise<void>) | undefined +beforeAll(async () => { + build = await buildStart({ + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) +}, timeout) +afterAll(() => dispose?.()) + +test( + 'vite build: a .jsx server fn module and a .jsx route file: the client calls by id without the handler, the route component is lazy and renders', + async () => { + const { client, ssr } = build + expect({ + handler: client.where('MARK_USER'), + page: client.where('MARK_JSX_PAGE'), + }).toEqual({ handler: 'nowhere', page: 'lazy' }) + const clientRun = ( + await client.run(`${requestsOfPrelude}return { + url: entry.getUser.url, + requests: await requestsOf(entry.getUser), + badge: entry.renderToString(entry.createElement(entry.Badge, { name: 'Ada' })), + page: await entry.renderPath(entry.getRouter().routeTree, '/'), +}`) + ).result as { + url: string + requests: Array<unknown> + badge: string + page: string + } + expect(clientRun.requests).toEqual([{ url: clientRun.url, method: 'GET' }]) + expect(clientRun.badge).toBe('<span class="badge">Ada</span>') + expect(clientRun.page).toContain( + 'MARK_JSX_PAGE <span class="badge">Ada</span>', + ) + const { result } = await ssr.run(`${callByIdPrelude}return { + byId: await callById(serverFnId(${JSON.stringify(clientRun.url)})), + page: await entry.renderPath(entry.getRouter().routeTree, '/'), +}`) + expect(result).toEqual({ + byId: 'MARK_USER', + page: expect.stringContaining( + 'MARK_JSX_PAGE <span class="badge">Ada</span>', + ), + }) + }, + timeout, +) + +test( + 'vite build: a server fn builder reused as middleware: the client runs auth.client() and has no auth.server() code; the server runs auth.server() then the handler', + async () => { + const { client, ssr } = build + expect(client.where(/MARK_AUDIT_USER|audit\.server/)).toBe('nowhere') + const clientRun = ( + await client.run(`${requestsOfPrelude}const requests = await requestsOf(entry.whoAmI) +return { + url: entry.whoAmI.url, + requests: requests.length, + clientCalls: globalThis.__clientCalls, +}`) + ).result as { url: string; requests: number; clientCalls: Array<string> } + expect(clientRun.requests).toBe(1) + expect(clientRun.clientCalls).toEqual(['auth']) + const { result } = await ssr.run(`${callByIdPrelude}return { + byId: await callById(serverFnId(${JSON.stringify(clientRun.url)})), + ssr: await entry.whoAmI(), +}`) + expect(result).toEqual({ byId: 'MARK_AUDIT_USER', ssr: 'MARK_AUDIT_USER' }) + }, + timeout, +) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-libraries.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-libraries.test.ts new file mode 100644 index 0000000000..ff928f0972 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-libraries.test.ts @@ -0,0 +1,217 @@ +/** + * Libraries written with Start APIs (uncompiled source) in real production + * builds through Start's Vite and Rsbuild plugins (build-harness.ts), SPEC + * J4.16, G11, J4.3: (a) a package whose only Start peer is + * `@tanstack/start-client-core`, importing its APIs from there; (b) a + * package without a Start peer, which the user bundles explicitly (Vite + * `noExternal`, Rsbuild `source.include`); (c) the package of (a) linked + * into `node_modules` by a real symlink from a directory outside it + * (pnpm-style, #8139 as quoted). Each exports an isomorphic fn and a server + * fn with a secret, and reads a module the app shares with it. Asserted + * per environment: the implementation of that environment runs, the ids of + * one build agree between client and server, the client has no server + * marker, the shared module initialises once and is one instance, and no + * module throws while evaluating (TDZ). No pin unless a compiler cause is + * shown (SPEC §9). + */ +import { describe, expect, test } from 'vitest' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import type { StartBundler } from '../build-harness' + +const timeout = 60_000 + +/** + * The source of a library `tag` importing Start's APIs from `startPackage`: + * records its own initialisation, reads the shared module, and exports an + * isomorphic fn, a server fn whose handler reads the library's secret, and + * the shared module's token. + */ +function libraryModule(tag: string, startPackage: string) { + return `import { createIsomorphicFn, createServerFn } from '${startPackage}' +import { shared } from 'lib-shared' +import { secret } from './secret.js' +globalThis.__inits_${tag} = (globalThis.__inits_${tag} ?? 0) + 1 +export const where = createIsomorphicFn() + .server(() => 'MARK_${tag}_SERVER') + .client(() => 'MARK_${tag}_CLIENT') +export const fn = createServerFn().handler(async () => secret()) +export const sharedToken = () => shared.token +` +} + +/** The files of a library package at `dir` (its `package.json` and modules). */ +function library( + dir: string, + name: string, + tag: string, + options: { peer?: string; startPackage: string }, +) { + return { + [`${dir}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: { '.': './index.js' }, + ...(options.peer && { peerDependencies: { [options.peer]: '*' } }), + }), + [`${dir}/index.js`]: libraryModule(tag, options.startPackage), + [`${dir}/secret.js`]: `export const secret = () => 'MARK_${tag}_SECRET'\n`, + } +} + +const files = { + // The module the app and every library share: one instance per + // environment. + 'node_modules/lib-shared/package.json': JSON.stringify({ + name: 'lib-shared', + type: 'module', + exports: { '.': './index.js' }, + }), + 'node_modules/lib-shared/index.js': `globalThis.__inits_SHARED = (globalThis.__inits_SHARED ?? 0) + 1 +export const shared = { token: 'MARK_SHARED_' + Math.random() } +`, + // (a) peer on start-client-core, framework-agnostic imports. + ...library('node_modules/lib-peer', 'lib-peer', 'PEER', { + peer: '@tanstack/start-client-core', + startPackage: '@tanstack/start-client-core', + }), + // (b) no Start peer: the app bundles it explicitly. + ...library('node_modules/lib-bundled', 'lib-bundled', 'BUNDLED', { + startPackage: '@tanstack/react-start', + }), + // (c) the package of (a), outside node_modules, linked into it. + ...library('packages/lib-linked', 'lib-linked', 'LINKED', { + peer: '@tanstack/start-client-core', + startPackage: '@tanstack/start-client-core', + }), + 'src/app.ts': `import { shared } from 'lib-shared' +import * as peer from 'lib-peer' +import * as bundled from 'lib-bundled' +import * as linked from 'lib-linked' +export const libraries = { peer, bundled, linked } +export const appToken = () => shared.token +`, + 'src/client-entry.ts': `export { libraries, appToken } from './app'\n`, + 'src/ssr-entry.ts': `export { libraries, appToken } from './app' +${callByIdExports}`, +} + +const tags = { peer: 'PEER', bundled: 'BUNDLED', linked: 'LINKED' } + +/** How each bundler bundles `lib-bundled` (b) into the server build. */ +const bundleExplicitly: Record< + StartBundler, + Pick<Parameters<typeof buildStart>[0], 'viteConfig' | 'rsbuildConfig'> +> = { + vite: { + viteConfig: { + environments: { ssr: { resolve: { noExternal: ['lib-bundled'] } } }, + }, + }, + rsbuild: { + rsbuildConfig: { + environments: { + ssr: { source: { include: [/node_modules[\\/]lib-bundled[\\/]/] } }, + }, + }, + }, +} + +/** What a script of either environment reports about every library. */ +const report = `const report = {} +for (const [name, lib] of Object.entries(entry.libraries)) { + report[name] = { + where: lib.where(), + url: lib.fn.url, + sameShared: lib.sharedToken() === entry.appToken(), + inits: globalThis['__inits_' + name.toUpperCase()], + } +} +report.sharedInits = globalThis.__inits_SHARED +` + +describe.each(startBundlers)('%s build', (bundler) => { + test( + 'a start-client-core peer library, an explicitly bundled library and a symlinked library each run the implementation of each environment, agree on ids and share one module instance', + async () => { + const { client, ssr } = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + // The app depends on the libraries, as an installed one; the peer + // of (a) and (c) resolves like a dependency pnpm installed for + // them. + packageJson: { + name: 'app', + private: true, + type: 'module', + dependencies: { + 'lib-peer': '*', + 'lib-bundled': '*', + 'lib-linked': '*', + }, + }, + symlinks: { + ...workspacePackageLinks(['@tanstack/start-client-core']), + 'node_modules/lib-linked': 'packages/lib-linked', + }, + ...bundleExplicitly[bundler], + }) + for (const tag of Object.values(tags)) { + expect( + { + server: client.where(`MARK_${tag}_SERVER`), + secret: client.where(`MARK_${tag}_SECRET`), + }, + tag, + ).toEqual({ server: 'nowhere', secret: 'nowhere' }) + } + const clientRun = ( + await client.run(`${requestsOfPrelude}${report} +report.requests = (await requestsOf(entry.libraries.peer.fn)).length +return report`) + ).result as Record<string, any> + const ssrRun = ( + await ssr.run(`${callByIdPrelude}${report} +report.byId = {} +report.called = {} +for (const [name, lib] of Object.entries(entry.libraries)) { + report.byId[name] = await callById(serverFnId(lib.fn)) + report.called[name] = await lib.fn() +} +return report`) + ).result as Record<string, any> + for (const [name, tag] of Object.entries(tags)) { + expect(clientRun[name], `client ${name}`).toEqual({ + where: `MARK_${tag}_CLIENT`, + url: expect.any(String), + sameShared: true, + inits: 1, + }) + expect(ssrRun[name], `ssr ${name}`).toEqual({ + where: `MARK_${tag}_SERVER`, + url: clientRun[name].url, + sameShared: true, + // (The SSR caller and provider instances of a server fn module + // are the known-bugs pin "SSR: a server fn module is initialised + // once ...".) + inits: expect.any(Number), + }) + expect(ssrRun.byId[name], `by id ${name}`).toBe(`MARK_${tag}_SECRET`) + expect(ssrRun.called[name], `ssr call ${name}`).toBe( + `MARK_${tag}_SECRET`, + ) + } + expect(clientRun.sharedInits).toBe(1) + expect(ssrRun.sharedInits).toBe(1) + expect(clientRun.requests).toBe(1) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-side-effect-hints.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-side-effect-hints.test.ts new file mode 100644 index 0000000000..9304e85bb2 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-side-effect-hints.test.ts @@ -0,0 +1,443 @@ +/** + * Start's hard rule (SPEC J4.12) in real production builds, through Start's + * Vite and Rsbuild plugins (build-harness.ts), with the side-effect hints + * bundlers read varied: the server side of each construct (handler, + * validator, middleware `.server()`, `createServerOnlyFn`) depends on + * packages declaring `sideEffects: true`, `false` and an array, and a + * server fn module has top-level initializers with and without + * `@__PURE__`. The surviving client code works and calls the server by id. + * One app per bundler also covers a dynamic `import()` inside a handler, a + * server fn module consumed statically, dynamically and through a barrel, a + * validator schema a client form also uses and non-JS modules whose text + * contains `createServerFn(` (SPEC J4.1, J4.7, J4.12, J4.14, G2, G3, §2.1). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + buildStart, + callByIdExports, + callByIdPrelude, + startBundlers, +} from '../build-harness' +import type { StartBuild, StartBundler } from '../build-harness' + +const timeout = 60_000 + +/** + * A dependency package `name` with the given `sideEffects` hint: its module + * records that it loaded and exports one function per construct, each + * returning a marker that names the package (`MARK_<TAG>_<CONSTRUCT>`). + * The array hint names a second module with a side effect, imported by the + * first. + */ +function dependency( + name: string, + tag: string, + sideEffects: boolean | Array<string>, +) { + const constructs = ['Handler', 'Validator', 'Middleware', 'ServerOnly'] + return { + [`node_modules/${name}/package.json`]: JSON.stringify({ + name, + type: 'module', + exports: { '.': './index.js', './effect': './effect.js' }, + sideEffects, + }), + [`node_modules/${name}/effect.js`]: `globalThis.MARK_${tag}_EFFECT = 'loaded'\n`, + [`node_modules/${name}/index.js`]: `import './effect.js' +globalThis.MARK_${tag}_LOADED = 'loaded' +${constructs + .map( + (construct) => + `export const for${construct} = () => 'MARK_${tag}_${construct.toUpperCase()}'`, + ) + .join('\n')} +`, + } +} + +/** The dependency packages, by the hint they declare. */ +const dependencies = { + ...dependency('deps-true', 'TRUE', true), + ...dependency('deps-false', 'FALSE', false), + ...dependency('deps-array', 'ARRAY', ['./effect.js']), +} +const dependencyTags = ['TRUE', 'FALSE', 'ARRAY'] +const dependencyImports = `import * as depsTrue from 'deps-true' +import * as depsFalse from 'deps-false' +import * as depsArray from 'deps-array' +` +/** One marker per package, from the function of `construct`. */ +const marksOf = (construct: string) => + `[depsTrue.for${construct}(), depsFalse.for${construct}(), depsArray.for${construct}()]` +const expectedMarks = (construct: string) => + dependencyTags.map((tag) => `MARK_${tag}_${construct.toUpperCase()}`) + +/** + * `src/text.ts`: the non-JS modules' text. `?raw` is Vite's (Rspack + * parses the query-less `.md` as JavaScript: not a Start matter), so the + * Rsbuild app imports the JSON only. + */ +const textModule = (bundler: StartBundler) => + bundler === 'vite' + ? `import notes from './notes.md?raw' +import data from './data.json' +export const rawText = () => ({ notes, code: data.code }) +` + : `import data from './data.json' +export const rawText = () => ({ code: data.code }) +` + +const files = { + ...dependencies, + // Each construct in a module of its own, so a leak names its construct. + 'src/fns/handler.ts': `import { createServerFn } from '@tanstack/react-start' +${dependencyImports}export const viaHandler = createServerFn().handler(async () => ${marksOf('Handler')}) +`, + 'src/fns/validator.ts': `import { createServerFn } from '@tanstack/react-start' +${dependencyImports}export const viaValidator = createServerFn() + .validator((input: unknown) => ({ input: String(input), marks: ${marksOf('Validator')} })) + .handler(async ({ data }) => data) +`, + 'src/fns/middleware.ts': `import { createMiddleware, createServerFn } from '@tanstack/react-start' +${dependencyImports}const marks = createMiddleware({ type: 'function' }).server(({ next }) => + next({ context: { marks: ${marksOf('Middleware')} } }), +) +export const viaMiddleware = createServerFn() + .middleware([marks]) + .handler(async ({ context }) => context.marks) +`, + 'src/fns/server-only.ts': `import { createServerOnlyFn } from '@tanstack/react-start' +${dependencyImports}export const serverOnlyMarks = createServerOnlyFn(() => ${marksOf('ServerOnly')}) +`, + // Top-level initializers next to a server fn: one annotated pure, two + // not; the client reads one of them, the handler all three and a + // server-only store (a neutral file name: the compiler alone decides its + // absence). + 'src/registry.ts': `export function createRegistry(name: string) { + ;((globalThis as Record<string, unknown>).__registries ??= []) as Array<string> + ;((globalThis as Record<string, unknown>).__registries as Array<string>).push(name) + return { name } +} +`, + 'src/secret-store.ts': `export const secretStore = { count: () => 'MARK_SECRET_STORE' }\n`, + 'src/init.ts': `import { createServerFn } from '@tanstack/react-start' +import { createRegistry } from './registry' +import { secretStore } from './secret-store' +const pureRegistry = /*#__PURE__*/ createRegistry('MARK_PURE_REGISTRY') +const registry = createRegistry('MARK_REGISTRY') +const handlerOnly = createRegistry('MARK_HANDLER_ONLY_REGISTRY') +export const countSecrets = createServerFn().handler(async () => [ + registry.name, + pureRegistry.name, + secretStore.count(), + handlerOnly.name, +]) +export const registryName = () => registry.name +`, + // A dynamic import inside the handler. + 'src/vault.server.ts': `export const secret = () => 'MARK_VAULT_SECRET'\n`, + 'src/fns/dynamic.ts': `import { createServerFn } from '@tanstack/react-start' +export const readVault = createServerFn().handler(async () => { + const { secret } = await import('../vault.server') + return secret() +}) +`, + // A server fn module with secret canaries, consumed three ways. + 'src/canaries/handler-canary.ts': `export const canaryHandler = (data: unknown) => + 'MARK_CANARY_HANDLER:' + JSON.stringify(data) +`, + 'src/canaries/validator-canary.ts': `export const canaryValidator = (input: unknown) => { + if (input === 'MARK_CANARY_VALIDATOR') { + throw new Error('rejected') + } + return input +} +`, + 'src/fns/target.ts': `import { createServerFn } from '@tanstack/react-start' +import { canaryHandler } from '../canaries/handler-canary' +import { canaryValidator } from '../canaries/validator-canary' +;(((globalThis as Record<string, unknown>).__targetInits ??= []) as Array<string>).push('target') +export const getTarget = createServerFn() + .validator((input: unknown) => canaryValidator(input)) + .handler(async ({ data }) => canaryHandler(data)) +`, + 'src/fns/index.ts': `export * from './target'\n`, + // A schema the client form also validates with, and one only a + // validator uses. + 'src/post-schema.ts': `export interface Post { + title: string +} +export function PostSchema(input: unknown): Post { + if (typeof (input as Post | null)?.title !== 'string') { + throw new Error('MARK_INVALID_POST') + } + return { title: (input as Post).title } +} +`, + 'src/draft-schema.ts': `export function DraftSchema(input: unknown): { body: string } { + if (typeof (input as { body?: unknown } | null)?.body !== 'string') { + throw new Error('MARK_INVALID_DRAFT') + } + return { body: (input as { body: string }).body } +} +`, + 'src/fns/posts.ts': `import { createServerFn } from '@tanstack/react-start' +import { PostSchema } from '../post-schema' +import { DraftSchema } from '../draft-schema' +export const createPost = createServerFn() + .validator(PostSchema) + .handler(async ({ data }) => ({ saved: data })) +export const saveDraft = createServerFn() + .validator(DraftSchema) + .handler(async ({ data }) => ({ saved: data })) +export function validateForm(input: unknown) { + return PostSchema(input) +} +`, + // Non-JS modules whose text contains the detection pattern. + 'src/notes.md': `# Notes + +Call \`createServerFn(\` from a route; \`createMiddleware(\` too. +`, + 'src/data.json': JSON.stringify({ + code: 'createServerFn().handler(() => 1)', + }), + 'src/client-entry.ts': `export { viaHandler } from './fns/handler' +export { viaValidator } from './fns/validator' +export { viaMiddleware } from './fns/middleware' +export { serverOnlyMarks } from './fns/server-only' +export { countSecrets, registryName } from './init' +export { readVault } from './fns/dynamic' +export { getTarget as viaStatic } from './fns/target' +export const viaDynamic = async () => (await import('./fns/target')).getTarget +export { getTarget as viaBarrel } from './fns' +export { createPost, saveDraft, validateForm } from './fns/posts' +export { rawText } from './text' +`, + 'src/ssr-entry.ts': `export * from './client-entry' +${callByIdExports}`, +} + +/** + * The client's server fns, as a client script returns them: each by its + * public URL (the server fn base, then its id). + */ +const clientUrls = `return { + viaHandler: entry.viaHandler.url, + viaValidator: entry.viaValidator.url, + viaMiddleware: entry.viaMiddleware.url, + countSecrets: entry.countSecrets.url, + readVault: entry.readVault.url, + viaStatic: entry.viaStatic.url, + viaDynamic: (await entry.viaDynamic()).url, + viaBarrel: entry.viaBarrel.url, + createPost: entry.createPost.url, + saveDraft: entry.saveDraft.url, +}` + +describe.each(startBundlers)('%s build', (bundler) => { + // One build for every row; the runs are independent (browser pages and + // Node processes). + let build: StartBuild + let urls: Record<string, string> + let dispose: (() => Promise<void>) | undefined + beforeAll(async () => { + build = await buildStart({ + bundler, + files: { ...files, 'src/text.ts': textModule(bundler) }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + urls = (await build.client.run(clientUrls)).result as Record<string, string> + }, timeout) + afterAll(() => dispose?.()) + + describe.concurrent('server code under side-effect hints', () => { + test.each([ + { construct: 'a handler', name: 'viaHandler', tag: 'Handler' }, + { construct: 'a validator', name: 'viaValidator', tag: 'Validator' }, + { + construct: 'a middleware .server()', + name: 'viaMiddleware', + tag: 'Middleware', + }, + ])( + "$construct's dependencies (sideEffects true, false, array) are not in the client bundle, and the server fn runs by id", + async ({ name, tag }) => { + const marks = expectedMarks(tag) + for (const mark of marks) { + expect(build.client.where(mark), mark).toBe('nowhere') + } + const { result } = await build.ssr.run( + `${callByIdPrelude}return await callById(serverFnId(${JSON.stringify(urls[name])}), 'input')`, + ) + expect(result).toEqual( + tag === 'Validator' ? { input: 'input', marks } : marks, + ) + }, + ) + + test("a createServerOnlyFn body's dependencies are not in the client bundle; the server runs it, the client is refused", async () => { + const marks = expectedMarks('ServerOnly') + for (const mark of marks) { + expect(build.client.where(mark), mark).toBe('nowhere') + } + expect( + (await build.ssr.run(`return entry.serverOnlyMarks()`)).result, + ).toEqual(marks) + const { result } = await build.client.run( + `try { return { value: entry.serverOnlyMarks() } } catch (error) { return { name: error.name, message: error.message } }`, + ) + // (it threw: the call is refused) + expect(result).toEqual({ + name: expect.any(String), + message: expect.any(String), + }) + }) + + test('no dependency package loads in the client, whatever its hint', async () => { + for (const tag of dependencyTags) { + expect(build.client.where(`MARK_${tag}_LOADED`), tag).toBe('nowhere') + expect(build.client.where(`MARK_${tag}_EFFECT`), tag).toBe('nowhere') + } + const { result } = await build.client.run( + `return Object.keys(globalThis).filter((key) => key.startsWith('MARK_'))`, + ) + expect(result).toEqual([]) + }) + + // The initializer the client reads runs once there; the pure one may + // go (SPEC G3: eager vs lazy initialization of a server-only binding is + // not pinned); the server-only store, and the unannotated initializer + // only the handler reads, never reach the client (G16: a bundler must + // keep a call it cannot prove pure). + test('top-level initializers with and without @__PURE__ next to a server fn', async () => { + expect([ + build.client.where('MARK_SECRET_STORE'), + build.client.where('MARK_HANDLER_ONLY_REGISTRY'), + ]).toEqual(['nowhere', 'nowhere']) + const client = ( + await build.client.run( + `return { name: entry.registryName(), registries: globalThis.__registries }`, + ) + ).result as { name: string; registries: Array<string> } + expect(client.name).toBe('MARK_REGISTRY') + expect( + client.registries.filter((name) => name === 'MARK_REGISTRY'), + ).toEqual(['MARK_REGISTRY']) + expect( + client.registries.filter((name) => name === 'MARK_PURE_REGISTRY') + .length, + ).toBeLessThanOrEqual(1) + const ssr = ( + await build.ssr.run(`${callByIdPrelude}return { + byId: await callById(serverFnId(${JSON.stringify(urls.countSecrets)})), + name: entry.registryName(), + registries: globalThis.__registries, +}`) + ).result as { + byId: Array<string> + name: string + registries: Array<string> + } + expect(ssr.byId).toEqual([ + 'MARK_REGISTRY', + 'MARK_PURE_REGISTRY', + 'MARK_SECRET_STORE', + 'MARK_HANDLER_ONLY_REGISTRY', + ]) + expect(ssr.name).toBe('MARK_REGISTRY') + // (How many times the SSR bundle initialises the module is the pin + // "SSR: a server fn module is initialised once and shares its state + // with SSR code" of known-bugs-start-compiler.test.ts: the SSR + // caller and the provider are two instances today.) + expect(ssr.registries).toEqual( + expect.arrayContaining(['MARK_PURE_REGISTRY', 'MARK_REGISTRY']), + ) + }) + }) + + test('a dynamic import inside a handler: no client chunk carries its target, the call by id returns its value', async () => { + expect(build.client.where('MARK_VAULT_SECRET')).toBe('nowhere') + const { result } = await build.ssr.run( + `${callByIdPrelude}return await callById(serverFnId(${JSON.stringify(urls.readVault)}))`, + ) + expect(result).toBe('MARK_VAULT_SECRET') + }) + + // Source: docs server-functions.md ("avoid dynamic imports"). + test('a server fn module consumed statically, dynamically and through a barrel: one id, no canary in the client, top-level code once per env', async () => { + expect(urls.viaDynamic).toBe(urls.viaStatic) + expect(urls.viaBarrel).toBe(urls.viaStatic) + expect( + build.client.where(/MARK_CANARY_HANDLER|MARK_CANARY_VALIDATOR/), + ).toBe('nowhere') + const client = ( + await build.client.run(`await entry.viaDynamic() +return globalThis.__targetInits`) + ).result + expect(client).toEqual(['target']) + const { result } = await build.ssr.run(`${callByIdPrelude}return { + byId: await callById(serverFnId(${JSON.stringify(urls.viaStatic)}), 'in'), + rejected: await callById(serverFnId(${JSON.stringify(urls.viaStatic)}), 'MARK_CANARY_VALIDATOR').then( + () => 'resolved', + (error) => error.message, + ), + ssr: await entry.viaStatic({ data: 'ssr' }), + inits: globalThis.__targetInits, +}`) + expect(result).toEqual({ + byId: 'MARK_CANARY_HANDLER:"in"', + rejected: 'rejected', + ssr: 'MARK_CANARY_HANDLER:"ssr"', + // Once per SSR instance of the module (the SSR caller and provider + // instances are the known-bugs pin cited above). + inits: expect.arrayContaining(['target']), + }) + }) + + test('a validator schema the client form also uses stays with its behaviour; a validator-only schema is gone', async () => { + expect(build.client.where('MARK_INVALID_DRAFT')).toBe('nowhere') + const client = ( + await build.client.run(`return { + valid: entry.validateForm({ title: 'hello' }), + invalid: (() => { try { entry.validateForm({}) } catch (error) { return error.message } })(), +}`) + ).result + expect(client).toEqual({ + valid: { title: 'hello' }, + invalid: 'MARK_INVALID_POST', + }) + const { result } = await build.ssr + .run(`${callByIdPrelude}const call = (url, data) => + callById(serverFnId(url), data).then((value) => ({ value }), (error) => ({ error: error.message })) +return { + post: await call(${JSON.stringify(urls.createPost)}, { title: 'hello' }), + invalidPost: await call(${JSON.stringify(urls.createPost)}, { nope: true }), + draft: await call(${JSON.stringify(urls.saveDraft)}, { body: 'draft' }), + invalidDraft: await call(${JSON.stringify(urls.saveDraft)}, {}), +}`) + expect(result).toEqual({ + post: { value: { saved: { title: 'hello' } } }, + invalidPost: { error: 'MARK_INVALID_POST' }, + draft: { value: { saved: { body: 'draft' } } }, + invalidDraft: { error: 'MARK_INVALID_DRAFT' }, + }) + }) + + // Source: #5525 (regression guard). + test('non-JS modules whose text contains createServerFn( are imported byte for byte', async () => { + const expected = { + ...(bundler === 'vite' && { notes: files['src/notes.md'] }), + code: JSON.parse(files['src/data.json']).code, + } + for (const env of ['client', 'ssr'] as const) { + expect( + (await build[env].run(`return entry.rawText()`)).result, + env, + ).toEqual(expected) + } + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-source-maps.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-source-maps.test.ts new file mode 100644 index 0000000000..9c5a5b1367 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-source-maps.test.ts @@ -0,0 +1,191 @@ +/** + * Build-level source map of a client module whose server fn became an RPC + * stub (SPEC G6): a component of that module throws at a known line, the + * real production build (Start's Vite and Rsbuild plugins, build-harness.ts) + * emits maps, and the thrown error's stack frame, read through the chunk's + * map with the standard consumer (`@tanstack/compiler-test-utils/ + * source-maps`), resolves to the user's file, the line of the throw and a + * column inside the throw statement. Also with a map-producing transform + * before Start (Oxc lowering the module's syntax, as a user plugin would): + * the maps compose. Minified builds (the production default). + */ +import path from 'node:path' +import { transformWithOxc } from 'vite' +import { describe, expect, test } from 'vitest' +import { mentionsFile } from '@tanstack/compiler-test-utils/diagnostics' +import { + findNodes, + positionAt, + traceStack, +} from '@tanstack/compiler-test-utils/source-maps' +import { buildStart, startBundlers } from '../build-harness' +import type { StartBuild, StartBundler } from '../build-harness' +import type { RsbuildPlugin } from '@rsbuild/core' +import type { Plugin } from 'vite' + +const timeout = 60_000 + +/** + * A client module with a server fn (an RPC stub in the client) and a + * component throwing at a known line; the throw line uses syntax the + * pre-transform lowers (`?.`, `??`). + */ +const fail = `import { createServerFn } from '@tanstack/react-start' +import { secret } from './secret' +export const getSecret = createServerFn().handler(async () => secret()) +export function Page(props: { label?: { prefix: string } }): never { + const label = props.label + throw new Error((label?.prefix ?? 'MARK') + '_PAGE_THROW') +} +` +const files = { + 'src/fail.tsx': fail, + 'src/secret.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/entry.ts': `export { getSecret, Page } from './fail'\n`, +} + +/** The throw statement of the fixture: its line and column span (0-based). */ +const throwStatement = (() => { + const [node] = findNodes( + fail, + (candidate) => candidate.type === 'ThrowStatement', + { + filename: 'fail.tsx', + }, + ) + const start = positionAt(fail, node!.start) + const end = positionAt(fail, node!.end) + expect(end.line).toBe(start.line) + return { line: start.line, from: start.column, to: end.column } +})() + +/** + * Whether the transform before Start saw the module as the user wrote it + * (its server-only import still there): a precondition of the composed-map + * row, not an assertion on Start. + */ +let preTransformSawSource = false + +/** Lowers `src/fail.tsx` with Oxc (a map-producing transform) before Start. */ +async function lower(code: string, id: string) { + preTransformSawSource ||= code.includes(`from './secret'`) + const result = await transformWithOxc(code, id, { + lang: 'tsx', + target: 'es2019', + sourcemap: true, + }) + return { code: result.code, map: result.map } +} + +const isFail = (id: string) => id.replace(/\?.*$/, '').endsWith('/src/fail.tsx') + +const vitePreTransform: Plugin = { + name: 'test-lower-before-start', + transform: { + order: 'pre', + handler: (code, id) => (isFail(id) ? lower(code, id) : undefined), + }, +} + +const rsbuildPreTransform: RsbuildPlugin = { + name: 'test-lower-before-start', + setup(api) { + api.transform( + { test: /[\\/]src[\\/]fail\.tsx$/, order: 'pre' }, + async (ctx) => { + const { code, map } = await lower(ctx.code, ctx.resourcePath) + // Rsbuild takes a map as JSON text or Rspack's own object. + return { code, map: map ? JSON.stringify(map) : null } + }, + ) + }, +} + +/** + * Builds the app (minified, with maps) and returns the frames of the throw + * in the client, resolved through the emitted maps. + */ +async function throwFrames( + bundler: StartBundler, + options: { preTransform: boolean }, +) { + const { client } = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + sourcemap: true, + ...(options.preTransform && + (bundler === 'vite' + ? { viteConfig: { plugins: [vitePreTransform] } } + : { rsbuildConfig: { plugins: [rsbuildPreTransform] } })), + }) + expect(client.where('MARK_SECRET')).toBe('nowhere') + const { result: stack } = await client.run( + `try { entry.Page({}) } catch (error) { return error.stack }`, + ) + expect(stack).toMatch(/MARK_PAGE_THROW/) + return { + client, + frames: traceStack(stack as string, (location) => + chunkMap(client, location), + ), + } +} + +/** The map of the chunk a page served at `location`, if it is one. */ +function chunkMap(client: StartBuild['client'], location: string) { + if (!/^https?:/.test(location)) { + return undefined + } + const file = path.join( + client.outDir, + decodeURIComponent(new URL(location).pathname), + ) + const chunk = client.chunks.find( + (candidate) => path.join(client.outDir, candidate.fileName) === file, + ) + if (chunk && !chunk.map) { + throw new Error(`${chunk.fileName} has no source map`) + } + return chunk?.map +} + +/** The innermost frame that resolves to the user's module. */ +function expectThrowFrame(frames: ReturnType<typeof traceStack>, root: string) { + const resolved = frames.filter((frame) => frame.original) + expect(resolved.length, 'frames with a mapping').toBeGreaterThan(0) + const frame = resolved[0]!.original! + expect( + mentionsFile(frame.source, 'src/fail.tsx', { root }), + `${frame.source} names src/fail.tsx`, + ).toBe(true) + expect(frame.line).toBe(throwStatement.line) + expect(frame.column).toBeGreaterThanOrEqual(throwStatement.from) + expect(frame.column).toBeLessThanOrEqual(throwStatement.to) +} + +describe.each(startBundlers)('%s build', (bundler) => { + test( + "client: a throw in the component of a server fn module maps to the user's file, line and throw statement (minified)", + async () => { + const { client, frames } = await throwFrames(bundler, { + preTransform: false, + }) + expectThrowFrame(frames, client.root) + }, + timeout, + ) + + test( + 'client: the same, through a map-producing transform that ran before Start', + async () => { + preTransformSawSource = false + const { client, frames } = await throwFrames(bundler, { + preTransform: true, + }) + expect(preTransformSawSource, 'the transform ran before Start').toBe(true) + expectThrowFrame(frames, client.root) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-v2-unresolvable-imports.test.ts b/packages/start-plugin-core/tests/integration/start-build-v2-unresolvable-imports.test.ts new file mode 100644 index 0000000000..d770dc2180 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-v2-unresolvable-imports.test.ts @@ -0,0 +1,171 @@ +/** + * Server-only imports the client cannot resolve, in real production builds + * through Start's Vite and Rsbuild plugins (build-harness.ts): a platform + * module (`cloudflare:workers`, read by a middleware `.server()`) and Node + * builtins (`node:fs`, read by a handler; `node:buffer`, read by a helper + * only a `createServerOnlyFn` body and an isomorphic `.server()` call) that + * only removed server code uses (SPEC J4.12, G16). No polyfill or alias + * plugin: the client build must not try to resolve them, and reports + * nothing about them (no browser stub, no warning). The server build marks the platform module external, as + * a Cloudflare app does, and Node's builtin is external anyway; the SSR run + * provides the platform module the way the worker runtime would (a module + * resolve hook of Node, registered by the SSR entry before any module of + * the app links: the one stand-in, as the test process is no worker). + * Source: #6185, #7460, #3990. + */ +import { describe, expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import { workerResolveHook } from './worker-resolve-hook' +import type { StartBundler } from '../build-harness' + +const timeout = 60_000 + +const platform = `import { createMiddleware, createServerFn } from '@tanstack/react-start' +import { env } from 'cloudflare:workers' +import { existsSync } from 'node:fs' +export const withEnv = createMiddleware({ type: 'function' }).server( + ({ next }) => next({ context: { secret: env.SECRET } }), +) +export const readConfig = createServerFn() + .middleware([withEnv]) + .handler(async ({ context }) => [ + context.secret, + existsSync(process.cwd()) ? 'MARK_FS_OK' : 'MARK_FS_MISSING', + ]) +export const label = () => 'MARK_CLIENT_LABEL' +` + +/** Environment functions whose server side reads the builtin through a helper. */ +const encoding = `import { createIsomorphicFn, createServerOnlyFn } from '@tanstack/react-start' +import { Buffer } from 'node:buffer' +const toBase64 = (value: string) => Buffer.from(value).toString('base64') +export const encode = createServerOnlyFn(() => toBase64('server-only')) +export const encodeEither = createIsomorphicFn() + .server(() => toBase64('isomorphic')) + .client(() => 'MARK_CLIENT_ENCODE') +` + +const files = { + 'src/platform.ts': platform, + 'src/encoding.ts': encoding, + 'src/client-entry.ts': `export { readConfig, label } from './platform' +export { encode, encodeEither } from './encoding' +`, + // Dynamic import lets the hook register before the app module links. + 'src/ssr-entry.ts': `${workerResolveHook} +export const platform = () => import('./platform') +export const encoding = () => import('./encoding') +${callByIdExports}`, +} + +/** The server build of each bundler leaves the platform module external. */ +const externalPlatform: Record< + StartBundler, + Pick<Parameters<typeof buildStart>[0], 'viteConfig' | 'rsbuildConfig'> +> = { + vite: { + viteConfig: { + environments: { ssr: { resolve: { external: ['cloudflare:workers'] } } }, + }, + }, + rsbuild: { + rsbuildConfig: { + environments: { ssr: { output: { externals: ['cloudflare:workers'] } } }, + }, + }, +} + +describe.each(startBundlers)('%s build', (bundler) => { + test.each([ + { name: 'sideEffects unset', sideEffects: undefined }, + { name: 'sideEffects false', sideEffects: false }, + ])( + 'the client build succeeds without the platform and builtin modules; the server build keeps them and the server fn runs ($name)', + async ({ sideEffects }) => { + const { client, ssr, root } = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + sideEffects, + ...externalPlatform[bundler], + }) + expect({ + platform: client.where('cloudflare:workers'), + builtin: client.where('node:fs'), + buffer: client.where('node:buffer'), + secret: client.where('MARK_ENV_SECRET'), + label: client.where('MARK_CLIENT_LABEL'), + }).toEqual({ + platform: 'nowhere', + builtin: 'nowhere', + buffer: 'nowhere', + secret: 'nowhere', + label: 'eager', + }) + // No stub either: a bundler that resolves a leftover import for the + // browser (Vite's empty module for a Node builtin) warns about the + // module that imports it (G16; by file and severity, §5.7). + expect( + ['src/platform.ts', 'src/encoding.ts'].flatMap((file) => + findDiagnostics(client.warnings, { file, root }), + ), + ).toEqual([]) + const clientRun = ( + await client.run(`${requestsOfPrelude}let refused = false +try { + entry.encode() +} catch { + refused = true +} +return { + label: entry.label(), + encoded: [refused, entry.encodeEither()], + url: entry.readConfig.url, + requests: await requestsOf(entry.readConfig), +}`) + ).result as { + label: string + encoded: Array<unknown> + url: string + requests: Array<unknown> + } + expect(clientRun.label).toBe('MARK_CLIENT_LABEL') + // The client refuses the server-only fn and runs its own + // implementation (J4.9, J4.10). + expect(clientRun.encoded).toEqual([true, 'MARK_CLIENT_ENCODE']) + expect(clientRun.requests).toEqual([ + { url: clientRun.url, method: 'GET' }, + ]) + const url = (await client.run(`return entry.readConfig.url`)).result + const { result } = + await ssr.run(`${callByIdPrelude}const { readConfig } = await entry.platform() +const { encode, encodeEither } = await entry.encoding() +return { + ssr: await readConfig(), + encoded: [encode(), encodeEither()], + byId: await callById(serverFnId(${JSON.stringify(url)})), + externalRequests: [...entry.workerRequests], +}`) + const expected = ['MARK_ENV_SECRET', 'MARK_FS_OK'] + expect(result).toEqual({ + ssr: expected, + encoded: [ + Buffer.from('server-only').toString('base64'), + Buffer.from('isomorphic').toString('base64'), + ], + byId: expected, + // A real external resolution, consumed by the middleware above: + // the hook's own specifier string is insufficient evidence. + externalRequests: expect.arrayContaining(['cloudflare:workers']), + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-build-warnings.test.ts b/packages/start-plugin-core/tests/integration/start-build-warnings.test.ts new file mode 100644 index 0000000000..d9cd990191 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-build-warnings.test.ts @@ -0,0 +1,51 @@ +/** + * A failure of the Start compiler fails the build and tells the user which + * module it is about, on every bundler, without hanging (SPEC G5, G11). + */ +import { describe, expect, test } from 'vitest' +import { problems } from '@tanstack/compiler-test-utils/diagnostic-channel' +import { StartBuildError, buildStart, startBundlers } from '../build-harness' + +const timeout = 60_000 + +describe.each(startBundlers)('%s build', (bundler) => { + // Source: mutation testing (on Rsbuild, the build hung forever + // when the compiler's module resolution failed). + test( + 'a server fn whose builder comes from a missing module fails the build, naming the module', + async () => { + let timer: ReturnType<typeof setTimeout> | undefined + // A hanging build fails the test well before its timeout. + const hang = new Promise<string>((resolve) => { + timer = setTimeout(() => resolve('the build hangs'), 20_000) + }) + const outcome = await Promise.race([ + buildStart({ + bundler, + files: { + 'src/fns.ts': `import { base } from './missing-base' +export const greet = base.handler(async () => 'MARK_HANDLER') +`, + 'src/entry.ts': `export { greet } from './fns'\n`, + }, + entry: 'src/entry.ts', + }).then( + () => 'the build succeeds', + // Every warning and error the failed build reported, on every + // channel (a compiler may print the details and fail with a short + // error); an info line tells the user nothing went wrong + // (SPEC G5, §5.7) + (error: unknown) => + error instanceof StartBuildError + ? problems(error.diagnostics) + .map(({ text }) => text) + .join('\n') + : String(error), + ), + hang, + ]).finally(() => clearTimeout(timer)) + expect(outcome).toContain('missing-base') + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-custom-ids.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-custom-ids.test.ts new file mode 100644 index 0000000000..b78017f7b4 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-custom-ids.test.ts @@ -0,0 +1,222 @@ +/** + * Server fn ids of production builds (SPEC J4.4, G4) through the public + * Start host in production mode (`createStartHost({ serve: false })`: real + * `vite build` with the Start plugin's documented `serverFns` options and + * Start's preview server; the client in the hydrated production page): + * - the id a custom `generateFunctionId` returns is the one the client calls + * (its public `url`) and the server answers to; which spelling of the file + * name it receives is not specified (J4.4); + * - a `generateFunctionId` returning `undefined` falls back to a working id; + * - server fns given the same custom id (in one module, or in two) still + * each reach their own handler, from the client and from server code; + * - the same project at another root builds correctly (relocation is + * correctness, not id equality: G4). + * Moved from the unit test start-compiler-determinism.test.ts, which + * compiled through the internal compiler; its Windows-path rows are not + * reachable through a POSIX host. + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { expectRelocatable } from '@tanstack/compiler-test-utils/determinism' +import { + callFromClient, + callOnServer, + createStartHost, + serverFnUrls, +} from '../regression-helpers' +import type { StartCase, StartHost } from '../regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +const serverFnModule = (name: string, value: string) => + `import { createServerFn } from '@tanstack/react-start' +export const ${name} = createServerFn().handler(async () => '${value}') +` + +/** What a call from the client and from server code give (equal). */ +async function callBothWays(startCase: StartCase, fn: string, file: string) { + const client = await callFromClient(startCase, fn, undefined, { file }) + expect( + await callOnServer(startCase, fn, undefined, { file }), + `${fn} called by server code`, + ).toEqual(client) + return client +} + +describe('a custom generateFunctionId', () => { + /** The ids the custom function returned. */ + const returned: Array<string> = [] + let host: StartHost | undefined + const cases: Record<string, StartCase> = {} + + beforeAll(async () => { + // One build: each case directory gets its own id policy. + host = await createStartHost({ + serve: false, + files: hostDefaults.files, + start: { + ...hostDefaults.start, + serverFns: { + generateFunctionId: ({ + filename, + functionName, + }: { + filename: string + functionName: string + }) => { + if (filename.includes('custom-ids')) { + // URL-safe: the id is a path segment of the server fn's url + // (an id with a '/' is not routed back to its handler by + // Start's runtime: a runtime limitation, not this test's + // subject) + const id = `custom_${Buffer.from(`${filename}:${functionName}`).toString('hex')}` + returned.push(id) + return id + } + if (filename.includes('no-ids')) { + return undefined + } + if (filename.includes('same-ids')) { + return 'same-id' + } + return undefined + }, + }, + }, + }) + cases.custom = await host.case({ + 'custom-ids.ts': serverFnModule('fn', 'from the server'), + }) + cases.fallback = await host.case({ + 'no-ids.ts': serverFnModule('fn', 'from the server'), + }) + cases.several = await host.case({ + 'same-ids.ts': `import { createServerFn } from '@tanstack/react-start' +export const a = createServerFn().handler(async () => 'from a') +export const b = createServerFn().handler(async () => 'from b') +export const c = createServerFn().handler(async () => 'from c') +`, + }) + cases.colliding = await host.case({ + 'same-ids-a.ts': serverFnModule('a', 'from a'), + 'same-ids-b.ts': serverFnModule('b', 'from b'), + }) + await host.preview() + }, 60_000) + afterAll(() => host?.close()) + + test('gives the id the client calls and the server answers to', async () => { + const [url] = await serverFnUrls(cases.custom!, 'module', { + file: 'custom-ids.ts', + }) + expect(url).toEqual(expect.any(String)) + expect( + returned.some((id) => url!.endsWith(id)), + `the url ${url} carries one of the ids the function returned: ${returned.join(', ')}`, + ).toBe(true) + expect( + await callBothWays(cases.custom!, 'module.fn', 'custom-ids.ts'), + ).toBe('from the server') + }) + + test('that returns undefined falls back to a working id', async () => { + expect( + await serverFnUrls(cases.fallback!, 'module', { file: 'no-ids.ts' }), + ).toEqual([expect.any(String)]) + expect(await callBothWays(cases.fallback!, 'module.fn', 'no-ids.ts')).toBe( + 'from the server', + ) + }) + + // The server gives each server fn of a module the id the client gave it, + // also when the custom function gives them all the same id. + test('giving one id to every server fn of a module: each reaches its own handler', async () => { + expect( + await serverFnUrls(cases.several!, 'module', { file: 'same-ids.ts' }), + ).toHaveLength(3) + const called: Record<string, unknown> = {} + for (const name of ['a', 'b', 'c']) { + called[name] = await callBothWays( + cases.several!, + `module.${name}`, + 'same-ids.ts', + ) + } + expect(called).toEqual({ a: 'from a', b: 'from b', c: 'from c' }) + }) + + // Two server fns of two modules get the same custom id: the build tells + // them apart, and each environment pairs each with its own handler. + test('colliding custom ids of two modules stay paired', async () => { + const urls = [ + ...(await serverFnUrls(cases.colliding!, 'module', { + file: 'same-ids-a.ts', + })), + ...(await serverFnUrls(cases.colliding!, 'module', { + file: 'same-ids-b.ts', + })), + ] + expect(new Set(urls).size).toBe(2) + expect( + await callBothWays(cases.colliding!, 'module.a', 'same-ids-a.ts'), + ).toBe('from a') + expect( + await callBothWays(cases.colliding!, 'module.b', 'same-ids-b.ts'), + ).toBe('from b') + }) +}) + +describe('relocation', () => { + const hosts: Array<StartHost> = [] + afterAll(async () => { + for (const host of hosts) { + await host.close() + } + }) + + // Two apps at two roots, the same project: each builds a working app (its + // client calls reach their handlers); only the results must agree, not + // the opaque ids. + test('the same project at another root compiles correctly: the client and the server agree on the id', async () => { + await expectRelocatable( + ['first root', 'second root'], + async () => { + const host = await createStartHost({ ...hostDefaults, serve: false }) + hosts.push(host) + const startCase = await host.case({ + 'fns.ts': serverFnModule('fn', 'from the server'), + }) + await host.preview() + return { + urls: await serverFnUrls(startCase, 'module', { file: 'fns.ts' }), + called: await callBothWays(startCase, 'module.fn', 'fns.ts'), + } + }, + { + check: (result) => { + expect(result.urls).toEqual([expect.any(String)]) + }, + portable: (result) => result.called, + }, + ) + }, 60_000) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-determinism.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-determinism.test.ts new file mode 100644 index 0000000000..9cfd06fbf8 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-determinism.test.ts @@ -0,0 +1,114 @@ +/** + * Server fn ids of production builds are deterministic for an unchanged + * project (SPEC J4.4, G4): the same app at the same root, built again with + * its files written in another order, gives every server fn the same public + * `url`, and each one reaches its own handler. Observed through the public + * Start host in production mode (`createStartHost({ ...hostDefaults, serve: false })`: real + * `vite build` and Start's preview server; the client in the hydrated + * production page, calling the server through the built server entry). + * The projection compared is the `url` of each server fn and what calling + * it gives (`@tanstack/compiler-test-utils/determinism`), never bytes or + * generated names. + * Moved from the unit test start-compiler-determinism.test.ts ("are + * deterministic for an unchanged project, whatever order its modules are + * compiled in"), which compiled through the internal compiler. + */ +import { writeFile } from 'node:fs/promises' +import { afterAll, expect, test } from 'vitest' +import { + expectDeterministic, + reorderedRecords, +} from '@tanstack/compiler-test-utils/determinism' +import { callFromClient, createStartHost, inPage } from '../regression-helpers' +import type { StartCase, StartHost } from '../regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +const serverFnModule = (name: string, value: string) => + `import { createServerFn } from '@tanstack/react-start' +export const ${name} = createServerFn().handler(async () => '${value}') +` + +/** Three server fn modules, two of the same base name and export name. */ +const modules = { + 'a.ts': serverFnModule('a', 'from a'), + 'b.ts': serverFnModule('b', 'from b'), + 'c/a.ts': serverFnModule('a', 'from c/a'), +} +/** The module the page loads: it gives the three server fns. */ +const index = `export { a } from './a' +export { b } from './b' +export { a as nestedA } from './c/a' +` + +let host: StartHost | undefined +afterAll(() => host?.close()) + +/** Each server fn's `url` and what a call from the client gives. */ +async function observe(startCase: StartCase) { + const urls = await inPage<Record<string, string>>( + startCase, + `return { a: module.a.url, b: module.b.url, nestedA: module.nestedA.url }`, + { file: 'index.ts' }, + ) + const called: Record<string, unknown> = {} + for (const name of ['a', 'b', 'nestedA']) { + called[name] = await callFromClient( + startCase, + `module.${name}`, + undefined, + { + file: 'index.ts', + }, + ) + } + return { urls, called } +} + +test('are deterministic for an unchanged project, whatever order its files are written in', async () => { + host = await createStartHost({ ...hostDefaults, serve: false }) + let startCase: StartCase | undefined + const observations = await expectDeterministic( + reorderedRecords(modules), + async ({ record }) => { + if (!startCase) { + startCase = await host!.case({ ...record, 'index.ts': index }) + await host!.preview() + } else { + for (const [file, code] of Object.entries(record)) { + await writeFile(startCase.file(file), code) + } + await host!.preview({ rebuild: true }) + } + return observe(startCase) + }, + ) + // Each build: three ids, each reaching its own handler. + const [first] = observations + expect(new Set(Object.values(first!.urls)).size).toBe(3) + expect(first!.called).toEqual({ + a: 'from a', + b: 'from b', + nestedA: 'from c/a', + }) +}, 60_000) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-env-fns.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-env-fns.test.ts new file mode 100644 index 0000000000..ece3f181fb --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-env-fns.test.ts @@ -0,0 +1,107 @@ +/** + * Environment-specific functions in a production build (SPEC J4.9, J4.10, + * J4.12): each environment keeps the implementation of its own environment + * and only the modules that implementation reads, and the other one throws. + * The production twin of the dev row of start-compiler-factories.test.ts + * ("dev and build compile alike"), through the + * public Start host in production mode (`createStartHost({ serve: false })`: + * real `vite build`, Start's preview server, the hydrated production page). + * Source: Waku vite-plugin-allow-server.test.ts "keeps only allowServer + * dependencies and removes allowServer imports", "supports allowServer + * aliasing and export specifiers". + */ +import { afterAll, expect, test } from 'vitest' +import { + createStartHost, + fromPage, + inPage, + settle, + throwsError, +} from '../regression-helpers' +import type { PageSettled, StartHost } from '../regression-helpers' + +/** + * The host defaults these tests use: no import + * protection and an app tsconfig with `verbatimModuleSyntax`. + */ +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, + }), + }, +} + +let host: StartHost | undefined +afterAll(() => host?.close()) + +test('build: each environment keeps the implementation of its environment and only its dependencies', async () => { + host = await createStartHost({ ...hostDefaults, serve: false }) + const startCase = await host.case({ + 'module.tsx': `import { createServerOnlyFn, createClientOnlyFn as clientOnly } from '@tanstack/react-start' +import { draw } from './chart.client' +import { query } from './db.server' +const shared = 1 +const readDb = () => query(shared) +const serverValue = createServerOnlyFn(readDb) +export const clientValue = clientOnly(() => draw(shared)) +export { serverValue as exposed }`, + 'chart.client.ts': `export const draw = (x: number) => 'MARK_DRAW:' + x\n`, + 'db.server.ts': `export const query = (x: number) => 'MARK_QUERY:' + x\n`, + }) + const { build } = await host.preview() + // Only its dependencies: the chunks the module is in, the chunks they + // import lazily, and every chunk those import statically ship nothing of + // the other environment's module. (Every case file is a lazy chunk of its + // own in this app, as the page imports each one through a glob: the lazy + // imports of shared chunks do not count.) + const code = (environment: string) => { + const { chunks } = build.environments[environment]! + const byName = new Map(chunks.map((chunk) => [chunk.fileName, chunk])) + const module = startCase.file('module.tsx') + const own = chunks.filter((chunk) => chunk.moduleIds.includes(module)) + expect(own.length, `${environment} chunks of the module`).toBeGreaterThan(0) + const reached = new Set([ + ...own, + ...own.flatMap((chunk) => + chunk.dynamicImports.flatMap((name) => byName.get(name) ?? []), + ), + ]) + for (const chunk of reached) { + for (const name of chunk.imports) { + const next = byName.get(name) + if (next) { + reached.add(next) + } + } + } + return [...reached].map((chunk) => chunk.code).join('\n') + } + expect(code('client')).not.toContain('MARK_QUERY') + expect(code('ssr')).not.toContain('MARK_DRAW') + // The client (the production page) runs the client implementation; the + // server-only fn throws. + expect(await inPage(startCase, 'return module.clientValue()')).toBe( + 'MARK_DRAW:1', + ) + expect( + fromPage( + await inPage<PageSettled>(startCase, 'return settle(module.exposed)'), + ), + ).toEqual(throwsError) + // The server build runs the server implementation; the client-only fn + // throws. + const ssr = await startCase.ssr() + expect([settle(ssr.clientValue), ssr.exposed()]).toEqual([ + throwsError, + 'MARK_QUERY:1', + ]) +}, 60_000) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-export-cache.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-export-cache.test.ts new file mode 100644 index 0000000000..07b4b254b3 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-export-cache.test.ts @@ -0,0 +1,141 @@ +/** + * Start compiler behaviour that only a production build exercises + * (build-mode export caches), moved from known-bugs-start-compiler.test.ts + * onto the production mode of the public Start host + * (`createStartHost({ serve: false })` + `preview()`: `vite build` with + * Start's plugin of the built `@tanstack/react-start`, Start's preview + * server, a hydrated production page). + * + * What is observed: the build succeeds, the client build bundles no + * server-only module (the modules of the client chunks, by resolved id; + * import protection is off, as on the fast tier's hosts), and each + * importer's server fn, called from the production page, reaches its + * handler on the server. Each row is its own app and build, so a row whose + * build fails fails alone. + * + * The importers are compiled in a fixed order, as an app's import graph + * orders them: `via-a.tsx` (a case module the build reaches at once) + * imports the builder through the head of the chain, and statically + * imports the importers through the other modules of the chain + * (`later/via-<module>.tsx`, reached only through it), so the bundler + * compiles them after it. (With every importer reached at once, the build + * compiles them in parallel and the outcome below depended on their timing: + * the "export * diamonds" row failed in about 1 of 10 runs.) + */ +import { describe, expect, test } from 'vitest' +import { callFromClient, createStartHost } from '../regression-helpers' + +const head = `import { createServerFn } from '@tanstack/react-start'\n` + +/** + * Builds an app with the `base` builder in `d.ts`, re-exported through + * `reExports` (whose first module is the head of the chain), an importer + * `via-a.tsx` of `base` through the head (`viaA`), and an importer of + * `base` through each other module of the chain, compiled after it (see the + * module comment; re-exported by `via-a.tsx` as `via_<module>`). Checks + * that no server-only module is in the client build and that each + * importer's server fn, called from the production page, reaches its + * handler. + */ +async function expectImportersThroughRpc(reExports: Record<string, string>) { + const [first, ...others] = Object.keys(reExports).map((file) => + file.replace(/\.ts$/, ''), + ) + const host = await createStartHost({ serve: false }) + try { + const startCase = await host.case({ + 'd.ts': `${head}export const base = createServerFn()`, + 'db.server.ts': `export const db = { x: () => 'from the server' }\n`, + ...reExports, + 'via-a.tsx': `import { base } from './${first}' +import { db } from './db.server' +export const viaA = base.handler(async () => db.x()) +${others.map((name) => `export { via as via_${name} } from './later/via-${name}'`).join('\n')} +`, + ...Object.fromEntries( + others.map((name) => [ + `later/via-${name}.tsx`, + `import { base } from '../${name}' +import { db } from '../db.server' +export const via = base.handler(async () => db.x()) +`, + ]), + ), + }) + const { build } = await host.preview() + const serverOnlyFile = startCase.file('db.server.ts') + const clientModules = build.environments.client!.chunks.flatMap( + (chunk) => chunk.moduleIds, + ) + expect( + clientModules.filter((id) => id.split('?')[0] === serverOnlyFile), + 'the server-only module in the client build', + ).toEqual([]) + for (const name of ['viaA', ...others.map((other) => `via_${other}`)]) { + expect( + await callFromClient(startCase, `module.${name}`, undefined, { + file: 'via-a.tsx', + }), + name, + ).toBe('from the server') + } + } finally { + await host.close() + } +} + +describe('server code in the client bundle', () => { + // Control for the pins below (same harness, same order): a chain without + // a diamond or a cycle. + test('importers through an export * chain call their server fn through its RPC', async () => { + await expectImportersThroughRpc({ + 'a.ts': `export * from './b'`, + 'b.ts': `export * from './d'`, + }) + }) + + // Bug: build-mode export lookups are cached per module, but the parallel + // `export *` branches of one lookup share one visited set: in a diamond + // (a -> b -> d, a -> c -> d) the branch that reaches `d` second finds it + // visited and caches its own module (`b` or `c`) as not exporting + // `base`; in a cycle (a -> b -> a, a -> d) the lookup through `a` caches + // `b` the same way. An importer compiled after that, through the module + // cached as "not found", is left untransformed. + // Impact: that importer's handler and the server-only module it reads + // ship to the client, and its server fn never reaches the server (the + // client call resolves to `undefined`). + // Fix-agnostic: no server-only module in the client build, and every + // importer's server fn reaches its handler. + // Source: known-bugs-start-compiler.test.ts "export * $name do not poison the + // build-mode export cache" (formerly a pin on the internal compiler; kept as + // a passing regression test, not reproduced through a real build). The + // intermittent failure of the diamond row (about 1 in 10 runs, when every + // importer compiled in parallel) was this bug, reached when the build + // happened to compile an importer after the lookup that poisoned the cache. + // Reproduced in every run with the compile order fixed (control above: + // green). + test.fails.each<{ name: string; reExports: Record<string, string> }>([ + { + name: 'diamonds', + reExports: { + 'a.ts': `export * from './b' +export * from './c'`, + 'b.ts': `export * from './d'`, + 'c.ts': `export * from './d'`, + }, + }, + { + name: 'cycles', + reExports: { + 'a.ts': `export * from './b' +export * from './d'`, + 'b.ts': `export * from './a'`, + }, + }, + ])( + 'export * $name do not poison the build-mode export cache', + async ({ reExports }) => { + await expectImportersThroughRpc(reExports) + }, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-ids.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-ids.test.ts new file mode 100644 index 0000000000..e0ce62d195 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-ids.test.ts @@ -0,0 +1,213 @@ +/** + * Server fns in production builds (SPEC J4.4 ids, G7 no development code): + * the build-only rows of the createServerFn suites, run against a real + * `vite build` of a Start app with the public Start plugin, served by + * Start's own preview server, its page hydrated in Chromium + * (`createStartHost({ serve: false })`, `preview()`). Server fns are called + * from that page (Start's client RPC, by id, through the built server + * entry) and from server code of the build (inside its real requests). + * + * Moved here from createServerFn/createServerFn.test.ts ("dedupes custom + * ids, the same way across compiler instances"), + * createServerFn/exports-and-directives.test.ts ("build providers have no + * dev HMR code", the build row of "ids are repeatable ...", "build ids do + * not ship source names", the build rows of "a provider for a module ending + * in a line comment ..."). + * + * No row for a server fn under a directory whose name contains `#` + * (formerly createServerFn/declaration-sites.test.ts, "a .ts module in a + * directory whose name contains # compiles as TypeScript"): Vite's resolver + * cuts a file path at its first `#` outside `node_modules`, so a plain Vite + * app without Start cannot serve a module under such a directory in dev, + * nor build any query import of one (`./c#proj/src/module.ts?raw`: + * UNRESOLVED_IMPORT), which is how the Start build fails there too (an + * upstream Vite limitation). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + callFromClient, + callServerFnThroughCallers, + createStartHost, + inPage, + serverFnUrls, +} from '../regression-helpers' +import type { StartCase, StartHost, StartPreview } from '../regression-helpers' + +const head = `import { createServerFn } from '@tanstack/react-start'\n` +const existing = `export const load = createServerFn().handler(async () => 'load') +export const save = createServerFn().handler(async () => 'save')` + +/** The cases of the app with Start's default ids. */ +interface DefaultCases { + noHmr: StartCase + versions: Array<{ startCase: StartCase; names: Array<string> }> + sourceNames: StartCase + trailing: Array<{ end: string; startCase: StartCase }> +} + +let defaultHost: StartHost | undefined +let defaultPreview: StartPreview +let defaults: DefaultCases +let customHost: StartHost | undefined +let customCase: StartCase + +beforeAll(async () => { + defaultHost = await createStartHost({ serve: false }) + defaults = { + noHmr: await defaultHost.case({ + 'module.tsx': `${head}export const getPosts = createServerFn().handler(async () => 'posts')`, + }), + versions: [ + { + startCase: await defaultHost.case({ + 'module.tsx': `${head}${existing}`, + }), + names: ['load', 'save'], + }, + { + startCase: await defaultHost.case({ + 'module.tsx': `${head}export const added = createServerFn().handler(async () => 'added')\n${existing}`, + }), + names: ['load', 'save', 'added'], + }, + ], + sourceNames: await defaultHost.case({ + 'module.tsx': `${head}export const loadSecretReport = createServerFn().handler(async () => 1)`, + }), + trailing: [ + { + end: '\n// trailing', + startCase: await defaultHost.case({ + 'module.tsx': `${head}export const fn = createServerFn().handler(async () => 'handler')\n// trailing`, + }), + }, + { + end: '\r\n// trailing', + startCase: await defaultHost.case({ + 'module.tsx': `${head}export const fn = createServerFn().handler(async () => 'handler')\r\n// trailing`, + }), + }, + ], + } + defaultPreview = await defaultHost.preview() + + // `generateFunctionId` gives every server fn the same id. + customHost = await createStartHost({ + serve: false, + start: { serverFns: { generateFunctionId: () => 'constant_id' } }, + }) + customCase = await customHost.case({ + 'submit-post-formdata.tsx': `${head}export const greetUser = createServerFn().handler(async () => 'first')`, + 'formdata-redirect/index.tsx': `${head}export const greetUser = createServerFn().handler(async () => 'second')`, + 'module.tsx': `export { greetUser as first } from './submit-post-formdata' +export { greetUser as second } from './formdata-redirect' +`, + }) + await customHost.preview() +}, 120_000) + +afterAll(async () => { + await defaultHost?.close() + await customHost?.close() +}) + +describe('production builds', () => { + // Dev-only code never reaches production (R7). The code the build emits for + // the module's server fn, on the client and the server, holds no HMR code, + // and the server fn works. The module's code is found by the chunks that hold + // nothing but the case's modules (their layout is free: wherever the bundler + // put the module with other code, that chunk is not judged here; the router + // plugin's paired production builds decide HMR gating, G7). + test('build providers have no dev HMR code', async () => { + expect(await callFromClient(defaults.noHmr, 'module.getPosts')).toBe( + 'posts', + ) + // Behaviour (G7): the production page, which hydrated and ran the + // case's client code, never read or wrote a development-only global + // (React Refresh registration, the router plugin's refresh bookkeeping): + // dev support shipped without its guard fails here even where no + // `import.meta.hot` text is left to find. + expect(await defaultHost!.devSupportTouches()).toEqual([]) + const caseDir = `/${defaults.noHmr.dir}/` + for (const [name, environment] of Object.entries( + defaultPreview.build.environments, + )) { + for (const chunk of environment.chunks) { + if ( + chunk.moduleIds.length === 0 || + !chunk.moduleIds.every((id) => id.includes(caseDir)) + ) { + continue + } + expect(chunk.code, `${name}: ${chunk.fileName}`).not.toMatch( + /import\.meta\.(webpack)?[Hh]ot/, + ) + } + } + }) + + // Within each version of a module the client and the server agree on the + // ids, and each runs its own handlers by id (SPEC J4.4, G4). Editing the + // module (here: adding a server fn above the others) changes the + // effective input, so ids need not survive the edit; the two versions + // are two modules of one build. + // Source: SolidStart compile.spec.ts "keeps ids of existing functions when a + // function is added above them", "keeps production ids stable ..." + test('build: each version of a module runs its own handlers by id, and the client and server agree on its ids', async () => { + for (const { startCase, names } of defaults.versions) { + const read = `Object.fromEntries(${JSON.stringify(names)}.map((name) => [name, module[name].url]))` + const clientUrls = await inPage(startCase, `return ${read}`) + const ssr = await startCase.ssr() + expect( + Object.fromEntries(names.map((name) => [name, ssr[name].url])), + ).toEqual(clientUrls) + for (const name of names) { + expect( + await callServerFnThroughCallers(startCase, `module.${name}`), + name, + ).toBe(name) + } + } + }) + + // Source: SolidStart compile.spec.ts "does not ship source names in production ids" + test('build ids do not ship source names', async () => { + const [url] = await serverFnUrls(defaults.sourceNames) + const id = url!.split('/').filter(Boolean).at(-1)! + for (const text of [id, Buffer.from(id, 'base64url').toString('latin1')]) { + expect(text).not.toMatch(/loadSecretReport|module|src/) + } + expect( + await callFromClient(defaults.sourceNames, 'module.loadSecretReport'), + ).toBe(1) + }) + + // The compiler may append code after the module's last statement. + // Source: Waku vite-plugin-allow-server.test.ts "transforms with trailing + // comment without new lines" + test.each([0, 1])( + 'build: a provider for a module ending in a line comment without a newline (%#)', + async (index) => { + const { startCase } = defaults.trailing[index]! + expect(await callServerFnThroughCallers(startCase, 'module.fn')).toBe( + 'handler', + ) + }, + ) + + // Two server fns of the same name in different files, both given the + // same id by a custom `generateFunctionId`: the build dedupes them, so + // each has its own id, which the client and the server agree on, and each + // id runs its own handler. + test('dedupes custom ids, the same way across compiler instances', async () => { + expect(await serverFnUrls(customCase)).toHaveLength(2) + const ssr = await customCase.ssr() + expect( + await inPage(customCase, 'return [module.first.url, module.second.url]'), + ).toEqual([ssr.first.url, ssr.second.url]) + expect([ + await callServerFnThroughCallers(customCase, 'module.first'), + await callServerFnThroughCallers(customCase, 'module.second'), + ]).toEqual(['first', 'second']) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-build-inputs.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-build-inputs.test.ts new file mode 100644 index 0000000000..8afe81a61e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-build-inputs.test.ts @@ -0,0 +1,589 @@ +/** + * The input shapes of the Start compiler's dev-server rows, in production + * builds through Start's Vite and Rsbuild plugins (../build-harness.ts): + * factories and builders that other project modules define or re-export, + * `export *` chains, packages re-exporting Start's factories, a factory of + * a query-distinct virtual module, handlers written as function + * expressions, identifiers and wrapper calls, builders called as factories, + * and renamed and namespace imports of createServerFn (SPEC J4.5, G13). A + * build resolves these through paths a dev server never takes (its own + * resolution caches, and the server fn manifest Start's server entry looks + * ids up in). The inputs are the dev rows' own (../compiler-inputs.ts). + * + * Every row has a directory of its own in one app per bundler. What is + * observed is what a user sees: the build succeeds (its production client + * output passes the dangling-name check), the client bundle holds none of a + * row's server-only modules (SPEC J4.12), a server fn of the client calls + * the server with its public URL (J4.1), the SSR build runs it in place + * and by that URL's id through Start's server entry (J4.2, J4.3), and the + * other exports do in each environment what the dev rows expect (J4.9, + * J4.10). + */ +import { afterAll, describe, expect, test } from 'vitest' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { + buildStart, + callByIdExports, + callByIdPrelude, + requestsOfPrelude, + startBundlers, +} from '../build-harness' +import { + aliasedClientOnlyFiles, + compiledLibraries, + cycleModule, + deeperChainModule, + exportStarModule, + exportStarRows, + factoryBuilderModule, + factoryDb, + factoryEdits, + factoryRows, + forms, + handlerFiles, + handlerModule, + handlerRows, + libraryChainRows, + libraryPackages, + moduleFiles, + moduleImports, + queryDistinctModule, + reexportCycles, + serverFnConstruct, + virtualFactories, +} from '../compiler-inputs' +import { throwsError } from '../diagnostics' +import type { StartBuild, StartBundler } from '../build-harness' + +const timeout = 60_000 + +interface Row { + name: string + /** The row's files, by path relative to its directory (`module.tsx` is its module). */ + files: Record<string, string> + /** The module's server fns: export, and what its handler returns. */ + serverFns?: Record<string, unknown> + /** + * Expressions of the module's exports (`shape`), read in each environment: + * what they give (`throwsError`: they throw). An environment left out is + * not read. + */ + reads?: Record<string, { client?: unknown; ssr?: unknown }> + /** Text the bundle of each environment does not hold. */ + absent?: { client?: Array<string>; ssr?: Array<string> } + /** Default: every bundler. */ + bundlers?: Array<StartBundler> + /** Bundlers whose build of the row is a known bug (pinned below). */ + pinnedOn?: Array<StartBundler> +} + +/** The library package names of the app (`libraryPackages`). */ +const libraries = Object.fromEntries( + compiledLibraries.map((name) => [name, '*']), +) + +const rows: Array<Row> = [ + // start-compiler-factories.test.ts "factories resolved through project + // modules" (one row per input) + ...factoryRows + .filter( + (row, index) => + factoryRows.findIndex((other) => other.name === row.name) === index, + ) + .map( + (row): Row => ({ + name: row.name, + files: { ...row.files, ...factoryDb, 'module.tsx': row.code }, + serverFns: row.serverFns > 0 ? { fn: 'x' } : {}, + reads: row.code.includes('export const iso') + ? { 'shape.iso()': { client: 'client', ssr: 'w' } } + : {}, + }), + ), + { + name: 'an aliased re-export of createClientOnlyFn next to createServerOnlyFn', + files: aliasedClientOnlyFiles, + reads: { + 'shape.serverValue()': { ssr: 'secret' }, + 'shape.clientValue()': { ssr: throwsError }, + }, + }, + // start-compiler-factories.test.ts "an export * chain with $name" + ...exportStarRows.map( + (row): Row => ({ + name: `an export * chain with ${row.name}`, + pinnedOn: Object.values(row.files).some((code) => + code.includes(`export * from '@tanstack/react-start'`), + ) + ? ['rsbuild'] + : [], + files: { ...row.files, ...factoryDb, 'module.tsx': exportStarModule }, + serverFns: { fn: 'x' }, + reads: { + 'shape.serverOnly()': { + client: row.resolvesServerOnlyFn ? throwsError : 'server-only-marker', + }, + }, + }), + ), + // compiler.test.ts "re-export chain resolution" + { + name: 'a package re-exporting the factories of @tanstack/start-client-core', + files: { + 'module.tsx': `export { getThemeData, initClientFeature } from '@third-party/lib'\n`, + }, + reads: Object.fromEntries( + ['createIsomorphicFn', 'createClientOnlyFn'].map((fn) => [ + fn === 'createIsomorphicFn' + ? 'shape.getThemeData()' + : 'shape.initClientFeature()', + Object.fromEntries( + libraryChainRows + .filter((row) => row.fn === fn) + .map((row) => [row.env === 'client' ? 'client' : 'ssr', row.value]), + ), + ]), + ), + absent: { + client: libraryChainRows + .filter((row) => row.env === 'client' && row.absent) + .map((row) => row.absent!), + ssr: libraryChainRows + .filter((row) => row.env === 'server' && row.absent) + .map((row) => row.absent!), + }, + }, + { + name: 'a deeper re-export chain through another package', + files: { 'module.tsx': deeperChainModule }, + reads: { 'shape.deepFn()': { client: 'deep-client' } }, + absent: { client: ['deep-server'] }, + }, + // createServerFn/createServerFn.test.ts + { + name: 'a factory a query-distinct virtual module re-exports', + files: { 'module.tsx': queryDistinctModule }, + serverFns: { issueServerFn: 'issue-handler' }, + absent: { client: ['issue-handler'] }, + // (a Vite plugin serves the virtual modules) + bundlers: ['vite'], + }, + { + name: 'server fn builders with middleware called as factories', + files: { 'module.tsx': factoryBuilderModule }, + serverFns: { + myAuthedFn: ['myAuthedFn', { auth: 'auth' }], + deleteUserFn: ['deleteUserFn', { auth: 'auth', admin: 'admin' }], + }, + reads: { 'shape.x': { client: 'fakeFn' } }, + absent: { + client: ['MARK_AUTHED_HANDLER_BODY', 'MARK_DELETE_HANDLER_BODY'], + }, + }, + // createServerFn/handler-scope.test.ts "the handler can be $name" + ...handlerRows + .filter((row) => + [ + 'a named function expression', + 'a wrapper call', + 'a function declared after the server fn', + 'an imported function', + ].includes(row.name), + ) + .map( + (row): Row => ({ + name: `a handler that is ${row.name}`, + files: { ...handlerFiles, 'module.tsx': handlerModule(row.code) }, + serverFns: { fn: row.expected }, + }), + ), + // integration/pages/start-compiler-import-forms.test.ts "createServerFn" + ...Object.entries(forms).map( + ([formName, form]): Row => ({ + name: `createServerFn through ${formName}`, + files: { + ...moduleFiles, + 'module.tsx': `${form.imports('@tanstack/react-start', 'createServerFn')} +${moduleImports} +${serverFnConstruct(form.callee('createServerFn'), form.wrap)}`, + }, + serverFns: { fn: 'x' }, + reads: { 'shape.fn.method': { client: 'POST', ssr: 'POST' } }, + }), + ), +] + +const slug = (row: Row) => `r${rows.indexOf(row)}` + +/** The marker of the row's server-only modules (`*.server.*`). */ +const serverMarker = (row: Row) => `MARK_SERVER_ONLY_${slug(row).toUpperCase()}` + +/** + * The app files of `list`: each row's files in its directory, its + * server-only modules setting its marker (so the marker is in a bundle as + * soon as the module is), and the entries re-exporting each row's module. + */ +function appFiles(list: Array<Row>) { + const files: Record<string, string> = { ...libraryPackages } + for (const row of list) { + for (const [file, code] of Object.entries(row.files)) { + files[`src/rows/${slug(row)}/${file}`] = /\.server\.[cm]?[jt]sx?$/.test( + file, + ) + ? `${code}\n;(globalThis as Record<string, unknown>).${serverMarker(row)} = true\n` + : code + } + } + files['src/entry.ts'] = list + .map( + (row) => `export * as ${slug(row)} from './rows/${slug(row)}/module'\n`, + ) + .join('') + files['src/ssr-entry.ts'] = `export * from './entry'\n${callByIdExports}` + return files +} + +/** What reading `expression` gives in a script: `{ value }` or `{ thrown }`. */ +const settlePrelude = `const settle = async (read) => { + try { + return { value: await read() } + } catch (error) { + return { thrown: String(error?.message ?? error) } + } +} +` + +/** The client script of `list`: each server fn's URL and requests, each read. */ +const clientScript = (list: Array<Row>) => `${requestsOfPrelude}${settlePrelude} +const results = {} +${list + .map( + (row) => `results.${slug(row)} = await (async () => { + const shape = entry.${slug(row)} + const fns = {} + for (const name of ${JSON.stringify(Object.keys(row.serverFns ?? {}))}) { + const fn = shape[name] + fns[name] = { + url: typeof fn?.url === 'string' ? fn.url : null, + method: fn?.method, + requests: typeof fn === 'function' ? (await requestsOf(fn)).map((request) => request.url) : null, + } + } + return { + fns, + reads: { +${Object.entries(row.reads ?? {}) + .filter(([, read]) => 'client' in read) + .map( + ([expression]) => + ` ${JSON.stringify(expression)}: await settle(() => ${expression}),`, + ) + .join('\n')} + }, + } +})()`, + ) + .join('\n')} +return results` + +/** + * The SSR script of `list`: each server fn called in place and by the id of + * the client's URL, each read. + */ +const ssrScript = ( + list: Array<Row>, + client: Record<string, unknown>, +) => `${callByIdPrelude}${settlePrelude} +const clientResults = ${JSON.stringify(client)} +const results = {} +${list + .map( + (row) => `results.${slug(row)} = await (async () => { + const shape = entry.${slug(row)} + const fns = {} + for (const name of ${JSON.stringify(Object.keys(row.serverFns ?? {}))}) { + const { url, method } = clientResults.${slug(row)}?.fns?.[name] ?? {} + fns[name] = { + called: await settle(() => shape[name]()), + byId: url ? await settle(() => callById(serverFnId(url), undefined, method)) : null, + } + } + return { + fns, + reads: { +${Object.entries(row.reads ?? {}) + .filter(([, read]) => 'ssr' in read) + .map( + ([expression]) => + ` ${JSON.stringify(expression)}: await settle(() => ${expression}),`, + ) + .join('\n')} + }, + } +})()`, + ) + .join('\n')} +return results` + +interface Observed { + fns: Record<string, any> + reads: Record<string, unknown> +} + +/** What a read gives when it is expected to give `expected`. */ +const settled = (expected: unknown) => + expected === throwsError + ? { thrown: expect.any(String) } + : { value: expected } + +/** A built app of rows, and what each row's client and SSR runs gave. */ +interface BuiltRows { + build: StartBuild + client: Record<string, Observed> + ssr: Record<string, Observed> +} + +/** Builds an app of `list` with `bundler` and runs every row once. */ +async function buildRows( + bundler: StartBundler, + list: Array<Row>, + registerCleanup?: (cleanup: () => Promise<void>) => void, +): Promise<BuiltRows> { + const build = await buildStart({ + bundler, + files: appFiles(list), + entry: { client: 'src/entry.ts', ssr: 'src/ssr-entry.ts' }, + // Unminified: a minifier renames functions, and a row reads one's name + minify: false, + // A leak shows in the bundle (import protection would fail the build + // on it) + start: { importProtection: { enabled: false } }, + // The app depends on the packages of `libraryPackages`, whose Start + // peer resolves like a dependency installed for them + packageJson: { + name: 'app', + private: true, + type: 'module', + dependencies: libraries, + }, + symlinks: workspacePackageLinks(['@tanstack/start-client-core']), + viteConfig: { plugins: [virtualFactories()] }, + registerCleanup, + }) + const client = (await build.client.run(clientScript(list))).result as Record< + string, + Observed + > + const ssr = (await build.ssr.run(ssrScript(list, client))).result as Record< + string, + Observed + > + return { build, client, ssr } +} + +/** The row works in the build, as the module comment says. */ +function expectRowWorks(row: Row, { build, client, ssr }: BuiltRows) { + const name = slug(row) + if (Object.keys(row.files).some((file) => /\.server\./.test(file))) { + expect( + build.client.where(serverMarker(row)), + 'the server-only modules in the client bundle', + ).toBe('nowhere') + } + for (const environment of ['client', 'ssr'] as const) { + for (const text of row.absent?.[environment] ?? []) { + expect(build[environment].where(text), `${environment}: ${text}`).toBe( + 'nowhere', + ) + } + } + for (const [fn, result] of Object.entries(row.serverFns ?? {})) { + const { url, requests } = client[name]!.fns[fn] + expect(url, `${fn}: the client's URL`).toMatch(/^\/_serverFn\/./) + expect(requests, `${fn}: the requests of a client call`).toEqual([url]) + expect(ssr[name]!.fns[fn], `${fn} on the server`).toEqual({ + called: { value: result }, + byId: { value: result }, + }) + } + for (const [expression, expected] of Object.entries(row.reads ?? {})) { + for (const environment of ['client', 'ssr'] as const) { + if (environment in expected) { + const observed = environment === 'client' ? client : ssr + expect( + observed[name]!.reads[expression], + `${environment}: ${expression}`, + ).toEqual(settled(expected[environment])) + } + } + } +} + +describe.each(startBundlers)('%s build', (bundler) => { + const list = rows.filter((row) => + (row.bundlers ?? startBundlers).includes(bundler), + ) + const isPinned = (row: Row) => row.pinnedOn?.includes(bundler) ?? false + const cleanups: Array<() => Promise<void>> = [] + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + let built: Promise<BuiltRows> | undefined + /** The app of every row not pinned on this bundler, built and run once. */ + const shared = () => + (built ??= buildRows( + bundler, + list.filter((row) => !isPinned(row)), + (cleanup) => cleanups.push(cleanup), + )) + + test.each(list.filter((row) => !isPinned(row)))( + '$name', + async (row) => { + expectRowWorks(row, await shared()) + }, + timeout, + ) + + // Bug: on Rsbuild, the Start compiler resolves the module an `export *` + // names with the loader's resolver (rsbuild/start-compiler-host.ts + // `resolveId`), which does not resolve `@tanstack/react-start` (its + // `exports` have `import` and `react-server` conditions only): + // "PackagePathNotExported". A named re-export of the package is + // recognised by its name and never resolved. + // Impact: an Rsbuild build of an app whose module re-exports Start with + // `export * from '@tanstack/react-start'`, and through which another + // module imports a factory, fails. (Each row builds alone, so its failure + // is its own.) + test.fails.each(list.filter(isPinned))( + '$name', + async (row) => { + expectRowWorks(row, await buildRows(bundler, [row])) + }, + timeout, + ) + + // compiler.test.ts "handles circular import chain: $name": the cycles + // never reach a Start factory, and the build ends, built or failed, + // instead of looping (the test's timeout bounds it). + test( + 'a build of modules importing a factory through re-export cycles ends', + async () => { + const files: Record<string, string> = {} + reexportCycles.forEach((cycle, index) => { + for (const [file, code] of Object.entries({ + ...cycle.files, + 'module.tsx': cycleModule, + })) { + files[`src/cycles/c${index}/${file}`] = code + } + }) + files['src/entry.ts'] = reexportCycles + .map( + (_, index) => + `export * as c${index} from './cycles/c${index}/module'\n`, + ) + .join('') + const ended = await buildStart({ + bundler, + files, + entry: 'src/entry.ts', + start: { importProtection: { enabled: false } }, + }).then( + () => 'built', + () => 'failed', + ) + expect(['built', 'failed']).toContain(ended) + }, + timeout, + ) +}) + +// The dev edits of known-bugs-start-compiler.test.ts ("dev edits"), in +// `rsbuild build --watch` (SPEC J4.5, G13): the first build fills the +// build's resolution caches, then one module a factory comes from is +// edited, which the module using the factory does not import directly. +// The rebuild runs the edited code. +describe('rsbuild build --watch', () => { + const dirs = { + reexportChain: 'src/edits/chain', + aliasedEnvOnly: 'src/edits/aliased', + } + const inDir = (dir: string, files: Record<string, string>) => + Object.fromEntries( + Object.entries(files).map(([file, code]) => [`${dir}/${file}`, code]), + ) + const cleanups: Array<() => Promise<void>> = [] + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + let rebuilt: Promise<StartBuild> | undefined + /** The rebuild both edits cause (one watch build). */ + const rebuild = () => + (rebuilt ??= buildStart({ + bundler: 'rsbuild', + files: { + ...inDir(dirs.reexportChain, factoryEdits.reexportChain.files), + ...inDir(dirs.aliasedEnvOnly, factoryEdits.aliasedEnvOnly.files), + 'src/entry.ts': `export * as chain from './edits/chain/module' +export * as aliased from './edits/aliased/module' +`, + 'src/ssr-entry.ts': `export * from './entry'\n${callByIdExports}`, + }, + entry: { client: 'src/entry.ts', ssr: 'src/ssr-entry.ts' }, + start: { importProtection: { enabled: false } }, + watchEdits: { + ...inDir(dirs.reexportChain, factoryEdits.reexportChain.edit), + ...inDir(dirs.aliasedEnvOnly, factoryEdits.aliasedEnvOnly.edit), + }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + })) + + // (The dev server's twin is pinned: known-bugs-start-compiler.test.ts + // "a dev edit of a module a re-export chain ends in recompiles its + // importers".) + test( + 'an edit of the module a re-export chain ends in recompiles its importers', + async () => { + const { client, ssr } = await rebuild() + const call = `try { + return { value: entry.chain.myFn() } +} catch (error) { + return { thrown: String(error?.message ?? error) } +}` + expect({ + client: (await client.run(call)).result, + ssr: (await ssr.run(call)).result, + }).toEqual({ + client: { value: 'server-only-value' }, + ssr: { thrown: expect.any(String) }, + }) + }, + timeout, + ) + + test( + 'an edit of an aliased env-only factory recompiles the server fn that calls it', + async () => { + const { client, ssr } = await rebuild() + const { url } = ( + await client.run(`return { url: entry.aliased.serverFn.url }`) + ).result as { url: string } + expect( + ( + await ssr.run(`${callByIdPrelude}${settlePrelude} +return { + called: await settle(() => entry.aliased.serverFn()), + byId: await settle(() => callById(serverFnId(${JSON.stringify(url)}))), +}`) + ).result, + ).toEqual({ + called: { thrown: expect.any(String) }, + byId: { thrown: expect.any(String) }, + }) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compiler-dev-server.test.ts b/packages/start-plugin-core/tests/integration/start-compiler-dev-server.test.ts new file mode 100644 index 0000000000..e46f06ce4c --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compiler-dev-server.test.ts @@ -0,0 +1,496 @@ +/** + * The Start compiler on a running Vite dev server with Start's whole public + * Vite plugin (client and SSR environments, SSR as the server fn provider): + * edits of server fn factories and handlers reach every environment without + * a restart. Client code runs in a real browser page of the dev server + * (`runViteClient`). + */ +import react from '@vitejs/plugin-react' +import { describe, expect, test } from 'vitest' +import { describeHmr } from '@tanstack/compiler-test-utils/dev-server' +import { requestsOfPrelude } from '../build-harness' +import { + callServerFn, + inDevRequest, + startDevServer, + startRequestFiles, +} from '../dev-server' +import { + runViteClient, + startBrowserStartDevServer, +} from './importProtection/client-pages' + +const timeout = 30_000 + +const factory = `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn() +` +const plain = `export const base = { handler: (fn: () => unknown) => fn }\n` + +describe('Vite dev: editing a server fn factory', () => { + // Mirrors rsbuild/dev-server.test.ts "every module importing a factory + // from ./b that stops being one keeps its handler". + test( + 'client: a module importing a factory that stops being one keeps its handler', + async () => { + // (`src/db.ts` is no denied file: what the client gets of it is the + // compiler's doing, not import protection's mock) + const server = await startBrowserStartDevServer({ + files: { + 'src/b.ts': factory, + 'src/db.ts': `export const db = { x: () => 'MARK_DB_SECRET' }\n`, + 'src/a.tsx': `import { base } from './b' +import { db } from './db' +export const fn = base.handler(async () => db.x()) +`, + }, + }) + /** Runs `script` in a real page that loaded `src/a.tsx` (`entry`). */ + const inClient = async (script: string) => + (await runViteClient(server, '/src/a.tsx', script)).result + expect( + containing(await server.load('/src/a.tsx'), 'MARK_DB_SECRET'), + ).toEqual([]) + // A server fn: the client calls the server, at the server fn's URL + // (its public `url`; the dev id is implementation-specific, J4.4) + const rpc = (await inClient(`${requestsOfPrelude} +return { + url: entry.fn.url, + requests: await requestsOf(entry.fn), +}`)) as { url: string; requests: Array<unknown> } + expect(rpc.url).toEqual(expect.any(String)) + expect(rpc.requests).toEqual([{ url: rpc.url, method: 'GET' }]) + + await server.edit({ 'src/b.ts': plain }) + + // A plain function now: the client runs it + expect(await inClient(`return await entry.fn()`)).toBe('MARK_DB_SECRET') + }, + timeout, + ) +}) + +describe('Vite dev: server fns by id', () => { + // A dev server compiles modules on demand: the resolver must find server + // fns of modules compiled after it first loaded. + // Source: mutation testing. + test( + 'SSR: a server fn of a module compiled after the resolver first loaded runs by id', + async () => { + const server = await startDevServer({ + start: {}, + files: { + ...startRequestFiles, + 'src/first.ts': `import { createServerFn } from '@tanstack/react-start' +export const first = createServerFn().handler(() => 'MARK_FIRST') +`, + 'src/later.ts': `import { createServerFn } from '@tanstack/react-start' +export const later = createServerFn().handler(() => 'MARK_LATER') +`, + }, + }) + /** Calls the server fn `name` of `url` the way a page does: by id. */ + const callById = async (url: string, name: string) => { + const fn = (await server.import(url))[name] + return callServerFn(server, fn) + } + expect(await callById('/src/first.ts', 'first')).toBe('MARK_FIRST') + expect(await callById('/src/later.ts', 'later')).toBe('MARK_LATER') + }, + timeout, + ) +}) + +describe('Vite dev: virtual modules of other plugins', () => { + // Start's dev plugins load their own `\0` virtual modules; a virtual + // module of a plugin placed after Start's must still load from its plugin. + // Source: mutation testing. + test( + 'a virtual module of a plugin placed after the Start compiler loads', + async () => { + const resolvedId = '\0virtual:user-thing' + const server = await startDevServer({ + plugins: [ + { + name: 'user-virtual-module', + resolveId: (source) => + source === 'virtual:user-thing' ? resolvedId : undefined, + load: (id) => + id === resolvedId + ? `export const thing = 'MARK_USER_THING'\n` + : undefined, + }, + ], + files: { + 'src/uses-thing.ts': `export { thing } from 'virtual:user-thing'\n`, + }, + }) + expect((await server.import('/src/uses-thing.ts')).thing).toBe( + 'MARK_USER_THING', + ) + }, + timeout, + ) +}) + +describe('Vite dev: editing a server fn handler', () => { + // Source: replaces server-fn-resolver-module.test.ts "imports on every call + // by default" and "keeps the imported module when memoizeModules is set", + // and the HMR half of exports-and-directives.test.ts "dev providers export + // the handler and accept HMR updates". + test( + 'SSR: the server fn resolver runs the edited handler, without a restart', + async () => { + const server = await startDevServer({ + start: {}, + files: { + ...startRequestFiles, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(() => 'before') +`, + }, + }) + /** + * Calls `greet` the way a page does: by the id its current caller + * carries (an edit may give the server fn a new id, J4.4). + */ + const call = async () => { + const { greet } = await server.import('/src/fns.ts') + return callServerFn(server, greet) + } + expect(await call()).toBe('before') + + await server.edit({ + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const greet = createServerFn().handler(() => 'after') +`, + }) + + expect(await call()).toBe('after') + }, + timeout, + ) + + // An edit of a module only handlers read must not reload the server (or + // the page): the handler runs the new code. Which server state survives + // is Vite's business. + // Source: the HMR half of exports-and-directives.test.ts "dev providers + // export the handler and accept HMR updates"; SPEC G10 (no full reload + // where feasible, no server-state requirement). + test( + 'SSR: an edit of a module only the handler reads does not fully reload, and the handler runs the new code', + async () => { + const server = await startDevServer({ + start: {}, + files: { + ...startRequestFiles, + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +export const greet = createServerFn().handler(() => db.x()) +`, + 'src/db.server.ts': `export const db = { x: () => 'before' }\n`, + }, + }) + const call = async () => { + const { greet } = await server.import('/src/fns.ts') + return callServerFn(server, greet) + } + expect(await call()).toBe('before') + + // What the server sent while it handled the edit (`edit()` settles on + // the watcher's report and Vite's handling of it, not on a quiet + // period). The server side has no page: a full reload of the server + // is the `full-reload` payload Vite sends its environment's module + // runner, so its absence is what J3.6 asks for (not a count of the + // updates the edit takes). + const messages = describeHmr( + await server.edit({ + 'src/db.server.ts': `export const db = { x: () => 'after' }\n`, + }), + ) + + expect(await call()).toBe('after') + expect( + messages.filter((message) => message.includes('full-reload')), + ).toEqual([]) + }, + timeout, + ) +}) + +/** URLs of the served modules (or bundle chunks) that contain `marker`. */ +function containing(modules: Record<string, string>, marker: string) { + return Object.keys(modules).filter((url) => modules[url]!.includes(marker)) +} + +describe('Vite dev: editing a middleware', () => { + /** A function middleware whose `.server()` puts `marker` in the context. */ + const middleware = ( + marker: string, + ) => `import { createMiddleware } from '@tanstack/react-start' +export const mw = createMiddleware({ type: 'function' }) + .client(({ next }) => next()) + .server(({ next }) => next({ context: { marker: '${marker}' } })) +` + + // With Start's whole Vite plugin (its environments and import + // protection, not the compiler plugin alone). No other test edits a + // createMiddleware in dev. + test( + 'the client never gets the edited .server(), and SSR runs the new one', + async () => { + const server = await startDevServer({ + start: {}, + files: { + ...startRequestFiles, + 'src/mw.ts': middleware('MARK_SERVER_V1'), + // A server fn with the middleware: its handler reads what the + // middleware's `.server()` put into the context of the call + 'src/fns.ts': `import { createServerFn } from '@tanstack/react-start' +import { mw } from './mw' +export const marker = createServerFn() + .middleware([mw]) + .handler(async ({ context }) => context.marker) +`, + }, + }) + /** + * What `.server()` puts in the context on the server, for a call over + * HTTP (Start's middleware chain runs it). + */ + const ssrMarker = async () => + callServerFn(server, (await server.import('/src/fns.ts')).marker) + expect( + containing(await server.load('/src/mw.ts'), 'MARK_SERVER_V1'), + ).toEqual([]) + expect(await ssrMarker()).toBe('MARK_SERVER_V1') + + await server.edit({ 'src/mw.ts': middleware('MARK_SERVER_V2') }) + + expect( + containing(await server.load('/src/mw.ts'), 'MARK_SERVER_V2'), + ).toEqual([]) + expect(await ssrMarker()).toBe('MARK_SERVER_V2') + }, + timeout, + ) +}) + +describe('Vite dev: editing an isomorphic fn', () => { + const isomorphic = ( + version: string, + ) => `import { createIsomorphicFn } from '@tanstack/react-start' +export const where = createIsomorphicFn() + .server(() => 'MARK_SERVER_${version}') + .client(() => 'MARK_CLIENT_${version}') +` + + // No other test edits an isomorphic fn in dev. + test( + 'each environment runs its edited branch, and the client never gets the server one', + async () => { + const server = await startBrowserStartDevServer({ + files: { 'src/iso.ts': isomorphic('V1') }, + }) + /** What `where()` returns in each environment, and server code in the client. */ + const run = async (version: string) => ({ + client: ( + await runViteClient(server, '/src/iso.ts', 'return entry.where()') + ).result, + ssr: (await server.import('/src/iso.ts')).where(), + serverCodeInClient: containing( + await server.load('/src/iso.ts'), + `MARK_SERVER_${version}`, + ), + }) + expect(await run('V1')).toEqual({ + client: 'MARK_CLIENT_V1', + ssr: 'MARK_SERVER_V1', + serverCodeInClient: [], + }) + + await server.edit({ 'src/iso.ts': isomorphic('V2') }) + + expect(await run('V2')).toEqual({ + client: 'MARK_CLIENT_V2', + ssr: 'MARK_SERVER_V2', + serverCodeInClient: [], + }) + }, + timeout, + ) +}) + +describe('Vite full-bundle dev (bundledDev)', () => { + /** + * `src/fns.ts` defines a server fn whose handler returns `MARK_HANDLER_*` + * and a client-side label; the client bundle starts from `src/entry.ts`, + * which exports both. `head` is added to `src/fns.ts`. + */ + const fns = ( + version: string, + head = '', + ) => `${head}import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 'MARK_HANDLER_${version}') +export const label = () => 'MARK_CLIENT_LABEL' +` + const entry = `export { fn, label } from './fns'\n` + /** Start's client entry, which the client bundle starts from, loads `src/entry.ts`. */ + const bundledClientEntry = { + 'harness/client-entry.ts': `export * from '../src/entry'\n`, + } + + /** Calls `fn` the way a page does: by its id. */ + async function callById(server: Awaited<ReturnType<typeof startDevServer>>) { + const { fn } = await server.import('/src/fns.ts') + return callServerFn(server, fn) + } + + test( + 'the client bundle has the client code and not the handler, and SSR runs the handler by id', + async () => { + const server = await startDevServer({ + start: {}, + plugins: [react()], + bundledDev: { entry: 'src/entry.ts' }, + files: { + ...startRequestFiles, + ...bundledClientEntry, + 'src/fns.ts': fns('V1'), + 'src/entry.ts': entry, + }, + }) + // The client code is there (in however many chunks), the handler not. + const bundle = await server.clientBundle() + expect(containing(bundle, 'MARK_CLIENT_LABEL')).not.toEqual([]) + expect(containing(bundle, 'MARK_HANDLER_V1')).toEqual([]) + expect(await callById(server)).toBe('MARK_HANDLER_V1') + }, + timeout, + ) + + // In full-bundle dev, the client compiler loads the modules a top-level + // call may come from through the bundler. + // Source: issue #8407 ("cannot load the module info" of a server fn + // module's dependency in bundledDev). + test( + 'a server fn module with a top-level call of a dependency bundles for the client without its handler', + async () => { + const server = await startDevServer({ + plugins: [react()], + bundledDev: { entry: 'src/entry.ts' }, + files: { + ...bundledClientEntry, + 'src/fns.ts': fns( + 'V1', + `import { z } from 'zod'\nexport const schema = z.object({})\n`, + ), + 'src/entry.ts': entry, + }, + }) + const bundle = await server.clientBundle() + expect(containing(bundle, 'MARK_CLIENT_LABEL')).not.toEqual([]) + expect(containing(bundle, 'MARK_HANDLER_V1')).toEqual([]) + expect(server.logs.filter((log) => log.startsWith('error:'))).toEqual([]) + }, + timeout, + ) + + // Source: issue #7535 (SSR does not reflect edits in bundledDev). + test( + 'SSR runs an edited handler, called directly and by id', + async () => { + const server = await startDevServer({ + start: {}, + plugins: [react()], + bundledDev: { entry: 'src/entry.ts' }, + files: { + ...startRequestFiles, + ...bundledClientEntry, + 'src/fns.ts': fns('V1'), + 'src/entry.ts': entry, + }, + }) + expect(await callById(server)).toBe('MARK_HANDLER_V1') + + await server.edit({ 'src/fns.ts': fns('V2') }) + + const { fn } = await server.import('/src/fns.ts') + expect({ + called: await inDevRequest(server, () => fn()), + byId: await callById(server), + }).toEqual({ + called: 'MARK_HANDLER_V2', + byId: 'MARK_HANDLER_V2', + }) + }, + timeout, + ) + + /** + * Serves `src/a.tsx`, which calls `.handler()` on `base` from `src/b.ts` + * (a plain object at first) with a handler reading the module `src/db.ts` + * (no denied file: what the client gets of it is the compiler's doing), + * and edits `src/b.ts` so that `base` becomes a server fn builder. + */ + async function editFactoryIntoBuilder() { + const server = await startDevServer({ + plugins: [react()], + bundledDev: { entry: 'src/a.tsx' }, + files: { + // Start's client entry, which the client bundle starts from + 'harness/client-entry.ts': `export * from '../src/a'\n`, + 'src/b.ts': plain, + 'src/db.ts': `export const db = { x: () => 'MARK_DB_SECRET' }\n`, + 'src/a.tsx': `import { base } from './b' +import { db } from './db' +export const fn = base.handler(async () => db.x()) +`, + }, + }) + expect( + containing(await server.clientBundle(), 'MARK_DB_SECRET'), + ).not.toEqual([]) + await server.edit({ 'src/b.ts': factory }) + return server + } + + // Source: issue #8062 (a hook of the Start compiler plugin threw on an + // edit in bundledDev; fix #8061 had no test). + test( + 'a module whose factory becomes a server fn builder bundles again without errors', + async () => { + const server = await editFactoryIntoBuilder() + await server.clientBundle() + expect(server.logs.filter((log) => log.startsWith('error:'))).toEqual([]) + }, + timeout, + ) + + // Control: "Vite dev: editing a server fn factory" above (unbundled dev, + // where the compiler invalidates the importers of an edited module). + + // Bug: in full-bundle dev, an edit of a module that turns what another + // module imports into a server fn builder does not recompile the + // importer: the dev engine re-bundles the edited module only, and the + // Start compiler's bundledDev `watchChange` forgets the edited module + // alone, so the importer keeps the output compiled against the old + // `base`, handler and server-only imports included. + // Source: packages/start-plugin-core/src/vite/start-compiler-plugin/plugin.ts:412-424 + // (client: `invalidateModule(id)` of the edited module only; the + // unbundled path invalidates the importers, :318-358). + // Impact: with `experimental.bundledDev`, the page keeps loading the + // handler and the modules only it reads (server-only code) in the client + // until the dev server restarts. Found with the real watchers + // (the replaying harness forced a full rebuild, which hid it). + test.fails( + 'a module whose factory becomes a server fn builder: the client bundle drops the handler', + async () => { + const server = await editFactoryIntoBuilder() + expect(containing(await server.clientBundle(), 'MARK_DB_SECRET')).toEqual( + [], + ) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compose-app.ts b/packages/start-plugin-core/tests/integration/start-compose-app.ts new file mode 100644 index 0000000000..df6347e89f --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-app.ts @@ -0,0 +1,240 @@ +/** + * A Start app in production, served the way a host serves it (SPEC G11): + * the app is built with Start's own Vite or + * Rsbuild plugin (`buildStart`), with Start's default entries (the client + * hydrates the document with `StartClient`, the server entry is + * `@tanstack/react-start/server-entry`), and `serveStartBuild` serves the + * client output as static files and hands every other request to the + * server entry's `fetch`, in this process. A real page (headless Chromium, + * `openPage`) then loads the server-rendered document, hydrates with the + * client build and calls server fns over HTTP, as a deployed app does. + * + * Thin glue only: the compilers, bundlers, router, React and Start runtime + * are the real ones; srvx owns HTTP request/response adaptation and the + * host only selects static output or Start's fetch handler. + */ +import { createRequire } from 'node:module' +import path from 'node:path' +import { pathToFileURL } from 'node:url' +import { serve } from 'srvx/node' +import { staticMiddleware } from 'srvx/static' +import ts from 'typescript' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { callByIdExports } from '../build-harness' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { StartBuild } from '../build-harness' + +/** + * Start's default entries of a page app, with the test entries' exports on + * the harness's global for `ssr.run` scripts (`entry`) and, in the page, on + * `globalThis.__app`: the client entry hydrates the document Start's server + * entry rendered (`StartClient`) and exposes `src/client-entry.ts`; the + * server entry is Start's HTTP handler (`fetch`), the default export a host + * imports, and exposes `src/ssr-entry.ts`. + */ +export const startPageEntries = { + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +import * as entry from '../src/client-entry' +;(globalThis as any).__app = entry +hydrateRoot(document, createElement(StartClient)) +`, + 'harness/server-entry.ts': `import handler from '@tanstack/react-start/server-entry' +import * as entry from '../src/ssr-entry' +;(globalThis as any).__tssBuildHarnessEntry = entry +export default handler +`, +} + +/** + * The test entries of a page app: the client's exposes the app's router; + * the SSR one also exposes the harness's `renderPath` and Start's server + * entry and client RPC for `callByIdPrelude`. + */ +export const pageEntries = { + 'src/client-entry.ts': `export { getRouter } from './router'\n`, + 'src/ssr-entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +${callByIdExports}`, +} + +/** `src/router.ts` of a page app: the real router over the generated tree. */ +export const routerFile = `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +` + +/** + * A root route rendering the document: `HeadContent`, the outlet under + * `#app`, a hydration marker, links to `to` (each `data-testid="to-<name>"`, + * the name being the path without its slashes), `Scripts`, and a not-found + * component. + */ +export function rootDocument(to: Array<string> = []) { + const links = to + .map( + (target) => + `<Link to=${JSON.stringify(target)} data-testid=${JSON.stringify(`to-${target.replace(/\//g, '') || 'home'}`)}>${target}</Link>`, + ) + .join('\n ') + return `import { HeadContent, Link, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: Root, + notFoundComponent: () => <p>MARK_NOT_FOUND</p>, +}) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <nav> + ${links} + </nav> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +` +} + +export interface ServedStartBuild { + /** Origin of the host (with a trailing slash). */ + url: string + /** Sends a request to the host (relative URLs are of its origin). */ + fetch: (url: string, init?: RequestInit) => Promise<Response> + close: () => Promise<void> +} + +/** + * Node's own `import()`, outside Vitest's module runner: a built server + * bundle loads its chunks itself (Rspack's by `file:` URL), which the + * runner would try to resolve. + */ +const nativeImport = createRequire(import.meta.url)( + '../../../compiler-test-utils/src/native-import.cjs', +) as (specifier: string) => Promise<Record<string, unknown>> + +/** + * The server entry's `fetch` of the SSR build, imported in this process: + * what a host calls with each request. + */ +async function serverFetch(build: StartBuild) { + const entryFile = path.join(build.ssr.outDir, build.ssr.entry.fileName) + const module = (await nativeImport(pathToFileURL(entryFile).href)) as { + default?: { fetch?: unknown; default?: { fetch?: unknown } } + } + const handler = module.default?.fetch + ? module.default + : module.default?.default + if (typeof handler?.fetch !== 'function') { + throw new Error(`${entryFile} does not export a server entry`) + } + return handler.fetch as (request: Request) => Promise<Response> +} + +/** + * Serves `build` on a free local port: a file of the client output + * directory for a request whose path names one, the server entry for every + * other request. + */ +export async function serveStartBuild( + build: StartBuild, + options: { registerCleanup?: (cleanup: () => Promise<void>) => void } = {}, +): Promise<ServedStartBuild> { + const handle = await serverFetch(build) + const clientDir = path.resolve(build.client.outDir) + const server = serve({ + hostname: '127.0.0.1', + port: 0, + silent: true, + middleware: [staticMiddleware({ dir: clientDir })], + fetch: handle, + }) + await server.ready() + const url = server.url! + const close = () => server.close(true) + options.registerCleanup?.(close) + return { + url, + fetch: (target, init) => fetch(new URL(target, url), init), + close, + } +} + +export interface AppPage extends BrowserPage { + /** + * Paths of the server fn requests the page sent since it loaded, in + * order. + */ + serverFnRequests: Array<string> + /** + * URLs (path and query) of the scripts the page requested since it + * loaded, in order: what a navigation loads on demand. + */ + scriptRequests: Array<string> + /** Clicks the link `data-testid="to-<name>"` of `rootDocument`. */ + follow: (name: string) => Promise<void> +} + +/** + * Opens `pathname` of a served app in a page and waits until it hydrated + * (`rootDocument`'s marker), recording the requests it sends from then on. + */ +export async function openAppPage( + served: Pick<ServedStartBuild, 'url'>, + pathname: string, + options: { registerCleanup?: (cleanup: () => Promise<void>) => void } = {}, +): Promise<AppPage> { + const serverFnRequests: Array<string> = [] + const scriptRequests: Array<string> = [] + const page = await openPage(new URL(pathname, served.url).href, options) + page.page.on('request', (request) => { + const url = new URL(request.url()) + if (url.pathname.startsWith('/_serverFn/')) { + serverFnRequests.push(url.pathname) + } else if (request.resourceType() === 'script') { + scriptRequests.push(url.pathname + url.search) + } + }) + await page.waitForText('hydrated', { selector: '[data-testid=hydrated]' }) + return { + ...page, + serverFnRequests, + scriptRequests, + follow: (name) => page.page.locator(`[data-testid=to-${name}]`).click(), + } +} + +/** + * Type-checks `files` of the app at `root` with the real declarations the + * app resolves; returns the diagnostics (empty when it compiles). + */ +export function typeCheck(root: string, files: Array<string>) { + const program = ts.createProgram( + files.map((file) => path.join(root, file)), + { + strict: true, + noEmit: true, + target: ts.ScriptTarget.ESNext, + module: ts.ModuleKind.ESNext, + moduleResolution: ts.ModuleResolutionKind.Bundler, + allowImportingTsExtensions: true, + jsx: ts.JsxEmit.Preserve, + skipLibCheck: true, + types: [], + }, + ) + return ts.getPreEmitDiagnostics(program).map((diagnostic) => { + const where = diagnostic.file + ? `${path.relative(root, diagnostic.file.fileName)}:${diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start ?? 0).line + 1}` + : '' + return `${where} ${ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n')}` + }) +} diff --git a/packages/start-plugin-core/tests/integration/start-compose-client-only.test.ts b/packages/start-plugin-core/tests/integration/start-compose-client-only.test.ts new file mode 100644 index 0000000000..082e196ea0 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-client-only.test.ts @@ -0,0 +1,134 @@ +/** + * `<ClientOnly>` children importing a `*.client.*` module in a route component, + * in a default-config Start build (SPEC J4.11): the module is one import + * protection denies on the server, and only the children use it, so the server + * build must not load it: a default-config build reports no import-protection + * violation, the server bundle holds none of its code, Start's real server + * entry renders the fallback (the module reads `window` at its top level, so + * loading it on the server would throw), and the page renders the children once + * hydrated. The route component is split by Start's code splitter, so the Start + * compiler, the splitter and import protection all touch the module (G11). + * Built with Start's Vite and Rsbuild plugins and served like a deployed app + * (start-compose-app.ts). + */ +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { BuildError } from '@tanstack/compiler-test-utils/build-harness' +import { buildStart, startBundlers } from '../build-harness' +import { reportedViolations } from '../importProtection/start-apps' +import { + openAppPage, + pageEntries, + rootDocument, + routerFile, + serveStartBuild, + startPageEntries, +} from './start-compose-app' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const files = { + ...startPageEntries, + 'src/chart.client.tsx': `// A browser-only module: evaluating it anywhere else throws. +const width = window.innerWidth +export function Chart() { + return <p data-testid="chart">MARK_CHART {width > 0 ? 'wide' : 'narrow'}</p> +} +`, + 'src/routes/__root.tsx': rootDocument(), + 'src/routes/index.tsx': `import { ClientOnly, createFileRoute } from '@tanstack/react-router' +import { Chart } from '../chart.client' +function Page() { + return ( + <main> + <h1>MARK_INDEX</h1> + <ClientOnly fallback={<p data-testid="chart">MARK_LOADING</p>}> + <Chart /> + </ClientOnly> + </main> + ) +} +export const Route = createFileRoute('/')({ component: Page }) +`, + 'src/router.ts': routerFile, + ...pageEntries, +} + +describe.each(startBundlers)( + '%s build with the default configuration', + (bundler) => { + let build: StartBuild | undefined + let failure: BuildError | undefined + const cleanups: Array<() => Promise<void>> = [] + + beforeAll(async () => { + try { + build = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + } catch (error) { + if (!(error instanceof BuildError)) { + throw error + } + failure = error + } + }, timeout) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + const built = () => { + if (!build) { + throw failure + } + return build + } + + test('builds, and reports no import-protection violation', () => { + expect(failure).toBeUndefined() + expect( + // (every channel of the build) + reportedViolations(built()), + ).toEqual([]) + }) + + test('the server bundle holds none of the client-only module', () => { + expect(built().ssr.where('MARK_CHART')).toBe('nowhere') + }) + + test( + 'the server renders the fallback, and the page renders the children once hydrated', + async () => { + const served = await serveStartBuild(built(), { + registerCleanup: onTestFinished, + }) + const response = await served.fetch('/') + const html = await response.text() + expect({ status: response.status, html }).toEqual({ + status: 200, + html: expect.stringContaining('MARK_LOADING'), + }) + expect(html).not.toContain('MARK_CHART') + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_CHART wide', { + selector: '[data-testid=chart]', + }) + expect(page.errors).toEqual([]) + }, + timeout, + ) + }, +) diff --git a/packages/start-plugin-core/tests/integration/start-compose-imported-options.test.ts b/packages/start-plugin-core/tests/integration/start-compose-imported-options.test.ts new file mode 100644 index 0000000000..287abb8732 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-imported-options.test.ts @@ -0,0 +1,131 @@ +/** + * Route options imported from another module under Start (SPEC J2.8, + * J2.14, J4.12): `createFileRoute('/x')(options)` with `options` from + * `x.options.tsx`, holding a component, a loader and server handlers + * that read a server-only helper (a neutral file name, so only the route + * option's removal keeps it out of the client). The route works on the + * server; the client build never ships the handlers silently: they and the + * helper are absent from the client bundle, or the build reports or fails + * naming the route file. Built with Start's Vite and Rsbuild plugins. + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { + expectDiagnostic, + findDiagnostics, +} from '@tanstack/compiler-test-utils/diagnostics' +import { + StartBuildError, + buildStart, + callByIdExports, + startBundlers, +} from '../build-harness' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const files = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/admin-helper.ts': `export const readSecret = () => 'MARK_HELPER_SECRET'\n`, + 'src/x.options.tsx': `import { readSecret } from './admin-helper' +export const options = { + component: () => <p>MARK_X_PAGE</p>, + loader: () => 'MARK_X_DATA', + server: { handlers: { GET: () => new Response(readSecret()) } }, +} +`, + 'src/routes/x.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { options } from '../x.options' +export const Route = createFileRoute('/x')(options) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/client-entry.ts': `export { getRouter } from './router'\n`, + 'src/ssr-entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +${callByIdExports}`, +} + +describe.each(startBundlers)('%s build', (bundler) => { + let build: StartBuild | undefined + let failure: StartBuildError | undefined + let dispose: (() => Promise<void>) | undefined + + beforeAll(async () => { + try { + build = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + } catch (error) { + if (!(error instanceof StartBuildError)) { + throw error + } + failure = error + } + }, timeout) + afterAll(() => dispose?.()) + + test('the route renders and its handler answers on the server', async () => { + if (failure) { + // A refusal names the route file (SPEC J2.8, §5.7) + expectDiagnostic(failure.diagnostics, { + severity: 'error', + file: 'src/routes/x.tsx', + }) + return + } + expect(build).toBeDefined() + const { result } = await build!.ssr.run(`const router = entry.getRouter() +const response = await entry.startServerEntry.fetch(new Request('http://localhost/x')) +return { + page: await entry.renderPath(router.routeTree, '/x'), + loader: await router.routeTree.children.find((route) => route.options.id === '/x').options.loader(), + handler: await response.text(), +}`) + expect(result).toEqual({ + page: expect.stringContaining('MARK_X_PAGE'), + loader: 'MARK_X_DATA', + handler: 'MARK_HELPER_SECRET', + }) + }) + + // Bug: the code splitter resolves route options only from an object + // literal in the route file (`resolveIdentifier`, compilers.ts), so for + // an imported options object it neither splits nor deletes anything, and + // says nothing: Start's client build keeps `server.handlers` and ships + // the helper they read. + // Impact: server code in the client bundle, silently. + // SPEC J2.8: "options the compiler cannot read statically ... never ships + // their ssr/server/headers silently". + test.fails( + 'the client build never ships the server handlers of imported route options silently', + () => { + if (failure) { + // A build that refuses the shape must name the route file (on any + // channel of the build; SPEC J2.8, §5.7). + expectDiagnostic(failure.diagnostics, { + severity: 'error', + file: 'src/routes/x.tsx', + }) + return + } + // (every channel of the build; a warning that informs the user names + // the route file) + const reported = findDiagnostics(build!.diagnostics, { + severity: 'warning', + file: 'src/routes/x.tsx', + }) + if (reported.length === 0) { + expect(build!.client.where('MARK_HELPER_SECRET')).toBe('nowhere') + } + }, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compose-project-path.test.ts b/packages/start-plugin-core/tests/integration/start-compose-project-path.test.ts new file mode 100644 index 0000000000..f595276824 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-project-path.test.ts @@ -0,0 +1,131 @@ +/** + * The project's path and the generated route tree's name (SPEC §2.1, + * J2.15, G1): a Start app whose directory carries characters a project path + * may (`my app (2)+`) builds, and its client route tree leaves + * out the server-only route like any other app's; and an app file whose + * name is one character away from the generated route tree's + * (`src/routeTree-gen.ts`) is the file it is, not the client route tree. + * Built with Start's Vite plugin (Rsbuild as a control: it has no client + * route tree of its own yet, see known-bugs-route-options.test.ts). + */ +import { afterAll, beforeAll, describe, expect, test } from 'vitest' +import { buildStart, startBundlers } from '../build-harness' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const head = `import { createFileRoute } from '@tanstack/react-router'\n` + +const routes = { + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ component: () => 'MARK_INDEX' })\n`, + 'src/routes/api.tsx': `${head}export const Route = createFileRoute('/api')({ server: { handlers: { GET: () => new Response('MARK_API') } } })\n`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +`, +} + +/** Ids of the routes of the build's client route tree. */ +const clientRouteIds = `return Object.values(entry.getRouter().routeTree.children ?? {}).map((route) => route.options.id)` + +describe.each(startBundlers)('%s build', (bundler) => { + describe('of an app whose path has characters a regular expression reads', () => { + let build: StartBuild + let dispose: (() => Promise<void>) | undefined + beforeAll(async () => { + build = await buildStart({ + bundler, + prefix: `.start-build-harness-${bundler} my app (2)+-`, + files: { + ...routes, + 'src/entry.ts': `export { getRouter } from './router' +export { renderPath } from '../harness/render' +`, + }, + entry: 'src/entry.ts', + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + }, timeout) + afterAll(() => dispose?.()) + + test('builds, and the page renders', async () => { + expect(build.client.root).toMatch(/my app \(2\)\+/) + expect( + ( + await build.ssr.run( + `${clientRouteIds.replace('return ', 'const ids = ')} +return { ids, page: await entry.renderPath(entry.getRouter().routeTree, '/') }`, + ) + ).result, + ).toEqual({ + ids: expect.arrayContaining(['/', '/api']), + page: expect.stringContaining('MARK_INDEX'), + }) + }) + + // Bug: Start's Vite plugin matches the module to serve the client route + // tree for with `new RegExp(<path of the generated route tree>)` + // (vite/start-router-plugin/plugin.ts, `clientTreePlugin.load.filter`), + // the path unescaped, so under a path with `(`, `)` or `+` the + // expression never matches the file and the client gets the full tree. + // Rsbuild: no client route tree at all (known-bugs-route-options.test.ts + // "a route with only server handlers is not in the client route tree"). + // Impact: the client bundle ships the server-only routes' entries and + // modules; a page can navigate to a route that has no page. + test.fails( + 'the client route tree leaves out the server-only route', + async () => { + expect((await build.client.run(clientRouteIds)).result).toEqual(['/']) + }, + ) + }) + + describe('of an app with a file named one character away from the generated route tree', () => { + let build: StartBuild | undefined + let failure: unknown + let dispose: (() => Promise<void>) | undefined + beforeAll(async () => { + try { + build = await buildStart({ + bundler, + files: { + ...routes, + 'src/routeTree-gen.ts': `export const sibling = 'MARK_SIBLING'\n`, + 'src/entry.ts': `export { getRouter } from './router' +export { sibling } from './routeTree-gen' +`, + }, + entry: 'src/entry.ts', + registerCleanup: (cleanup) => { + dispose = cleanup + }, + }) + } catch (error) { + failure = error + } + }, timeout) + afterAll(() => dispose?.()) + + // Bug: the same unescaped `new RegExp(<path>)` (above): its `.` before + // `gen` matches any character, so `src/routeTree-gen.ts` is served the + // client route tree instead of its own code. + // Impact: the build fails (the file's exports are gone) or the app + // reads the wrong module. + ;(bundler === 'vite' ? test.fails : test)( + 'the client gets the file, not the client route tree', + async () => { + if (!build) { + throw failure + } + expect((await build.client.run(`return entry.sibling`)).result).toBe( + 'MARK_SIBLING', + ) + }, + ) + }) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compose-server-fn-route.test.ts b/packages/start-plugin-core/tests/integration/start-compose-server-fn-route.test.ts new file mode 100644 index 0000000000..4163ae8ff1 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-server-fn-route.test.ts @@ -0,0 +1,275 @@ +/** + * A route file whose server fn the loader and the split component both read + * (SPEC G11, J4.1, J4.12, J2.3, J2.4): the Start compiler, + * the code splitter and import protection compose on one module. Built + * with Start's Vite and Rsbuild plugins and served like a deployed app + * (start-compose-app.ts), with the real router: the server renders the + * loader's data; in a real page, navigating to the route runs the loader + * through the server fn and a click calls it again, both by the id the + * server's handler is registered under; the component's chunk loads on + * navigation; the route module's state initialises once in the page, and + * the chunk shares it; nothing of the server-only module reaches the + * client; import protection reports nothing. A Vite dev server with Start's + * whole plugin serves the same app to a page. + */ +import react from '@vitejs/plugin-react' +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { buildStart, callByIdPrelude, startBundlers } from '../build-harness' +import { startDevServer, startServerEntryFiles } from '../dev-server' +import { + reportedViolations, + violationRecorder, +} from '../importProtection/start-apps' +import { + openAppPage, + pageEntries, + rootDocument, + routerFile, + serveStartBuild, + startPageEntries, +} from './start-compose-app' +import type { AppPage } from './start-compose-app' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const files = { + 'src/db.server.ts': `export const secret = () => 'MARK_SECRET'\n`, + 'src/routes/__root.tsx': rootDocument(['/', '/posts']), + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +export const Route = createFileRoute('/')({ component: () => <p>MARK_HOME</p> }) +`, + 'src/routes/posts.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { createServerFn } from '@tanstack/react-start' +import { useState } from 'react' +import { secret } from '../db.server' + +// Module state the loader fills and the component reads: one instance. +const cache = new Map<string, string>() +// Top-level code of the route module: runs once per environment. +;(globalThis as any).__postsInits = ((globalThis as any).__postsInits ?? 0) + 1 + +const getPosts = createServerFn().handler(async () => 'posts:' + secret()) + +function Posts() { + const data = Route.useLoaderData() + const [clicked, setClicked] = useState('') + return ( + <div> + <p data-testid="data">{'MARK_POSTS_COMPONENT ' + data}</p> + <button + data-testid="load" + onClick={async () => { + setClicked((await getPosts()) + '|' + (cache.get('posts') ?? 'MARK_NO_CACHE')) + }} + > + load + </button> + <p data-testid="clicked">{clicked}</p> + </div> + ) +} + +export const Route = createFileRoute('/posts')({ + loader: async () => { + const posts = await getPosts() + cache.set('posts', posts) + return posts + }, + component: Posts, +}) +`, + 'src/router.ts': routerFile, + ...pageEntries, +} + +/** + * Drives the page of the app at `/`: navigates to `/posts` (the loader runs + * through the server fn), clicks `load` (the component calls it), and + * returns what the page showed, sent and loaded. + */ +async function visitPosts(page: AppPage) { + const scriptsBefore = page.scriptRequests.length + await page.follow('posts') + await page.waitForText('MARK_POSTS_COMPONENT posts:MARK_SECRET', { + selector: '[data-testid=data]', + }) + const scriptsLoadedForPosts = page.scriptRequests.slice(scriptsBefore) + await page.page.locator('[data-testid=load]').click() + await page.waitForText(/posts:MARK_SECRET\|/, { + selector: '[data-testid=clicked]', + }) + return { + clicked: await page.text('[data-testid=clicked]'), + inits: await page.page.evaluate<number>('globalThis.__postsInits'), + requests: [...page.serverFnRequests], + scriptsLoadedForPosts, + errors: [...page.errors], + } +} + +/** What `visitPosts` must give, the loaded scripts aside. */ +const visited = { + // The click's call reached the handler, and the chunk reads the route + // module's cache the loader filled (one instance). + clicked: 'posts:MARK_SECRET|posts:MARK_SECRET', + inits: 1, + // The loader's call and the click's call: two requests, the same id. + requests: [expect.stringMatching(/^\/_serverFn\/./), expect.any(String)], + errors: [], +} + +describe.each(startBundlers)('%s production build, served', (bundler) => { + let build: StartBuild + const cleanups: Array<() => Promise<void>> = [] + let served: Awaited<ReturnType<typeof serveStartBuild>> + + beforeAll(async () => { + build = await buildStart({ + bundler, + files: { ...startPageEntries, ...files }, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + served = await serveStartBuild(build, { + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + }, timeout) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + test('nothing of the server-only module is in the client build, and import protection reports nothing', () => { + expect({ + secret: build.client.where('MARK_SECRET'), + serverModule: build.client.chunks + .filter((chunk) => chunk.code.includes('db.server')) + .map((chunk) => chunk.fileName), + // (every channel of the build) + violations: reportedViolations(build), + }).toEqual({ secret: 'nowhere', serverModule: [], violations: [] }) + }) + + test('the component is in a chunk of its own', () => { + expect(build.client.where('MARK_POSTS_COMPONENT')).toBe('lazy') + }) + + test( + 'the server renders the loader data through the server fn', + async () => { + const { result } = await build.ssr.run( + `return await entry.renderPath(entry.getRouter().routeTree, '/posts')`, + ) + expect(result).toContain('MARK_POSTS_COMPONENT posts:MARK_SECRET') + }, + timeout, + ) + + // Same bug as known-bugs-start-compiler.test.ts "SSR: a server fn module + // is initialised once and shares its state with SSR code": the SSR bundle + // holds the route module twice (the SSR module and the server fn provider + // module of the same file), so its top-level code runs twice. + test.fails( + 'the server runs the route module once', + async () => { + const { result } = await build.ssr.run( + `await entry.renderPath(entry.getRouter().routeTree, '/posts') +return globalThis.__postsInits`, + ) + expect(result).toBe(1) + }, + timeout, + ) + + test( + 'the page navigates to the route, loads its chunk, and the loader and a click call the same server fn the server answers', + async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + const result = await visitPosts(page) + const chunks = build.client.locate('MARK_POSTS_COMPONENT').lazy + expect(result).toEqual({ + ...visited, + scriptsLoadedForPosts: expect.arrayContaining( + chunks.map((chunk) => `/${chunk}`), + ), + }) + expect(result.requests[1]).toBe(result.requests[0]) + // That id is the one the server's handler is registered under. + const id = result.requests[0]!.slice('/_serverFn/'.length) + expect( + ( + await build.ssr.run( + `${callByIdPrelude}return await callById(${JSON.stringify(id)})`, + ) + ).result, + ).toBe('posts:MARK_SECRET') + }, + timeout, + ) +}) + +describe('Vite dev server with Start', () => { + test( + 'the page navigates to the route, and the loader and a click call the same server fn the dev server answers', + async () => { + const recorder = violationRecorder() + const server = await startDevServer({ + start: { importProtection: recorder.importProtection }, + browser: true, + config: { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + ], + }, + }, + plugins: [react()], + files: { + ...startServerEntryFiles, + 'harness/client-entry.ts': + startPageEntries['harness/client-entry.ts'], + ...files, + }, + }) + const page = await openAppPage({ url: server.url! }, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + const result = await visitPosts(page) + expect(result).toEqual({ + ...visited, + scriptsLoadedForPosts: expect.any(Array), + }) + // The route's component loads on navigation: one of the scripts the + // page requested then serves it (whatever its URL). + const served = await Promise.all( + result.scriptsLoadedForPosts.map( + async (url) => (await server.fetch(url)).body, + ), + ) + expect(served.some((code) => code.includes('MARK_POSTS_COMPONENT'))).toBe( + true, + ) + expect(result.requests[1]).toBe(result.requests[0]) + expect(reportedViolations({ root: server.root, ...recorder })).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-compose-server-only-routes.test.ts b/packages/start-plugin-core/tests/integration/start-compose-server-only-routes.test.ts new file mode 100644 index 0000000000..84af69c4f1 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-compose-server-only-routes.test.ts @@ -0,0 +1,295 @@ +/** + * Server-only routes among pages (SPEC J2.15, J1.9, J1.13): + * a route with only server handlers (`/admin`) that is the parent of a page + * (`/admin/users`), a server-only subtree (`/api`, `/api/users`), and a + * page whose component comes in through a spread (`/spread`). Built with + * Start's Vite and Rsbuild plugins and served like a deployed app + * (start-compose-app.ts): the client route tree keeps the page under its + * server-only ancestor and the spread route, and leaves out the server-only + * subtree, so client-side navigation reaches the pages and finds nothing at + * the server-only routes; the server keeps every route: each handler + * answers and each page renders; and the generated route tree's types know + * every route (tsc). The page under the server-only ancestor has a server + * handler of its own, reading a Node builtin through a helper: Start's + * client `deleteNodes` takes both with the handler, so the client build + * neither resolves nor warns about it (SPEC J2.14, J4.12, G16). + */ +import { writeFile } from 'node:fs/promises' +import path from 'node:path' +import { + afterAll, + beforeAll, + describe, + expect, + onTestFinished, + test, +} from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { buildStart, startBundlers } from '../build-harness' +import { probeRoutePath } from '../request-probe' +import { + openAppPage, + pageEntries, + rootDocument, + routerFile, + serveStartBuild, + startPageEntries, + typeCheck, +} from './start-compose-app' +import type { AppPage, ServedStartBuild } from './start-compose-app' +import type { StartBuild } from '../build-harness' + +const timeout = 60_000 + +const head = `import { createFileRoute } from '@tanstack/react-router'\n` +const handler = (method: 'GET' | 'POST', text: string) => + `server: { handlers: { ${method}: () => new Response('${text}') } }` + +const files = { + ...startPageEntries, + 'src/routes/__root.tsx': rootDocument([ + '/', + '/admin/users', + '/spread', + '/api/users', + ]), + 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ component: () => <p>MARK_HOME</p> })\n`, + // A server-only route with a page under it (its handler answers POST, so + // nothing renders at its own path). + 'src/routes/admin.tsx': `${head}export const Route = createFileRoute('/admin')({ ${handler('POST', 'MARK_ADMIN_HANDLER')} })\n`, + 'src/routes/admin/users.tsx': `${head}import { Buffer } from 'node:buffer' +const encode = (value: string) => Buffer.from(value).toString('base64') +export const Route = createFileRoute('/admin/users')({ + server: { handlers: { POST: () => new Response(encode('admin users')) } }, + component: () => <p>MARK_ADMIN_PAGE</p>, +}) +`, + // A server-only subtree. + 'src/routes/api/route.tsx': `${head}export const Route = createFileRoute('/api')({ ${handler('GET', 'MARK_API_HANDLER')} })\n`, + 'src/routes/api/users.ts': `${head}export const Route = createFileRoute('/api/users')({ ${handler('GET', 'MARK_USERS_HANDLER')} })\n`, + // A page whose component the route options spread in (its handler + // answers POST, so GET renders the page). + 'src/routes/spread.tsx': `${head}const page = { component: () => <p>MARK_SPREAD_PAGE</p> } +export const Route = createFileRoute('/spread')({ ${handler('POST', 'MARK_SPREAD_HANDLER')}, ...page }) +`, + 'src/router.ts': routerFile, + // The types of the builtin the handler above reads, as @types/node gives + // them to a real app (the type check below loads no `@types`). + 'src/node-buffer.d.ts': `declare module 'node:buffer' { + export const Buffer: { from(value: string): { toString(encoding: string): string } } +} +`, + ...pageEntries, +} + +/** Ids of the routes of a route tree of the real router, depth first. */ +const routeIds = `const ids = (route) => Object.values(route.children ?? {}).flatMap((child) => [ + child.id, + ...ids(child), +])` + +/** + * After a link click from the home page: waits until the page's URL + * matches `url` and the outlet no longer shows the home page, and returns + * the outlet's text (empty for a route without a page). + */ +async function settledOutlet(page: AppPage, url: RegExp) { + await page.page.waitForURL(url, { timeout: 5_000 }) + const deadline = Date.now() + 5_000 + let text = await page.text('#app') + while (text.includes('MARK_HOME') && Date.now() < deadline) { + await new Promise((resolve) => setTimeout(resolve, 25)) + text = await page.text('#app') + } + return text +} + +/** Every route of the app. */ +const allRoutes = [ + '/', + '/admin', + '/admin/users', + '/api', + '/api/users', + '/spread', +] + +/** + * Type assertions on the generated route tree: every route, the server-only + * ones included, is in its types. + */ +const typeChecks = `import type { FileRouteTypes } from './routeTree.gen' +type Expect<T extends true> = T +export type Checks = [ + Expect<'/admin/users' extends FileRouteTypes['to'] ? true : false>, + Expect<'/spread' extends FileRouteTypes['to'] ? true : false>, + Expect<'/admin' extends FileRouteTypes['id'] ? true : false>, + Expect<'/api' extends FileRouteTypes['id'] ? true : false>, + Expect<'/api/users' extends FileRouteTypes['id'] ? true : false>, +] +` + +describe.each(startBundlers)('%s build, served', (bundler) => { + let build: StartBuild + let served: ServedStartBuild + const cleanups: Array<() => Promise<void>> = [] + /** Ids of the routes of the client build's route tree. */ + let clientRoutes: Array<string> + + beforeAll(async () => { + build = await buildStart({ + bundler, + files, + entry: { client: 'src/client-entry.ts', ssr: 'src/ssr-entry.ts' }, + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + served = await serveStartBuild(build, { + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + const page = await openAppPage(served, '/', { + registerCleanup: (cleanup) => cleanups.push(cleanup), + }) + clientRoutes = await page.page.evaluate<Array<string>>( + `(() => { ${routeIds}; return ids(globalThis.__app.getRouter().routeTree) })()`, + ) + }, timeout) + + afterAll(async () => { + await Promise.all(cleanups.map((cleanup) => cleanup())) + }) + + test('the server route tree has every route', async () => { + const { result } = await build.ssr.run( + `${routeIds}\nreturn ids(entry.getRouter().routeTree)`, + ) + // (besides the harness's probe route, which serves the requests SSR + // scripts run in) + expect( + (result as Array<string>).filter((id) => id !== probeRoutePath).sort(), + ).toEqual([...allRoutes].sort()) + }) + + test('every server handler answers, and every page renders on the server', async () => { + const text = async (pathname: string, method: 'GET' | 'POST' = 'GET') => + (await served.fetch(pathname, { method })).text() + expect({ + admin: await text('/admin', 'POST'), + adminUsers: await text('/admin/users', 'POST'), + spread: await text('/spread', 'POST'), + api: await text('/api'), + users: await text('/api/users'), + adminPage: await text('/admin/users'), + spreadPage: await text('/spread'), + }).toEqual({ + admin: 'MARK_ADMIN_HANDLER', + adminUsers: Buffer.from('admin users').toString('base64'), + spread: 'MARK_SPREAD_HANDLER', + api: 'MARK_API_HANDLER', + users: 'MARK_USERS_HANDLER', + adminPage: expect.stringContaining('MARK_ADMIN_PAGE'), + spreadPage: expect.stringContaining('MARK_SPREAD_PAGE'), + }) + }) + + test('the client build neither bundles nor warns about the builtin only a deleted handler reads', () => { + expect(build.client.where('node:buffer')).toBe('nowhere') + expect( + findDiagnostics(build.client.warnings, { + file: 'src/routes/admin/users.tsx', + root: build.root, + }), + ).toEqual([]) + }) + + test('the generated route tree types every route', async () => { + await writeFile(path.join(build.ssr.root, 'src/check.ts'), typeChecks) + expect( + typeCheck(build.ssr.root, [ + 'src/routeTree.gen.ts', + 'src/check.ts', + 'src/node-buffer.d.ts', + ]), + ).toEqual([]) + }) + + test('the client route tree keeps the page under its server-only ancestor, and the ancestor', () => { + expect(clientRoutes).toEqual( + expect.arrayContaining(['/', '/admin', '/admin/users']), + ) + }) + + // Rsbuild: same bug as known-bugs-route-options.test.ts "a route with + // only server handlers is not in the client route tree" (only Start's + // Vite plugin prunes the client route tree). + ;(bundler === 'vite' ? test : test.fails)( + 'the client route tree leaves out the server-only subtree', + () => { + expect(clientRoutes.filter((id) => id.startsWith('/api'))).toEqual([]) + }, + ) + + // Vite: same bug as known-bugs-route-options.test.ts "a route with server + // handlers and these options is in the client route tree: a spread" (the + // route generator misses the spread component, so Start takes the route + // for server-only and prunes it; Rsbuild prunes nothing). + ;(bundler === 'vite' ? test.fails : test)( + 'the client route tree keeps the page whose component is spread in', + () => { + expect(clientRoutes).toContain('/spread') + }, + ) + + test( + 'client-side navigation reaches the page under the server-only ancestor', + async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + await page.follow('adminusers') + await page.waitForText('MARK_ADMIN_PAGE', { selector: '#app' }) + await page.follow('home') + await page.waitForText('MARK_HOME', { selector: '#app' }) + expect({ loads: page.loads(), errors: page.errors }).toEqual({ + loads: 1, + errors: [], + }) + }, + timeout, + ) + + // Rsbuild: the server-only route is in the client route tree (pinned + // above), so the navigation finds a route without a page. + ;(bundler === 'vite' ? test : test.fails)( + 'client-side navigation to a server-only route finds nothing', + async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + await page.follow('apiusers') + expect(await settledOutlet(page, /\/api\/users$/)).toContain( + 'MARK_NOT_FOUND', + ) + expect(page.loads()).toBe(1) + }, + timeout, + ) + + // Vite: the spread route is pruned (pinned above). + ;(bundler === 'vite' ? test.fails : test)( + 'client-side navigation reaches the page whose component is spread in', + async () => { + const page = await openAppPage(served, '/', { + registerCleanup: onTestFinished, + }) + await page.waitForText('MARK_HOME', { selector: '#app' }) + await page.follow('spread') + expect(await settledOutlet(page, /\/spread$/)).toContain( + 'MARK_SPREAD_PAGE', + ) + expect(page.loads()).toBe(1) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-dev-restart.test.ts b/packages/start-plugin-core/tests/integration/start-dev-restart.test.ts deleted file mode 100644 index faca6d3068..0000000000 --- a/packages/start-plugin-core/tests/integration/start-dev-restart.test.ts +++ /dev/null @@ -1,54 +0,0 @@ -/** - * A Vite dev server restart (`r` in the terminal, or an edit of the Vite - * config) loads the app's Vite config again, with new Start plugin - * instances: they see the app's files as they are now. - */ -import path from 'node:path' -import { createServer } from 'vite' -import { expect, onTestFinished, test } from 'vitest' -import { appFiles, createStartApp } from './start-app' - -const timeout = 60_000 - -// Start looks up its optional entries (`src/start.ts`, `src/client.tsx`, -// `src/server.ts`) once per plugin instance. The lookup's cache was -// process-wide and kept misses, so a restart did not see an entry created -// since. -test( - 'after a dev server restart, a start entry created since is used', - async () => { - const app = await createStartApp( - appFiles({ - 'vite.config.ts': `import { tanstackStart } from '@tanstack/react-start/plugin/vite' -export default { plugins: [tanstackStart()] } -`, - }), - ) - // (listening, as `vite dev`: Start leaves its request handler out in - // middleware mode) - const server = await createServer({ - root: app.root, - configFile: path.join(app.root, 'vite.config.ts'), - logLevel: 'error', - server: { port: 0 }, - }) - onTestFinished(() => server.close()) - await server.listen() - const page = () => fetch(server.resolvedUrls!.local[0]!) - expect((await page()).headers.get('x-start')).toBeNull() - - await app.write({ - 'src/start.ts': `import { createMiddleware, createStart } from '@tanstack/react-start' -import { setResponseHeader } from '@tanstack/react-start/server' -const mark = createMiddleware().server(({ next }) => { - setResponseHeader('x-start', 'MARK_START') - return next() -}) -export const startInstance = createStart(() => ({ requestMiddleware: [mark] })) -`, - }) - await server.restart() - expect((await page()).headers.get('x-start')).toBe('MARK_START') - }, - timeout, -) diff --git a/packages/start-plugin-core/tests/integration/start-router-dev-server.test.ts b/packages/start-plugin-core/tests/integration/start-router-dev-server.test.ts new file mode 100644 index 0000000000..24e82bb019 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-router-dev-server.test.ts @@ -0,0 +1,316 @@ +/** + * Start's router wiring on a running Vite dev server, with Start's whole + * Vite plugin (dev-server.ts `start`), seen from a real browser page served + * by Start's own dev middleware: the client route tree, which leaves out + * server-only routes, follows edits that turn a route into a page or into a + * server-only route; an edited page route hot-updates. + */ +import react from '@vitejs/plugin-react' +import { describe, expect, onTestFinished, test } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { + hmrSyncModule, + settlePage, + trackRequests, +} from '@tanstack/compiler-test-utils/hmr-sync' +import { startDevServer, startServerEntryFiles } from '../dev-server' +import type { DevServer } from '@tanstack/compiler-test-utils/dev-server' + +const timeout = 30_000 + +const head = `import { createFileRoute } from '@tanstack/react-router'\n` +const handlers = (text: string) => + `server: { handlers: { GET: () => new Response('${text}') } }` +/** `src/routes/api.tsx` with these route options. */ +const api = (options: string) => + `${head}export const Route = createFileRoute('/api')({ ${options} })\n` +const component = `component: () => 'MARK_API_PAGE'` + +/** + * The app of the page tests: Start's default client entry (hydration of + * `StartClient`), its default server entry (the HTTP handler), the real + * router over the generated route tree, and a root route that renders the + * document with a link to `/api`, a hydration marker and a not-found + * component. The router module loads `src/hmr-sync.ts` (`settlePage`). + */ +const pageAppFiles = { + ...startServerEntryFiles, + 'harness/client-entry.ts': `import { createElement } from 'react' +import { hydrateRoot } from 'react-dom/client' +import { StartClient } from '@tanstack/react-start/client' +hydrateRoot(document, createElement(StartClient)) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +import './hmr-sync' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/hmr-sync.ts': hmrSyncModule, + 'src/routes/__root.tsx': `import { HeadContent, Link, Outlet, Scripts, createRootRoute, useHydrated } from '@tanstack/react-router' +export const Route = createRootRoute({ + component: Root, + notFoundComponent: () => <p>MARK_NOT_FOUND</p>, +}) +function Root() { + const hydrated = useHydrated() + return ( + <html> + <head> + <HeadContent /> + </head> + <body> + <nav> + <Link to="/page" data-testid="to-page">to page</Link> + <Link to="/api" data-testid="to-api">to api</Link> + </nav> + <div id="app"><Outlet /></div> + <span data-testid="hydrated">{hydrated ? 'hydrated' : 'hydrating'}</span> + <Scripts /> + </body> + </html> + ) +} +`, + 'src/routes/page.tsx': `${head}export const Route = createFileRoute('/page')({ component: () => 'MARK_PAGE' })\n`, +} + +/** Pre-bundled up front, as Vite does for an app that installed them. */ +const pageAppConfig = { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + '@tanstack/react-router > @tanstack/router-core > seroval', + '@tanstack/react-router > @tanstack/router-core > seroval-plugins/web', + ], + }, +} + +/** Waits until `/api` answers `expected` (a handler edit took effect). */ +async function apiAnswers(server: DevServer, expected: string) { + const deadline = Date.now() + 10_000 + for (;;) { + const { body } = await server.fetch('/api') + if (body.includes(expected)) { + return + } + if (Date.now() > deadline) { + throw new Error(`/api did not answer ${expected} within 10 s: ${body}`) + } + await new Promise((resolve) => setTimeout(resolve, 50)) + } +} + +describe('Vite dev: a route switching between page and server-only', () => { + // The client's route tree follows each change of a route between a + // server-only route and a page: after each edit, the page navigates to + // the route (its link) and shows the page, or the not-found state once + // the route is server-only again. A full reload is allowed for a tree + // change (SPEC J3.10, J1.10); an edit that keeps the route server-only + // changes nothing for the client (no reload, no update). + // Source: mutation testing. + test( + 'the page follows a route that becomes a page, loses its handlers and becomes server-only again', + async () => { + const server = await startDevServer({ + start: {}, + browser: true, + config: pageAppConfig, + plugins: [react()], + files: { ...pageAppFiles, 'src/routes/api.tsx': api(handlers('x')) }, + }) + const browser = await openPage(new URL('/page', server.url).href, { + registerCleanup: onTestFinished, + }) + const inFlight = trackRequests(browser) + await browser.waitForText('MARK_PAGE', { selector: '#app' }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + /** Waits until the page took in what the server sent (a reload too). */ + const settled = () => settlePage(server, browser, inFlight) + /** Navigates to `/api` through its link and waits for `expected`. */ + const visitApi = async (expected: string) => { + await browser.page.locator('[data-testid=to-api]').click() + await browser.waitForText(expected, { selector: '#app' }) + } + // Server-only: the page shows not found + await visitApi('MARK_NOT_FOUND') + await browser.page.locator('[data-testid=to-page]').click() + await browser.waitForText('MARK_PAGE', { selector: '#app' }) + await settled() + + // An edit of a server-only route that keeps it server-only changes + // nothing for the page: no reload + const loads = browser.loads() + await server.edit({ 'src/routes/api.tsx': api(handlers('y')) }) + await apiAnswers(server, 'y') + await settled() + expect(browser.loads()).toBe(loads) + + // Server-only -> page (`edit`: the watcher reported every file the edit + // and the router generator wrote, and the server handled them) + await server.edit({ + 'src/routes/api.tsx': api(`${handlers('y')}, ${component}`), + }) + await settled() + await visitApi('MARK_API_PAGE') + + // Page with handlers -> page without handlers + await server.edit({ 'src/routes/api.tsx': api(component) }) + await apiAnswers(server, 'MARK_API_PAGE') + await settled() + await browser.page.locator('[data-testid=to-page]').click() + await browser.waitForText('MARK_PAGE', { selector: '#app' }) + await visitApi('MARK_API_PAGE') + + // Page -> server-only (edited while the page shows another route: a + // page left on the route would reload into the handler's response) + await browser.page.locator('[data-testid=to-page]').click() + await browser.waitForText('MARK_PAGE', { selector: '#app' }) + await server.edit({ 'src/routes/api.tsx': api(handlers('z')) }) + await apiAnswers(server, 'z') + await settled() + await visitApi('MARK_NOT_FOUND') + expect(browser.errors).toEqual([]) + }, + timeout, + ) + + // The server starts before any browser loaded the client route tree. + // Source: mutation testing. + test( + 'a route that becomes a page before the client loaded the route tree is in the client route tree', + async () => { + const server = await startDevServer({ + start: {}, + browser: true, + config: pageAppConfig, + plugins: [react()], + files: { ...pageAppFiles, 'src/routes/api.tsx': api(handlers('x')) }, + }) + await server.edit({ + 'src/routes/api.tsx': api(`${handlers('x')}, ${component}`), + }) + await server.idle() + const browser = await openPage(new URL('/page', server.url).href, { + registerCleanup: onTestFinished, + }) + await browser.waitForText('hydrated', { + selector: '[data-testid=hydrated]', + }) + await browser.page.locator('[data-testid=to-api]').click() + await browser.waitForText('MARK_API_PAGE', { selector: '#app' }) + }, + timeout, + ) +}) + +describe('Vite dev: route HMR in a real page', () => { + // Start's client code splitting adds route HMR (Start forces `addHmr` on + // the client). A real Vite dev server with Start's whole Vite plugin and + // `@vitejs/plugin-react` serves an app with the real router to a real page + // (headless Chromium), Vite's own watcher reports the edits, and Vite's + // HMR client, React Refresh and the route HMR code apply them. The edited + // page route shows its new loader data and component without a full + // reload, and its split component keeps its state (no remount). + // The page is the app's `index.html`, rendered on the client: Start's dev + // server middleware, which would answer the page request with the app's + // server entry, is off. Start's SSR with HMR in a real app: + // e2e/react-start/hmr. + // Source: mutation testing. + test( + 'an edited page route shows its new loader and component without a full reload, and its split component keeps its state', + async () => { + const page = (loader: string, text: string) => + `import { createFileRoute } from '@tanstack/react-router' +import { useState } from 'react' +function Page() { + const [count, setCount] = useState(0) + const data = Route.useLoaderData() + return <button onClick={() => setCount(count + 1)}>${text} {data} count {count}</button> +} +export const Route = createFileRoute('/')({ loader: () => '${loader}', component: Page }) +` + const server = await startDevServer({ + start: { vite: { installDevServerMiddleware: false } }, + browser: true, + // Pre-bundled up front, as Vite does for an app that installed them + // (the router is a linked workspace package here) + config: { + optimizeDeps: { + include: [ + 'react', + 'react/jsx-dev-runtime', + 'react-dom', + 'react-dom/client', + '@tanstack/react-router', + ], + }, + }, + plugins: [react()], + files: { + 'index.html': `<!doctype html> +<html> + <body> + <div id="app"></div> + <script type="module" src="/src/main.tsx"></script> + </body> +</html> +`, + 'src/main.tsx': `import { createRoot } from 'react-dom/client' +import { RouterProvider } from '@tanstack/react-router' +import { getRouter } from './router' +createRoot(document.getElementById('app')!).render(<RouterProvider router={getRouter()} />) +`, + 'src/router.ts': `import { createRouter } from '@tanstack/react-router' +import { routeTree } from './routeTree.gen' +import './hmr-sync' +export const getRouter = () => createRouter({ routeTree }) +`, + 'src/hmr-sync.ts': hmrSyncModule, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + 'src/routes/index.tsx': page('loader v1', 'Page v1'), + }, + }) + const browser = await openPage(server.url!, { + registerCleanup: onTestFinished, + }) + const inFlight = trackRequests(browser) + /** Waits until the page took in what the server sent (a reload too). */ + const settled = () => settlePage(server, browser, inFlight) + const shows = (text: string) => + browser.waitForText(text, { selector: '#app' }) + await shows('Page v1 loader v1 count 0') + await settled() + await browser.page.locator('#app button').click() + await browser.page.locator('#app button').click() + await shows('Page v1 loader v1 count 2') + + // Route options outside the split component change + await server.edit({ + 'src/routes/index.tsx': page('loader v2', 'Page v1'), + }) + await settled() + await shows('Page v1 loader v2 count 2') + + // The split component changes + await server.edit({ + 'src/routes/index.tsx': page('loader v2', 'Page v2'), + }) + await settled() + await shows('Page v2 loader v2 count 2') + + // No full reload: the page kept its first document (and the + // component its state, above) + expect(browser.loads()).toBe(1) + expect(browser.errors).toEqual([]) + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-router-wiring.test.ts b/packages/start-plugin-core/tests/integration/start-router-wiring.test.ts deleted file mode 100644 index 4e11f92554..0000000000 --- a/packages/start-plugin-core/tests/integration/start-router-wiring.test.ts +++ /dev/null @@ -1,149 +0,0 @@ -/** - * The router options of a Start app reach the route generator and the code - * splitter the way they reach a router app's, in real builds and dev servers - * of Start's Vite and Rsbuild plugins (`start-app.ts`). - */ -import { describe, expect, test } from 'vitest' -import { - appFiles, - buildStartApp, - createStartApp, - startViteDevServer, - until, - watcherReady, -} from './start-app' -import type { GeneratorPlugin } from '@tanstack/router-generator' - -const timeout = 60_000 - -const head = `import { createFileRoute } from '@tanstack/react-router'\n` - -describe.each(['vite', 'rsbuild'] as const)('%s build', (bundler) => { - // #7768: Start's own generator plugins replaced the app's. - test( - 'generator plugins of router.plugins see the route tree', - async () => { - const seen = new Set<string>() - const probe: GeneratorPlugin = { - name: 'probe', - onRouteTreeChanged: ({ routeNodes }) => { - for (const node of routeNodes) { - seen.add(node.routePath ?? '') - } - }, - } - const app = await createStartApp( - appFiles({ - 'src/routes/about.tsx': `${head}export const Route = createFileRoute('/about')({ component: () => 'MARK_ABOUT' })\n`, - }), - ) - const build = await buildStartApp(app, bundler, { - router: { plugins: [probe] }, - }) - // (Start's own generator plugins still run: the app builds with its route) - expect(build.client).toContain('MARK_ABOUT') - expect([...seen]).toEqual(['/about']) - }, - timeout, - ) - - // The server build erases the options `codeSplittingOptions.deleteNodes` - // names; the client build erases Start's server-only options instead. - // Start's Rsbuild plugin dropped the option for the server. - test( - 'router.codeSplittingOptions.deleteNodes: the server build erases the options, the client build keeps them', - async () => { - const app = await createStartApp( - appFiles({ - 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ - staticData: { marker: 'MARK_STATIC' }, - component: () => 'MARK_COMPONENT', -}) -`, - }), - ) - const build = await buildStartApp(app, bundler, { - router: { codeSplittingOptions: { deleteNodes: ['staticData'] } }, - }) - expect({ - client: build.client.includes('MARK_STATIC'), - server: build.server.includes('MARK_STATIC'), - }).toEqual({ client: true, server: false }) - expect(build.server).toContain('MARK_COMPONENT') - }, - timeout, - ) -}) - -describe('vite build', () => { - const routes = { - 'src/routes/index.tsx': `${head}export const Route = createFileRoute('/')({ component: () => 'MARK_INDEX' })\n`, - 'src/routes/api.tsx': `${head}export const Route = createFileRoute('/api')({ server: { handlers: { GET: () => new Response('MARK_API') } } })\n`, - } - - // #8839: the client route tree was matched with - // `new RegExp(<path of the route tree>)`, the path unescaped. - test( - 'of an app whose path has characters a regular expression reads: the client route tree leaves out the server-only route', - async () => { - const app = await createStartApp( - appFiles(routes), - 'start-app my app (2)+-', - ) - const build = await buildStartApp(app, 'vite') - expect(build.client).toContain('MARK_INDEX') - expect(build.client).not.toMatch(/["'`]\/api["'`]/) - expect(build.server).toMatch(/["'`]\/api["'`]/) - }, - timeout, - ) - - // The same unescaped expression: its `.` before `gen` matches any - // character, so the app's `src/routeTree-gen.ts` got the client route tree. - test( - 'of an app with a file named one character away from the route tree: the client gets the file', - async () => { - const app = await createStartApp( - appFiles({ - ...routes, - 'src/routeTree-gen.ts': `export const sibling = 'MARK_SIBLING'\n`, - 'src/routes/index.tsx': `${head}import { sibling } from '../routeTree-gen' -export const Route = createFileRoute('/')({ staticData: { sibling } }) -`, - }), - ) - const build = await buildStartApp(app, 'vite') - expect(build.client).toContain('MARK_SIBLING') - }, - timeout, - ) -}) - -describe('vite dev', () => { - test( - 'a function-form routeTreeFileFooter gives its current lines at every print of the route tree', - async () => { - let line = 'MARK_FOOTER_FIRST' - const app = await createStartApp(appFiles()) - const server = await startViteDevServer(app, { - router: { routeTreeFileFooter: () => [`// ${line}`] }, - }) - const tree = () => app.read('src/routeTree.gen.ts').catch(() => '') - await until( - async () => (await tree()).includes('MARK_FOOTER_FIRST'), - 'the first route tree', - ) - await watcherReady(app, server, 'src/routes') - line = 'MARK_FOOTER_NEXT' - await app.write({ - 'src/routes/later.tsx': `${head}export const Route = createFileRoute('/later')({})\n`, - }) - await until( - async () => (await tree()).includes(`'/later'`), - 'the route tree with /later', - ) - expect(await tree()).toContain('// MARK_FOOTER_NEXT') - }, - timeout, - ) -}) diff --git a/packages/start-plugin-core/tests/integration/start-rsbuild-root.test.ts b/packages/start-plugin-core/tests/integration/start-rsbuild-root.test.ts deleted file mode 100644 index 807261c68a..0000000000 --- a/packages/start-plugin-core/tests/integration/start-rsbuild-root.test.ts +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Start's Rsbuild plugin reads the app from Rsbuild's root, not from the - * working directory: `rsbuild build --root <app>` run from another directory - * (a monorepo root, a script) builds the app as `rsbuild build` in its - * directory does. - */ -import { execFile } from 'node:child_process' -import { existsSync, realpathSync } from 'node:fs' -import { mkdtemp, rm, writeFile } from 'node:fs/promises' -import os from 'node:os' -import path from 'node:path' -import { pathToFileURL } from 'node:url' -import { promisify } from 'node:util' -import { createRsbuild } from '@rsbuild/core' -import { expect, onTestFinished, test } from 'vitest' -import { appFiles, buildStartApp, createStartApp } from './start-app' - -const timeout = 60_000 - -/** - * Makes a new directory the working directory: a monorepo root, whose - * package.json is not the app's. (A sibling of the app: the generator moves - * its temporary files from under the working directory into the app.) - */ -async function runElsewhere() { - const dir = realpathSync(await mkdtemp(path.join(os.tmpdir(), 'start-cwd-'))) - const cwd = process.cwd() - // (finish callbacks run last first: leave `dir` before removing it) - onTestFinished(async () => { - process.chdir(cwd) - await rm(dir, { recursive: true, force: true }) - }) - await writeFile( - path.join(dir, 'package.json'), - JSON.stringify({ name: 'monorepo', private: true }), - ) - process.chdir(dir) -} - -// Start's virtual modules (here, RSC's serialization adapters, which import -// `@tanstack/react-start`) were written under the working directory, where -// the app's packages do not resolve: the build failed with "Module not -// found". -test( - 'an RSC app builds when the build runs from another directory', - async () => { - const app = await createStartApp( - appFiles({ - 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ component: () => 'MARK_INDEX' }) -`, - }), - ) - await runElsewhere() - const build = await buildStartApp(app, 'rsbuild', { - rsc: { enabled: true }, - }) - expect(build.client).toContain('MARK_INDEX') - }, - timeout, -) - -/** What the built server of the app in `root` answers `url` with, in a Node process of its own. */ -async function serverResponse(root: string, url: string) { - const serverJs = path.join(root, 'dist/server/server.js') - const entry = pathToFileURL( - existsSync(serverJs) ? serverJs : path.join(root, 'dist/server/index.js'), - ) - const script = `const { default: server } = await import(${JSON.stringify(entry.href)}) -const response = await server.fetch(new Request(${JSON.stringify(url)})) -process.stdout.write(JSON.stringify({ status: response.status, html: await response.text() })) -` - const { stdout } = await promisify(execFile)( - process.execPath, - ['--input-type=module', '--eval', script], - { cwd: root }, - ) - return JSON.parse(stdout) as { status: number; html: string } -} - -// Rsbuild accepts a relative `root` (resolved against its `cwd`), and its -// plugins see it as written: the virtual modules' paths were relative too, -// and the modules importing them did not find them. -test( - 'an app whose Rsbuild root is relative builds and renders its pages', - async () => { - const app = await createStartApp( - appFiles({ - 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' -export const Route = createFileRoute('/')({ component: () => 'MARK_INDEX' }) -`, - }), - ) - const { tanstackStart } = await import( - new URL( - '../../../react-start/dist/esm/plugin/rsbuild.js', - import.meta.url, - ).href - ) - const rsbuild = await createRsbuild({ - cwd: app.root, - loadEnv: false, - rsbuildConfig: { - root: '.', - logLevel: 'error', - plugins: [tanstackStart()], - }, - }) - await rsbuild.build() - const response = await serverResponse(app.root, 'http://localhost/') - expect(response.status).toBe(200) - expect(response.html).toContain('MARK_INDEX') - }, - timeout, -) diff --git a/packages/start-plugin-core/tests/integration/start-rsc-warnings.test.ts b/packages/start-plugin-core/tests/integration/start-rsc-warnings.test.ts new file mode 100644 index 0000000000..9d66ebb29e --- /dev/null +++ b/packages/start-plugin-core/tests/integration/start-rsc-warnings.test.ts @@ -0,0 +1,120 @@ +/** + * A real compiler warning reaching the user (SPEC G5, J2.19, J7.3): React's RSC + * CSS transform cannot give a `renderToReadableStream` call its styles when the + * argument is not JSX it can see (a variable, a spread), so the stream renders + * without its CSS; in development the user is told, once per file, naming the + * module (the file and the API), on whichever channel the host prints it (SPEC + * §5.7: console, logger or bundler, all read together). SPEC J7.3 asks for the + * warning in development only: builds are not required to warn. + * + * The app is a React Start app with RSC enabled, on each host's dev server, + * through the public plugins (`rsc-warning-app.ts`). A request of its page + * makes the server run both server functions, so the modules holding the + * calls were compiled for the server (the precondition: the page shows the + * streamed component); then the warning is read. + * + * This replaces, as compiler acceptance, the former synthetic + * `compilerTransforms` warning plumbing tests. The Vite dev twin with a real + * page and CSS is react-start-rsc's `tests/integration/rsc-css.test.ts` ("dev: + * renderToReadableStream with $name warns, naming the file"). + */ +import { describe, expect, test } from 'vitest' +import { expectDiagnostic } from '@tanstack/compiler-test-utils/diagnostics' +import { startRsbuildRscApp, startViteRscApp } from './rsc-warning-app' + +const timeout = 30_000 + +/** A server function module streaming `<Card />` through `body`. */ +const streamingModule = ( + name: string, + body: string, +) => `import { createServerFn } from '@tanstack/react-start' +import { renderToReadableStream } from '@tanstack/react-start/rsc' +function Card() { + return <div>MARK_CARD</div> +} +export const ${name} = createServerFn().handler(async () => { +${body} +}) +` + +/** The calls the transform cannot see the JSX of. */ +const skipped = { + identifier: { + file: 'src/rows/identifier.tsx', + code: streamingModule( + 'identifier', + ` const node = <Card /> + return new Response(renderToReadableStream(node)).text()`, + ), + }, + spread: { + file: 'src/rows/spread.tsx', + code: streamingModule( + 'spread', + ` const args = [<Card />] as const + return new Response(renderToReadableStream(...args)).text()`, + ), + }, +} + +const files = { + [skipped.identifier.file]: skipped.identifier.code, + [skipped.spread.file]: skipped.spread.code, + 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' +import { identifier } from '../rows/identifier' +import { spread } from '../rows/spread' +export const Route = createFileRoute('/')({ + loader: async () => [await identifier(), await spread()], + component: Page, +}) +function Page() { + const streams = Route.useLoaderData() + return <p>{streams.every((stream) => stream.includes('MARK_CARD')) ? 'MARK_STREAMED' : 'MARK_MISSING'}</p> +} +`, +} + +const hosts = { + 'Vite dev': async () => { + const server = await startViteRscApp(files) + const page = await server.fetch('/') + return { server, html: page.body } + }, + 'Rsbuild dev': async () => { + const server = await startRsbuildRscApp(files) + const page = await fetch(new URL('/', server.url)) + return { server, html: await page.text() } + }, +} + +describe.each(Object.keys(hosts) as Array<keyof typeof hosts>)('%s', (host) => { + // Bug: the transform (react-start-rsc src/plugin/rscCssTransform.ts, + // `renderToReadableStream` branch) skips an argument that is not + // top-level JSX (`isTopLevelJsx`) with `continue`, and reports nothing; + // on Rsbuild, Start's compiler host would drop a warning of a transform + // too (rsbuild/start-compiler-host.ts `warnTransformContext` calls the + // transform context's `emitWarning`, which Rsbuild's `api.transform` + // context does not have). + // Impact: the stream renders without its styles and nothing tells the + // developer why. + // SPEC J7.3: warn in dev only. Real coverage of the warning's delivery, + // replacing two tests of start-build-warnings.test.ts. + test.fails( + 'renderToReadableStream with a variable or a spread warns once per file, naming the module', + async () => { + const { server, html } = await hosts[host]() + // (the server ran both calls: their modules were compiled for it) + expect(html).toContain('MARK_STREAMED') + for (const { file } of Object.values(skipped)) { + expectDiagnostic(server.diagnostics, { + severity: 'warning', + file, + root: server.root, + times: 1, + }) + } + }, + timeout, + ) +}) diff --git a/packages/start-plugin-core/tests/integration/start-vite-root.test.ts b/packages/start-plugin-core/tests/integration/start-vite-root.test.ts deleted file mode 100644 index b635071d4a..0000000000 --- a/packages/start-plugin-core/tests/integration/start-vite-root.test.ts +++ /dev/null @@ -1,191 +0,0 @@ -/** - * Start's Vite plugin reads the app from Vite's root, not from the working - * directory: `vite build <app>` run from another directory (a monorepo root, - * a script) builds the app as `vite build` in its directory does. - */ -import { execFile } from 'node:child_process' -import { realpathSync } from 'node:fs' -import { mkdtemp, rm, symlink, writeFile } from 'node:fs/promises' -import os from 'node:os' -import path from 'node:path' -import { pathToFileURL } from 'node:url' -import { promisify } from 'node:util' -import { createBuilder } from 'vite' -import { expect, onTestFinished, test } from 'vitest' -import { appFiles, buildStartApp, createStartApp } from './start-app' - -const timeout = 60_000 - -/** - * Makes a new directory the working directory: a monorepo root, whose - * package.json is not the app's. (A sibling of the app: the generator moves - * its temporary files from under the working directory into the app.) - */ -async function runElsewhere() { - const dir = realpathSync(await mkdtemp(path.join(os.tmpdir(), 'start-cwd-'))) - const cwd = process.cwd() - // (finish callbacks run last first: leave `dir` before removing it) - onTestFinished(async () => { - process.chdir(cwd) - await rm(dir, { recursive: true, force: true }) - }) - await writeFile( - path.join(dir, 'package.json'), - JSON.stringify({ name: 'monorepo', private: true }), - ) - process.chdir(dir) -} - -/** The HTML the built server of the app in `root` answers `url` with, in a Node process of its own. */ -async function serverHtml(root: string, url: string) { - const server = pathToFileURL(path.join(root, 'dist/server/server.js')) - const script = `const { default: server } = await import(${JSON.stringify(server.href)}) -const response = await server.fetch(new Request(${JSON.stringify(url)})) -process.stdout.write(await response.text()) -` - const { stdout } = await promisify(execFile)( - process.execPath, - ['--input-type=module', '--eval', script], - { cwd: root }, - ) - return stdout -} - -// Start bundles the Start libraries (dependencies with a peer dependency on -// Start) in the SSR build, so that its compiler compiles their server fns. -// It looked for them in the working directory's package.json: run elsewhere, -// the SSR build left the library external, and its server fn, uncompiled, -// returned nothing. -test( - "a build run from another directory: a Start library's server fn runs during SSR", - async () => { - const app = await createStartApp( - appFiles({ - 'package.json': JSON.stringify({ - name: 'app', - type: 'module', - dependencies: { 'server-fn-lib': '*' }, - }), - 'node_modules/server-fn-lib/package.json': JSON.stringify({ - name: 'server-fn-lib', - type: 'module', - exports: './index.js', - peerDependencies: { '@tanstack/react-start': '*' }, - }), - 'node_modules/server-fn-lib/index.js': `import { createServerFn } from '@tanstack/react-start' -export const libFn = createServerFn().handler(async () => 'MARK_LIB_HANDLER') -`, - 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' -import { libFn } from 'server-fn-lib' -export const Route = createFileRoute('/')({ - loader: () => libFn(), - component: () => \`loaded: \${Route.useLoaderData()}\`, -}) -`, - }), - ) - await runElsewhere() - await buildStartApp(app, 'vite') - expect(await serverHtml(app.root, 'http://localhost/')).toContain( - 'loaded: MARK_LIB_HANDLER', - ) - }, - timeout, -) - -/** - * A monorepo whose `node_modules` holds the Start library (hoisted), and its - * app in `apps/web`; returns the app's directory. - */ -async function hoistedLibraryMonorepo() { - const lib = 'node_modules/server-fn-lib' - const monorepo = await createStartApp({ - 'package.json': JSON.stringify({ name: 'monorepo', private: true }), - [`${lib}/package.json`]: JSON.stringify({ - name: 'server-fn-lib', - type: 'module', - exports: './index.js', - peerDependencies: { '@tanstack/react-start': '*' }, - }), - [`${lib}/index.js`]: `import { createServerFn } from '@tanstack/react-start' -export const libFn = createServerFn().handler(async () => 'MARK_LIB_HANDLER') -`, - ...Object.fromEntries( - Object.entries( - appFiles({ - 'package.json': JSON.stringify({ - name: 'web', - type: 'module', - dependencies: { 'server-fn-lib': '*' }, - }), - 'src/routes/index.tsx': `import { createFileRoute } from '@tanstack/react-router' -import { libFn } from 'server-fn-lib' -export const Route = createFileRoute('/')({ - loader: () => libFn(), - component: () => \`loaded: \${Route.useLoaderData()}\`, -}) -`, - }), - ).map(([file, code]) => [`apps/web/${file}`, code]), - ), - }) - return path.join(monorepo.root, 'apps/web') -} - -/** Builds with Vite's root as given, as `vite build <root>` does. */ -async function buildWithRoot(root: string) { - const { tanstackStart } = await import( - new URL('../../../react-start/dist/esm/plugin/vite.js', import.meta.url) - .href - ) - const builder = await createBuilder({ - root, - configFile: false, - logLevel: 'error', - plugins: [tanstackStart()], - }) - await builder.buildApp() -} - -// Vite's root as configured can be relative (`root: '.'`, `vite build .`): -// the libraries' lookup then stopped at the working directory, short of a -// library hoisted to a monorepo's `node_modules` above it. -test( - "a relative root: a Start library hoisted above the app's directory runs during SSR", - async () => { - const web = await hoistedLibraryMonorepo() - process.chdir(web) - await buildWithRoot('.') - expect(await serverHtml(web, 'http://localhost/')).toContain( - 'loaded: MARK_LIB_HANDLER', - ) - }, - timeout, -) - -// A root through a symlink (`vite build "$PWD"` in a symlinked directory): -// the lookup walked up the symlink's parents, not the app's, where Vite -// resolves the app's imports from. -test( - "a symlinked root: a Start library hoisted above the app's directory runs during SSR", - async () => { - const web = await hoistedLibraryMonorepo() - const linkParent = realpathSync( - await mkdtemp(path.join(os.tmpdir(), 'start-link-')), - ) - const cwd = process.cwd() - // (finish callbacks run last first: leave the link before removing it) - onTestFinished(async () => { - process.chdir(cwd) - await rm(linkParent, { recursive: true, force: true }) - }) - const link = path.join(linkParent, 'web') - await symlink(web, link, 'junction') - process.chdir(link) - await buildWithRoot(link) - expect(await serverHtml(web, 'http://localhost/')).toContain( - 'loaded: MARK_LIB_HANDLER', - ) - }, - timeout, -) diff --git a/packages/start-plugin-core/tests/integration/worker-resolve-hook.ts b/packages/start-plugin-core/tests/integration/worker-resolve-hook.ts new file mode 100644 index 0000000000..d1d4ea5052 --- /dev/null +++ b/packages/start-plugin-core/tests/integration/worker-resolve-hook.ts @@ -0,0 +1,22 @@ +/** + * The resolve hook an SSR entry registers to provide `cloudflare:workers` the + * way the worker runtime would (start-build-v2-unresolvable-imports.test.ts): + * the one stand-in of a platform module. + */ +/** String-binding contract for the resolve hook, checked against workerd below; what the worker runtime provides for `cloudflare:workers`. */ +export const workerEnvModule = `export const env = { SECRET: 'MARK_ENV_SECRET' }` + +export const workerResolveHook = `import { registerHooks } from 'node:module' +export const workerRequests = new Set() +registerHooks({ + resolve(specifier, context, next) { + if (specifier === 'cloudflare:workers') { + workerRequests.add(specifier) + return { + url: 'data:text/javascript,' + encodeURIComponent(${JSON.stringify(workerEnvModule)}), + shortCircuit: true, + } + } + return next(specifier, context) + }, +})` diff --git a/packages/start-plugin-core/tests/known-bugs-start-compiler.test.ts b/packages/start-plugin-core/tests/known-bugs-start-compiler.test.ts new file mode 100644 index 0000000000..7f570645d8 --- /dev/null +++ b/packages/start-plugin-core/tests/known-bugs-start-compiler.test.ts @@ -0,0 +1,1673 @@ +/** + * Known Start compiler bugs. Each test asserts correct behaviour for a bug on + * main and is marked .fails; remove .fails when the bug is fixed. + * + * Every row runs through the public Start host (`./start-host`: Start's + * Vite plugin of the built `@tanstack/react-start` in a real dev server, a + * real Chromium page for client code, Start's real server entry and request + * context): what a page that imports the module loads and gets, what the + * server gets, and server fns called from the client (Start's RPC through + * the dev server) and from server code (in a real request). Each case is a + * directory of real files (the module and every module it imports). + * + * Elsewhere: the build-mode export cache rows, which only a production + * build exercises and which a real build does not reproduce (regression + * tests now: integration/start-compiler-build-export-cache.test.ts); the + * CommonJS dependency pins (SPEC J4.16), in + * integration/known-bugs-start-compiler.test.ts; the Vue SFC pin, in + * integration/known-bugs-start-compiler-vue-sfc.test.ts. + */ + +import { describe, expect, test } from 'vitest' +import { findDiagnostics } from '@tanstack/compiler-test-utils/diagnostics' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + Thrown, + callFromClient, + callOnServer, + callServerFnThroughCallers, + compileError, + expectCompileError, + expectNoClientHandler, + fromPage, + inPage, + serveCase, + serverFnUrls, + serverOnlyModule, + settle, + settleAsync, + throwsError, + useStartHost, +} from './regression-helpers' +import { bindingNames } from './binding-names' +import { + clientMiddleware, + clientMiddlewareOf, + runOnServerModule, + shapeOf, +} from './page-values' +import { + capturingPlacement, + placementHeads, + placementModule, + placements, +} from './createServerFn/placements' +import { factoryEdits } from './compiler-inputs' +import type { PageSettled, StartCase, StartHost } from './regression-helpers' +import type { PlacementHead } from './createServerFn/placements' + +const head = `import { createServerFn } from '@tanstack/react-start'\n` + +/** Server-only module that must never reach the client bundle. */ +const serverOnly = serverOnlyModule + +/** The server-only module of the cases below (`./db.server`). */ +const dbFile = `export const db = { + x: () => 'from the server', + log: () => 'logged', + secret: () => 'secret', +} +` + +/** + * The dev-edit pins' app (its own host, which runs no cases: a dev edit + * settles once the watcher reported every app file, and case directories + * are not watched): its files are on disk before the dev server starts, and + * a server route of the app calls the aliased server fn from server code. + */ +const editDirs = { + reexportChain: 'src/edits/reexport-chain', + aliasedEnvOnly: 'src/edits/aliased-env-only', +} +/** `files` in the directory `dir`. */ +const inDir = (dir: string, files: Record<string, string>) => + Object.fromEntries( + Object.entries(files).map(([file, code]) => [`${dir}/${file}`, code]), + ) +const editFiles = { + ...inDir(editDirs.reexportChain, factoryEdits.reexportChain.files), + ...inDir(editDirs.aliasedEnvOnly, factoryEdits.aliasedEnvOnly.files), + 'src/routes/edit-probe.ts': `import { createFileRoute } from '@tanstack/react-router' +import { serverFn } from '../edits/aliased-env-only/module' +export const Route = createFileRoute('/edit-probe')({ + server: { + handlers: { + GET: async () => { + try { + return Response.json({ value: await serverFn() }) + } catch (error) { + return Response.json({ thrown: { name: error.name, message: error.message } }) + } + }, + }, + }, +}) +`, +} + +const host = useStartHost() +const editHost = useStartHost({ files: editFiles }) + +/** A case of `files` with the server-only module. */ +async function newCase(files: Record<string, string>) { + return (await host()).case({ 'db.server.ts': dbFile, ...files }) +} + +/** + * Serves a case of `files` (every environment serves and evaluates its + * module) and calls every server fn the module exports from the client, by + * id through the dev server (the server runs each handler). Returns the case + * and the results of the calls. + */ +async function callServerFns(files: Record<string, string>) { + const served = await serveCase(await host(), { + 'db.server.ts': dbFile, + ...files, + }) + const results = await inPage( + served, + `const results = [] +for (const value of Object.values(module)) { + if (typeof value === 'function' && typeof value.url === 'string') { + results.push(await value({ data: undefined })) + } +} +return results`, + ) + return { served, results } +} + +/** + * What `expression` (a page expression with the module as `module`) gives + * in the page: its value (`shapeOf`: functions spelled `'<function>'`), or + * a `Thrown` with what it throws. + */ +async function clientValue( + startCase: StartCase, + expression: string, + options: { file?: string } = {}, +) { + return fromPage( + await inPage<PageSettled>( + startCase, + `${shapeOf}\nreturn settle(async () => shapeOf(await (${expression})))`, + options, + ), + ) +} + +/** + * The client of a case of `code` does not load the server-only module, and + * calling its `read` export throws the server-only error. + */ +async function expectServerOnlyRead(code: string) { + const startCase = await newCase({ 'module.tsx': code }) + expectNotLoaded(await startCase.loads(), [serverOnly]) + expect(await clientValue(startCase, 'module.read()')).toEqual(throwsError) +} + +/** + * The client of the case keeps no server-only import and calls its server + * fn `fn` through an RPC (a public `url`), which reaches the handler on the + * server. + */ +async function expectServerFnThroughRpc(startCase: StartCase) { + expectNotLoaded(await startCase.loads(), [serverOnly]) + expect(await inPage(startCase, 'return typeof module.fn.url')).toBe('string') + expect(await callFromClient(startCase, 'module.fn')).toBe('from the server') +} + +/** `read` of a placement: a page expression, or a function of the module. */ +function readOf( + read: string | ((module: Record<string, any>) => unknown) | undefined, +) { + if (read === undefined || typeof read === 'string') { + return read + } + return `(${read.toString()})(module)` +} + +describe('server code in the client bundle', () => { + test('a server fn in a plain .ts module compiles by its id', async () => { + const served = await serveCase( + await host(), + { + 'db.server.ts': dbFile, + 'fns.ts': `${head}import { db } from './db.server' +const input = <string>(globalThis as any).input +export const fn = createServerFn().handler(async () => db.x(input))`, + }, + { file: 'fns.ts' }, + ) + expect( + await serverFnUrls(served, 'module', { file: 'fns.ts' }), + ).toHaveLength(1) + expectNotLoaded(await served.loads('fns.ts'), [serverOnly]) + }) + + /** + * A case of `code` (with project modules `files`): its client keeps no + * server-only import, and `expression` (a page expression) gives + * `expected` in the page. + */ + async function expectClientCompiled( + code: string, + files: Record<string, string>, + check?: { expression: string; expected: unknown }, + ) { + const startCase = await newCase({ 'module.tsx': code, ...files }) + expectNotLoaded(await startCase.loads(), [serverOnly]) + if (check) { + expect(await clientValue(startCase, check.expression)).toEqual( + check.expected, + ) + } + } + + // Control for the pin below (same harness): with `createMiddleware` + // imported too, the module is compiled. + test('client builds compile a middleware builder finished in another module when the module imports createMiddleware', async () => { + await expectClientCompiled( + `import { createMiddleware } from '@tanstack/react-start' +import { mw } from './mw' +import { db } from './db.server' +export const logged = mw.server(async ({ next }) => { db.log(); return next() })`, + { + 'mw.ts': `import { createMiddleware } from '@tanstack/react-start' +export const mw = createMiddleware({ type: 'function' })`, + }, + { + expression: clientMiddlewareOf('module.logged'), + expected: clientMiddleware('function'), + }, + ) + }) + + // Bug: middleware, isomorphic and env-only fns are detected by the + // `createMiddleware` / `createIsomorphicFn` / `createServerOnlyFn` text, so + // a module that only finishes a builder imported from another module, or + // calls a factory re-exported or aliased under another name, is never + // compiled. + // Impact: the `.server()` implementation (the server-only implementation, + // which the uncompiled factory returns as is) and its server-only imports + // ship to the client. + test.fails.each<{ + name: string + files: Record<string, string> + code: string + check: { expression: string; expected: unknown } + }>([ + { + name: 'a middleware builder', + files: { + 'mw.ts': `import { createMiddleware } from '@tanstack/react-start' +export const mw = createMiddleware({ type: 'function' })`, + }, + code: `import { mw } from './mw' +import { db } from './db.server' +export const logged = mw.server(async ({ next }) => { db.log(); return next() })`, + check: { + expression: clientMiddlewareOf('module.logged'), + expected: clientMiddleware('function'), + }, + }, + { + // Source: createMiddleware.test.ts "slow path for a factory alias" + // (asserted resolveId calls only). + name: 'a createMiddleware alias', + files: { + 'mw.ts': `import { createMiddleware } from '@tanstack/react-start' +export const createFooMiddleware = createMiddleware`, + }, + code: `import { createFooMiddleware } from './mw' +import { db } from './db.server' +export const logged = createFooMiddleware({ type: 'function' }).server(async ({ next }) => { + db.log() + return next() +})`, + check: { + expression: clientMiddlewareOf('module.logged'), + expected: clientMiddleware('function'), + }, + }, + { + name: 'an isomorphic builder', + files: { + 'iso.ts': `import { createIsomorphicFn } from '@tanstack/react-start' +export const iso = createIsomorphicFn()`, + }, + code: `import { iso } from './iso' +import { db } from './db.server' +export const fn = iso.server(() => db.x()).client(() => 'client')`, + check: { expression: 'module.fn()', expected: 'client' }, + }, + { + // Source: #8504 compiler.test.ts "resolves distinct re-export aliases + // without conflating their source bindings". The module's text names + // no factory, so the text detection the bundler plugins run before + // compiling skips it and the module is left untransformed. #8504's + // test calls the compiler without that detection; with it, #8504 has + // the same bug. + name: 'a renamed createServerOnlyFn re-export', + files: { + 'env.ts': `export { createServerOnlyFn as serverOnly } from '@tanstack/react-start'`, + }, + code: `import { serverOnly } from './env' +import { db } from './db.server' +export const read = serverOnly(() => db.x())`, + check: { expression: 'module.read()', expected: throwsError }, + }, + ])( + 'client builds compile $name finished or called in another module', + async ({ files, code, check }) => { + await expectClientCompiled(code, files, check) + }, + ) + + // Control for the two pins below (same harness): the builder imported by + // name. + test('client builds compile a builder imported by name', async () => { + await expectServerFnThroughRpc( + await newCase({ + 'module.tsx': `import { authed } from './fns' +import { db } from './db.server' +export const fn = authed.handler(async () => db.x())`, + 'fns.ts': `${head}export const authed = createServerFn({ method: 'POST' })`, + }), + ) + }) + + // Bug: a server fn builder read as a member of a namespace import + // (`F.authed.handler`) is not resolved, unlike the same builder imported by + // name. + // Impact: the module is left untransformed and ships its handler and + // server-only imports to the client. + test.fails( + 'client builds compile a builder read from a namespace import', + async () => { + await expectServerFnThroughRpc( + await newCase({ + 'module.tsx': `import * as F from './fns' +import { db } from './db.server' +export const fn = F.authed.handler(async () => db.x())`, + 'fns.ts': `${head}export const authed = createServerFn({ method: 'POST' })`, + }), + ) + }, + ) + + // Bug: a namespace of the Start package re-exported by a project module + // (`export * as Start from '@tanstack/react-start'`) is not resolved. + // Impact: `Start.createServerFn()` modules are left untransformed and ship + // their handler and server-only imports to the client. + test.fails( + 'client builds compile factories of a re-exported Start namespace', + async () => { + await expectServerFnThroughRpc( + await newCase({ + 'module.tsx': `import { Start } from './start' +import { db } from './db.server' +export const fn = Start.createServerFn().handler(async () => db.x())`, + 'start.ts': `export * as Start from '@tanstack/react-start'`, + }), + ) + }, + ) + + // Bug: the builder of a `.handler()` chain is resolved through identifiers + // and member expressions only, so a builder returned by a function call + // (`authed().handler(...)`) is not traced. Builders returned by user + // factories are a supported recognition form (SPEC J4.5), so the fix + // supports it: the client calls an RPC and the server runs the handler + // (a rejection is no fix). + // Impact: the module is left untransformed and ships its handler and + // server-only imports to the client, without an RPC. + test.fails.each<{ + name: string + code: string + files: Record<string, string> + }>([ + { + name: 'the same module', + code: `${head}import { db } from './db.server' +const authed = () => createServerFn({ method: 'POST' }) +export const fn = authed().handler(async () => db.x())`, + files: {}, + }, + { + name: 'another module', + code: `import { authed } from './fns' +import { db } from './db.server' +export const fn = authed().handler(async () => db.x())`, + files: { + 'fns.ts': `${head}export const authed = () => createServerFn({ method: 'POST' })`, + }, + }, + ])( + 'client builds compile a builder returned by a function of $name', + async ({ code, files }) => { + await expectServerFnThroughRpc( + await newCase({ 'module.tsx': code, ...files }), + ) + }, + ) + + // Bug: same family as above, for a builder the user passes through a + // helper function (`applyStep(createServerFn().validator(schema))`): the + // `.handler()` chain is not traced through the call, so the module is + // left untransformed. Transparent wrappers are a supported form (SPEC + // J4.5): the client gets neither the validator nor the handler, and the + // server runs both (a rejection is no fix). + // Source: fuzzing (builders passed through user helpers). + // Impact: the validator, the handler and what they import ship to the + // client, and the client runs the handler instead of calling the server. + test.fails( + 'client builds compile a server fn whose builder passes through a helper function', + async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}import { schema } from './schema' +function applyStep<T>(builder: T) { + return builder +} +export const fn = applyStep( + createServerFn({ method: 'POST' }).validator(schema), +).handler(async ({ data }) => data)`, + 'schema.ts': `export const schema = (data: string) => \`\${data}!\`\n`, + }) + expectNotLoaded(await served.loads(), ['./schema']) + expect(await callFromClient(served, 'module.fn', 'data')).toBe('data!') + }, + ) + + // Bug: same family, for an isomorphic fn whose chain passes through a + // helper function (`withBuilder(createIsomorphicFn().server(f)).client(g)`): + // the inner `createIsomorphicFn().server(f)` is compiled on its own into a + // plain function, so `.client(g)` is then called on that function. The + // fix supports it (SPEC J4.5): each output runs its implementation (a + // rejection is no fix). + // Source: fuzzing (builders passed through user helpers). + // Impact: the module throws when it loads ("withBuilder(...).client is not + // a function"), on the client and on the server. + test.fails( + 'each output keeps its implementation of an isomorphic fn whose chain passes through a helper function', + async () => { + const startCase = await newCase({ + 'module.tsx': `import { createIsomorphicFn } from '@tanstack/react-start' +function withBuilder<T>(builder: T) { + return builder +} +export const getEnv = withBuilder( + createIsomorphicFn().server(() => 'server'), +).client(() => 'client')`, + }) + expect({ + client: await clientValue(startCase, 'module.getEnv()'), + ssr: settle((await startCase.ssr()).getEnv), + }).toEqual({ client: 'client', ssr: 'server' }) + }, + ) + + // Bug: env-only factories nested in other code are found by the factory's + // exported name (`isNestedDirectCallCandidate`), so a renamed import or a + // local alias is only compiled as a top-level variable initializer. + // Impact: the implementation and its server-only imports ship to the + // client, where calling the server-only fn runs it instead of throwing. + test.fails.each([ + { + name: 'a renamed import in a function body', + code: `import { createServerOnlyFn as serverOnly } from '@tanstack/react-start' +import { db } from './db.server' +export function getRead() { return serverOnly(() => db.secret()) } +export const read = () => getRead()()`, + }, + { + name: 'a renamed import in an object property', + code: `import { createServerOnlyFn as serverOnly } from '@tanstack/react-start' +import { db } from './db.server' +export const api = { read: serverOnly(() => db.secret()) } +export const read = () => api.read()`, + }, + { + name: 'a local alias in a function body', + code: `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +const so = createServerOnlyFn +export function getRead() { return so(() => db.secret()) } +export const read = () => getRead()()`, + }, + { + name: 'a local alias in a function-local const', + code: `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +const so = createServerOnlyFn +export function getRead() { const fn = so(() => db.secret()); return fn } +export const read = () => getRead()()`, + }, + ])( + 'client: a createServerOnlyFn called through $name is compiled', + async ({ code }) => { + await expectServerOnlyRead(code) + }, + ) + + /** + * The server-only module of the call shapes: `x` and `secret` record a + * call in its exported `calls`. + */ + const callShapeDb = `export const calls: Array<string> = [] +export const db = { + x: () => { + calls.push('x') + return 'x' + }, + secret: () => { + calls.push('secret') + return 'secret' + }, +} +` + + /** + * A module whose server code a compiler may not recognise (SPEC J4.5, + * J4.6, J4.12), and what each environment must do if it compiles. + */ + interface CallShape { + name: string + code: string + /** The text of the call a rejection points at. */ + at: string + /** Server code the client must not hold. */ + body: string + /** A page expression on the client module, and what it must give. */ + client: { expression: string; expected: unknown } + /** + * Checks the module the SSR environment evaluated (`calls`: the + * server-only calls it made). + */ + ssr?: ( + module: Record<string, any>, + calls: Array<string>, + ) => void | Promise<void> + /** + * The server fn (a page and server expression): when both environments + * compiled the module, calling it from the client and from server code + * gives what the handler returns. + */ + serverFn?: string + } + + /** + * Each environment serving `shape.code` either rejects it with a compile + * error at the call (`expectCompileError`: the line of `at`), or follows its + * contract: the client neither loads the server-only module nor holds the + * server code, and each environment runs what the runtime contract + * promises. + */ + async function expectWorksOrRejectedAtCall(shape: CallShape) { + const startCase = await newCase({ + 'db.server.ts': callShapeDb, + 'module.tsx': shape.code, + }) + const compiled: Partial<Record<'client' | 'ssr', string>> = {} + for (const environment of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, environment) + if (failure !== undefined) { + expectCompileError(failure, { + source: shape.code, + at: shape.at, + }) + continue + } + compiled[environment] = await startCase.served('module.tsx', environment) + } + if (compiled.client !== undefined) { + expectNotLoaded(await startCase.loads(), [serverOnly]) + expect(compiled.client, 'client').not.toContain(shape.body) + expect(await clientValue(startCase, shape.client.expression)).toEqual( + shape.client.expected, + ) + } + if (compiled.ssr !== undefined && shape.ssr) { + const { calls } = await startCase.ssr('db.server.ts') + calls.length = 0 + await shape.ssr(await startCase.ssr(), calls) + } + if ( + shape.serverFn && + compiled.client !== undefined && + compiled.ssr !== undefined + ) { + expect(await callServerFnThroughCallers(startCase, shape.serverFn)).toBe( + 'x', + ) + } + } + + // Bug: chain methods are only recognised when called through a static + // member (`.handler(...)`, `.server(...)`), and a call whose result is + // member-called (`createServerOnlyFn(...).bind(null)`) is taken for the + // inner call of a method chain and never visited as a candidate itself: + // each module below is left untransformed in every environment. + // Source: #8630 pins; SPEC J4.5 ("unrecognised shapes must not silently + // leak"), J4.12. tsc against the real declarations accepts every row. + // Impact: the server implementation and its server-only import ship to the + // client, where the server fn, isomorphic fn or server-only fn runs it in + // the browser. + // Fix-agnostic: each environment either rejects the module with a + // compile error at the call, or + // follows its contract: the client neither loads the server-only module + // nor holds the server code, and each environment runs what the runtime + // contract promises. + // The request middleware shape (`createMiddleware()['server'](...)`, the + // same root cause) is pinned once, in its build twin: + // integration/start-build-call-shapes.test.ts runs it as the app's request + // middleware in a real request (same input, same outcomes), which this + // file's shared host has no start entry for. + test.fails.each<CallShape>([ + { + name: 'a server fn handler called through a computed member', + code: `${head}import { db } from './db.server' +export const fn = createServerFn()['handler'](async () => db.x())`, + at: `createServerFn()['handler']`, + body: 'db.x()', + client: { expression: 'typeof module.fn.url', expected: 'string' }, + serverFn: 'module.fn', + }, + { + name: 'an isomorphic server implementation called through a computed member', + code: `import { createIsomorphicFn } from '@tanstack/react-start' +import { db } from './db.server' +export const fn = createIsomorphicFn()['server'](() => db.x()).client(() => 'client')`, + at: `createIsomorphicFn()['server']`, + body: 'db.x()', + client: { expression: 'module.fn()', expected: 'client' }, + ssr: (module) => expect(module.fn()).toBe('x'), + }, + { + name: 'a createServerOnlyFn whose result is bound', + code: `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +export const read = createServerOnlyFn(() => db.secret()).bind(null)`, + at: 'createServerOnlyFn(', + body: 'db.secret()', + client: { expression: 'module.read()', expected: throwsError }, + ssr: (module) => expect(module.read()).toBe('secret'), + }, + ])( + '$name: the client holds no server code, or the module is rejected at the call', + async (shape) => { + await expectWorksOrRejectedAtCall(shape) + }, + ) + + // Bug: env-only factories nested in other code are found by the factory's + // exported name (`isNestedDirectCallCandidate`), so a local alias of + // createServerOnlyFn called in a top-level block is neither compiled nor + // rejected. + // Source: the known-bug row "a local alias in a top-level block" deleted in + // a945fe4563, restored (the "block" position of SPEC J4.6). + // Impact: the implementation and its server-only import ship to the + // client, where calling the server-only fn runs it instead of throwing. + // Fix-agnostic: compiled per its contract (the client throws the + // server-only error and loads nothing server-only, SSR runs it) or + // rejected with a clear compile error at the call. + test.fails( + 'a createServerOnlyFn local alias called in a top-level block works in each environment, or is rejected at the call', + async () => { + await expectWorksOrRejectedAtCall({ + name: 'a local alias in a top-level block', + code: `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +const so = createServerOnlyFn +export let read: () => unknown +{ + const fn = so(() => db.secret()) + read = () => fn() +}`, + at: 'so(() =>', + body: 'db.secret()', + client: { expression: 'module.read()', expected: throwsError }, + ssr: (module) => expect(module.read()).toBe('secret'), + }) + }, + ) + + // Bug: when createServerFn is the only factory imported, the compiler only + // visits top-level variable declarations, so a server fn anywhere else is + // neither extracted nor rejected. With another Start factory imported, a + // server fn initializing a declarator below the top level (in a function, + // a block or a switch case) is extracted on the client, but the server + // has no handler for it. Rejecting a placement with a clear compile error + // at the call is a valid fix here; supporting it is the goal + // (createServerFn/declaration-sites.test.ts "supports a server fn in + // ..."), and a supported one must reach its handler through an RPC. + // Impact: the handler and its server-only imports ship to the client + // (createServerFn alone), or the server fails to serve the module + // (another factory). + // The block row covers the "block" position of SPEC J4.6. + describe.each([ + { importHead: 'createServerFn alone' as const, rows: placements }, + { + importHead: 'another Start factory' as const, + rows: placements.filter((placement) => placement.declarator), + }, + ])('with $importHead imported', ({ importHead, rows }) => { + test.fails.each(rows)( + 'a createServerFn in $name does not ship its handler to the client', + async ({ code, read }) => { + await expectNoClientHandler( + await host(), + placementModule(importHead, code), + { read: readOf(read) }, + ) + }, + ) + }) + + // Bug: next to another Start factory, a server fn that is not assigned to + // a variable (an object property, a class field, a default export, an + // assignment, a call argument, a JSX attribute, a conditional, a + // destructuring) is rejected with a plain `Error` ("createServerFn must + // be assigned to a variable!") that carries no position: the user is told + // the file (by the bundler) but not where in it. + // Source: start-compiler/handleCreateServerFn.ts:232 (the other rejections + // of this handler use `codeFrameError`); SPEC G5 ("errors about the + // user's source carry a position/code frame"), J4.6. + // Impact: in a module with several server fns the user has to find the + // misplaced one by hand. Loosened twin (any rejection, at no + // position): declaration-sites.test.ts "next to another Start factory, ...". + // (A declarator below the top level, e.g. in a top-level block, is + // extracted instead: pinned above.) + test.fails.each( + placements.filter( + (placement) => !placement.nested && !placement.declarator, + ), + )( + 'with another Start factory imported, a server fn in $name works or is rejected at the call', + async ({ code, read }) => { + await expectNoClientHandler( + await host(), + placementModule('another Start factory', code), + { read: readOf(read) }, + ) + }, + ) + + // Bug: same cause as above; a server fn nested in a function whose + // handler reads a local of that function (here `id`) cannot run on its own + // on the server, and is neither supported nor rejected. + // Fix-agnostic (SPEC J4.6, §5.13): each environment independently rejects + // with a clear capture diagnostic or preserves each make(id) closure. + // SSR may keep the handler inline; successful clients must use safe RPCs. + // Impact: its handler and server-only imports ship to the client + // (createServerFn alone), or the server fails to serve the module + // (another factory). + test.fails.each(Object.keys(placementHeads) as Array<PlacementHead>)( + 'with %s imported, a nested server fn whose handler reads a local of its function is supported or rejected at the capture', + async (importHead) => { + const code = placementModule(importHead, capturingPlacement.code) + const startCase = await newCase({ + 'module.tsx': code, + 'db.server.ts': `export const db = { + inner: (id: string) => \`inner:\${id}\`, + top: () => 'top', +} +`, + }) + // Each environment has its own valid outcome: SSR may keep the + // closure inline even when client extraction is rejected. + for (const environment of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, environment) + if (failure !== undefined) { + expectCompileError(failure, { + source: code, + at: 'db.inner(id)', + }) + continue + } + if (environment === 'client') { + expectNotLoaded(await startCase.loads(), [serverOnly]) + expect(await startCase.served()).not.toContain('MARK_INNER_HANDLER') + expect( + await inPage( + startCase, + `return Promise.all(['a', 'b'].map((id) => module.make(id)()))`, + ), + ).toEqual(['inner:a', 'inner:b']) + } else { + const ssr = await startCase.ssr() + expect( + await startCase.inRequest(() => + Promise.all(['a', 'b'].map((id) => ssr.make(id)())), + ), + ).toEqual(['inner:a', 'inner:b']) + } + } + }, + ) + + // Bug: the export a re-export forwards is looked up by its local name + // (`wrap`) only, so two re-exports of different modules' `wrap` under + // distinct names resolve to the same factory. + // Impact: here both aliases compile as createClientOnlyFn: the server-only + // implementation ships to the client and runs there, and throws on the + // server. + // Source: #8504 compiler.test.ts "resolves distinct re-export aliases + // without conflating their source bindings" (red on main). + test.fails( + 'distinct re-export aliases of two factories keep their own kind', + async () => { + const startCase = await newCase({ + 'barrel.ts': `export { wrap as allowed } from './server' +export { wrap as denied } from './client'`, + 'server.ts': `export { createServerOnlyFn as wrap } from '@tanstack/react-start'`, + 'client.ts': `export { createClientOnlyFn as wrap } from '@tanstack/react-start'`, + // The direct createServerOnlyFn call makes the module a candidate of + // the compiler's text detection. + 'module.tsx': `import { createServerOnlyFn } from '@tanstack/react-start' +import { allowed, denied } from './barrel' +export const a = allowed(() => 'server-value') +export const b = denied(() => 'client-value') +export const c = createServerOnlyFn(() => 'direct')`, + }) + const ssr = await startCase.ssr() + expect({ + client: [ + await clientValue(startCase, 'module.a()'), + await clientValue(startCase, 'module.b()'), + ], + ssr: [settle(ssr.a), settle(ssr.b)], + }).toEqual({ + client: [throwsError, 'client-value'], + ssr: ['server-value', throwsError], + }) + }, + ) + + /** + * Calls the exports of the shadowing module below with the stand-ins of + * the shadowed factories (a page script, also run on the server). + */ + const shadowingProbe = `const identity = (fn) => fn +const builder = { + server: (server) => ({ client: (client) => [server(), client()] }), + handler: (handler) => handler(), +} +const run = async (call) => fromSettled(await settle(call)) +const fromSettled = (settled) => ('thrown' in settled ? { thrown: settled.thrown.message } : settled.value) +return { + real: await settle(() => module.real()), + wrap: await run(() => module.wrap(identity)()), + receiver: await run(() => module.receiver({ createServerOnlyFn: identity })()), + local: await run(() => module.local()()), + iso: await run(() => module.iso(() => builder)), + mw: await run(() => module.mw(() => ({ server: (fn) => fn() }))), + make: await run(() => module.make(() => builder)), +}` + + // Same bug, every factory and both environments, next to a compiled + // factory call. Source: #8504 start-compiler-factories.test.ts "parameters + // and locals shadowing the factories are left alone next to a compiled + // factory call" (red on main). (The provider row of the internal harness + // has no public counterpart: the server is the SSR row.) + test.fails.each(['client', 'ssr'] as const)( + '%s: parameters and locals shadowing the factories are left alone next to a compiled factory call', + async (environment) => { + const startCase = await newCase({ + 'module.tsx': `import * as Start from '@tanstack/react-start' +import { createServerFn, createServerOnlyFn, createClientOnlyFn, createIsomorphicFn, createMiddleware } from '@tanstack/react-start' +export const real = createServerOnlyFn(() => 'real') +export function wrap(createServerOnlyFn) { + return createServerOnlyFn(() => 'param') +} +export function receiver(Start) { + return (Start).createServerOnlyFn(() => 'receiver') +} +export function local() { + const createClientOnlyFn = (fn: () => string) => fn + return createClientOnlyFn(() => 'local') +} +export function iso(createIsomorphicFn) { + return createIsomorphicFn().server(() => 's').client(() => 'c') +} +export function mw(createMiddleware) { + return createMiddleware().server(() => 's') +} +export function make(createServerFn) { + const made = createServerFn().handler(() => 'param') + return made +}`, + }) + const observed = + environment === 'client' + ? await inPage<Record<string, unknown>>(startCase, shadowingProbe) + : await runOnServerModule<Record<string, unknown>>( + await startCase.ssr(), + shadowingProbe, + ) + expect({ + ...observed, + real: fromPage(observed.real as PageSettled), + }).toEqual({ + real: environment === 'client' ? throwsError : 'real', + wrap: 'param', + receiver: 'receiver', + local: 'local', + iso: ['s', 'c'], + mw: 's', + make: 'param', + }) + }, + ) +}) + +describe('server function handlers', () => { + // Bug: generated imports and handler names are not made unique against + // user bindings, so a user binding named like one of them collides with it. + // Impact: the module fails to build. + test.fails.each(['createClientRpc', 'createSsrRpc', 'createServerRpc'])( + 'a user binding named %s does not collide with generated code', + async (binding) => { + const { results } = await callServerFns({ + 'module.tsx': `${head}const ${binding} = (value: unknown) => value +export const used = ${binding}('user') +export const fn = createServerFn().handler(async () => 'from the server')`, + }) + expect(results).toEqual(['from the server']) + }, + ) + + // Bug: the server calls each server fn from a generated wrapper, + // `opts => fn.__executeServer(opts)`, whose `opts` parameter shadows a + // server fn named `opts`. + // Impact: every call of a server fn named `opts` fails on the server. + test.fails('a server fn named opts runs on the server', async () => { + const { results } = await callServerFns({ + 'module.tsx': `${head}export const opts = createServerFn().handler(async () => 'from the server')`, + }) + expect(results).toEqual(['from the server']) + }) + + /** + * The names the compiler introduces into what it serves for a module with + * a server fn: bindings of the served client and SSR code that neither the + * source nor a control module (the same imports, nothing to compile, served + * by the same pipeline) has; digits are ignored when comparing with the + * control, so the dev pipeline's own numbered names never count. Read from + * the served code, not assumed: the probe follows any compiler's + * naming. + */ + async function introducedNames() { + const started = await host() + const source = `${head}export const fn = createServerFn().handler(async () => 'from the server')` + const control = `${head}export const fn = createServerFn\nexport const value = 'from the server'` + const probe = await serveCase(started, { 'module.tsx': source }) + const plain = await serveCase(started, { 'module.tsx': control }) + const shape = (name: string) => name.replace(/\d+/g, '') + // Vite's SSR transform turns `import { x } from 'm'` into reads of + // `__vite_ssr_import_<n>__.x`: those `x` are the module's imported names + const ssrNames = (code: string) => [ + ...bindingNames(code), + ...[...code.matchAll(/__vite_ssr_import_\d+__\.([A-Za-z_$][\w$]*)/g)].map( + (match) => match[1]!, + ), + ] + const known = new Set( + [ + ...bindingNames(source), + ...bindingNames(plain.code.client), + ...ssrNames(plain.code.ssr), + ].map(shape), + ) + return [ + ...new Set([ + ...bindingNames(probe.code.client), + ...ssrNames(probe.code.ssr), + ]), + ].filter((name) => !known.has(shape(name))) + } + + // Bug: the same as the two pins above, for whatever names the compiler + // introduces (adaptive: they are read from the served code, so a compiler + // that only renames its generated bindings still collides here, while one + // that keeps them apart from user bindings passes). + // Impact: a user binding or a server fn named like generated code breaks + // the module or its server calls. + test.fails( + 'no name the compiler introduces collides with a user binding or a server fn of that name', + async () => { + const names = await introducedNames() + expect(names.length, 'names the compiler introduced').toBeGreaterThan(0) + const failures: Array<string> = [] + for (const name of names) { + for (const [kind, code] of [ + [ + 'a user binding', + `${head}const ${name} = (value: unknown) => value +export const used = ${name}('user') +export const fn = createServerFn().handler(async () => 'from the server')`, + ], + [ + 'a server fn', + `${head}export const ${name} = createServerFn().handler(async () => 'from the server')`, + ], + ] as const) { + try { + const { results } = await callServerFns({ 'module.tsx': code }) + if ( + JSON.stringify(results) !== JSON.stringify(['from the server']) + ) { + failures.push(`${kind} named ${name}: ${JSON.stringify(results)}`) + } + } catch (error) { + failures.push( + `${kind} named ${name}: ${String((error as Error).message).split('\n')[0]}`, + ) + } + } + } + expect(failures).toEqual([]) + }, + 30_000, + ) + + // Bug: when the handler passed to `.handler()` is a `createServerOnlyFn()` + // call, the inner call is compiled first and the caller is never rewritten + // into an RPC. + // Impact: the server fn cannot be called: calling it from the client + // throws the server-only error, and calling it from server code does not + // run the handler. + // The outcome (SPEC J4.1, J4.2, G5): a call from either side returns + // what the handler returns (how the call reaches it is free), or the + // module is reported: a compile error, or in dev a warning, naming the + // file. + test.fails.each(['client', 'ssr'] as const)( + '%s: a server fn whose handler is a createServerOnlyFn call returns the handler result, or is reported', + async (environment) => { + const code = `import { createServerFn, createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +export const fn = createServerFn().handler(createServerOnlyFn(async () => db.x()))` + const startCase = await newCase({ 'module.tsx': code }) + const mark = startCase.diagnostics().length + for (const served of ['client', 'ssr'] as const) { + const failure = await compileError(startCase, served) + if (failure !== undefined) { + expectCompileError(failure, { source: code, at: undefined }) + return + } + } + // What compiling the module reported (not what calling it logs) + const reported = findDiagnostics(startCase.diagnostics().slice(mark), { + file: startCase.file(), + }) + if (reported.length === 0) { + const call = environment === 'client' ? callFromClient : callOnServer + expect(await call(startCase, 'module.fn')).toBe('from the server') + } + }, + ) + + // The server fn of a `'use client'` module (#7943) is pinned through a + // real RSC app: react-start-rsc tests/integration/rsc-start-dev.test.ts + // "a server function of a 'use client' module runs on the server" (no + // directive-mechanism requirement here). +}) + +describe('dev edits', () => { + /** + * Edits app files through the dev server's watcher (written before the + * server started, so this is a change of existing files), and evaluates + * `module.tsx` of `dir` in the SSR environment. + */ + async function editAndImport( + started: StartHost, + dir: string, + files: Record<string, string>, + ) { + await started.edit( + Object.fromEntries( + Object.entries(files).map(([file, code]) => [`${dir}/${file}`, code]), + ), + ) + return started.host.importServer(`/${dir}/module.tsx`, 'ssr') + } + + // Bug: after a dev edit of the module a re-export chain of an env-only + // factory ends in (here it now re-exports createClientOnlyFn under the + // createServerOnlyFn name), the module importing the factory, unchanged, + // keeps the code compiled for the old factory: its compiled output imports + // nothing of the chain, so no module graph links it to the edited module, + // and the compiler's own invalidation does not reach it. + // Impact: in dev, the importer keeps the old behaviour (here it runs a + // function that should now be client-only) until it is edited itself or + // the server restarts. + // Source: rerouted compiler.test.ts "invalidateModule clears cached module + // resolution state" (green through the internal compiler, which the test + // invalidated and recompiled itself); reproduced through a real Vite dev + // edit. Unbundled client edits of a server fn factory are + // covered by integration/start-compiler-dev-server.test.ts. + test.fails( + 'a dev edit of a module a re-export chain ends in recompiles its importers', + async () => { + const started = await editHost() + const dir = editDirs.reexportChain + const before = await started.host.importServer(`/${dir}/module.tsx`) + expect(settle(before.myFn)).toBe('server-only-value') + + const after = await editAndImport( + started, + dir, + factoryEdits.reexportChain.edit, + ) + expect(settle(after.myFn)).toEqual(throwsError) + }, + 30_000, + ) + + // Control for the pin above (same harness, and the concept of + // compiler.test.ts "recompiles aliased env-only calls in a provider whose + // source only mentions createServerFn", rerouted through a real dev edit): + // a server fn module whose source only mentions createServerFn calls an + // env-only factory the factory module renames; after the factory module + // is edited into another kind, the server fn runs the new code. + test('a dev edit of an aliased env-only factory recompiles the server fn that calls it', async () => { + const started = await editHost() + const dir = editDirs.aliasedEnvOnly + // The server route of the app calls the server fn from server code. + const callServerFn = async () => + fromPage( + (await ( + await fetch(new URL('/edit-probe', started.host.dev.url)) + ).json()) as PageSettled, + ) + + expect(await callServerFn()).toBe('server-only-value') + + await started.edit(inDir(dir, factoryEdits.aliasedEnvOnly.edit)) + expect(await callServerFn()).toEqual(throwsError) + }, 30_000) +}) + +describe('dead-code elimination', () => { + /** + * Renders `Probe` of the case on the server (the SSR environment's React + * renders it to HTML), then hydrates that HTML in the page with the + * client's `Probe`: the errors React and the page report. + */ + async function hydrationErrors(startCase: StartCase) { + const { render } = await startCase.ssr('render.server.tsx') + const html = render() as string + const run = await startCase.client<Array<string>>( + `const { hydrate } = await load('hydrate.client.tsx') +return hydrate(${JSON.stringify(html)})`, + ) + return [...run.result, ...run.errors] + } + + /** The render and hydrate files of a case whose `Probe` uses `useField`. */ + const hookProbeFiles = { + 'probe.tsx': `import { useField } from './module' +export function Probe() { + const [, inputId] = useField() + return <span>{inputId}</span> +} +`, + 'render.server.tsx': `import { renderToString } from 'react-dom/server' +import { Probe } from './probe' +export const render = () => renderToString(<Probe />) +`, + 'hydrate.client.tsx': `import { hydrateRoot } from 'react-dom/client' +import { Probe } from './probe' +export async function hydrate(html: string) { + const container = document.createElement('div') + container.innerHTML = html + document.body.append(container) + const errors: Array<string> = [] + const root = hydrateRoot(container, <Probe />, { + onRecoverableError: (error) => { + errors.push(String(error)) + }, + }) + await new Promise((resolve) => setTimeout(resolve, 100)) + root.unmount() + container.remove() + return errors +} +`, + } + + // Bug: removing the other environment's implementation of an env function + // declared in a hook leaves the locals only that implementation read + // unreferenced, and dead-code elimination (babel-dead-code-elimination, + // which removes newly unreferenced bindings) deletes their declarators, + // hook calls included. + // Impact: the hooks after it run in a different order on the server and + // the client (`useId` mismatches, hydration errors). + // Observed: the server's HTML of a component using the hook hydrates in + // the page without a mismatch (formerly: the hook's `useId` calls counted + // through a stubbed React). + test.fails.each([ + { + output: 'client' as const, + code: `import { createIsomorphicFn } from '@tanstack/react-start' +import { useId } from 'react' +export function useField() { + const serverId = useId() + const describe = createIsomorphicFn().server(() => serverId).client(() => 'client') + const inputId = useId() + return [describe(), inputId] +}`, + }, + { + output: 'ssr' as const, + code: `import { createClientOnlyFn } from '@tanstack/react-start' +import { useId } from 'react' +export function useField() { + const clientId = useId() + const describe = createClientOnlyFn(() => clientId) + const inputId = useId() + return [describe, inputId] +}`, + }, + ])( + '$output: hook calls read only by the removed implementation still run', + async ({ code }) => { + const startCase = await newCase({ 'module.tsx': code, ...hookProbeFiles }) + expect(await hydrationErrors(startCase)).toEqual([]) + }, + ) + + const pragmaModule = `/** @jsxRuntime classic */ +/** @jsx h */ +import { h } from './jsx' +import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => h('p', null)) +export const Card = () => <div />` + const jsxFile = `export const h = (type: string) => \`h(\${type})\`\n` + + // Bug: dead-code elimination does not count a classic JSX pragma + // (`/** @jsx h */`) as a use of the factory it names, so the factory import + // is removed when no other code reads it (the generated imports also land + // above the pragma comment, where Oxc no longer reads it). Same root cause + // as the JSX pragma pins in known-bugs-hydrate.test.ts and + // router-plugin/tests/known-bugs-code-splitter.test.ts. + // Impact: the module's components throw "h is not defined" or render + // through another JSX factory than the one the module selects. + test.fails( + 'client: the factory of a classic JSX pragma stays imported', + async () => { + const startCase = await newCase({ + 'module.tsx': pragmaModule, + 'jsx.ts': jsxFile, + }) + expect(await clientValue(startCase, 'module.Card()')).toBe('h(div)') + }, + ) + + /** + * A module with a classic JSX runtime pragma whose `Hero` renders `Chart` + * in `<ClientOnly>`; `heroBody` runs first in `Hero`. + */ + const classicRuntimeModule = (heroBody: string) => `/** @jsxRuntime classic */ +import * as React from 'react' +import { ClientOnly } from '@tanstack/react-router' +export function Hero() { + ${heroBody} + return <div><ClientOnly><Chart /></ClientOnly></div> +} +function Chart() { + const ref = React.useRef(false) + return <canvas data-rendered={ref.current} /> +}` + + /** Renders `Hero` of the case on the server (its HTML, or what threw). */ + async function renderHero(code: string) { + const startCase = await newCase({ + 'module.tsx': code, + 'render.server.ts': `import { createElement } from 'react' +import { renderToString } from 'react-dom/server' +import { Hero } from './module' +export const render = () => renderToString(createElement(Hero)) +`, + }) + const { render } = await startCase.ssr('render.server.ts') + const rendered = settle(render) + return rendered instanceof Thrown + ? `the render throws: ${(rendered.error as Error).message}` + : (rendered as string) + } + + // Control for the pin below (same harness): code the SSR output keeps + // still reads `React`. + test('ssr: a module with a classic JSX runtime pragma that reads React elsewhere stays valid', async () => { + expect(await renderHero(classicRuntimeModule('React.useId()'))).toContain( + '<div>', + ) + }) + + // Bug: same family as the pin above: under a classic JSX runtime pragma + // (`/** @jsxRuntime classic */`, whose JSX reads `React`), the SSR output + // removes the `<ClientOnly>` children, then dead-code elimination drops + // `import * as React`, which only the JSX still reads. + // Source: start-compiler/handleClientOnlyJSX.ts:26-27 (children removed), + // start-compiler/compiler.ts:1349,1410 (dead-code elimination does not + // count the JSX as a read of `React`); fuzzing (an unmodified file of a + // real app, a charts hero background). + // Impact: the server render throws "React is not defined". + test.fails( + 'ssr: a module with a classic JSX runtime pragma keeps its React import', + async () => { + expect(await renderHero(classicRuntimeModule(''))).toContain('<div>') + }, + ) + + // Bug: a type-only import re-exported without `type` (`export { Settings }`, + // which TypeScript accepts unless verbatimModuleSyntax is on) loses its + // import in the client and SSR outputs, which keep the export that the + // TypeScript transform can then no longer erase. The code splitter has the + // same bug (pin in router-plugin/tests/known-bugs-code-splitter.test.ts). + // Impact: the module fails to load ("Export 'Settings' is not defined"). + test.fails.each([ + `import type { Settings } from './settings'`, + `import { type Settings } from './settings'`, + ])( + 'client and SSR: a type-only import re-exported as `export { Settings }` is erased (%s)', + async (importDeclaration) => { + const startCase = await newCase({ + 'module.tsx': `${head}${importDeclaration} +export { Settings } +export const fn = createServerFn().handler(async () => 1)`, + 'settings.ts': `export type Settings = { theme: string }\n`, + }) + const loaded = async (run: () => Promise<unknown>) => { + const settled = await settleAsync(run) + return settled instanceof Thrown + ? `fails to load: ${(settled.error as Error).message}` + : 'loads' + } + expect({ + client: await loaded(() => startCase.client('return true')), + ssr: await loaded(() => startCase.ssr()), + }).toEqual({ client: 'loads', ssr: 'loads' }) + }, + ) + + /** + * A server-only module that fails loudly when a client module loads it + * (the server may load it). + */ + const throwingServerModule = `if (typeof window !== 'undefined') { + throw new Error('server module loaded on the client') +} +export const db = { a: 1, users: (id?: string) => [id] } +export const TaggedError = (tag: string) => () => + class { + tag = tag + } +` + + /** + * A case of `code` with the throwing server-only module: the client does + * not load it, the page imports the module, and `expression` gives + * `expected`. + */ + async function expectClientWithoutServerModule( + code: string, + check: { expression: string; expected: unknown }, + ) { + const startCase = await ( + await host() + ).case({ + 'module.tsx': code, + 'db.server.ts': throwingServerModule, + }) + // (Import protection hands the page a mock of a `.server` module the + // client imports: the module graph still holds the denied import.) + expectNotLoaded(await startCase.loads(), [serverOnly]) + expect(await clientValue(startCase, check.expression)).toEqual( + check.expected, + ) + } + + // Control for the pin below (same harness): a plain function only the + // server code uses leaves with its server-only import. + test('client: a function only server code uses does not load its server-only import', async () => { + await expectClientWithoutServerModule( + `${head}import { db } from './db.server' +function find() { return db.users() } +export const fn = createServerFn().handler(async () => find())`, + { expression: 'module.fn !== undefined', expected: true }, + ) + }) + + // Bug: dead-code elimination (babel-dead-code-elimination) removes + // unreferenced functions and variables but never class declarations, TS + // enums, namespaces, overloaded functions or redeclared `var`s, so such a + // declaration that only server code used keeps its server-only import. + // Impact: the client (always in dev; in builds, the server module's + // top-level code, see the Vite build pin) loads the server-only module. + // Source: review; #8504 caller-dead-code.test.ts:563 covers server fns. + test.fails.each([ + { + name: 'a class used by a server fn handler', + code: `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +class Repo { get() { return db.users() } } +export const fn = createServerFn().handler(async () => new Repo().get())`, + check: { expression: 'module.fn !== undefined', expected: true }, + }, + { + // A class whose `extends` clause calls an imported factory, as error + // classes of effect (`Data.TaggedError('NotFound')<...>`) and + // better-result are written. + // Source: fuzzing (two files of real apps). + name: 'a class with a call in its extends clause used by a server fn handler', + code: `import { createServerFn } from '@tanstack/react-start' +import { TaggedError } from './db.server' +class NotFound extends TaggedError('NotFound')<{ id: string }>() {} +export const fn = createServerFn().handler(async () => { + throw new NotFound({ id: '1' }) +})`, + check: { expression: 'module.fn !== undefined', expected: true }, + }, + { + name: 'an enum used by a server fn handler', + code: `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +enum Kind { A = db.a } +export const fn = createServerFn().handler(async () => Kind.A)`, + check: { expression: 'module.fn !== undefined', expected: true }, + }, + { + name: 'a namespace used by a server fn handler', + code: `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +namespace Repo { export const get = () => db.users() } +export const fn = createServerFn().handler(async () => Repo.get())`, + check: { expression: 'module.fn !== undefined', expected: true }, + }, + { + name: 'an overloaded function used by a server fn handler', + code: `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +function get(): string +function get(id?: string) { return db.users(id) } +export const fn = createServerFn().handler(async () => get())`, + check: { expression: 'module.fn !== undefined', expected: true }, + }, + { + name: 'a class used by a middleware .server()', + code: `import { createMiddleware } from '@tanstack/react-start' +import { db } from './db.server' +class Repo { get() { return db.users() } } +export const mw = createMiddleware().server(async ({ next }) => { + new Repo().get() + return next() +})`, + check: { expression: 'module.mw !== undefined', expected: true }, + }, + { + name: 'a class used by an isomorphic .server()', + code: `import { createIsomorphicFn } from '@tanstack/react-start' +import { db } from './db.server' +class Repo { get() { return db.users() } } +export const iso = createIsomorphicFn().server(() => new Repo().get()).client(() => 'client')`, + check: { expression: 'module.iso()', expected: 'client' }, + }, + { + name: 'an overloaded function used by a createServerOnlyFn', + code: `import { createServerOnlyFn } from '@tanstack/react-start' +import { db } from './db.server' +function get(): string +function get(id?: string) { return db.users(id) } +export const read = createServerOnlyFn(() => get())`, + check: { expression: 'module.read()', expected: throwsError }, + }, + ])( + 'client: $name does not load its server-only import', + async ({ code, check }) => { + await expectClientWithoutServerModule(code, check) + }, + ) + + /** + * A tsconfig.json of a case: TypeScript erased with or without + * `verbatimModuleSyntax` (the app's own setting, which Vite's TypeScript + * transform reads). + */ + const tsconfig = (verbatimModuleSyntax: boolean) => + JSON.stringify({ compilerOptions: { verbatimModuleSyntax } }) + + /** The server-only `./auth` module of the rows below. */ + const authFile = `export const auth = { get: () => 'auth', session: 'session' }\n` + + /** + * What the client of a case of `code` loads when TypeScript is erased with + * `verbatimModuleSyntax` (only `import type` declarations and `type` + * specifiers are dropped). + */ + async function verbatimLoads(code: string) { + const startCase = await ( + await host() + ).case({ + 'tsconfig.json': tsconfig(true), + 'module.tsx': code, + 'auth.ts': authFile, + 'db.server.ts': dbFile, + }) + return { startCase, loads: await startCase.loads() } + } + + // Control for the pin below (same harness): a server-only import that only + // the handler read leaves the client. + test('client: a server-only import only the handler reads is not loaded with verbatimModuleSyntax', async () => { + const { loads } = await verbatimLoads(`${head}import { auth } from './auth' +export const fn = createServerFn().handler(async () => auth.get())`) + expectNotLoaded(loads, ['./auth']) + }) + + // With `verbatimModuleSyntax`, `import { type Db } from './db.server'` + // keeps the module as a side-effect import (`import {} from`); the client + // must still not load the server-only module for code it keeps that only + // mentions the type. + test('client: a server-only module imported only for a type specifier is not loaded with verbatimModuleSyntax', async () => { + const { startCase, loads } = + await verbatimLoads(`${head}import { type Db } from './db.server' +export function describeDb(db?: Db) { + return db ? 'custom' : 'default' +} +export const fn = createServerFn().handler(async () => describeDb())`) + expectNotLoaded(loads, ['./db.server']) + expect(await inPage(startCase, 'return module.describeDb()')).toBe( + 'default', + ) + }) + + // Bug: dead-code elimination counts a `typeof auth` type query in a + // top-level type alias as a use of the `auth` import, so a server-only + // import that the handler read and that such a type still mentions stays a + // value import in the client output. + // Impact: with `verbatimModuleSyntax` (TypeScript keeps value imports), + // the client loads the server-only module and its top-level code ships + // (see the Vite build pin). + // Source: review. + test.fails( + 'client: a server-only import last mentioned by a type alias is not loaded with verbatimModuleSyntax', + async () => { + const { loads } = + await verbatimLoads(`${head}import { auth } from './auth' +type Session = typeof auth.session +export const fn = createServerFn().handler(async () => auth.get() as Session)`) + expectNotLoaded(loads, ['./auth']) + }, + ) + + /** A server fn whose validator is a module-level schema. */ + const schemaModule = (typeAlias: string) => `${head}import { z } from 'zod' +const themeValidator = z.union([z.literal('light'), z.literal('dark')]) +${typeAlias} +export const setTheme = createServerFn({ method: 'POST' }) + .validator(themeValidator) + .handler(async ({ data }) => data)` + + /** + * A case of `code` whose TypeScript is erased without + * `verbatimModuleSyntax` (imports nothing reads go too), with the + * client-only chart module. + */ + async function erasedCase(code: string) { + return (await host()).case({ + 'tsconfig.json': tsconfig(false), + 'module.tsx': code, + 'chart.client.ts': `export const createChart = () => ({ draw: () => 'drawn' })\n`, + }) + } + + // Control for the pin below (same harness): a schema only the validator + // reads leaves the client with its import. + test('client: a validator schema only the validator reads is not loaded', async () => { + const startCase = await erasedCase(schemaModule('')) + expectNotLoaded(await startCase.loads(), ['zod']) + }) + + // Bug: same family as above, for a module-level declaration: a validator + // schema that a type alias also reads (`z.infer<typeof themeValidator>`) + // stays in the client output, with what its initializer imports, although + // types read no value at runtime. The root cause is upstream: + // babel-dead-code-elimination 1.0.12 counts a `typeof` type query as a + // reference (no workaround here; `deadCodeElimination` at + // router-utils/src/ast.ts:190 runs it). + // Source: fuzzing (an unmodified file of a real app). + // Impact: the schema and its library (or server-only modules) ship to the + // client, which never runs them (see the build pin in + // start-build-env-separation.test.ts). + test.fails( + 'client: a validator schema that a type alias reads with typeof is not loaded', + async () => { + const startCase = await erasedCase( + schemaModule('type Theme = z.infer<typeof themeValidator>'), + ) + expectNotLoaded(await startCase.loads(), ['zod']) + }, + ) + + /** + * A client-only fn whose implementation reads a module-level chart that a + * client-only module creates. + */ + const clientOnlyChartModule = ( + typeAlias: string, + ) => `import { createClientOnlyFn } from '@tanstack/react-start' +import { createChart } from './chart.client' +const chart = createChart() +${typeAlias} +export const draw = createClientOnlyFn(() => chart.draw())` + + // Control for the pin below (same harness): a declaration only the + // client-only implementation reads leaves the SSR output with its import. + test('ssr: a declaration only a client-only fn reads is not loaded', async () => { + const startCase = await erasedCase(clientOnlyChartModule('')) + expectNotLoaded(await startCase.serverLoads(), ['./chart.client']) + }) + + // Bug: same root cause as the pin above (upstream + // babel-dead-code-elimination 1.0.12 counts a `typeof` type query as a + // reference; no workaround here), mirrored on the server: a module-level + // declaration that only a client-only implementation and a `typeof` type + // query read stays in the SSR output, with its initializer and imports. + // Source: fuzzing (an unmodified file of tanstack.com, + // src/components/ThemeProvider.tsx). + // Impact: the server loads the client-only module and runs the + // initializer (e.g. `window.matchMedia(...)`), which can throw during + // SSR. + test.fails( + 'ssr: a declaration a client-only fn reads and a type alias reads with typeof is not loaded', + async () => { + const startCase = await erasedCase( + clientOnlyChartModule('type Chart = typeof chart'), + ) + expectNotLoaded(await startCase.serverLoads(), ['./chart.client']) + }, + ) + + // Bug: the server twin of the class rows of "client: $name does not load + // its server-only import" above (dead-code elimination never removes a + // class declaration): a class only a client-only implementation uses + // stays in the SSR output with its client-only import (SPEC J4.11, G16). + // Impact: the server loads the client-only module and runs its top-level + // code; a browser-only package that reads `window` when it loads crashes + // SSR (Vite dev and build, Rsbuild build). + // Source: review (dead-code investigation, server direction). + test.fails( + 'ssr: a class only a client-only fn uses does not load its client-only import', + async () => { + const startCase = + await erasedCase(`import { createClientOnlyFn } from '@tanstack/react-start' +import { createChart } from './chart.client' +class Chart { draw() { return createChart().draw() } } +export const draw = createClientOnlyFn(() => new Chart().draw())`) + expectNotLoaded(await startCase.serverLoads(), ['./chart.client']) + expect(await inPage(startCase, 'return module.draw()')).toBe('drawn') + }, + ) +}) diff --git a/packages/start-plugin-core/tests/noncompiler-tests.json b/packages/start-plugin-core/tests/noncompiler-tests.json new file mode 100644 index 0000000000..3897d2ed98 --- /dev/null +++ b/packages/start-plugin-core/tests/noncompiler-tests.json @@ -0,0 +1,20 @@ +[ + "createVirtualModule.test.ts", + "csrf-warning-config.test.ts", + "entry-planning.test.ts", + "post-server-build.test.ts", + "prerender-ssrf.test.ts", + "prerender-vite.test.ts", + "rsbuild/normalized-client-build.test.ts", + "rsbuild/output-directory.test.ts", + "rsbuild/plugin.test.ts", + "rsbuild/post-build.test.ts", + "rsbuild/watch-ignored.test.ts", + "schema.test.ts", + "sitemap-output.test.ts", + "start-manifest-plugin.test.ts", + "start-manifest-plugin/manifestBuilder.test.ts", + "utils.test.ts", + "vite/bundled-dev-styles.test.ts", + "vite/dev-styles.test.ts" +] diff --git a/packages/start-plugin-core/tests/page-values.ts b/packages/start-plugin-core/tests/page-values.ts new file mode 100644 index 0000000000..611c752177 --- /dev/null +++ b/packages/start-plugin-core/tests/page-values.ts @@ -0,0 +1,48 @@ +/** + * Helpers for checks that compare values a module computes, on the client + * (a page script of `StartCase.client` / `inPage`, whose result crosses + * JSON) and on the server (the same script run in Node on the module the SSR + * environment evaluated). + */ +import { pagePrelude } from './start-host' + +/** + * Page source of `shapeOf(value)`: the value as JSON, functions spelled + * `'<function>'` and object properties whose value is `undefined` left out + * (what `toEqual` ignores too), so a function-valued property is never + * mistaken for an absent one. Prepend it to a page script. + */ +export const shapeOf = `const shapeOf = (value) => JSON.parse(JSON.stringify(value, (key, inner) => typeof inner === 'function' ? '<function>' : inner) ?? 'null')` + +/** + * A page expression of what the client must get of the options of the + * middleware `middleware` (a page expression): its `type`, and whether a + * server implementation or a validator ships (`server`, `validator`: `true` + * when present). On the client both are absent, not stubs (SPEC J4.8); + * other fields of `.options` (metadata a compiler adds) are free + * (SPEC §5.19). + */ +export const clientMiddlewareOf = (middleware: string) => + `((options) => ({ type: options.type, server: options.server !== undefined, validator: options.validator !== undefined }))(${middleware}.options)` + +/** What `clientMiddlewareOf` gives for a client middleware of `type`. */ +export const clientMiddleware = (type: 'request' | 'function') => ({ + type, + server: false, + validator: false, +}) + +/** + * Runs a page-style `script` (an async function body with `module`, the + * prelude's `settle` and `shapeOf` in scope) in Node, on `module` (e.g. what + * `StartCase.ssr()` gave): the same check on the server's module. + */ +export function runOnServerModule<T = unknown>( + module: Record<string, any>, + script: string, +): Promise<T> { + return new Function( + 'module', + `return (async () => {\n${pagePrelude}\n${shapeOf}\n${script}\n})()`, + )(module) as Promise<T> +} diff --git a/packages/start-plugin-core/tests/regression-helpers.ts b/packages/start-plugin-core/tests/regression-helpers.ts index dcdc80d79a..0dd7408cb0 100644 --- a/packages/start-plugin-core/tests/regression-helpers.ts +++ b/packages/start-plugin-core/tests/regression-helpers.ts @@ -1,471 +1,303 @@ /** - * Shared harness of the Start compiler behaviour suites: compile a module - * into its client, SSR caller and server-function provider outputs, split - * `<Hydrate>` children into chunks, and evaluate compiled modules against a - * minimal Start runtime. + * The Start compiler test kit of the fast tier, on the public Start host + * (`./start-host`: `tanstackStart()` of the built framework package in a + * real Vite dev server, a real Chromium page for client code, Start's real + * server entry and request context for server code). Tests write the + * modules a user writes (a case of the app: `module.tsx` and the files it + * imports, all real files) and observe what a user observes: + * + * - what a page that imports the module gets and loads (`StartCase.client`, + * `StartCase.loads`), and what calling a server fn there does: Start's + * client RPC sends its request to the dev server, whose server entry runs + * the handler (`callFromClient`); + * - what server code gets: the module evaluated by the SSR environment + * (`StartCase.ssr`), and server fns called inside a real request + * (`callOnServer`); + * - what an environment serves (`StartCase.served`, for shipped-text checks + * such as a server-only marker string) and the compile error it throws + * (`compileError`, judged with `./diagnostics`). + * + * Nothing here names a compiler internal: no compiler class, module id or + * query, provider module, server-fn report, emitted helper specifier or + * runtime-internal property. A server fn is found the way an app finds it + * (an export, or what the app's code returns) and identified by its public + * `url`. */ -import { transformWithOxc } from 'vite' +import { parseSync } from 'vite' import { expect } from 'vitest' -import { createHydrateCompilerPlugin } from '../src/hydrate-when-transform' -import { - StartCompiler, - detectKindsInCode, - getLookupKindsForEnv, -} from '../src/start-compiler/compiler' -import { getLookupConfigurationsForEnv } from '../src/start-compiler/config' -import { getModuleErrors } from './validate-module' -import type { ServerFn } from '../src/start-compiler/types' -import type { StartCompilerPlugin } from '../src/types' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { ClientRun, StartCase, StartHost } from './start-host' -export type Output = 'client' | 'ssr' | 'provider' -export const outputs: Array<Output> = ['client', 'ssr', 'provider'] -const moduleId = '/test/src/module.tsx' +export { createStartHost, useStartHost, useStartHosts } from './start-host' +export type { + StartCase, + StartFramework as Framework, + StartHost, + StartPreview, +} from './start-host' +export { + expectCompileError, + expectNoClientHandler, + serverOnlyModule, + throwsError, +} from './diagnostics' -interface StartCompilerOptions { - env: 'client' | 'server' - mode?: 'build' | 'dev' - /** Project modules by absolute id; `./name` resolves to `/test/src/name.ts`. */ - files?: Record<string, string> - /** `serverFnProviderModuleDirectives` */ - directives?: Array<string> - compilerPlugins?: Array<StartCompilerPlugin> +/** The case file a test's module is written to, by default. */ +export const moduleFile = 'module.tsx' + +/** + * What `settle` gives for a call that throws: the thrown value itself, so + * oracles (`throwsError`) read the real error, and a + * value the call returns is never mistaken for a throw. + */ +export class Thrown { + constructor(readonly error: unknown) {} } /** - * Creates a React `StartCompiler` configured the way the bundler plugins do, - * and records the server functions it reports. + * What calling `run` gives: its value, or `Thrown` with the error it + * throws. A `run` that is no function is given back as it is, never a + * `Thrown`: "calling it throws" needs a function (J4.10). */ -export function createStartCompiler(options: StartCompilerOptions) { - const { env, files = {} } = options - const serverFns: Record<string, ServerFn> = {} - const compiler: StartCompiler = new StartCompiler({ - env, - envName: env === 'client' ? 'client' : 'ssr', - root: '/test', - framework: 'react', - providerEnvName: 'ssr', - mode: options.mode ?? 'build', - lookupKinds: getLookupKindsForEnv(env), - lookupConfigurations: getLookupConfigurationsForEnv(env, 'react'), - getKnownServerFns: () => ({}), - devServerFnModuleSpecifierEncoder: ({ extractedFilename, root }) => - `/@id${extractedFilename.slice(root.length)}`, - serverFnProviderModuleDirectives: options.directives, - onServerFnsById: (fns) => Object.assign(serverFns, fns), - loadModule: async (id) => { - const code = files[id] - if (code !== undefined) { - compiler.ingestModule({ code, id }) - } - }, - resolveId: async (id) => { - if (id.startsWith('@tanstack/')) { - return id - } - const file = id.startsWith('./') ? `/test/src/${id.slice(2)}.ts` : id - return file in files ? file : null - }, - compilerPlugins: options.compilerPlugins, - }) - const compile = async (code: string, id = moduleId) => { - const result = await compiler.compile({ - code, - id, - detectedKinds: detectKindsInCode(code, env), - }) - return result?.code ?? null +export function settle(run: unknown) { + if (typeof run !== 'function') { + return run } - return { compiler, compile, serverFns } -} - -/** - * Compiles `code` for one output: the client, the SSR caller or the - * server-function provider module (`?tss-serverfn-split`). - */ -export async function compileFor( - output: Output, - code: string, - options: Omit<StartCompilerOptions, 'env'> & { id?: string } = {}, -) { - const { compile, serverFns } = createStartCompiler({ - ...options, - env: output === 'client' ? 'client' : 'server', - }) - const id = options.id ?? moduleId - const result = await compile( - code, - output === 'provider' ? `${id}?tss-serverfn-split` : id, - ) - return { code: result, serverFns } -} - -/** Like `compileFor`, returning only the code (null when untouched). */ -export async function compileCode( - ...args: Parameters<typeof compileFor> -): Promise<string | null> { - return (await compileFor(...args)).code -} - -/** - * Compiles the client, SSR caller and provider outputs, checks that each is - * a valid module and returns them with the server functions the client - * compilation reported. - */ -export async function compileAll( - code: string, - options: Omit<StartCompilerOptions, 'env'> = {}, -) { - const compiled = {} as Record<Output, string> - const errors = {} as Record<Output, Array<string>> - let serverFns: Record<string, ServerFn> = {} - for (const output of outputs) { - const result = await compileFor(output, code, options) - expect(result.code, output).not.toBeNull() - compiled[output] = result.code! - errors[output] = await getModuleErrors(result.code!) - if (output === 'client') { - serverFns = result.serverFns - } - } - expect(errors).toEqual({ client: [], ssr: [], provider: [] }) - return { ...compiled, serverFns } -} - -/** - * Matches the source of an import or re-export statement (specifier names - * may be string literals). - */ -const moduleSource = - /^(\s*import\s*|\s*(?:import|export)\b(?:[^;'"]|'[^'\n]*'|"[^"\n]*")*?\bfrom\s*)(["'])([^"']+)\2/gm - -/** Project-local import and re-export sources of a module, sorted. */ -export function importSources(code: string) { - return [...code.matchAll(moduleSource)] - .map((match) => match[3]!) - .filter((source) => !source.startsWith('@tanstack/')) - .sort() -} - -const dataUrl = (code: string, type = 'text/javascript') => - `data:${type},${encodeURIComponent(code)}` - -/** - * Minimal Start package: callers keep the RPC they were given, providers run - * the original handler. The other factories throw when they are called - * uncompiled, so a test only passes if the compiler ran. - */ -const startRuntime: Record<string, string> = { - '@tanstack/react-start': ` -const uncompiled = () => { throw new Error('uncompiled Start factory') } -const builder = () => { - const self = { - handler: (rpc, impl) => - impl - ? Object.assign((opts) => impl(opts ?? {}), { - __executeServer: (opts) => impl(opts), - }) - : { rpc }, - } - return self -} -export const createServerFn = builder -export const createServerOnlyFn = uncompiled -export const createClientOnlyFn = uncompiled -export const createIsomorphicFn = uncompiled -export const createMiddleware = () => ({ server: uncompiled })`, - '@tanstack/react-start/server-rpc': `export const createServerRpc = (meta, fn) => Object.assign(fn, { meta })`, - '@tanstack/react-start/client-rpc': `export const createClientRpc = (id) => ({ client: id })`, - '@tanstack/react-start/ssr-rpc': `export const createSsrRpc = (id) => ({ ssr: id })`, -} - -/** - * JSX runtime of evaluated modules: intrinsic elements render as tags, - * components are called with their props. - */ -const jsxToText = `const __Fragment = Symbol('Fragment') -const __jsx = (type, props, ...children) => { - const text = children.flat(Infinity).filter((c) => c != null && c !== false && c !== true).join('') - if (type === __Fragment) return text - if (typeof type === 'function') return type(children.length ? { ...props, children: text } : { ...props }) - if (typeof type !== 'string') throw new Error('cannot render ' + String(type)) - return '<' + type + '>' + text + '</' + type + '>' -} -` - -/** Module stub: module source code, or the exports of the module. */ -export type ModuleStub = string | Record<string, unknown> - -const stubsKey = '__startCompilerTestStubs' -const stubRegistry: Array<Record<string, unknown>> = [] -;(globalThis as Record<string, unknown>)[stubsKey] = stubRegistry - -function stubUrl(source: string, stub: ModuleStub) { - if (typeof stub === 'string') { - return source.endsWith('.json') - ? dataUrl(stub, 'application/json') - : dataUrl(stub) - } - const index = stubRegistry.push(stub) - 1 - const named = Object.keys(stub).filter((name) => name !== 'default') - return dataUrl(`const stub = globalThis.${stubsKey}[${index}] -export default stub.default -export const { ${named.join(', ')} } = stub`) -} - -let evaluations = 0 - -/** - * Evaluates a compiled module like a bundler would: TypeScript is erased, JSX - * becomes calls of `runtime` (which defines `__jsx` and `__Fragment`), and - * every import is linked to the minimal Start runtime or to `stubs` (by - * specifier; `.json` string stubs are JSON modules). Every call evaluates a - * fresh instance, even for identical code. - */ -export async function evaluateModule( - code: string, - stubs: Record<string, ModuleStub> = {}, - runtime = jsxToText, -): Promise<Record<string, any>> { - const sources: Record<string, ModuleStub> = { ...startRuntime, ...stubs } - const { code: javascript } = await transformWithOxc(code, 'module.tsx', { - jsx: { runtime: 'classic', pragma: '__jsx', pragmaFrag: '__Fragment' }, - }) - const linked = javascript.replace( - moduleSource, - (_match, prefix: string, _quote: string, source: string) => { - const stub = sources[source] - if (stub === undefined) { - throw new Error(`No stub for import ${source}`) - } - return `${prefix}${JSON.stringify(stubUrl(source, stub))}` - }, - ) - return import( - /* @vite-ignore */ dataUrl( - `${runtime}${linked}\n// evaluation ${++evaluations}`, - ) - ) -} - -/** Runs a provider's extracted handler the way the server-fn router does. */ -export async function callProvider( - provider: string | Record<string, any>, - name: string, - stubs: Record<string, ModuleStub> = {}, - data?: unknown, -) { - const module = - typeof provider === 'string' - ? await evaluateModule(provider, stubs) - : provider - const handler = module[`${name}_createServerFn_handler`] - expect(handler, name).toBeTypeOf('function') - return handler({ data }) -} - -/** The value of `run`, or the message of the error it throws. */ -export function settle(run: () => unknown) { try { return run() } catch (error) { - return `throws: ${(error as Error).message}` + return new Thrown(error) } } -export const serverOnlyError = - 'throws: createServerOnlyFn() functions can only be called on the server!' -export const clientOnlyError = - 'throws: createClientOnlyFn() functions can only be called on the client!' - -type HydratePlugin = ReturnType<typeof createHydrateCompilerPlugin> - -/** The `<Hydrate>` chunk ids a compiled module imports, in source order. */ -export function getChunkIds(code: string) { - return [...code.matchAll(/import\((["'])(.+?)\1\)/g)] - .map(([, , id]) => id!) - .filter((id) => id.includes('tss-hydrate=')) -} - -/** Boundary ids (`h` props) a compiled module renders, in source order. */ -export function getBoundaryIds(code: string) { - return [...code.matchAll(/\bh=\s*["']([^"']+)["']/g)].map(([, id]) => id!) -} - -/** Loads a `<Hydrate>` chunk the way the bundler loads the virtual module. */ -export function loadChunk( - plugin: HydratePlugin, - env: 'client' | 'server', - id: string, -) { - return ( - plugin.loadVirtualModule?.({ - id, - root: '/test', - env, - envName: env === 'client' ? 'client' : 'ssr', - })?.code ?? null - ) -} - /** - * Compiles a module with `<Hydrate>` and loads the split chunks it imports, - * ordered by boundary index. + * The value `run` resolves to, or `Thrown` with the error it throws or + * rejects with. */ -export async function compileHydrate(env: 'client' | 'server', code: string) { - const plugin = createHydrateCompilerPlugin() - const { compile } = createStartCompiler({ env, compilerPlugins: [plugin] }) - const parent = await compile(code) - if (parent === null) { - throw new Error('expected the module to be transformed') +export async function settleAsync(run: () => unknown) { + try { + return await run() + } catch (error) { + return new Thrown(error) } - const chunks = getChunkIds(parent).map((id) => { - const chunk = loadChunk(plugin, env, id) - if (chunk === null) { - throw new Error(`expected virtual module ${id} to load`) +} + +/** What the page's `settle` gave (`pagePrelude`). */ +export type PageSettled = + | { value: unknown } + | { thrown: { name?: string; message: string } } + +/** + * A page `settle` result as the test reads it: the value, or a `Thrown` + * with an `Error` of the page error's name and message. + */ +export function fromPage(settled: PageSettled): unknown { + if ('thrown' in settled) { + const error = new Error(settled.thrown.message) + if (settled.thrown.name) { + error.name = settled.thrown.name } - return chunk - }) - // Order chunks by boundary index, however the parent declares them. - const index = (chunk: string) => - Number(chunk.match(/export function H(\d+)\(/)?.[1] ?? -1) - chunks.sort((a, b) => index(a) - index(b)) - return { parent, chunks, plugin } -} - -/** - * Loads the first chunk a parent module imports and compiles it for the - * client under its virtual module id, like the bundler does. - */ -export async function compileFirstChunk(plugin: HydratePlugin, parent: string) { - const id = getChunkIds(parent)[0]! - const { compile, serverFns } = createStartCompiler({ - env: 'client', - compilerPlugins: [plugin], - }) - const code = await compile(loadChunk(plugin, 'client', id)!, id) - return { code, serverFns } -} - -/** Exported function declarations: name and parameter list. */ -const exportedFunction = - /export\s+(?:default\s+)?function\s*([\w$]*)\s*\(([^)]*)\)/g - -/** - * The names the component of a split chunk receives as props, sorted. The - * component is the generated `H<index>` export, else the only exported - * function. - */ -export function getChunkParams(chunk: string) { - const components = [...chunk.matchAll(exportedFunction)] - const component = - components.find(([, name]) => /^H\d+$/.test(name!)) ?? - (components.length === 1 ? components[0] : undefined) - const params = component?.[2] ?? '' - return [...params.matchAll(/[\w$]+/g)].map(([name]) => name).sort() -} - -/** - * The component an evaluated `<Hydrate>` chunk exports: the generated - * `H<index>` export, else the only exported function. - */ -export function getChunkComponent(module: Record<string, any>) { - const functions = Object.keys(module).filter( - (key) => typeof module[key] === 'function', - ) - const name = - functions.find((key) => /^H\d+$/.test(key)) ?? - (functions.length === 1 ? functions[0] : undefined) - if (!name) { - throw new Error('expected the chunk to export a component') + return new Thrown(error) } - return module[name] as (props: Record<string, unknown>) => any -} - -/** Renders the component a `<Hydrate>` chunk exports with the given props. */ -export async function renderChunk( - chunk: string, - props: Record<string, unknown> = {}, - stubs: Record<string, ModuleStub> = {}, -) { - return getChunkComponent(await evaluateModule(chunk, stubs))(props) -} - -/** Parent-module stubs: `<Hydrate>` marks where its children render, lazy chunks render their props. */ -export const hydrateParentStubs = { - '@tanstack/react-start': { - Hydrate: (props: { children: unknown }) => `[${props.children ?? ''}]`, - }, - '@tanstack/react-start/hydration': { - idle: () => 'idle', - visible: () => 'visible', - }, - '@tanstack/react-router': { - lazyRouteComponent: () => (props: Record<string, unknown>) => - `lazy(${Object.keys(props) - .filter((name) => name !== 'children') - .sort() - .map((name) => `${name}=${String(props[name])}`) - .join(',')})`, - }, + return settled.value } /** - * Import sources of a `<Hydrate>` module that name the parent module, with any - * query or hash: a chunk may import the module bindings it shares with the - * parent instead of declaring its own copy. + * An environment's refusal to serve a module (`file`, its absolute path): + * the error it threw, and what the app reported on every channel meanwhile + * (a compiler may give its explanation on the console or the dev server's + * logger and hand the bundler a short error, SPEC §5.7). + * `expectCompileError` reads both. */ -export function parentImportSources(code: string) { - return importSources(code).filter((source) => - [moduleId, './module.tsx', './module'].includes( - source.replace(/[?#].*$/, ''), - ), +export class CompileFailure extends Error { + constructor( + readonly error: unknown, + readonly reported: Array<ChannelDiagnostic>, + readonly file: string, + ) { + super(error instanceof Error ? error.message : String(error), { + cause: error, + }) + this.name = 'CompileFailure' + } +} + +/** + * The failure of an environment (default `client`) to serve a case file + * (default `module.tsx`): a `CompileFailure` (the error it threw and the + * warnings and errors the app reported on any channel while it tried), or + * `undefined` when it serves the file. + */ +export async function compileError( + startCase: StartCase, + environment: 'client' | 'ssr' = 'client', + file = moduleFile, +): Promise<CompileFailure | undefined> { + const mark = startCase.diagnostics().length + try { + await startCase.served(file, environment) + return undefined + } catch (error) { + return new CompileFailure( + error, + startCase + .diagnostics() + .slice(mark) + .filter((diagnostic) => diagnostic.severity !== 'info'), + startCase.file(file), + ) + } +} + +/** A case whose module every environment served and evaluated. */ +export interface ServedCase extends StartCase { + /** What each environment serves for the module. */ + code: { client: string; ssr: string } +} + +/** + * Writes a case of the app (`files`, by path relative to the case + * directory; the module under test is `module.tsx` unless `file` says + * otherwise) and checks that it is a working module everywhere: the client + * and SSR environments serve it, the SSR environment evaluates it, and a + * page imports it without an error. Returns the case with the served code. + */ +export async function serveCase( + host: StartHost, + files: Record<string, string>, + options: { file?: string } = {}, +): Promise<ServedCase> { + const file = options.file ?? moduleFile + const startCase = await host.case(files) + const client = await startCase.served(file, 'client') + const ssr = await startCase.served(file, 'ssr') + await startCase.ssr(file) + const run = await startCase.client('return true', { file }) + expect(run.errors, `page errors importing ${file}`).toEqual([]) + return { ...startCase, code: { client, ssr } } +} + +/** `data` as a JavaScript expression of a page script. */ +function dataExpression(data: unknown) { + return data === undefined ? 'undefined' : JSON.stringify(data) +} + +/** + * Calls a server fn from the client the way an app does: in the host's page, + * `fn` (a JavaScript expression with the case module as `module`, e.g. + * `module.getUser` or `module.api.read`) is called with `{ data }`; Start's + * client runtime sends its request to the dev server, whose server entry + * runs the handler. Gives what the call resolves to (JSON), or throws an + * `Error` with the page error's name and message. + */ +export async function callFromClient( + startCase: StartCase, + fn: string, + data?: unknown, + options: { file?: string } = {}, +): Promise<unknown> { + const run = await startCase.client<PageSettled>( + `const fn = ${fn} +if (typeof fn !== 'function') { + throw new Error(${JSON.stringify(`${fn} is not a function on the client`)} + ': ' + typeof fn) +} +return settle(() => fn({ data: ${dataExpression(data)} }))`, + options, + ) + const result = fromPage(run.result) + if (result instanceof Thrown) { + throw result.error + } + return result +} + +/** `read` (a JavaScript expression with the module as `module`) in Node. */ +function readExpression(expression: string) { + return new Function('module', `return (${expression})`) as ( + module: Record<string, any>, + ) => unknown +} + +/** + * Calls a server fn from server code the way an app does: inside a real + * request of the app (`StartCase.inRequest`), `fn` (the same expression as + * for `callFromClient`, read from the module the SSR environment evaluated) + * is called with `{ data }`. Gives what it resolves to, or throws what it + * throws. + */ +export async function callOnServer( + startCase: StartCase, + fn: string, + data?: unknown, + options: { file?: string } = {}, +): Promise<unknown> { + const module = await startCase.ssr(options.file) + const server = readExpression(fn)(module) + expect(server, `${fn} on the server`).toBeTypeOf('function') + return startCase.inRequest(() => + (server as (options: { data?: unknown }) => unknown)({ data }), ) } /** - * Evaluates a client `<Hydrate>` parent and links its modules like a bundler. - * An import of the parent module (`parentImportSources`) resolves to the - * virtual module the Hydrate plugin loads for that id, evaluated once and - * shared by the parent and its chunks, or else to the evaluated parent. - * Returns the parent module and `parentModuleStubs(chunk)`, the stubs that - * link a chunk's parent imports. + * Calls a server fn the way the app does, from both sides: from the client + * (`callFromClient`: the request reaches the handler through the server + * entry) and from server code (`callOnServer`), and checks that both give + * the same result, which it returns. */ -export async function evaluateHydrateParent( - plugin: HydratePlugin, - parent: string, - stubs: Record<string, ModuleStub> = hydrateParentStubs, - runtime?: string, -) { - const virtualModules = new Map<string, Promise<Record<string, unknown>>>() - const link = async (code: string, parentModule?: Record<string, unknown>) => { - const linked: Record<string, ModuleStub> = {} - for (const source of parentImportSources(code)) { - const id = `${moduleId}${source.match(/[?#].*$/)?.[0] ?? ''}` - const virtualModule = loadChunk(plugin, 'client', id) - if (virtualModule !== null) { - if (!virtualModules.has(id)) { - const linkedModule = link(virtualModule, parentModule).then( - (imports) => - evaluateModule(virtualModule, { ...stubs, ...imports }, runtime), - ) - virtualModules.set(id, linkedModule) - } - linked[source] = await virtualModules.get(id)! - } else if (parentModule) { - linked[source] = parentModule - } else { - throw new Error(`Cannot link ${source} before the parent is evaluated`) - } +export async function callServerFnThroughCallers( + startCase: StartCase, + fn: string, + data?: unknown, + options: { file?: string } = {}, +): Promise<unknown> { + const client = await callFromClient(startCase, fn, data, options) + const server = await callOnServer(startCase, fn, data, options) + expect(server, `${fn} called by server code`).toEqual(client) + return client +} + +/** + * The distinct `url`s of the server fns among the values of `namespace` (a + * JavaScript expression of the page, default the case module's namespace): + * how many server fns a module gives its importers, by their public + * identity. + */ +export async function serverFnUrls( + startCase: StartCase, + namespace = 'module', + options: { file?: string } = {}, +): Promise<Array<string>> { + const run = await startCase.client<Array<string>>( + `return serverFnUrls(${namespace})`, + options, + ) + return run.result +} + +/** Runs a page script and returns its JSON result (`StartCase.client`). */ +export async function inPage<T = unknown>( + startCase: StartCase, + script: string, + options: { file?: string } = {}, +): Promise<T> { + const run: ClientRun<T> = await startCase.client<T>(script, options) + return run.result +} + +/** The directives of a module's directive prologue, in order. */ +export function directivePrologue(code: string) { + const { program } = parseSync('module.tsx', code, { sourceType: 'module' }) + const directives: Array<string> = [] + for (const statement of program.body) { + if ( + statement.type !== 'ExpressionStatement' || + !('directive' in statement) || + typeof statement.directive !== 'string' + ) { + break } - return linked - } - const module: Record<string, any> = await evaluateModule( - parent, - { ...stubs, ...(await link(parent)) }, - runtime, - ) - return { - module, - parentModuleStubs: (chunk: string) => link(chunk, module), + directives.push(statement.directive) } + return directives } diff --git a/packages/start-plugin-core/tests/render.ts b/packages/start-plugin-core/tests/render.ts new file mode 100644 index 0000000000..a81bcb790e --- /dev/null +++ b/packages/start-plugin-core/tests/render.ts @@ -0,0 +1,1241 @@ +/** + * `<Hydrate>` modules rendered and hydrated through the public Start + * plugin: the case module of a Start app on a real dev server + * (`./start-host`: `tanstackStart()` and the framework's Vite plugin) is + * + * - rendered on the server by the SSR environment (its module runner + * evaluates the module as the dev server compiles it for SSR) with React's + * own server renderer (`react-dom/static`'s `prerenderToNodeStream`, which + * waits for lazy components and Suspense like a streaming render), reached + * through an app module so React is the app's own instance; + * - hydrated on the client in a real Chromium page of the same dev server: + * the page imports the module as a browser does, puts the server's HTML in + * a fresh container and hydrates it with `hydrateRoot` (React's + * development build, which reports mismatches through + * `onRecoverableError` and `console.error`), then opens every boundary's + * gate (a boundary becomes visible, an interaction event reaches it, idle + * and load gates open themselves) and waits until the page is quiet; + * - compared with the uncompiled source (`renderSource`): the same files on + * a plain Vite dev server with only `@vitejs/plugin-react` (no Start + * plugin), rendered by its SSR environment with the same renderer, where + * the real `Hydrate` renders its children in place. + * + * Markup is compared semantically: the page parses each HTML + * string and serializes its DOM again with sorted attributes, merged text + * and no comments (`html`), hydration ids blanked where the uncompiled + * source is the reference. What loads when is read from the page's own + * resource timing: `loaded` (the case files the import of the module + * requested) and `lazy` (everything the page requested once hydration + * started: the split code, wherever the compiler put it). Nothing here names + * a compiler internal: no plugin, virtual module id, query or chunk count. + */ +import { mkdir, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import { afterAll, beforeAll, expect } from 'vitest' +import { createPluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import { workspacePackageLinks } from '@tanstack/compiler-test-utils/workspace-packages' +import { + currentTest, + onTestFinished, +} from '@tanstack/compiler-test-utils/test-scope' +import { createStartHost, giveBackHost, hostKey, takeHost } from './start-host' +import type { PluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import type { StartCase, StartHost } from './start-host' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +/** The app modules that render (server) and hydrate (client) a case. */ +const renderFiles = { + 'src/harness/render.server.tsx': `import { createElement } from 'react' +import { prerenderToNodeStream } from 'react-dom/static' +export const h = createElement +export async function renderToHtml(element: unknown) { + const errors: Array<unknown> = [] + const { prelude } = await prerenderToNodeStream(element as any, { + onError: (error: unknown) => { + errors.push(error) + }, + }) + let html = '' + for await (const part of prelude) { + html += String(part) + } + if (errors.length > 0) { + throw new AggregateError( + errors, + 'rendering failed: ' + + errors.map((error) => (error instanceof Error ? error.message : String(error))).join('; '), + ) + } + return html +} +`, + 'src/harness/render.client.tsx': `export { createElement as h } from 'react' +export { createRoot, hydrateRoot } from 'react-dom/client' +`, +} + +/** The reference host's files: the renderer and the cases' runtime. */ +const referenceFiles = { + 'src/harness/render.server.tsx': renderFiles['src/harness/render.server.tsx'], +} + +const casesDir = 'src/cases' + +/** + * The app's `tsconfig.json`: with `verbatimModuleSyntax`, as a Start app + * configures it (otherwise the app inherits this package's tsconfig, and + * Vite's TypeScript transform erases unreferenced imports after the + * compilers ran, hiding what they left behind). + */ +const appTsconfig = (jsx: Record<string, string>) => + JSON.stringify({ + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + strict: true, + verbatimModuleSyntax: true, + ...jsx, + }, + }) +const reactTsconfig = appTsconfig({ jsx: 'react-jsx' }) + +/** + * The Start plugin options of the hosts: import protection off (its dev + * mocks of denied `*.server.*` imports on the client would hide what the + * compiler ships), as the other Start compiler suites run it. + */ +const startOptions = { importProtection: { enabled: false } } + +/** A plain Vite dev server rendering uncompiled modules (no Start plugin). */ +export interface ReferenceHost { + host: PluginHost + /** Writes a case (files relative to its directory); returns its directory. */ + case: (files: Record<string, string>) => Promise<string> + close: () => Promise<void> +} + +async function createReferenceHost(): Promise<ReferenceHost> { + const host = await createPluginHost({ + dir: harnessDir, + prefix: '.hydrate-reference-', + plugins: [react()], + config: { server: { watch: { ignored: [`**/${casesDir}/**`] } } }, + symlinks: workspacePackageLinks(['@tanstack/react-start']), + files: { ...referenceFiles, 'tsconfig.json': reactTsconfig }, + }) + let cases = 0 + return { + host, + case: async (files) => { + const dir = `${casesDir}/r${++cases}` + await writeCase(host.root, dir, files) + return dir + }, + close: () => host.close(), + } +} + +async function writeCase( + root: string, + dir: string, + files: Record<string, string>, +) { + for (const [file, code] of Object.entries(files)) { + const absolute = path.join(root, dir, file) + await mkdir(path.dirname(absolute), { recursive: true }) + await writeFile(absolute, code) + } +} + +/** The Start host and the uncompiled-source reference host of a test file. */ +export interface HydrateHost { + start: StartHost + reference: () => Promise<ReferenceHost> + /** + * Whether the Start host writes cases (`StartHost.case`). An edit host + * (`useEditHost`) writes only watched files, through the dev server's + * watcher, and runs page code in its page directly. + */ + cases: boolean +} + +/** The result of page code (`runPage`). */ +interface PageResult<T> { + result: T + errors: Array<string> +} + +/** + * Runs page code (the body of an async function) in the Start host's page: + * through a case of the host (`StartCase.client`, which reruns it on a + * fresh document when the page reloaded), or, on an edit host, in the page + * itself. + */ +async function runPage<T>( + hosts: HydrateHost, + script: string, + startCase?: StartCase, + runOptions: { fresh?: boolean } = {}, +): Promise<PageResult<T>> { + if (startCase || hosts.cases) { + const runner = startCase ?? (await runnerCase(hosts)) + for (let attempt = 0; ; attempt++) { + try { + const run = await runner.client<T>(script, { + file: 'setup.ts', + fresh: runOptions.fresh, + }) + return { result: run.result, errors: run.errors } + } catch (error) { + // A reload an earlier case caused (the dev server reloads its pages + // when a module it served fails) can still be under way when this + // run starts: run again on the new document. + if ( + attempt >= 2 || + !/Execution context was destroyed/.test(String(error)) + ) { + throw error + } + } + } + } + const run = await hosts.start.run<T>(`(async () => {\n${script}\n})()`, { + fresh: runOptions.fresh, + }) + return { result: run.result, errors: run.errors } +} + +/** The options of the hosts of `useHydrateHost`. */ +const hydrateHostOptions = { + start: startOptions, + files: { ...renderFiles, 'tsconfig.json': reactTsconfig }, +} +const hydrateHostKey = `hydrate ${hostKey(hydrateHostOptions)}` +const referenceHostKey = 'hydrate reference' + +/** + * One Start host (React) and, on first use, one reference host per test + * file, taken before its tests (free ones an earlier file of the test + * process gave back, or new ones: `takeHost`) and given back after them. + */ +export function useHydrateHost(): () => Promise<HydrateHost> { + let started: Promise<HydrateHost> | undefined + let reference: Promise<ReferenceHost> | undefined + beforeAll(() => { + started = takeHost(hydrateHostKey, () => + createStartHost(hydrateHostOptions), + ).then((start) => ({ + start, + reference: () => + (reference ??= takeHost(referenceHostKey, createReferenceHost)), + cases: true, + })) + // The page and the renderers, before the first test + return started.then((hosts) => warm(hosts)) + }, 60_000) + afterAll(async () => { + try { + const referenceHost = await reference?.catch(() => undefined) + if (referenceHost) { + await giveBackHost(referenceHostKey, referenceHost) + } + } finally { + const hosts = await started?.catch(() => undefined) + if (hosts) { + await giveBackHost(hydrateHostKey, hosts.start) + } + } + }) + return () => { + if (!started) { + throw new Error('useHydrateHost: no host before beforeAll ran') + } + return started + } +} + +/** Loads the page and the renderers. */ +async function warm(hosts: HydrateHost) { + await runPage( + hosts, + `await Promise.all([import('/src/harness/render.client.tsx'), import('/@id/@tanstack/react-start'), import('/@id/@tanstack/react-start/hydration')])`, + ) + await hosts.start.host.importServer('/src/harness/render.server.tsx') +} + +/** + * A Start host for dev edits (React), one per test (its own dev server and + * page: an edit's hot updates and reloads reach no other test), created on + * first use in the test and closed when the test ends: it writes no case, + * so its dev server's settle after an edit (`StartHost.edit`) sees only + * watched files. Use `editableFiles` and watched route files with it; + * `renderClient` with a `target`. + */ +export function useEditHost(): () => Promise<HydrateHost> { + const started = new WeakMap<object, Promise<HydrateHost>>() + const outsideTests = {} + return () => { + const test = currentTest() + const owner = test ?? outsideTests + let hosts = started.get(owner) + if (!hosts) { + hosts = createStartHost({ + start: startOptions, + files: { ...renderFiles, 'tsconfig.json': reactTsconfig }, + }).then(async (start) => { + // The page loads its runtime before an edit reloads it + await start.run('1') + return { + start, + reference: () => { + throw new Error('an edit host has no reference host') + }, + cases: false, + } + }) + started.set(owner, hosts) + const created = hosts + onTestFinished(async () => { + await (await created.catch(() => undefined))?.start.close() + }) + } + return hosts + } +} + +export interface RenderOptions { + /** + * What to render: a JavaScript expression with the module as `m`, React's + * `createElement` as `h` and `props` in scope, evaluated on the server and + * in the page (default `h(m.Page, props)`). It runs inside a component, so + * hooks it calls run there. + */ + render?: string + /** JSON props of the render. */ + props?: Record<string, unknown> + /** + * Project modules the module imports, by relative specifier + * (`'./widgets'`, a `.tsx` module unless it has an extension) or path + * relative to the case directory, written as real files. + */ + files?: Record<string, string> + /** + * Source of a module (`setup.ts` of the case) each realm (the server, the + * reference, the page) evaluates before the module: globals the fixture + * reads, counters it resets. The page is shared by the cases of a file: + * the module exports `cleanup`, the names of the globals it defines, which + * the page deletes after the run. + */ + setup?: string + /** + * App code each realm runs once the module evaluated, before it renders + * (statements with the module as `m` in scope), e.g. what the route tree + * of an app does to a route module. + */ + beforeRender?: string + /** The module's file in the case (default `module.tsx`). */ + file?: string +} + +export interface ClientOptions extends RenderOptions { + /** + * Body of an async function run in the page once the page hydrated and + * every gate opened, with `root` (the container), `m`, `settled()` and + * `openGates()` in scope; its JSON value is `result`. + */ + script?: string + /** + * Which gates the run opens: `'all'` (default), `'none'` (only idle and + * load gates open themselves), or a page expression of a function that + * gets a boundary still waiting for its gate (the element carrying the + * runtime's gate marker) and says whether to open it, e.g. + * `(boundary) => boundary.textContent.includes('chart')`. + */ + gates?: 'all' | 'none' | string +} + +const caseFileName = (specifier: string) => { + if (!specifier.startsWith('./')) { + return specifier + } + const relative = specifier.slice(2) + return /\.[\w]+$/.test(relative) ? relative : `${relative}.tsx` +} + +/** The case files of `code` and `options.files`. */ +function caseFiles(code: string, options: RenderOptions) { + const files: Record<string, string> = { + 'setup.ts': options.setup ?? 'export {}\n', + } + for (const [specifier, source] of Object.entries(options.files ?? {})) { + files[caseFileName(specifier)] = source + } + files[options.file ?? 'module.tsx'] = code + return files +} + +const renderExpression = (options: RenderOptions) => + options.render ?? 'h(m.Page, props)' + +/** Renders `m` with the SSR renderer module of a host (in this process). */ +async function renderWith( + renderer: Record<string, any>, + module: Record<string, any>, + options: RenderOptions, +) { + const render = new Function( + 'm', + 'h', + 'props', + `return (${renderExpression(options)})`, + ) as (m: unknown, h: unknown, props: unknown) => unknown + if (options.beforeRender !== undefined) { + await ( + new Function( + 'm', + `return (async () => {\n${options.beforeRender}\n})()`, + ) as (m: unknown) => Promise<unknown> + )(module) + } + const props = options.props ?? {} + const Root = () => render(module, renderer.h, props) + return (await renderer.renderToHtml(renderer.h(Root))) as string +} + +/** + * Page code: `normalize(html, { ids })`, the DOM of `html` serialized again + * with sorted attributes, merged text nodes and no comments; hydration ids + * kept (`ids: true`), blanked (`false`), or kept for the boundaries no other + * boundary contains (`'outer'`). + */ +const normalizeSource = `const normalize = (html, { ids = true } = {}) => { + const template = document.createElement('template') + template.innerHTML = html + const voids = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'source', 'track', 'wbr']) + const text = (value) => value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\\u00a0/g, ' ') + const attribute = (value) => value.replace(/&/g, '&').replace(/"/g, '"') + const walk = (node) => { + let out = '' + let pending = null + for (const child of node.childNodes) { + if (child.nodeType === 3) { + pending = (pending ?? '') + child.data + continue + } + if (pending !== null) { + out += text(pending) + pending = null + } + if (child.nodeType !== 1) { + continue + } + // A wrapper the runtime renders around a boundary's content while it + // waits (display: contents: no box of its own) is not markup. + if (child.localName === 'div' && child.attributes.length === 1 && child.getAttribute('style')?.replace(/\\s/g, '') === 'display:contents;') { + out += walk(child) + continue + } + const tag = child.localName + // The gate-state marker is the runtime's (it drops it once a boundary + // hydrated): not markup the compiler renders. + const attributes = [...child.attributes] + .filter((attr) => attr.name !== 'data-ts-hydrate-when') + .map((attr) => [ + attr.name, + attr.name === 'data-ts-hydrate-id' && + (ids === false || (ids === 'outer' && child.parentElement?.closest('[data-ts-hydrate-id]'))) + ? '' + : attr.value, + ]) + .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)) + out += '<' + tag + attributes.map(([name, value]) => ' ' + name + '="' + attribute(value) + '"').join('') + '>' + if (!voids.has(tag)) { + out += walk(child.content ?? child) + '</' + tag + '>' + } + } + if (pending !== null) { + out += text(pending) + } + return out + } + return walk(template.content) +}` + +/** Normalizes HTML strings in the host page (`normalizeSource`). */ +async function normalizeInPage( + hosts: HydrateHost, + htmls: Array<string>, + ids: boolean, +): Promise<Array<string>> { + const run = await runPage<Array<string>>( + hosts, + `${normalizeSource} +return ${JSON.stringify(htmls)}.map((html) => normalize(html, { ids: ${ids} }))`, + ) + return run.result +} + +/** The markup with every hydration id blanked. */ +export function withoutHydrationIds(html: string) { + return html.replace(/ data-ts-hydrate-id="[^"]*"/g, ' data-ts-hydrate-id=""') +} + +/** A case of the Start host whose page runs the render kit's page code. */ +const runners = new WeakMap<HydrateHost, Promise<StartCase>>() +function runnerCase(hosts: HydrateHost) { + let runner = runners.get(hosts) + if (!runner) { + runner = hosts.start.case({ 'setup.ts': 'export {}\n' }) + runners.set(hosts, runner) + } + return runner +} + +export interface ServerRender { + /** The normalized markup (hydration ids kept). */ + html: string + /** The HTML React rendered. */ + raw: string + /** The case the module was written to. */ + case: StartCase + /** What the SSR environment serves for the module. */ + code: string + /** The module the SSR environment evaluated. */ + module?: Record<string, any> +} + +/** + * Renders the uncompiled `code` (the reference: `<Hydrate>` renders its + * children in place) on the reference host's server. `html` is normalized + * (in the Start host's page) with hydration ids blanked. + */ +export async function renderSource( + hosts: HydrateHost, + code: string, + options: RenderOptions = {}, +): Promise<{ html: string; raw: string }> { + const reference = await hosts.reference() + const dir = await reference.case(caseFiles(code, options)) + await reference.host.importServer(`/${dir}/setup.ts`) + const module = await reference.host.importServer( + `/${dir}/${options.file ?? 'module.tsx'}`, + ) + const renderer = await reference.host.importServer( + '/src/harness/render.server.tsx', + ) + const raw = await renderWith(renderer, module, options) + const [html] = await normalizeInPage(hosts, [raw], false) + return { html: html!, raw } +} + +/** Renders the case module on the Start host's server (SSR environment). */ +async function serverRender( + hosts: HydrateHost, + target: RenderTarget, + options: RenderOptions, +) { + const file = options.file ?? 'module.tsx' + const code = await target.served(file, 'ssr') + if (target.setup !== false) { + await target.ssr(target.setup ?? 'setup.ts') + } + const module = await target.ssr(file) + const renderer = await hosts.start.host.importServer( + '/src/harness/render.server.tsx', + ) + return { raw: await renderWith(renderer, module, options), code, module } +} + +/** + * Compiles `code` with the Start plugin for the server (the SSR environment + * serves and evaluates it) and renders it. + */ +export async function renderServer( + hosts: HydrateHost, + code: string, + options: RenderOptions = {}, +): Promise<ServerRender> { + const startCase = await hosts.start.case(caseFiles(code, options)) + const rendered = await serverRender(hosts, caseTarget(startCase), options) + const [html] = await normalizeInPage(hosts, [rendered.raw], true) + return { + html: html!, + raw: rendered.raw, + case: startCase, + code: rendered.code, + module: rendered.module, + } +} + +export interface ClientRender { + case: StartCase + /** The server render the page hydrated. */ + server: ServerRender + /** The normalized markup of the container after hydration and the script. */ + html: string + /** The container's `innerHTML` after hydration and the script. */ + raw: string + /** + * `html` with the hydration ids of nested boundaries blanked: a boundary + * inside split children renders with them when their code loads, so its + * id is the client's own (`serverOuter`: the server's markup the same way). + */ + outer: string + serverOuter: string + /** What React reported through `onRecoverableError` (mismatches). */ + recoverableErrors: Array<string> + /** + * Uncaught errors of the page during the run, and what React logged about + * hydration (`console.error` messages about hydration or a mismatch). + * React's other development warnings (a missing `key`, an unknown DOM + * property) are about the fixture's own code, not its compilation: they + * are in `warnings`. + */ + errors: Array<string> + /** Every other `console.error` message of the page during the run. */ + warnings: Array<string> + /** + * Case files (`./name`, with and without extension) the import of the + * module requested, before hydration. + */ + loaded: Array<string> + /** + * What the page requested once hydration started: case files as + * `./name` (with and without extension), other modules by path. + */ + lazy: Array<string> + /** `lazy` as the page requested it (paths with their query). */ + lazyUrls: Array<string> + /** + * What the import of the module requested, before hydration, as the page + * requested it (paths with their query; modules of any kind). + */ + importedUrls: Array<string> + /** + * The case's own code among `lazyUrls`: the modules the page requested + * once hydration started whose served code's source map names a file of + * the case directory (or, served with an empty map, that the case + * module's own graph imports: through the case's own modules only), + * wherever the compiler put them and under any id. Code of a package, of + * the harness or of Vite, and a module the dev server fails to serve, is + * not the case's split code. + */ + chunks: Array<string> + /** What the script returned. */ + result: unknown +} + +/** A `console.error` message of React about hydration. */ +const hydrationMessage = + /hydration failed|tree hydrated|didn't match|did not match|while hydrating|hydration mismatch/i + +/** Page code: `settled(quiet)`, `openGates()`. */ +const settleSource = `const settled = async (quiet = 30, timeout = 10000) => { + const start = performance.now() + let last = '' + let since = performance.now() + while (performance.now() - start < timeout) { + await new Promise((resolve) => setTimeout(resolve, 10)) + // A module request still in flight (the page's own count, from the + // browser's network events) keeps the page busy. + const inFlight = window.__harnessInFlight ? await window.__harnessInFlight() : 0 + const state = performance.getEntriesByType('resource').length + ':' + inFlight + ':' + root.innerHTML + if (state !== last || inFlight > 0) { + last = state + since = performance.now() + } else if (performance.now() - since >= quiet) { + return + } + } + throw new Error('the page did not settle: ' + root.innerHTML) +} +const nonActivating = (events) => events.filter((name) => !/click|pointerdown|mousedown|mouseup|pointerup|keydown|keyup|contextmenu/.test(name)) +// Boundaries still waiting for their gate (the runtime drops the marker once +// one hydrated); a never() gate never opens. +const pending = (which = () => true) => [...root.querySelectorAll('[data-ts-hydrate-when]')].filter((marker) => marker.getAttribute('data-ts-hydrate-when') !== 'never').filter(which) +// Gates that open on their own or on an event this opens: wait for them +// (an idle gate waits for the page to be idle, which a busy machine +// delays); a media or condition gate may never open. +const awaited = (which) => pending(which).filter((marker) => ['idle', 'interaction', 'dynamic', 'visible', 'load'].includes(marker.getAttribute('data-ts-hydrate-when'))) +const openGates = async (timeout = 8000, stuck = 1500, which = () => true) => { + const deadline = performance.now() + timeout + let unchanged = 0 + let changedAt = performance.now() + // An awaited gate gets time to open (an idle callback waits for an idle + // page); one that stays shut with nothing changing for \`stuck\` ms + // (its split code failed) does not hold the run up to the deadline. + for (let round = 0; pending(which).length > 0 && (awaited(which).length > 0 ? performance.now() < deadline && performance.now() - changedAt < stuck : unchanged < 4); round++) { + const before = root.innerHTML + ':' + performance.getEntriesByType('resource').length + for (const marker of pending(which)) { + marker.scrollIntoView() + const when = marker.getAttribute('data-ts-hydrate-when') + if (when === 'interaction' || when === 'dynamic') { + const listed = marker.getAttribute('data-ts-hydrate-interaction-events') + const events = listed === null ? ['pointerenter', 'focusin', 'pointerdown', 'click'] : listed.split(/\\s+/).filter(Boolean) + const quiet = nonActivating(events) + // Not bubbling: the gate opens, and no handler replays the event. + for (const name of when === 'dynamic' ? ['click'] : quiet.length > 0 ? quiet : events) { + marker.dispatchEvent(new Event(name, { bubbles: false })) + } + } + } + await settled() + unchanged = root.innerHTML + ':' + performance.getEntriesByType('resource').length === before ? unchanged + 1 : 0 + if (unchanged === 0) { + changedAt = performance.now() + } + } +}` + +/** + * Where a module to render lives: a case of the Start host (`StartCase`), or + * a directory of watched app files (`editableFiles`, for dev edits). + */ +export interface RenderTarget { + /** Directory relative to the app root. */ + dir: string + /** The SSR environment's namespace of a file of the directory. */ + ssr: (file: string) => Promise<Record<string, any>> + /** What the SSR environment serves for a file of the directory. */ + served: (file: string, environment: 'client' | 'ssr') => Promise<string> + /** The setup module of the directory (default `setup.ts`; `false`: none). */ + setup?: string | false +} + +function caseTarget(startCase: StartCase): RenderTarget { + return { + dir: startCase.dir, + ssr: (file) => startCase.ssr(file), + served: (file, environment) => startCase.served(file, environment), + } +} + +/** + * A directory of watched app files of the Start host (`src/edits/e<n>`), + * written and edited through the dev server's watcher (`StartHost.edit`): + * for dev-edit scenarios, where the dev server compiles a module again. + */ +export async function editableFiles( + hosts: HydrateHost, + code: string, + options: RenderOptions = {}, +) { + const dir = `src/edits/e${++edits}` + const write = (files: Record<string, string>) => + hosts.start.edit( + Object.fromEntries( + Object.entries(files).map(([file, source]) => [ + `${dir}/${file}`, + source, + ]), + ), + ) + await write(caseFiles(code, options)) + const url = (file: string) => `/${dir}/${file}` + const target: RenderTarget = { + dir, + ssr: (file) => hosts.start.host.importServer(url(file), 'ssr'), + served: (file, environment) => + hosts.start.host.transform(url(file), environment), + } + return { + target, + /** Writes the module again (through the watcher). */ + edit: (source: string) => write({ [options.file ?? 'module.tsx']: source }), + } +} +let edits = 0 + +/** + * Compiles `code` with the Start plugin, renders it on the server and + * hydrates the HTML in the host's page (see the module comment), opening + * the gates `options.gates` names (default every gate), then runs `script`. With `target`, the + * module is not written: it is the one of that case or directory. + */ +export async function renderClient( + hosts: HydrateHost, + code: string, + options: ClientOptions & { + target?: RenderTarget | StartCase + /** Reload the page first: a fresh document, no module instance kept. */ + freshPage?: boolean + } = {}, +): Promise<ClientRender> { + const given = options.target + // The case of the module (a new one, or the given case); a directory of + // other files renders through the runner case's page. + const startCase: StartCase | undefined = + given === undefined + ? await hosts.start.case(caseFiles(code, options)) + : 'client' in given + ? given + : undefined + const target: RenderTarget = startCase + ? caseTarget(startCase) + : (given as RenderTarget) + const rendered = await serverRender(hosts, target, options) + const file = options.file ?? 'module.tsx' + + const caseUrl = (name: string) => JSON.stringify(`/${target.dir}/${name}`) + const run = await runPage<{ + raw: string + serverHtml: string + html: string + recoverableErrors: Array<string> + consoleErrors: Array<string> + uncaught: Array<string> + loaded: Array<string> + importedUrls: Array<string> + lazy: Array<string> + lazyUrls: Array<string> + serverOuter: string + outer: string + result: unknown + }>( + hosts, + `performance.setResourceTimingBufferSize(100000) +const caseDir = ${JSON.stringify(`/${target.dir}/`)} +const requested = (from) => performance.getEntriesByType('resource').slice(from).map((entry) => { + const url = new URL(entry.name) + return url.origin === location.origin ? decodeURIComponent(url.pathname) + url.search : entry.name +}) +const caseNames = (urls) => [...new Set(urls.flatMap((url) => { + const pathname = url.split('?')[0] + if (!pathname.startsWith(caseDir)) { + return [pathname] + } + const relative = pathname.slice(caseDir.length) + return ['./' + relative.replace(/\\.[cm]?[jt]sx?$/, ''), './' + relative] +}))] +const glue = await import('/src/harness/render.client.tsx') +const setup = ${target.setup === false ? '{}' : `await import(${caseUrl(target.setup ?? 'setup.ts')})`} +const beforeImport = performance.getEntriesByType('resource').length +const m = await import(${caseUrl(file)}) +const importedUrls = requested(beforeImport) +const loaded = caseNames(importedUrls).filter((name) => name.startsWith('./')) +await (async () => { +${options.beforeRender ?? ''} +})() +const root = document.createElement('div') +document.body.append(root) +${normalizeSource} +${settleSource} +const serverHtml = ${JSON.stringify(rendered.raw)} +root.innerHTML = serverHtml +const recoverableErrors = [] +const consoleErrors = [] +const consoleError = console.error +console.error = (...args) => { + consoleErrors.push(args.map((arg) => (arg instanceof Error ? arg.stack ?? arg.message : String(arg))).join(' ')) + consoleError(...args) +} +const uncaught = [] +const onError = (event) => uncaught.push(String(event.error && (event.error.stack || event.error.message) || event.message)) +const onRejection = (event) => uncaught.push(String(event.reason && (event.reason.stack || event.reason.message) || event.reason)) +window.addEventListener('error', onError) +window.addEventListener('unhandledrejection', onRejection) +let reactRoot +try { + const h = glue.h + const props = ${JSON.stringify(options.props ?? {})} + const Root = () => (${renderExpression(options)}) + const beforeHydration = performance.getEntriesByType('resource').length + reactRoot = glue.hydrateRoot(root, h(Root), { + onRecoverableError: (error) => { + recoverableErrors.push(error instanceof Error ? error.message : String(error)) + }, + }) + await settled() + ${ + options.gates === 'none' + ? '' + : options.gates === undefined || options.gates === 'all' + ? 'await openGates()' + : `await openGates(undefined, undefined, ${options.gates})` + } + const result = await (async () => { +${options.script ?? 'return null'} + })() + ${options.script ? 'await settled()' : ''} + const lazyUrls = requested(beforeHydration) + return { + raw: root.innerHTML, + serverHtml: normalize(serverHtml), + html: normalize(root.innerHTML), + serverOuter: normalize(serverHtml, { ids: 'outer' }), + outer: normalize(root.innerHTML, { ids: 'outer' }), + recoverableErrors, + consoleErrors, + uncaught, + loaded, + importedUrls, + lazy: caseNames(lazyUrls), + lazyUrls, + result: result === undefined ? null : result, + } +} finally { + console.error = consoleError + window.removeEventListener('error', onError) + window.removeEventListener('unhandledrejection', onRejection) + reactRoot?.unmount() + root.remove() + for (const name of setup.cleanup ?? []) { + delete globalThis[name] + } +}`, + startCase, + { fresh: options.freshPage }, + ) + const chunks = await caseCode(hosts, target.dir, file, run.result.lazyUrls) + const caseForResult = startCase ?? (target as unknown as StartCase) + return { + case: caseForResult, + server: { + html: run.result.serverHtml, + raw: rendered.raw, + case: caseForResult, + code: rendered.code, + }, + html: run.result.html, + outer: run.result.outer, + serverOuter: run.result.serverOuter, + raw: run.result.raw, + recoverableErrors: run.result.recoverableErrors, + errors: [ + ...run.result.uncaught, + ...run.result.consoleErrors.filter((message) => + hydrationMessage.test(message), + ), + ], + warnings: run.result.consoleErrors.filter( + (message) => !hydrationMessage.test(message), + ), + loaded: run.result.loaded, + importedUrls: run.result.importedUrls, + lazy: run.result.lazy, + lazyUrls: run.result.lazyUrls, + chunks, + result: run.result.result, + } +} + +/** + * The URLs among `urls` (what the page requested) whose served code is the + * case's own, wherever the compiler put it and under any id: its source map + * names a file of the case directory `dir` (relative to the app root), or, + * for code whose map names no file (a split text-only child is served with + * an empty map), the case module `file`'s own graph imports it: a module + * of the case directory or one whose map names a file of it imports it + * (an import edge, static or dynamic), reached from the case module through + * such modules only (never through a module of the harness + * or another directory, a package or a virtual module of its own). A + * module the dev server fails to serve is not the case's code, nor is a + * package, the runtime or Vite's client. Observation only: the dev + * server's served maps and module graph. + */ +export async function caseCode( + hosts: HydrateHost, + dir: string, + file: string, + urls: Array<string>, +): Promise<Array<string>> { + const caseDir = `${path.join(hosts.start.root, dir)}${path.sep}` + const servedUrls = new Map< + string, + { mapped: boolean; empty: boolean } | undefined + >() + for (const url of urls) { + if (!url.startsWith('/')) { + continue + } + const served = await servedWithMap(hosts, url).catch(() => undefined) + const sources = (served?.map?.sources ?? []).filter( + (source): source is string => source !== null, + ) + servedUrls.set( + url, + served && { + mapped: sources.some((source) => source.startsWith(caseDir)), + empty: sources.length === 0, + }, + ) + } + const mapped = new Set( + [...servedUrls] + .filter(([, served]) => served?.mapped) + .map(([url]) => comparableUrl(url)), + ) + const reached = caseGraph(hosts, `/${dir}/${file}`, caseDir, mapped) + return [...servedUrls] + .filter( + ([url, served]) => + served !== undefined && + (served.mapped || (served.empty && reached.has(comparableUrl(url)))), + ) + .map(([url]) => url) +} + +/** A module URL without Vite's `t` (HMR timestamp) parameter. */ +function comparableUrl(url: string) { + const parsed = new URL(url, 'http://page.invalid') + parsed.searchParams.delete('t') + const query = parsed.searchParams.toString() + return decodeURIComponent(parsed.pathname) + (query ? `?${query}` : '') +} + +/** + * The URLs of the modules the case module at `url` imports through the + * case's own modules (static and dynamic imports, in the client module + * graph): every module a case module imports, where a case module is the + * module at `url`, a module of the case directory `caseDir` (any query) or + * one of `mapped` (served code whose map names a file of it); of them, + * the modules of the app and the virtual ones (a package is never case + * code). The walk goes on only from case modules, so a module of the + * harness or of another directory, a package or a virtual module adds + * nothing it imports. + */ +function caseGraph( + hosts: HydrateHost, + url: string, + caseDir: string, + mapped: Set<string>, +): Set<string> { + const graph = hosts.start.host.dev.vite.environments.client.moduleGraph + const root = `${hosts.start.root}${path.sep}` + const start = [ + ...(graph.getModulesByFile(path.join(hosts.start.root, url)) ?? []), + ].filter((node) => node.url === url) + const isCaseModule = (node: (typeof start)[number]) => + (node.file !== null && node.file.startsWith(caseDir)) || + mapped.has(comparableUrl(node.url)) + const reached = new Set<string>() + const seen = new Set<unknown>(start) + const queue = start.flatMap((node) => [...node.importedModules]) + while (queue.length > 0) { + const node = queue.shift()! + if (seen.has(node)) { + continue + } + seen.add(node) + // Modules of the app (not packages: workspace packages resolve outside + // the app root, `node_modules` holds Vite's pre-bundled dependencies) + // or virtual ones + const appFile = + node.file !== null && + node.file.startsWith(root) && + !/[\\/]node_modules[\\/]/.test(node.file) + if (!appFile && !(node.id?.startsWith('\0') ?? false)) { + continue + } + reached.add(comparableUrl(node.url)) + if (isCaseModule(node)) { + queue.push(...node.importedModules) + } + } + return reached +} + +/** + * The code and source map the client environment serves for a URL the page + * requested (Vite's `transformRequest`, the dev server's own pipeline). + */ +export async function servedWithMap(hosts: HydrateHost, url: string) { + const result = + await hosts.start.host.dev.vite.environments.client.transformRequest(url) + if (!result) { + throw new Error(`the client environment serves nothing for ${url}`) + } + const map = result.map as { sources?: Array<string | null> } | null + if (map?.sources) { + // Sources are relative to the module's own location (the standard + // reading of a source map); absolute paths are left as they are + const file = hosts.start.host.file(url.split('?')[0]!.slice(1)) + map.sources = map.sources.map((source) => + source === null ? source : path.resolve(path.dirname(file), source), + ) + } + return { code: result.code, map } +} + +/** + * What the client environment serves for each module the page requested + * once hydration started (the split code, wherever it lives), by URL. + */ +export async function lazyCode(hosts: HydrateHost, client: ClientRender) { + const code: Record<string, string> = {} + for (const url of client.lazyUrls) { + if (url.startsWith('/') && !url.startsWith('/node_modules/')) { + code[url] = await hosts.start.host.transform(url, 'client') + } + } + return code +} + +/** The page hydrated without a mismatch or an error. */ +export function expectHydratedCleanly(client: ClientRender) { + expect(client.recoverableErrors, 'recoverable hydration errors').toEqual([]) + expect(client.errors, 'page errors while hydrating').toEqual([]) +} + +/** + * The page loaded the case's own code on demand once hydration started + * (`ClientRender.chunks`): not just any module (a package, Vite's client). + */ +export function expectRenderedThroughChunks( + client: Pick<ClientRender, 'chunks'>, +) { + expect( + client.chunks, + 'the case code the page requested once it hydrated', + ).not.toEqual([]) +} + +/** + * The client hydrates the server's HTML without an error or mismatch and, + * once every gate opened, shows the markup the server rendered (the + * hydration ids of the boundaries no other boundary contains included: + * `ClientRender.outer`), and loaded code on demand (unless `split: false`: then + * nothing is required of what loads). Returns the renders. + */ +export async function expectClientRendersLikeServer( + hosts: HydrateHost, + code: string, + options: ClientOptions & { split?: boolean } = {}, +) { + const client = await renderClient(hosts, code, options) + expectHydratedCleanly(client) + expect(client.outer, 'the hydrated page').toBe(client.serverOuter) + if (options.split !== false) { + expectRenderedThroughChunks(client) + } + return { server: client.server, client } +} + +/** + * `expectClientRendersLikeServer`, and the server's markup is the markup + * the uncompiled source renders (hydration ids blanked). + */ +export async function expectRendersLikeSource( + hosts: HydrateHost, + code: string, + options: ClientOptions & { split?: boolean } = {}, +) { + const source = await renderSource(hosts, code, options) + const rendered = await expectClientRendersLikeServer(hosts, code, options) + expect(withoutHydrationIds(rendered.server.html), 'the server markup').toBe( + source.html, + ) + return { source, ...rendered } +} + +/** What mounting a Solid case in the page gave (`SolidHost.mount`). */ +export interface SolidMount { + case: StartCase + /** The normalized markup of the container once every gate opened. */ + html: string + /** `console.error` output and uncaught errors of the page during the run. */ + errors: Array<string> + /** What the page requested once the mount started (paths with query). */ + lazy: Array<string> + /** `StartCase.loads()` of the module (client graph, static and dynamic). */ + loads: Array<string> + /** `StartCase.serverLoads()` of the module. */ + serverLoads: Array<string> +} + +/** A Solid Start host (`vite-plugin-solid`) whose page mounts a module. */ +export interface SolidHost { + start: StartHost + /** + * Writes `code` (and `files`) as a case of the Solid app, checks that the + * client and SSR environments serve it and the SSR environment evaluates + * it, then mounts `<Page />` in the page (Solid's `render`: the boundary + * appears after startup), opens every gate and waits until it is quiet. + */ + mount: (code: string, files?: Record<string, string>) => Promise<SolidMount> +} + +/** + * One Solid Start host per test file, created on first use and closed after + * the file's tests. + */ +export function useSolidHost(): () => Promise<SolidHost> { + let started: Promise<StartHost> | undefined + afterAll(async () => { + await (await started)?.close() + }) + return async () => { + started ??= createStartHost({ + framework: 'solid', + start: startOptions, + files: { + 'tsconfig.json': appTsconfig({ + jsx: 'preserve', + jsxImportSource: 'solid-js', + }), + 'src/harness/solid.client.tsx': `export { createComponent, render } from 'solid-js/web' +`, + }, + }) + const start = await started + return { + start, + mount: async (code, files = {}) => { + const startCase = await start.case({ + 'setup.ts': 'export {}\n', + ...Object.fromEntries( + Object.entries(files).map(([name, source]) => [ + caseFileName(name), + source, + ]), + ), + 'module.tsx': code, + }) + await startCase.served('module.tsx', 'client') + await startCase.served('module.tsx', 'ssr') + await startCase.ssr() + const run = await startCase.client<{ + html: string + lazy: Array<string> + }>( + `performance.setResourceTimingBufferSize(100000) +const glue = await import('/src/harness/solid.client.tsx') +const m = await load('module.tsx') +const root = document.createElement('div') +document.body.append(root) +${normalizeSource} +${settleSource} +const before = performance.getEntriesByType('resource').length +const dispose = glue.render(() => glue.createComponent(m.Page, {}), root) +try { + await settled() + await openGates() + return { + html: normalize(root.innerHTML), + lazy: performance.getEntriesByType('resource').slice(before).map((entry) => { + const url = new URL(entry.name) + return url.origin === location.origin ? decodeURIComponent(url.pathname) + url.search : entry.name + }), + } +} finally { + dispose() + root.remove() +}`, + { file: 'setup.ts' }, + ) + return { + case: startCase, + html: run.result.html, + errors: run.errors, + lazy: run.result.lazy, + loads: await startCase.loads(), + serverLoads: await startCase.serverLoads(), + } + }, + } + } +} diff --git a/packages/start-plugin-core/tests/request-probe.ts b/packages/start-plugin-core/tests/request-probe.ts new file mode 100644 index 0000000000..dff003f32b --- /dev/null +++ b/packages/start-plugin-core/tests/request-probe.ts @@ -0,0 +1,135 @@ +/** + * The probe route of the harness apps: how a test runs server code inside a + * real request of a Start app, so that Start's request context (the + * request, the start options, the router, the global middleware's context) + * is the one Start's own server entry opens, never one the harness builds. + * + * Every harness app that runs server code has a real router over the + * generated route tree (`routerFile`) and a server route, the probe + * (`probeRouteFile`, at `probeRoutePath`). A test registers a callback + * under a token on a process-wide global, then sends a request for the + * probe to the app's server entry (Start's `fetch`, the default export of + * the server bundle a host imports, or the dev server's server entry): the + * route's `GET` handler runs the callback while Start serves the request, + * and the test gets what the callback returned or threw + * (`inProbeRequest`). + * + * Used by the build harness (`build-harness.ts`, in the child process that + * runs the server bundle), the dev-server harness (`dev-server.ts`) and the + * public Start host (`start-host.ts`). + */ + +/** The path of the probe route of a harness app. */ +export const probeRoutePath = '/harness-probe' + +/** The probe route's file (the router generator's routes directory). */ +export const probeRouteFile = 'src/routes/harness-probe.ts' + +/** + * The global (`Symbol.for`) the probe route reads the callbacks from: a + * `Map` from token to callback, shared by every copy of the harness in a + * process. + */ +const probesKey = 'tanstack.start-harness.probes' + +/** + * Source of the probe route for an app of the router package `router` + * (e.g. `@tanstack/react-router`). The route's `GET` handler runs the + * callback the request's `run` parameter names, with `context` (an + * expression of the route module, e.g. what a production host gives its + * callbacks), after `prelude` (statements at the top of the module). + */ +export function probeRoute( + router: string, + options: { prelude?: string; context?: string } = {}, +): string { + return `import { createFileRoute } from '${router}' +${options.prelude ?? ''}type Probe = (context?: unknown) => Promise<void> +export const Route = createFileRoute('${probeRoutePath}')({ + server: { + handlers: { + GET: async ({ request }) => { + const run = new URL(request.url).searchParams.get('run') ?? '' + const probes = (globalThis as unknown as Record<symbol, Map<string, Probe> | undefined>)[ + Symbol.for(${JSON.stringify(probesKey)}) + ] + const probe = probes?.get(run) + if (!probe) { + return new Response('no probe ' + run, { status: 404 }) + } + await probe(${options.context ?? ''}) + return new Response('ok') + }, + }, + }, +}) +` +} + +/** + * `src/router.ts` of a harness app of the router package `router`: the real + * router over the route tree the router generator writes. + */ +export const routerFile = (router: string) => + `import { createRouter } from '${router}' +import { routeTree } from './routeTree.gen' +export const getRouter = () => createRouter({ routeTree }) +` + +/** `src/routes/__root.tsx` of a harness app: a root route of its own. */ +export const rootRouteFile = (router: string) => + `import { createRootRoute } from '${router}' +export const Route = createRootRoute() +` + +/** + * The app files a harness app needs to run server code in a request: the + * router, a root route and the probe route (an app's own files of the same + * paths win). + */ +export const requestFiles = (router: string): Record<string, string> => ({ + 'src/router.ts': routerFile(router), + 'src/routes/__root.tsx': rootRouteFile(router), + [probeRouteFile]: probeRoute(router), +}) + +/** + * Runs `run` inside a request for the probe route that `send` sends to the + * app's server entry (`send(path)`, `path` relative to the app's origin), + * and gives what `run` returned, or throws what it threw. Fails when the + * request did not run it (the app has no probe route, or the request failed + * before the route), with the response. Self-contained: the build harness + * runs its source in the child process of a server bundle. + */ +export async function inProbeRequest<T>( + send: (path: string) => Promise<Response>, + run: (context?: any) => T | Promise<T>, +): Promise<T> { + const probes = ((globalThis as Record<symbol, unknown>)[ + Symbol.for('tanstack.start-harness.probes') + ] ??= new Map()) as Map<string, (context?: unknown) => Promise<void>> + const token = Math.random().toString(36).slice(2) + let outcome: { value: T } | { error: unknown } | undefined + probes.set(token, async (context) => { + try { + outcome = { value: await run(context) } + } catch (error) { + outcome = { error } + } + }) + try { + const response = await send(`/harness-probe?run=${token}`) + const body = await response.text() + if (!outcome) { + throw new Error( + `the probe request did not run (${response.status}): ${body}`, + ) + } + } finally { + probes.delete(token) + } + if ('error' in outcome) { + throw outcome.error + } + return outcome.value +} diff --git a/packages/start-plugin-core/tests/rsbuild-dev-server.ts b/packages/start-plugin-core/tests/rsbuild-dev-server.ts new file mode 100644 index 0000000000..0026445360 --- /dev/null +++ b/packages/start-plugin-core/tests/rsbuild-dev-server.ts @@ -0,0 +1,394 @@ +/** + * Rsbuild dev-server harness of the Start compiler: an Rsbuild dev server + * with the plugins a Start app's `rsbuild.config.ts` lists, `tanstackStart()` + * of the built framework package (`@tanstack/react-start/plugin/rsbuild`, or + * `@tanstack/solid-start`'s; see `start-plugins.ts`: client and SSR + * environments, SSR as the server fn provider) and a React app's + * `@rsbuild/plugin-react` (unless the test gives it), on a temporary app, + * through the shared Rsbuild dev-server harness + * (`@tanstack/compiler-test-utils/rsbuild-dev-server`). Rspack loads Start's + * loaders from the package, as in an installed app. + * `@tanstack/react-start` is the real package (`startRuntimeLinks` of the + * build harness). `runInClient()` and `runRsbuildClient()` run the emitted + * client code in a real browser page of the dev server (started with + * `clientPage`). The temporary apps stand in for apps in this directory + * (`@tanstack/compiler-test-utils/app-directory`). + */ +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { pluginNames } from '@tanstack/compiler-test-utils/build-harness' +import { createRsbuildDevServer } from '@tanstack/compiler-test-utils/rsbuild-dev-server' +import { pluginReact } from '@rsbuild/plugin-react' +import { onTestFinished } from 'vitest' +import { startRuntimeLinks } from './build-harness' +import { startRsbuildPluginFactory, withHarnessEntries } from './start-plugins' +import type { TanStackStartInputConfig } from '../src' +import type { TanStackStartRsbuildInputConfig } from '../src/rsbuild' +import type { RsbuildPlugin } from '@rsbuild/core' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { + RsbuildDevServer, + RsbuildDevServerOptions, +} from '@tanstack/compiler-test-utils/rsbuild-dev-server' + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +/** + * Starts an Rsbuild dev server with Start's whole Rsbuild plugin + * (`startRsbuildStartDevServer`) on an app of `files` (its entry + * `src/entry.ts`), with Start's `importProtection` option when given: the + * import-protection tests' shorthand of `start`. + */ +export function startRsbuildDevServer( + options: Omit<RsbuildDevServerOptions, 'dir' | 'plugins'> & { + importProtection?: TanStackStartInputConfig['importProtection'] + }, +): Promise<RsbuildDevServer> { + const { importProtection, ...devServerOptions } = options + return startRsbuildStartDevServer({ + ...devServerOptions, + start: { ...(importProtection && { importProtection }) }, + }) +} + +/** + * What a page loads to start the app: the initial JavaScript files of the + * `client` environment's entry, by URL path on the dev server, as its last + * compile emitted them, and whether they are ES modules. + */ +interface ClientEntry { + files: Array<string> + module: boolean +} + +const clientEntries = new WeakMap<object, ClientEntry>() + +function withClientEntry(server: RsbuildDevServer, entry: ClientEntry) { + clientEntries.set(server, entry) + return server +} + +/** + * The initial JavaScript files of the `client` environment's entry as its + * last compile emitted them (Rspack's stats entrypoints, the configured + * input), relative to the client output directory: the files a page loads + * first. A dev server of this harness only. + */ +export function clientEntryFiles( + server: Pick<RsbuildDevServer, 'url'>, +): Array<string> { + const entry = clientEntries.get(server) + if (!entry) { + throw new Error('not a dev server of this harness') + } + return entry.files.map((file) => file.replace(/^\/+/, '')) +} + +/** + * The errors a dev server reported on every channel (the compilations, the + * console, the process streams; SPEC §5.7) since `since` (a length of its + * `diagnostics`), by text: what "nothing failed" reads. + */ +export function reportedErrors( + server: Pick<RsbuildDevServer, 'diagnostics'>, + since = 0, +): Array<string> { + return server.diagnostics + .slice(since) + .filter(({ severity }) => severity === 'error') + .map(({ text }) => text) +} + +/** + * Records the `ClientEntry` of each compile of the `client` environment, + * from Rspack's stats (its entrypoints and public path). + */ +function recordClientEntry(entry: ClientEntry): RsbuildPlugin { + return { + name: 'test:client-entry', + setup(api) { + api.onAfterEnvironmentCompile(({ stats, environment }) => { + if (environment.name !== 'client' || !stats) { + return + } + const json = stats.toJson({ + all: false, + entrypoints: true, + publicPath: true, + }) + const publicPath = + json.publicPath && json.publicPath !== 'auto' ? json.publicPath : '/' + entry.files = Object.values(json.entrypoints ?? {}) + .flatMap((entrypoint) => entrypoint.assets ?? []) + .map((asset) => asset.name) + .filter((name) => /\.[cm]?js$/.test(name)) + .map((name) => `${publicPath.replace(/\/?$/, '/')}${name}`) + entry.module = environment.config.output.module === true + }) + }, + } +} + +/** + * Starts an Rsbuild dev server with Start's whole Rsbuild plugin + * (`tanstackStart()` of `@tanstack/react-start/plugin/rsbuild`) and + * `pluginReact()` (unless `config.plugins` has it): client and SSR + * environments, SSR as the server fn provider, and the generated server fn + * resolver. Both entries (given to Start as `client.entry` and + * `server.entry` unless the app has its own) import `src/entry.ts`; the + * server entry is Start's default one (`@tanstack/react-start/server-entry`, + * the app's HTTP handler, which reaches the server fns through Start's own + * resolver). `src/router.ts` and `src/routes/__root.tsx` are stubs unless + * the app has them. With `framework: 'solid'`, Start's plugin is + * `@tanstack/solid-start`'s and the built `@tanstack/solid-start` and + * `@tanstack/solid-router` are linked (Solid's JSX plugins come from + * `config`). + */ +export async function startRsbuildStartDevServer( + options: Omit<RsbuildDevServerOptions, 'dir' | 'plugins'> & { + /** The app's Start options (`tanStackStart(options)`). */ + start?: TanStackStartRsbuildInputConfig + /** The Start framework package of the app (default `react`). */ + framework?: 'react' | 'solid' + }, +): Promise<RsbuildDevServer> { + const { files, start, framework = 'react', ...devServerOptions } = options + const entry: ClientEntry = { files: [], module: false } + const tanstackStart = await startRsbuildPluginFactory(framework) + return createRsbuildDevServer({ + dir: harnessDir, + prefix: '.start-rsbuild-start-dev-server-', + registerCleanup: onTestFinished, + ...devServerOptions, + symlinks: { + ...startRuntimeLinks(framework), + ...devServerOptions.symlinks, + }, + files: { + 'harness/client-entry.ts': `import '../src/entry'\n`, + 'harness/server-entry.ts': `import '../src/entry' +export { default } from '@tanstack/${framework}-start/server-entry' +`, + 'src/router.ts': `export const getRouter = () => undefined\n`, + 'src/routes/__root.tsx': `import { createRootRoute } from '@tanstack/react-router' +export const Route = createRootRoute() +`, + ...files, + }, + plugins: ({ root }) => { + const entries = { + client: path.join(root, 'harness/client-entry.ts'), + server: path.join(root, 'harness/server-entry.ts'), + } + return [ + // A React app's own Rsbuild plugin, as in every React Start app, + // unless the test gives it + ...(framework === 'react' && + !pluginNames(devServerOptions.config?.plugins).includes('rsbuild:react') + ? [pluginReact()] + : []), + tanstackStart(withHarnessEntries(root, start ?? {}, entries)), + recordClientEntry(entry), + ] + }, + }).then((server) => withClientEntry(server, entry)) +} + +/** + * Options of a dev server whose client code a test runs (`runInClient`, + * `runRsbuildClient`): the dev server serves the app to real browser pages + * over HTTP (`browser`), without HMR, as the other tests of its output + * expect (a test of hot updates sets `hmr: true` after these). + */ +export const clientPage = { browser: true, hmr: false } as const + +/** + * Runs in the page before its own code: records what the page's code logs + * through `console` (by method; an argument with a `message`, e.g. an + * error, by its message) and the errors it does not catch. + */ +const recorderScript = `(() => { + const text = (arg) => + typeof arg === 'object' && arg !== null && 'message' in arg + ? String(arg.message) + : String(arg) + const calls = [] + const uncaught = [] + for (const level of ['log', 'info', 'warn', 'error', 'debug']) { + const original = console[level].bind(console) + console[level] = (...args) => { + calls.push({ level, text: args.map(text).join(' ') }) + original(...args) + } + } + addEventListener('error', (event) => { + uncaught.push(text(event.error ?? event.message)) + }) + addEventListener('unhandledrejection', (event) => { + uncaught.push(text(event.reason)) + }) + Object.defineProperty(globalThis, '__clientRun', { + value: { calls, uncaught }, + }) +})()` + +export interface ClientRun { + calls: Array<{ level: string; text: string }> + uncaught: Array<string> +} + +/** A page `withRecordedPage` opened, recording from its first statement on. */ +export interface RecordedPage { + page: BrowserPage['page'] + /** What the page's code logged and did not catch so far. */ + record: () => Promise<ClientRun> + /** + * Waits a turn of the page's event loop (what its load scheduled ran), + * then rejects with the errors the page's code did not catch so far. + */ + settled: () => Promise<void> +} + +/** Throws the errors the page's code did not catch so far, if any. */ +export function throwUncaught({ uncaught }: Pick<ClientRun, 'uncaught'>) { + if (uncaught.length > 0) { + throw new Error( + `the client code threw while the page loaded:\n${uncaught.join('\n')}`, + ) + } +} + +/** + * The one client runner of the Start dev-server tests (Vite and Rsbuild): + * opens `url` in a real browser (Chromium) page that records what its code + * logs through `console` and the errors it does not catch, from its first + * statement on (`recorderScript`), runs `run` on it and closes it. `html`: + * the document of `url` instead of what the server answers. + */ +export async function withRecordedPage<T>( + url: string, + options: { html?: string }, + run: (page: RecordedPage) => Promise<T>, +): Promise<T> { + const browser = await openPage(url, { + initScript: recorderScript, + html: options.html, + }) + const record = () => + browser.page.evaluate<ClientRun>('globalThis.__clientRun') + try { + return await run({ + page: browser.page, + record, + settled: async () => { + throwUncaught( + await browser.page.evaluate<ClientRun>( + `new Promise((resolve) => setTimeout(() => resolve(globalThis.__clientRun)))`, + ), + ) + }, + }) + } finally { + await browser.close() + } +} + +/** + * Opens a page of a dev server started with `clientPage` (by this harness) + * (`withRecordedPage`), runs `run` on it once it loaded, and closes it. The + * page's document loads the initial files of the `client` environment's + * entry from the dev server, in order, as the HTML of an app does (Start's + * dev server renders the app's HTML with its server entry, which the + * harness's apps do not have). Rejects with the errors the page's code did + * not catch while the page loaded, and when a file did not load. + * + * Not for HMR checks: the document is fulfilled by the + * test, not served by the dev server, so the page's HMR client never + * connects. Every caller opens a fresh page per run and reads the code a + * fresh load gives (e.g. `v2-edits.test.ts` after an edit); a check of a + * hot update needs a document the dev server serves (ctu + * `rsbuild-plugin-host` `runClient`, or the `browser` mode of ctu's Rsbuild + * dev server, which serves `index.html`). + */ +async function withClientPage<T>( + server: Pick<RsbuildDevServer, 'url'>, + run: (page: RecordedPage) => Promise<T>, +): Promise<T> { + const entry = clientEntries.get(server) + if (server.url === undefined || !entry) { + throw new Error( + 'the client code runs in a browser page: start the dev server with `clientPage`, through this harness', + ) + } + if (entry.files.length === 0) { + throw new Error('the client environment emitted no entry file') + } + const scripts = entry.files + .map( + (file) => + `<script src="${file}"${entry.module ? ' type="module"' : ''} onerror="__clientRun.uncaught.push('could not load ' + this.src)"></script>`, + ) + .join('\n') + return withRecordedPage( + new URL('/__client-run', server.url).href, + { + html: `<!doctype html> +<html><head><meta charset="utf-8"></head> +<body><div id="root"></div> +${scripts} +</body></html>`, + }, + async (page) => { + await page.settled() + return run(page) + }, + ) +} + +/** + * Runs `script` (the body of an async function) in the page of the dev + * server (`withClientPage`; the server started with `clientPage`), once the + * page loaded the client code. Returns what the script returns (`result`: + * plain data the page hands over), or the message of what it throws + * (`error`). (A script must not await an import-protection mock: the mock + * is a thenable that resolves to itself, which never settles.) + */ +export function runInClient( + server: Pick<RsbuildDevServer, 'url'>, + script: string, +): Promise<{ result: unknown } | { error: string }> { + return withClientPage(server, ({ page }) => + page.evaluate<{ result: unknown } | { error: string }>(`(async () => { + try { + return { result: await (async () => {\n${script}\n})() } + } catch (error) { + return { + error: + typeof error === 'object' && error !== null && 'message' in error + ? String(error.message) + : String(error), + } + } +})()`), + ) +} + +/** + * Loads the client code in the page of the dev server (`withClientPage`; the + * server started with `clientPage`) and returns what the page's code logged + * to the console meanwhile, one message per call (an argument with a + * `message`, e.g. an error, by its message), each prefixed with its console + * method (`warn: ...`) when `options.levels`. + */ +export function runRsbuildClient( + server: Pick<RsbuildDevServer, 'url'>, + options: { levels?: boolean } = {}, +): Promise<Array<string>> { + return withClientPage(server, async ({ record }) => { + const { calls } = await record() + return calls.map( + ({ level, text }) => (options.levels ? `${level}: ` : '') + text, + ) + }) +} diff --git a/packages/start-plugin-core/tests/rsbuild/import-protection.test.ts b/packages/start-plugin-core/tests/rsbuild/import-protection.test.ts deleted file mode 100644 index c419b2f6e8..0000000000 --- a/packages/start-plugin-core/tests/rsbuild/import-protection.test.ts +++ /dev/null @@ -1,362 +0,0 @@ -import { describe, expect, test, vi } from 'vitest' -import { compileMatchers } from '../../src/import-protection/matchers' -import { - getRsbuildResolvedImportProtectionCheck, - registerImportProtection, -} from '../../src/rsbuild/import-protection' - -type ImportProtectionApi = Parameters<typeof registerImportProtection>[0] -type ModifyRspackConfigHandler = Parameters< - ImportProtectionApi['modifyRspackConfig'] ->[0] -type ProcessAssetsHandler = Parameters<ImportProtectionApi['processAssets']>[1] -type ProcessAssetsContext = Parameters<ProcessAssetsHandler>[0] - -interface MockRspackModule { - buildInfo: Record<string, unknown> - error?: Error - resourceResolveData: { path: string; resource: string } - identifier: () => string - originalSource: () => { - sourceAndMap: () => { - source: string - map: null - } - } -} - -interface MockRspackDependency { - request?: string -} - -interface MockRspackConnection { - dependency: MockRspackDependency - module: MockRspackModule -} - -interface MockRspackEntry { - dependencies: Array<MockRspackDependency> -} - -interface MockProcessAssetsContext { - environment: { name: string } - compilation: { - entries: Map<string, MockRspackEntry> - errors: Array<Error> - inputFileSystem: null - modules: Set<MockRspackModule> - moduleGraph: { - getConnection: ( - dependency: MockRspackDependency, - ) => MockRspackConnection | undefined - getOutgoingConnectionsInOrder: ( - module: MockRspackModule, - ) => Array<MockRspackConnection> - } - warnings: Array<Error> - } - compiler: { rspack: { WebpackError: typeof Error } } -} - -function asProcessAssetsContext( - context: MockProcessAssetsContext, -): ProcessAssetsContext { - return context as unknown as ProcessAssetsContext -} - -describe('getRsbuildResolvedImportProtectionCheck', () => { - test('skips file and marker checks for excluded resolved files', () => { - const matchers = { - files: compileMatchers(['**/*.server.*']), - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - expect( - getRsbuildResolvedImportProtectionCheck( - 'node_modules/pkg/marked-server-only.ts', - matchers, - ), - ).toBeUndefined() - }) - - test('classifies non-excluded denied files as file checks', () => { - const matchers = { - files: compileMatchers(['**/*.server.*']), - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - const result = getRsbuildResolvedImportProtectionCheck( - 'src/secret.server.ts', - matchers, - ) - - expect(result?.type).toBe('file') - if (result?.type !== 'file') { - throw new Error('Expected file import-protection check') - } - expect(result.fileMatch.pattern).toBe('**/*.server.*') - }) - - test('classifies non-excluded non-denied files as marker candidates', () => { - const matchers = { - files: compileMatchers(['**/*.server.*']), - excludeFiles: compileMatchers(['**/node_modules/**']), - } - - expect( - getRsbuildResolvedImportProtectionCheck( - 'src/marked-server-only.ts', - matchers, - ), - ).toEqual({ type: 'marker' }) - }) -}) - -describe('registerImportProtection loader registration', () => { - test('registers a post loader instead of an Rsbuild transform', () => { - let modifyRspackConfig: ModifyRspackConfigHandler | undefined - const transform = vi.fn() - - const api = { - context: { action: 'build' }, - onBeforeBuild() {}, - onBeforeDevCompile() {}, - modifyRspackConfig(handler) { - modifyRspackConfig = handler - }, - transform, - processAssets() {}, - } satisfies ImportProtectionApi & { transform: typeof transform } - - registerImportProtection(api, { - framework: 'react', - environments: [{ name: 'client', type: 'client' }], - getConfig: () => ({ - startConfig: {}, - resolvedStartConfig: { - root: '/app', - srcDirectory: '/app/src', - }, - }), - }) - - if (!modifyRspackConfig) { - throw new Error('Expected modifyRspackConfig to be registered') - } - - class VirtualModulesPlugin { - constructor(_modules: Record<string, string>) {} - - writeModule(_filePath: string, _contents: string) {} - } - - const config: Parameters<ModifyRspackConfigHandler>[0] = { - module: { rules: [] }, - plugins: [], - } - const utils: Parameters<ModifyRspackConfigHandler>[1] = { - environment: { name: 'client' }, - rspack: { - experiments: { VirtualModulesPlugin }, - }, - } - modifyRspackConfig(config, utils) - - expect(transform).not.toHaveBeenCalled() - const rules = config.module.rules - expect(rules).toHaveLength(1) - const rule = rules?.[0] - if (!rule || typeof rule !== 'object' || !('test' in rule)) { - throw new Error('Expected an import-protection Rspack rule') - } - expect(rule).toMatchObject({ - enforce: 'post', - use: [ - { - loader: expect.stringMatching(/import-protection-loader\.js$/), - options: { - envName: 'client', - }, - }, - ], - }) - expect(rule.test).toEqual(/\.[cm]?[tj]sx?$/) - }) -}) - -describe('registerImportProtection marker scope', () => { - async function runMarkerBuild( - importerFiles: Array<string>, - options: { - markedModuleIsEntry?: boolean - importerError?: Error - importerResourceQuery?: string - reportBuildError?: boolean - } = {}, - ) { - let beforeBuild: (() => void) | undefined - let processAssetsHandler: ProcessAssetsHandler | undefined - const onViolation = vi.fn(() => false) - - const api = { - context: { action: 'build' }, - onBeforeBuild(handler) { - beforeBuild = handler - }, - onBeforeDevCompile() {}, - modifyRspackConfig() {}, - processAssets(_options, handler) { - processAssetsHandler = handler - }, - } satisfies ImportProtectionApi - - registerImportProtection(api, { - framework: 'react', - environments: [{ name: 'client', type: 'client' }], - getConfig: () => ({ - startConfig: { - importProtection: { - ignoreImporters: ['**/ignored.ts'], - onViolation: options.reportBuildError ? undefined : onViolation, - }, - }, - resolvedStartConfig: { - root: '/app', - srcDirectory: '/app/src', - }, - }), - }) - - if (!beforeBuild || !processAssetsHandler) { - throw new Error('Expected import-protection hooks to be registered') - } - beforeBuild() - - const createModule = ( - file: string, - marker = false, - resourceQuery = '', - error?: Error, - ): MockRspackModule => ({ - buildInfo: marker - ? { - 'tanstack.start.importProtection': { - kind: 'server', - source: '@tanstack/react-start/server-only', - }, - } - : {}, - ...(error ? { error } : {}), - resourceResolveData: { path: file, resource: `${file}${resourceQuery}` }, - identifier: () => `${file}${resourceQuery}`, - originalSource: () => ({ - sourceAndMap: () => ({ - source: marker ? "import '@tanstack/react-start/server-only'" : '', - map: null, - }), - }), - }) - - const markedModule = createModule('/app/src/marked.ts', true) - const importerModules = importerFiles.map((file) => - createModule( - file, - false, - options.importerResourceQuery, - options.importerError, - ), - ) - const connectionsByModule = new Map< - MockRspackModule, - Array<MockRspackConnection> - >( - importerModules.map((module) => [ - module, - [ - { - dependency: { request: './marked' }, - module: markedModule, - }, - ], - ]), - ) - const entryDependency: MockRspackDependency = { request: './marked' } - const entryConnection: MockRspackConnection = { - dependency: entryDependency, - module: markedModule, - } - - const context: MockProcessAssetsContext = { - environment: { name: 'client' }, - compilation: { - entries: options.markedModuleIsEntry - ? new Map([['main', { dependencies: [entryDependency] }]]) - : new Map(), - errors: [], - inputFileSystem: null, - modules: new Set([...importerModules, markedModule]), - moduleGraph: { - getConnection(dependency) { - return dependency === entryDependency ? entryConnection : undefined - }, - getOutgoingConnectionsInOrder(module) { - return connectionsByModule.get(module) ?? [] - }, - }, - warnings: [], - }, - compiler: { rspack: { WebpackError: Error } }, - } - - await processAssetsHandler(asProcessAssetsContext(context)) - - return { errors: context.compilation.errors, onViolation } - } - - test('skips marker violations imported only by an ignored importer', async () => { - const { onViolation } = await runMarkerBuild(['/app/src/ignored.ts']) - - expect(onViolation).not.toHaveBeenCalled() - }) - - test('reports a marker shared with a non-ignored importer', async () => { - const { onViolation } = await runMarkerBuild([ - '/app/src/ignored.ts', - '/app/src/entry.ts', - ]) - - expect(onViolation).toHaveBeenCalledTimes(1) - expect(onViolation).toHaveBeenCalledWith( - expect.objectContaining({ - importer: '/app/src/marked.ts', - type: 'marker', - }), - ) - }) - - test('reports a marker imported by a resource-query module', async () => { - const { onViolation } = await runMarkerBuild(['/app/src/entry.ts'], { - importerResourceQuery: '?tsr-split=component', - }) - - expect(onViolation).toHaveBeenCalledTimes(1) - }) - - test('skips marker violations from an errored importer module', async () => { - const { onViolation } = await runMarkerBuild(['/app/src/entry.ts'], { - importerError: new Error('Failed to build importer'), - }) - - expect(onViolation).not.toHaveBeenCalled() - }) - - test('reports a marker violation when the marked module is an entry', async () => { - const { errors } = await runMarkerBuild([], { - markedModuleIsEntry: true, - reportBuildError: true, - }) - - expect(errors).toHaveLength(1) - expect(errors[0]?.message).toContain('@tanstack/react-start/server-only') - }) -}) diff --git a/packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts b/packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts index 66e6c58cea..f563c57bf7 100644 --- a/packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts +++ b/packages/start-plugin-core/tests/rsbuild/normalized-client-build.test.ts @@ -469,43 +469,6 @@ describe('normalizeRspackClientBuild', () => { ]) }) - test('imports the chunk of a side-effect-free module used after its inactive import', async () => { - // The import statement's own connection to `lib.js` is inactive (no side - // effects); the later connection for the used `lib` binding is active. - const { clientBuild } = await buildClientFixture( - { - 'index.js': `globalThis.route = () => import(/* webpackChunkName: "alpha" */ './alpha.js?tsr-split=component')`, - 'alpha.js': ` - import { lib } from './lib.js' - export const render = () => lib() + 'alpha' - `, - 'lib.js': `export const lib = () => 'lib'`, - }, - { - module: { rules: [{ test: /lib\.js$/, sideEffects: false }] }, - optimization: { - splitChunks: { - minSize: 0, - cacheGroups: { - default: false, - defaultVendors: false, - vendor: { - name: 'vendor', - test: /lib\.js$/, - chunks: 'all', - enforce: true, - }, - }, - }, - }, - }, - ) - - expect(clientBuild.chunksByFileName.get('alpha.js')?.imports).toEqual([ - 'vendor.js', - ]) - }) - test('uses a dependency in the parent group without importing its copy in another entry', async () => { const { clientBuild } = await buildClientFixture( { @@ -533,77 +496,6 @@ describe('normalizeRspackClientBuild', () => { ]) }) - // #8780: a chunk of a module two routes share must not import either - // route's chunk for a module duplicated into each of them (a chunk is a - // dependency only when every group of the shared chunk has it). - test('does not import a sibling route chunk through a module duplicated into each route', async () => { - const { clientBuild, directory } = await buildClientFixture( - { - 'index.js': ` - globalThis.routes = [ - () => import(/* webpackChunkName: "alpha" */ './alpha.js?tsr-split=component'), - () => import(/* webpackChunkName: "beta" */ './beta.js?tsr-split=component'), - ] - `, - 'alpha.js': ` - import { shared } from './shared.js' - import './alpha.css' - export const render = () => shared() + 'alpha' - `, - 'beta.js': ` - import { shared } from './shared.js' - import './beta.css' - export const render = () => shared() + 'beta' - `, - 'shared.js': `import { widget } from './widget.js'; export const shared = () => widget()`, - 'widget.js': `export const widget = () => 'widget'`, - 'alpha.css': '.alpha { color: red; }', - 'beta.css': '.beta { color: blue; }', - }, - { - optimization: { - splitChunks: { - minSize: 0, - cacheGroups: { - default: false, - defaultVendors: false, - shared: { - name: 'shared', - test: /shared\.js$/, - chunks: 'async', - enforce: true, - }, - }, - }, - }, - }, - ) - - expect(clientBuild.chunksByFileName.get('shared.js')?.imports).toEqual([]) - const manifest = buildStartManifest({ - clientBuild, - basePath: '/', - routeTreeRoutes: { - __root__: { - filePath: join(directory, 'root.js'), - children: ['/alpha', '/beta'], - }, - '/alpha': { filePath: join(directory, 'alpha.js') }, - '/beta': { filePath: join(directory, 'beta.js') }, - }, - }) - expect(manifest.routes['/alpha']?.css).toEqual(['/alpha.css']) - expect(manifest.routes['/alpha']?.preloads).toEqual([ - '/alpha.js', - '/shared.js', - ]) - expect(manifest.routes['/beta']?.css).toEqual(['/beta.css']) - expect(manifest.routes['/beta']?.preloads).toEqual([ - '/beta.js', - '/shared.js', - ]) - }) - test('collects nested CSS imports before the importing route stylesheet', async () => { const { clientBuild, directory } = await buildClientFixture( { diff --git a/packages/start-plugin-core/tests/rsbuild/server-compress.test.ts b/packages/start-plugin-core/tests/rsbuild/server-compress.test.ts deleted file mode 100644 index 759809de37..0000000000 --- a/packages/start-plugin-core/tests/rsbuild/server-compress.test.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises' -import { tmpdir } from 'node:os' -import { createRsbuild } from '@rsbuild/core' -import { join } from 'pathe' -import { afterEach, describe, expect, test } from 'vitest' -import { - RSBUILD_ENVIRONMENT_NAMES, - tanStackStartRsbuild, -} from '../../src/rsbuild' -import type { RsbuildConfig } from '@rsbuild/core' - -const roots: Array<string> = [] - -afterEach(async () => { - await Promise.all( - roots.splice(0).map((root) => rm(root, { recursive: true, force: true })), - ) -}) - -/** The dev server's `server.compress` once Start's plugin has run. */ -async function devServerCompress(server: RsbuildConfig['server']) { - const root = await mkdtemp(join(tmpdir(), 'tss-rsbuild-compress-')) - roots.push(root) - await mkdir(join(root, 'src')) - await writeFile(join(root, 'src/router.tsx'), 'export {}\n') - - const rsbuild = await createRsbuild({ - cwd: root, - config: { - root, - server, - plugins: [ - tanStackStartRsbuild({ - framework: 'react', - defaultEntryPaths: { - client: join(root, 'src/router.tsx'), - server: join(root, 'src/router.tsx'), - start: join(root, 'src/router.tsx'), - }, - providerEnvironmentName: RSBUILD_ENVIRONMENT_NAMES.server, - ssrIsProvider: true, - }), - ], - }, - }) - await rsbuild.initConfigs({ action: 'dev' }) - return rsbuild.getNormalizedConfig().server.compress -} - -describe('Rsbuild dev server compression', () => { - test('is off when the app leaves server.compress unset', async () => { - expect(await devServerCompress(undefined)).toBe(false) - }) - - // #8544: Start's plugin overrode the app's `server.compress`. - test.each([true, false])( - 'follows the app when it sets server.compress to %s', - async (compress) => { - expect(await devServerCompress({ compress })).toBe(compress) - }, - ) -}) diff --git a/packages/start-plugin-core/tests/rsbuild/server-fn-resolver-rebuild.test.ts b/packages/start-plugin-core/tests/rsbuild/server-fn-resolver-rebuild.test.ts deleted file mode 100644 index 8934ba19dd..0000000000 --- a/packages/start-plugin-core/tests/rsbuild/server-fn-resolver-rebuild.test.ts +++ /dev/null @@ -1,169 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { RSBUILD_ENVIRONMENT_NAMES } from '../../src/rsbuild/planning' -import { tapServerFnResolverRebuild } from '../../src/rsbuild/server-fn-resolver-rebuild' -import { registerVirtualModules } from '../../src/rsbuild/virtual-modules' -import type { ServerFn } from '../../src/start-compiler/types' - -type FinishMakeTap = (compilation: { compiler: object }) => Promise<void> - -function serverFn(name: string): ServerFn { - return { - functionName: name, - functionId: name, - extractedFilename: `/app/src/${name}.ts?tss-serverfn-split`, - filename: `/app/src/${name}.ts`, - } -} - -function setup(opts: { action?: 'dev' | 'build'; rsc?: boolean } = {}) { - const serverFnsById: Record<string, ServerFn> = {} - const virtualModules = registerVirtualModules( - { - context: { action: opts.action ?? 'dev' }, - modifyRspackConfig: () => {}, - } as any, - { - getRoot: () => '/app', - getConfig: () => { - throw new Error('getConfig is not used by these tests') - }, - serverFnsById, - providerEnvName: RSBUILD_ENVIRONMENT_NAMES.server, - ssrIsProvider: true, - serializationAdapters: undefined, - getDevClientEntryUrl: () => '/client.js', - rscEnabled: opts.rsc, - scriptFormat: 'module', - }, - ) - - const taps: Array<FinishMakeTap> = [] - const compiler = { - hooks: { - finishMake: { - tapPromise: (_options: unknown, tap: FinishMakeTap) => { - taps.push(tap) - }, - }, - }, - } - - // Wired the same way as the non-RSC and RSC hooks in plugin.ts. - let rebuilds = 0 - let duringNextRebuild: (() => void) | undefined - tapServerFnResolverRebuild(compiler as any, { - name: 'test', - updateResolver: opts.rsc - ? () => { - virtualModules.tryUpdateServerFnResolver( - virtualModules.generateCurrentResolverContent(true), - ) - } - : () => { - virtualModules.updateServerFnResolver() - }, - getResolverWriteCount: () => - virtualModules.getServerFnResolverWriteCount( - RSBUILD_ENVIRONMENT_NAMES.server, - ), - rebuildResolver: () => { - rebuilds++ - const during = duringNextRebuild - duringNextRebuild = undefined - during?.() - return Promise.resolve() - }, - }) - - const runFinishMake = async (compilationCompiler: object) => { - for (const tap of taps) { - await tap({ compiler: compilationCompiler }) - } - } - - return { - serverFnsById, - virtualModules, - rebuilds: () => rebuilds, - duringNextRebuild: (callback: () => void) => { - duringNextRebuild = callback - }, - finishMake: () => runFinishMake(compiler), - // Rspack copies finishMake taps into child compilers. - finishMakeInChild: () => runFinishMake({}), - } -} - -describe('server function resolver rebuild', () => { - test.each([ - { resolver: 'resolver', rsc: false }, - { resolver: 'RSC resolver', rsc: true }, - ])( - 'rebuilds the $resolver only when its content changes', - async ({ rsc }) => { - const t = setup({ rsc }) - - await t.finishMake() - expect(t.rebuilds()).toBe(1) - - await t.finishMake() - expect(t.rebuilds()).toBe(1) - - t.serverFnsById.a = serverFn('a') - await t.finishMake() - expect(t.rebuilds()).toBe(2) - - await t.finishMake() - expect(t.rebuilds()).toBe(2) - - delete t.serverFnsById.a - await t.finishMake() - expect(t.rebuilds()).toBe(3) - }, - ) - - test('rebuilds after another write to the resolver, even if the content is restored', async () => { - const t = setup() - await t.finishMake() - - // For example, a child compilation that wrote content from another registry. - t.virtualModules.tryUpdateServerFnResolver('export {}') - await t.finishMake() - expect(t.rebuilds()).toBe(2) - }) - - test('rebuilds after a write that lands while the resolver is being rebuilt', async () => { - const t = setup() - // For example, another compiler's finishMake updating the shared registry. - t.duringNextRebuild(() => { - t.serverFnsById.a = serverFn('a') - t.virtualModules.updateServerFnResolver() - }) - - await t.finishMake() - await t.finishMake() - expect(t.rebuilds()).toBe(2) - }) - - test('child compilations always rebuild and do not count for the parent', async () => { - const t = setup() - - await t.finishMakeInChild() - await t.finishMake() - expect(t.rebuilds()).toBe(2) - - await t.finishMakeInChild() - expect(t.rebuilds()).toBe(3) - - await t.finishMake() - expect(t.rebuilds()).toBe(3) - }) - - test('rebuilds in every compilation of a production build', async () => { - const t = setup({ action: 'build' }) - - await t.finishMake() - await t.finishMake() - expect(t.rebuilds()).toBe(2) - }) -}) diff --git a/packages/start-plugin-core/tests/server-fn-resolver-module.test.ts b/packages/start-plugin-core/tests/server-fn-resolver-module.test.ts deleted file mode 100644 index 89a24b0844..0000000000 --- a/packages/start-plugin-core/tests/server-fn-resolver-module.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { generateServerFnResolverModule } from '../src/start-compiler/server-fn-resolver-module' - -const serverFnsById = { - fn_a: { - functionName: 'fnA', - functionId: 'fn_a', - extractedFilename: '/app/fn-a.ts', - filename: '/app/fn-a.ts', - isClientReferenced: true, - }, -} - -describe('generateServerFnResolverModule', () => { - test.each([false, true])( - 'resolves public exports and checks client access with static imports: %s', - async (useStaticImports) => { - const entry = { - ...serverFnsById.fn_a, - extractedFilename: `data:text/javascript,${encodeURIComponent( - 'export const fnA = () => "resolved"', - )}`, - } - const source = generateServerFnResolverModule({ - serverFnsById: { - fn_a: entry, - fn_private: { ...entry, isClientReferenced: false }, - }, - includeClientReferencedCheck: true, - memoizeModules: true, - useStaticImports, - }) - const { getServerFnById } = await import( - /* @vite-ignore */ `data:text/javascript,${encodeURIComponent(source)}` - ) - const action = await getServerFnById('fn_a', { origin: 'client' }) - expect(action()).toBe('resolved') - await expect( - getServerFnById('fn_private', { origin: 'client' }), - ).rejects.toThrow('Server function not accessible from client') - await expect( - getServerFnById('fn_private', { origin: 'server' }), - ).resolves.toBe(action) - await expect( - getServerFnById('missing', { origin: 'server' }), - ).rejects.toThrow('Server function info not found') - }, - ) - - test('imports on every call by default', () => { - const source = generateServerFnResolverModule({ - serverFnsById, - includeClientReferencedCheck: false, - }) - expect(source).toContain( - 'serverFnInfo.module ?? (await serverFnInfo.importer())', - ) - expect(source).not.toContain('??=') - }) - - test('keeps the imported module when memoizeModules is set', () => { - const source = generateServerFnResolverModule({ - serverFnsById, - includeClientReferencedCheck: false, - memoizeModules: true, - }) - expect(source).toContain( - 'serverFnInfo.module ??= await serverFnInfo.importer()', - ) - }) -}) diff --git a/packages/start-plugin-core/tests/start-compiler-dead-code-shapes.test.ts b/packages/start-plugin-core/tests/start-compiler-dead-code-shapes.test.ts new file mode 100644 index 0000000000..aa843b3646 --- /dev/null +++ b/packages/start-plugin-core/tests/start-compiler-dead-code-shapes.test.ts @@ -0,0 +1,211 @@ +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + deadCodeShapes, + depSource, + recordFile, + shapeSetup, +} from '@tanstack/compiler-test-utils/dead-code-shapes' +import { + callServerFnThroughCallers, + fromPage, + inPage, + serveCase, + settle, + throwsError, + useStartHost, +} from './regression-helpers' +import type { PageSettled, ServedCase } from './regression-helpers' + +// Every removal of the Start compiler takes with it, in that module, what +// only the removed code used, whatever the shape of the code in between, +// before the bundler sees it (SPEC G16, J4.1, J4.9, J4.10, J4.11, J4.12): +// the environment the code leaves does not load the module only that code +// imported. Kept code keeps what it reads, and code already dead before the +// transform keeps running (G3). Every cell runs through the public Start +// host: the module is served and evaluated in both environments, the client +// in a real page, the server in the SSR environment and in real requests. +// "Not loaded" is what the environment's module graph reaches. + +/** + * No import protection (its dev mock would hide a leaked import from the + * loads) and `verbatimModuleSyntax` (without it, the TypeScript transform + * drops imports nothing reads after the compiler and hides leaks). + */ +const host = useStartHost({ + start: { importProtection: { enabled: false } }, + files: { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, + }), + }, +}) + +type Environment = 'client' | 'ssr' + +/** `expression` (with the case module as `module`) in an environment. */ +async function read( + served: ServedCase, + environment: Environment, + expression: string, +) { + if (environment === 'client') { + return inPage(served, `return ${expression}`) + } + const module = await served.ssr() + return (new Function('module', `return (${expression})`) as any)(module) +} + +/** What calling `module.fn` gives in an environment (`settle`). */ +async function settled(served: ServedCase, environment: Environment) { + if (environment === 'client') { + return fromPage( + await inPage<PageSettled>(served, 'return settle(module.fn)'), + ) + } + return settle((await served.ssr()).fn) +} + +interface Removal { + name: string + /** The environment the removed code leaves. */ + removedFrom: Environment + /** The module's code around `root`, the expression the removed code returns. */ + code: (root: string) => string + /** What the module gives each environment, with `expected` from `root`. */ + check: (served: ServedCase, expected: unknown) => Promise<void> +} + +const removals: Array<Removal> = [ + { + name: 'a server fn handler', + removedFrom: 'client', + code: (root) => `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => ${root})`, + check: async (served, expected) => { + expect(await callServerFnThroughCallers(served, 'module.fn')).toEqual( + expected, + ) + }, + }, + { + name: 'a createServerOnlyFn body', + removedFrom: 'client', + code: (root) => `import { createServerOnlyFn } from '@tanstack/react-start' +export const fn = createServerOnlyFn(() => ${root})`, + check: async (served, expected) => { + expect([ + await settled(served, 'client'), + await settled(served, 'ssr'), + ]).toEqual([throwsError, expected]) + }, + }, + { + name: 'an isomorphic .server()', + removedFrom: 'client', + code: (root) => `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn = createIsomorphicFn().server(() => ${root}).client(() => 'client')`, + check: async (served, expected) => { + expect([ + await settled(served, 'client'), + await settled(served, 'ssr'), + ]).toEqual(['client', expected]) + }, + }, + { + name: 'a createClientOnlyFn body', + removedFrom: 'ssr', + code: (root) => `import { createClientOnlyFn } from '@tanstack/react-start' +export const fn = createClientOnlyFn(() => ${root})`, + check: async (served, expected) => { + expect([ + await settled(served, 'client'), + await settled(served, 'ssr'), + ]).toEqual([expected, throwsError]) + }, + }, + { + name: 'an isomorphic .client()', + removedFrom: 'ssr', + code: (root) => `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn = createIsomorphicFn().server(() => 'server').client(() => ${root})`, + check: async (served, expected) => { + expect([ + await settled(served, 'client'), + await settled(served, 'ssr'), + ]).toEqual([expected, 'server']) + }, + }, +] + +/** + * Cells main gets wrong (KNOWN-BUGS S7): the module keeps the class of a + * class and const cycle only the removed code used, and drops the const its + * static field reads (`ReferenceError` when the module loads, in the + * environment the code left). + */ +const failsToday = new Set( + removals.map( + (removal) => `${removal.name}: a class and a const that read each other`, + ), +) + +describe.each(removals)('$name', (removal) => { + // The module only the removed code needs is a `*.server.*` file where + // server code leaves the client, and a neutral module where client code + // leaves the server (J4.11: dropped whatever the file's name). + const dep = removal.removedFrom === 'client' ? 'dep.server' : 'dep' + for (const shape of deadCodeShapes) { + test( + `takes with it what only it uses through ${shape.name}`, + { fails: failsToday.has(`${removal.name}: ${shape.name}`) }, + async () => { + const kept = shape.kept + ? `\nexport const kept = () => ${shape.kept.expression} +export { ${shape.kept.binding} as aliased }` + : '' + const served = await serveCase(await host(), { + 'module.tsx': `${shapeSetup(shape, `./${dep}`)} +${removal.code(shape.root)}${kept}`, + [`${dep}.ts`]: depSource, + ...recordFile, + }) + await removal.check(served, shape.expected) + if (shape.kept) { + expect( + await read( + served, + removal.removedFrom, + '[module.kept(), module.aliased()]', + ), + ).toEqual([shape.kept.expected, 'dep']) + } else { + expectNotLoaded( + removal.removedFrom === 'client' + ? await served.loads() + : await served.serverLoads(), + [`./${dep}`], + ) + } + if (shape.alreadyDead) { + expect( + removal.removedFrom === 'client' + ? await read( + served, + 'client', + `[...(await load('record.ts')).calls]`, + ) + : (await served.ssr('record.ts')).calls, + ).toContain('dead') + } + }, + ) + } +}) diff --git a/packages/start-plugin-core/tests/start-compiler-determinism.test.ts b/packages/start-plugin-core/tests/start-compiler-determinism.test.ts new file mode 100644 index 0000000000..7da13e9ad4 --- /dev/null +++ b/packages/start-plugin-core/tests/start-compiler-determinism.test.ts @@ -0,0 +1,106 @@ +/** + * Server fn ids (SPEC J4.4, G4) in a dev server of the public Start host + * (`./start-host`): the client's server fn reaches the handler it was + * created with, and each server fn of a module with several reaches its own + * handler, from the client (through the dev server) and from server code. + * Ids are opaque: they are observed through the public `url` of the client's + * server fns and the handler a call reaches, never generated names. + * + * Build ids (J4.4: deterministic for an unchanged project, a custom + * `generateFunctionId`, colliding custom ids) and relocation to another + * root are build clauses: integration/start-compiler-build-determinism.test.ts + * and integration/start-compiler-build-custom-ids.test.ts (real `vite build` and + * Start's preview server). Windows module ids (Rsbuild on Windows) are not + * reachable through a POSIX host; only a Windows CI build covers them. + * Source: review. + */ +import { beforeAll, describe, expect, test } from 'vitest' +import { + callFromClient, + callOnServer, + serveCase, + serverFnUrls, + useStartHost, +} from './regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +const host = useStartHost(hostDefaults) +beforeAll(async () => { + await (await host()).page() +}, 60_000) + +const serverFnModule = (name: string, value: string) => + `import { createServerFn } from '@tanstack/react-start' +export const ${name} = createServerFn().handler(async () => '${value}')` + +describe('server fn ids', () => { + test('the client and the server agree on the id: a call reaches its handler', async () => { + const served = await serveCase( + await host(), + { 'fns.ts': serverFnModule('fn', 'from the server') }, + { file: 'fns.ts' }, + ) + expect(await serverFnUrls(served, 'module', { file: 'fns.ts' })).toEqual([ + expect.any(String), + ]) + expect( + await callFromClient(served, 'module.fn', undefined, { file: 'fns.ts' }), + ).toBe('from the server') + expect( + await callOnServer(served, 'module.fn', undefined, { file: 'fns.ts' }), + ).toBe('from the server') + }) + + // Each server fn of a module gets an id of its own, and the server runs + // the handler of that id. (With one custom id for all of them, a build + // clause: integration/start-compiler-build-custom-ids.test.ts.) + test('each server fn of a module with several reaches its own handler (default ids)', async () => { + const served = await serveCase( + await host(), + { + 'fns.ts': `import { createServerFn } from '@tanstack/react-start' +export const a = createServerFn().handler(async () => 'from a') +export const b = createServerFn().handler(async () => 'from b') +export const c = createServerFn().handler(async () => 'from c')`, + }, + { file: 'fns.ts' }, + ) + expect( + await serverFnUrls(served, 'module', { file: 'fns.ts' }), + ).toHaveLength(3) + const called: Record<string, unknown> = {} + for (const name of ['a', 'b', 'c']) { + called[name] = await callFromClient(served, `module.${name}`, undefined, { + file: 'fns.ts', + }) + expect( + await callOnServer(served, `module.${name}`, undefined, { + file: 'fns.ts', + }), + `${name} called by server code`, + ).toBe(called[name]) + } + expect(called).toEqual({ a: 'from a', b: 'from b', c: 'from c' }) + }) +}) diff --git a/packages/start-plugin-core/tests/start-compiler-diagnostics.test.ts b/packages/start-plugin-core/tests/start-compiler-diagnostics.test.ts new file mode 100644 index 0000000000..468efb3ca4 --- /dev/null +++ b/packages/start-plugin-core/tests/start-compiler-diagnostics.test.ts @@ -0,0 +1,30 @@ +/** + * Malformed server fn input is rejected clearly (SPEC G5, §8 malformed-input + * control), through the public Start plugin: the dev server's client + * environment refuses to serve the module with a compile error that points + * at the offending line. Prose, frame layout and + * context length are free (§5.7). + */ +import { test } from 'vitest' +import { + compileError, + expectCompileError, + useStartHost, +} from './regression-helpers' + +const host = useStartHost() + +// Spreading the handler's arguments is a type error (TS2556 against the real +// declarations: a spread argument must be a tuple or go to a rest +// parameter), so this is a malformed-input control: the compiler cannot tell +// which function is the handler, and has to say so. +test('a server fn whose handler arguments are spread is rejected at the call', async () => { + const source = `import { createServerFn } from '@tanstack/react-start' +const args: Array<() => unknown> = [] +export const fn = createServerFn().handler(...args)` + const startCase = await (await host()).case({ 'module.tsx': source }) + expectCompileError(await compileError(startCase), { + source, + at: '...args', + }) +}) diff --git a/packages/start-plugin-core/tests/start-compiler-factories.test.ts b/packages/start-plugin-core/tests/start-compiler-factories.test.ts index f00175d205..6b92c05ed7 100644 --- a/packages/start-plugin-core/tests/start-compiler-factories.test.ts +++ b/packages/start-plugin-core/tests/start-compiler-factories.test.ts @@ -1,76 +1,201 @@ -import { describe, expect, test } from 'vitest' +import { beforeAll, describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' import { - clientOnlyError, - compileAll, - compileCode, - compileFor, - createStartCompiler, - evaluateModule, - importSources, - outputs, - serverOnlyError, + callFromClient, + callServerFnThroughCallers, + compileError, + expectCompileError, + fromPage, + inPage, + serveCase, + serverFnUrls, settle, + throwsError, + useStartHost, } from './regression-helpers' -import { getModuleErrors } from './validate-module' -import type { Output } from './regression-helpers' +import { clientMiddleware, clientMiddlewareOf } from './page-values' +import { + aliasedClientOnlyFiles, + exportStarModule, + exportStarRows, + factoryDb, + factoryRows, +} from './compiler-inputs' +import type { PageSettled, StartCase } from './regression-helpers' -// Each output keeps the implementation of its own environment (and only the -// imports that implementation reads) and replaces the other one with a stub -// that throws. The compiler only rewrites calls it can resolve to a Start -// factory, through any chain of project modules. +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +// Each environment keeps the implementation of its own environment (and only +// the imports that implementation reads) and replaces the other one with a +// stub that throws. The compiler only rewrites calls it can resolve to a +// Start factory, through any chain of project modules. "Only its imports" +// is observed as loading: the client never loads a server-only module, the +// SSR environment never a client-only one. Everything runs through the +// public Start host (`./start-host`): the client in a real page, the server +// in the SSR environment and in real requests, on Start's real runtime. + +const host = useStartHost(hostDefaults) +beforeAll(async () => { + await (await host()).page() +}, 60_000) + +/** The client loads none of `forbidden` (default: `./db.server`). */ +async function expectClientFree( + served: StartCase, + forbidden = ['./db.server'], + file?: string, +) { + expectNotLoaded(await served.loads(file), forbidden) +} + +/** The SSR environment does not load the client-only module. */ +async function expectSsrFree(served: StartCase, file?: string) { + expectNotLoaded(await served.serverLoads(file), ['./chart.client']) +} + +/** + * What calling the function `fn` (a page expression) gives in the page (its + * value, or a `Thrown` of what it threw; `fn` itself when it is no + * function, like `settle`). Only plain data and Start's promises are kept: code the compiler + * wrongly left on the client may return a mock import protection put in + * place of a server module, whose value must not be awaited (a mock is + * thenable forever); it is reported by its type. + */ +async function settleInPage(served: StartCase, fn: string, file?: string) { + return fromPage( + await inPage<PageSettled>( + served, + `try { + const fn = ${fn} + let value = typeof fn === 'function' ? fn() : fn + if (value instanceof Promise) { + value = await value + } + const plain = value === null || ['string', 'number', 'boolean', 'undefined'].includes(typeof value) || Array.isArray(value) || + (typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) + return { value: plain ? value : '<' + typeof value + '>' } +} catch (error) { + return { thrown: { name: error && error.name, message: String(error && error.message !== undefined ? error.message : error) } } +}`, + { file }, + ), + ) +} + +/** A case of `module.tsx` (`code`) and its real modules (`files`). */ +async function serve( + code: string, + files: Record<string, string> = {}, + file = 'module.tsx', +) { + return serveCase(await host(), { [file]: code, ...files }, { file }) +} const head = `import { createClientOnlyFn, createIsomorphicFn, createServerOnlyFn } from '@tanstack/react-start'\n` +type Wrap = (expression: string) => string describe('environment-specific functions', () => { // Source: Waku vite-plugin-allow-server.test.ts "keeps only allowServer // dependencies and removes allowServer imports", "supports allowServer - // aliasing and export specifiers" - test('each output keeps the implementation of its environment and only its dependencies', async () => { - const compiled = - await compileAll(`import { createServerOnlyFn, createClientOnlyFn as clientOnly } from '@tanstack/react-start' + // aliasing and export specifiers". Dev and build compile alike: the + // production build of the same module is in + // integration/start-compiler-build-env-fns.test.ts. + test('dev: each environment keeps the implementation of its environment and only its dependencies', async () => { + const served = await serve( + `import { createServerOnlyFn, createClientOnlyFn as clientOnly } from '@tanstack/react-start' import { draw } from './chart.client' import { query } from './db.server' const shared = 1 const readDb = () => query(shared) const serverValue = createServerOnlyFn(readDb) export const clientValue = clientOnly(() => draw(shared)) -export { serverValue as exposed }`) - const stubs = { - './chart.client': `export const draw = (x) => 'draw:' + x`, - './db.server': `export const query = (x) => 'query:' + x`, - } - expect(importSources(compiled.client)).toEqual(['./chart.client']) - const client = await evaluateModule(compiled.client, stubs) - expect([client.clientValue(), settle(client.exposed)]).toEqual([ - 'draw:1', - serverOnlyError, - ]) - for (const output of ['ssr', 'provider'] as const) { - expect(importSources(compiled[output])).toEqual(['./db.server']) - } - const ssr = await evaluateModule(compiled.ssr, stubs) +export { serverValue as exposed }`, + { + 'chart.client.ts': `export const draw = (x: number) => 'draw:' + x\n`, + 'db.server.ts': `export const query = (x: number) => 'query:' + x\n`, + }, + ) + await expectClientFree(served) + expect([ + await inPage(served, 'return module.clientValue()'), + await settleInPage(served, 'module.exposed'), + ]).toEqual(['draw:1', throwsError]) + await expectSsrFree(served) + const ssr = await served.ssr() expect([settle(ssr.clientValue), ssr.exposed()]).toEqual([ - clientOnlyError, + throwsError, 'query:1', ]) }) + // An installed browser-only package (it reads `window` when it loads) + // that only client-only code reads, through a diamond and a cycle of + // helpers, never loads on the server, where it would crash (SPEC J4.11, + // G16). The production twin: integration/start-build-client-only-imports.test.ts. + test('dev: the SSR environment does not load a browser-only package only client-only code reads', async () => { + const served = await serve( + `import { createClientOnlyFn, createIsomorphicFn } from '@tanstack/react-start' +import { measure } from 'browser-lib' +const measured = () => measure() +const left = () => measured() +const right = () => measured() +function ping(n: number): string { return n > 0 ? pong(n - 1) : left() + right() } +function pong(n: number): string { return n > 0 ? ping(n - 1) : '' } +export const size = createClientOnlyFn(() => measure()) +export const resize = createIsomorphicFn().server(() => 'server').client(() => ping(2))`, + { + 'node_modules/browser-lib/package.json': JSON.stringify({ + name: 'browser-lib', + type: 'module', + exports: './index.js', + }), + 'node_modules/browser-lib/index.js': `const width = window.innerWidth +export const measure = () => 'measure:' + typeof width +`, + }, + ) + expectNotLoaded(await served.serverLoads(), ['browser-lib']) + expect( + await inPage(served, 'return [module.size(), module.resize()]'), + ).toEqual(['measure:number', 'measure:numbermeasure:number']) + const ssr = await served.ssr() + expect([settle(ssr.size), ssr.resize()]).toEqual([throwsError, 'server']) + }) + // Source: Waku vite-plugin-allow-server.test.ts "handles default allowServer // export", "stubs default exports while preserving allowServer dependencies" test.each([ { code: `import { db } from './db.server' export default createServerOnlyFn(() => db.x())`, - client: serverOnlyError, + client: throwsError, server: 'db', - clientImports: [], }, { code: `import { chart } from './chart.client' export default createClientOnlyFn(() => chart())`, client: 'chart', - server: clientOnlyError, - clientImports: ['./chart.client'], + server: throwsError, }, { code: `import { db } from './db.server' @@ -78,50 +203,411 @@ import { chart } from './chart.client' export default createIsomorphicFn().server(() => db.x()).client(() => chart())`, client: 'chart', server: 'db', - clientImports: ['./chart.client'], }, - ])( - 'a default-exported function: $code', - async ({ code, client, server, clientImports }) => { - const compiled = await compileAll(`${head}${code}`) - expect(importSources(compiled.client)).toEqual(clientImports) - expect(importSources(compiled.ssr)).not.toContain('./chart.client') - const stubs = { - './db.server': `export const db = { x: () => 'db' }`, - './chart.client': `export const chart = () => 'chart'`, - } - expect( - settle((await evaluateModule(compiled.client, stubs)).default), - ).toBe(client) - expect(settle((await evaluateModule(compiled.ssr, stubs)).default)).toBe( - server, - ) - }, - ) + ])('a default-exported function: $code', async ({ code, client, server }) => { + const served = await serve(`${head}${code}`, { + 'db.server.ts': `export const db = { x: () => 'db' }\n`, + 'chart.client.ts': `export const chart = () => 'chart'\n`, + }) + await expectClientFree(served) + await expectSsrFree(served) + expect(await settleInPage(served, 'module.default')).toEqual(client) + const ssr = await served.ssr() + expect(settle(ssr.default)).toEqual(server) + }) // Source: Waku vite-plugin-allow-server.test.ts "handles default allowServer // export" (middleware variant) test('the client strips the server implementation of a default-exported middleware', async () => { - const client = await compileCode( - 'client', + const served = await serve( `import { createMiddleware } from '@tanstack/react-start' import { db } from './db.server' export default createMiddleware().server(async ({ next }) => { db.log() return next() })`, + { 'db.server.ts': `export const db = { log: () => {} }\n` }, ) - expect(await getModuleErrors(client!)).toEqual([]) - expect(importSources(client!)).toEqual([]) - expect((await evaluateModule(client!)).default).toHaveProperty('server') + await expectClientFree(served) + // The middleware records no server implementation. + expect( + await inPage(served, `return ${clientMiddlewareOf('module.default')}`), + ).toEqual(clientMiddleware('request')) }) + describe('a middleware chain with a wrapped link', () => { + // A `.ts` module, so that `<any>x` is a type assertion. + const file = 'module.ts' + const serverLink = `.server(async ({ next }) => next({ context: db.read('SERVER_SECRET') }))` + const clientLink = `.client(async ({ next }) => next({ sendContext: 'client' }))` + const validatorLink = `.validator((data) => check(data, 'VALIDATOR_SECRET'))` + const middlewareModule = (chain: string) => + [ + `import { createMiddleware } from '@tanstack/react-start'`, + `import { db } from './db.server'`, + chain.includes('check(') && `import { check } from './check.server'`, + `export const mw = ${chain}`, + ] + .filter(Boolean) + .join('\n') + const serverFiles = { + 'db.server.ts': `export const db = { read: (key: string) => 'db:' + key }\n`, + 'check.server.ts': `export const check = (data: unknown, key: string) => data + ':' + key\n`, + } + + /** + * The links of the middleware (Start's createMiddleware records each in + * its options), each with the result of its implementation: the same + * page script and server code. + */ + // Only Start's own results (promises, plain data) are awaited and kept: + // a link left on the client may call a module import protection + // replaced with a mock, whose value must not be awaited (a mock is + // thenable forever). + const runLinksSource = `const plain = (value) => + value === null || ['string', 'number', 'boolean', 'undefined'].includes(typeof value) || Array.isArray(value) || + (typeof value === 'object' && Object.getPrototypeOf(value) === Object.prototype) +const links = {} +for (const method of ['middleware', 'validator', 'client', 'server']) { + const impl = mw.options[method] + if (impl !== undefined) { + let result = method === 'middleware' ? impl : impl(method === 'validator' ? 'data' : { next: (opts) => opts }) + if (result instanceof Promise) { + result = await result + } + links[method] = plain(result) ? result : '<' + typeof result + '>' + } +} +return links` + + /** The links each environment keeps, with their results. */ + async function runLinks(code: string) { + const served = await serve(code, serverFiles, file) + const client = await inPage( + served, + `const mw = module.mw\n${runLinksSource}`, + { file }, + ) + const AsyncFunction = (async () => {}).constructor as new ( + ...args: Array<string> + ) => (mw: unknown) => Promise<unknown> + const ssr = await new AsyncFunction('mw', runLinksSource)( + (await served.ssr(file)).mw, + ) + return { served, client, ssr } + } + + // Parentheses and each TypeScript wrapper are different AST nodes. + const wrappers = [ + { name: 'parentheses', wrap: (x: string) => `(${x})` }, + { name: 'as any', wrap: (x: string) => `(${x} as any)` }, + { + name: 'as unknown as T', + wrap: (x: string) => `(${x} as unknown as Middleware)`, + }, + { name: 'satisfies', wrap: (x: string) => `(${x} satisfies unknown)` }, + ] + const serverModules = ['./db.server', './check.server'] + const serverResult = { context: 'db:SERVER_SECRET' } + const clientResult = { sendContext: 'client' } + + // Source: #8504 start-compiler-factories.test.ts (a regression of the + // Yuku migration found by differential fuzzing; main builds these). + test.each( + [ + { + end: '.client()', + chain: (wrap: Wrap) => + `${wrap(`createMiddleware({ type: 'function' })${clientLink}`)}${serverLink}`, + clientLinks: { client: clientResult }, + ssrLinks: { client: clientResult, server: serverResult }, + }, + { + end: '.client(), and the whole chain', + chain: (wrap: Wrap) => + wrap( + `${wrap(`createMiddleware({ type: 'function' })${clientLink}`)}${serverLink}`, + ), + clientLinks: { client: clientResult }, + ssrLinks: { client: clientResult, server: serverResult }, + }, + { + // Only parentheses: a validator link wrapped in a TypeScript + // wrapper is pinned below. + end: '.middleware().validator()', + wrappers: [wrappers[0]!], + chain: (wrap: Wrap) => + `${wrap(`createMiddleware({ type: 'function' }).middleware([])${validatorLink}`)}${clientLink}${serverLink}`, + clientLinks: { middleware: [], client: clientResult }, + ssrLinks: { + middleware: [], + validator: 'data:VALIDATOR_SECRET', + client: clientResult, + server: serverResult, + }, + }, + { + // The wrapped part ends in `.client()`; `.server()` follows it. + // Source: fuzzing (a crash of the Yuku migration, #8504; main + // builds it). + end: '.middleware().validator().client(), before .server()', + chain: (wrap: Wrap) => + `${wrap(`createMiddleware({ type: 'function' }).middleware([])${validatorLink}${clientLink}`)}${serverLink}`, + clientLinks: { middleware: [], client: clientResult }, + ssrLinks: { + middleware: [], + validator: 'data:VALIDATOR_SECRET', + client: clientResult, + server: serverResult, + }, + }, + ].flatMap(({ wrappers: rowWrappers = wrappers, ...chain }) => + rowWrappers.map((wrapper) => ({ ...chain, ...wrapper })), + ), + )( + 'the client strips the server implementation when $name wraps the chain up to $end', + async ({ chain, wrap, clientLinks, ssrLinks }) => { + const { served, client, ssr } = await runLinks( + middlewareModule(chain(wrap)), + ) + await expectClientFree(served, serverModules, file) + expect(served.code.client).not.toMatch(/SERVER_SECRET|VALIDATOR_SECRET/) + expect(client).toEqual(clientLinks) + expect(ssr).toEqual(ssrLinks) + }, + ) + + // The validator only runs on the server. + // Bug: a `.validator()` link wrapped in `satisfies` / `as` is not + // recognised as a link of the middleware chain on the client, so it is + // not stripped. + // Impact: the validator and its server-only imports ship to the client. + // Source: #8504 start-compiler-factories.test.ts "the client strips a + // validator link wrapped in $name" (Vite and Rsbuild builds; red on main). + test.fails.each( + ['', '.middleware([])'].flatMap((middleware) => + wrappers.slice(1).map((wrapper) => ({ ...wrapper, middleware })), + ), + )( + 'the client strips a validator link$middleware wrapped in $name', + async ({ wrap, middleware }) => { + const { served, client, ssr } = await runLinks( + middlewareModule( + `${wrap(`createMiddleware({ type: 'function' })${middleware}${validatorLink}`)}${clientLink}${serverLink}`, + ), + ) + const kept = middleware ? { middleware: [] } : {} + await expectClientFree(served, serverModules, file) + expect(served.code.client).not.toMatch(/SERVER_SECRET|VALIDATOR_SECRET/) + expect(client).toEqual({ ...kept, client: clientResult }) + expect(ssr).toEqual({ + ...kept, + validator: 'data:VALIDATOR_SECRET', + client: clientResult, + server: serverResult, + }) + }, + ) + + /** A module whose middleware chain continues a builder variable. */ + const builderVariableModule = (base: string, rest: string) => + [ + `import { createMiddleware } from '@tanstack/react-start'`, + `import { db } from './db.server'`, + base.includes('check(') && `import { check } from './check.server'`, + `const base = createMiddleware({ type: 'function' })${base}`, + `export const mw = base${rest}`, + ] + .filter(Boolean) + .join('\n') + + // Control for the pin below (same harness): the `.server()` link of a + // builder stored in a variable is stripped on the client. + test('the client strips a .server() link of a builder stored in a variable', async () => { + const { served, client, ssr } = await runLinks( + builderVariableModule(clientLink, serverLink), + ) + await expectClientFree(served, serverModules, file) + expect(served.code.client).not.toMatch(/SERVER_SECRET/) + expect(client).toEqual({ client: clientResult }) + expect(ssr).toEqual({ client: clientResult, server: serverResult }) + }) + + // Bug: a `.validator()` link of a middleware builder stored in a variable + // is not stripped on the client: the chain walk from `base.server(...)` + // stops at the identifier, so the variable's declaration keeps its + // validator (its `.server()` link is stripped, the control above). + // Source: start-compiler/compiler.ts:1296-1330 (the chain walk stops at + // an identifier), start-compiler/handleCreateMiddleware.ts:21-32; + // fuzzing. + // Impact: the validator and its server-only imports ship to the client. + test.fails( + 'the client strips a validator link of a builder stored in a variable', + async () => { + const { served, client, ssr } = await runLinks( + builderVariableModule(validatorLink, serverLink), + ) + await expectClientFree(served, serverModules, file) + expect(served.code.client).not.toMatch(/SERVER_SECRET|VALIDATOR_SECRET/) + expect(client).toEqual({}) + expect(ssr).toEqual({ + validator: 'data:VALIDATOR_SECRET', + server: serverResult, + }) + }, + ) + }) + + /** + * Serves `code` (which exports `getEnv`) and calls `getEnv` in each + * environment, on the Start runtime of that environment. + */ + async function callIsomorphicFn(code: string, name = 'getEnv') { + const served = await serve(code) + const ssr = await served.ssr() + return { + client: await settleInPage(served, `module.${name}`), + ssr: settle(ssr[name]), + } + } + + // Control for the pin below (same harness): the inline chain. + test('each output keeps its implementation of an isomorphic fn written as one chain', async () => { + expect( + await callIsomorphicFn(`import { createIsomorphicFn } from '@tanstack/react-start' +export const getEnv = createIsomorphicFn().server(() => 'server').client(() => 'client')`), + ).toEqual({ client: 'client', ssr: 'server' }) + }) + + // Bug: an isomorphic fn whose first link is stored in a variable + // (`const base = createIsomorphicFn().server(...)`, then + // `export const getEnv = base.client(...)`) loses that link's + // implementation: each call is compiled on its own, the chain walk from + // `base.client(...)` stops at the identifier, so the output of the stored + // link's environment gets a no-op. Same chain walk as the `.validator()` + // pin of a builder stored in a variable above. + // Source: start-compiler/handleCreateIsomorphicFn.ts:17-25, + // start-compiler/compiler.ts:1296-1330; fuzzing (Vite and Rsbuild builds + // return undefined too). + // Impact: the server (or client) call silently returns undefined instead + // of running its implementation. + test.fails.each([ + { + name: '.server() link', + code: `const base = createIsomorphicFn().server(() => 'server') +export const getEnv = base.client(() => 'client')`, + }, + { + name: '.client() link', + code: `const base = createIsomorphicFn().client(() => 'client') +export const getEnv = base.server(() => 'server')`, + }, + ])( + 'each output keeps its implementation of an isomorphic fn whose $name is stored in a variable', + async ({ code }) => { + expect( + await callIsomorphicFn( + `import { createIsomorphicFn } from '@tanstack/react-start'\n${code}`, + ), + ).toEqual({ client: 'client', ssr: 'server' }) + }, + ) + + // Bug: an isomorphic chain link wrapped in `satisfies` / `as` is not + // followed: the implementation of the wrapped link is lost. + // Impact: the output that needs it gets a no-op isomorphic fn (the server + // or the client call returns undefined). + // Source: #8504 start-compiler-factories.test.ts (differential fuzzing, + // Vite and Rsbuild builds; red on main) + test.fails.each([ + `(createIsomorphicFn().server(() => 'server') satisfies any).client(() => 'client')`, + `(createIsomorphicFn().server(() => 'server') as any).client(() => 'client')`, + `(createIsomorphicFn().client(() => 'client') as any).server(() => 'server')`, + ])( + 'each output keeps its implementation of an isomorphic fn with a wrapped chain link: %s', + async (chain) => { + expect( + await callIsomorphicFn( + `import { createIsomorphicFn } from '@tanstack/react-start' +export const fn = ${chain}`, + 'fn', + ), + ).toEqual({ client: 'client', ssr: 'server' }) + }, + ) + + // Bug: a factory callee wrapped in `as any` is not resolved, so the call + // is left untransformed. + // Impact: the client bundle ships the server implementation and its + // imports and runs it in the browser (the uncompiled factories return the + // implementation); a client-only fn runs during SSR. + // Source: #8504 start-compiler-factories.test.ts (Vite and Rsbuild builds; + // red on main) + test.fails.each( + [ + { + shape: 'createServerOnlyFn(fn)', + code: (wrap: Wrap) => + `${wrap('createServerOnlyFn')}(() => db.x('SERVER_SECRET'))`, + client: throwsError, + server: 'db:SERVER_SECRET', + }, + { + shape: 'createIsomorphicFn().server().client()', + code: (wrap: Wrap) => + `${wrap('createIsomorphicFn')}().server(() => db.x('SERVER_SECRET')).client(() => chart())`, + client: 'chart', + server: 'db:SERVER_SECRET', + }, + { + shape: 'createIsomorphicFn().client().server()', + code: (wrap: Wrap) => + `${wrap('createIsomorphicFn')}().client(() => chart()).server(() => db.x('SERVER_SECRET'))`, + client: 'chart', + server: 'db:SERVER_SECRET', + }, + { + shape: 'createClientOnlyFn(fn)', + code: (wrap: Wrap) => `${wrap('createClientOnlyFn')}(() => chart())`, + client: 'chart', + server: throwsError, + }, + ].map((row) => ({ + ...row, + name: 'as any', + wrap: (x: string) => `(${x} as any)`, + })), + )( + 'each output keeps its implementation of $shape with the callee in $name', + async ({ code: factory, wrap, client, server }) => { + const code = `export const fn = ${factory(wrap)}` + const source = [ + head, + code.includes('db.x') && `import { db } from './db.server'\n`, + code.includes('chart()') && `import { chart } from './chart.client'\n`, + code, + ] + .filter(Boolean) + .join('') + const served = await serve(source, { + 'db.server.ts': `export const db = { x: (key: string) => 'db:' + key }\n`, + 'chart.client.ts': `export const chart = () => 'chart'\n`, + }) + await expectClientFree(served) + expect(served.code.client).not.toContain('SERVER_SECRET') + await expectSsrFree(served) + expect(await settleInPage(served, 'module.fn')).toEqual(client) + const ssr = await served.ssr() + expect(settle(ssr.fn)).toEqual(server) + }, + ) + // SolidStart rejects these captures because it hoists `"use server"` // functions; env-only functions stay where they are written. // Source: SolidStart directives validate.ts (assertHoistable), compile.spec.ts // "unsupported server functions" test('an env-only function in a class body keeps this, private members, super and arguments', async () => { - const compiled = await compileAll(`${head}class Base { + const served = await serve(`${head}class Base { name() { return 'base' } @@ -132,16 +618,58 @@ export class Api extends Base { return createServerOnlyFn(() => [this.#secret, super.name(), arguments.length]) } }`) - const client = await evaluateModule(compiled.client) - expect(settle(new client.Api().read(1))).toBe(serverOnlyError) - const ssr = await evaluateModule(compiled.ssr) + expect(await settleInPage(served, 'new module.Api().read(1)')).toEqual( + throwsError, + ) + const ssr = await served.ssr() expect(new ssr.Api().read(1)()).toEqual(['s', 'base', 1]) }) + // Source: snapshot fixture envOnlyFactory (createClientOnlyFn half). + test.each([ + { + name: 'a function', + code: `export function makeDraw() { + return createClientOnlyFn(() => chart()) +}`, + }, + { + name: 'an arrow function', + code: `export const makeDraw = () => createClientOnlyFn(() => chart())`, + }, + ])( + 'a createClientOnlyFn returned by $name runs only on the client', + async ({ code }) => { + const served = await serve( + `${head}import { chart } from './chart.client'\n${code}`, + { 'chart.client.ts': `export const chart = () => 'chart'\n` }, + ) + expect(await inPage(served, 'return module.makeDraw()()')).toBe('chart') + await expectSsrFree(served) + const ssr = await served.ssr() + expect(settle(ssr.makeDraw())).toEqual(throwsError) + }, + ) + + test('a createServerOnlyFn wrapped in two calls runs only on the server', async () => { + const served = await serve( + `${head}import { db } from './db.server' +const wrap = <T,>(fn: T) => fn +export const read = wrap(wrap(createServerOnlyFn(() => db.secret())))`, + { 'db.server.ts': `export const db = { secret: () => 'secret' }\n` }, + ) + await expectClientFree(served) + expect(await settleInPage(served, 'module.read')).toEqual(throwsError) + expect((await served.ssr()).read()).toBe('secret') + }) + // On the server, a middleware `.server()` next to an isomorphic fn stays a - // middleware: it is not compiled as the isomorphic fn's `.server()`. + // middleware: it is not compiled as the isomorphic fn's `.server()`. On + // Start's real runtime (an uncompiled factory is the real one's business, + // not a throwing stand-in). test('isomorphic, server-only and middleware implementations in one module reach only their environment', async () => { - const code = `${head}import { createMiddleware } from '@tanstack/react-start' + const served = await serve( + `${head}import { createMiddleware } from '@tanstack/react-start' import { chart } from './chart.client' import { db } from './db.server' export const iso = createIsomorphicFn() @@ -150,62 +678,151 @@ export const iso = createIsomorphicFn() export const serverOnly = createServerOnlyFn(() => db.x()) export const mw = createMiddleware().server(async ({ next }) => next({ context: { value: db.x() } }), -)` - const stubs = { - '@tanstack/react-start': { - createMiddleware: () => ({ server: () => 'middleware' }), +)`, + { + 'chart.client.ts': `export const chart = { draw: () => 'drawn' }\n`, + 'db.server.ts': `export const db = { x: () => 'x' }\n`, + // The middleware's user: a server fn whose handler gives what the + // middleware put into its context. + 'uses-mw.ts': `import { createServerFn } from '@tanstack/react-start' +import { mw } from './module' +export const value = createServerFn() + .middleware([mw]) + .handler(async ({ context }) => context.value) +`, }, - './chart.client': `export const chart = { draw: () => 'drawn' }`, - './db.server': `export const db = { x: () => 'x' }`, - } - const client = await compileCode('client', code) - expect(importSources(client!)).toEqual(['./chart.client']) - expect((await evaluateModule(client!, stubs)).iso()).toBe('drawn') - const ssr = await compileCode('ssr', code) - expect(importSources(ssr!)).toEqual(['./db.server']) - const ssrModule = await evaluateModule(ssr!, stubs) - expect([ssrModule.iso(), ssrModule.serverOnly(), ssrModule.mw]).toEqual([ - 'x', - 'x', - 'middleware', - ]) + ) + await expectClientFree(served) + expect(await inPage(served, 'return module.iso()')).toBe('drawn') + await expectSsrFree(served) + const ssr = await served.ssr() + // The middleware runs in Start's middleware chain: for a call of the + // server fn from the client (over HTTP) and from server code (inside a + // real request). + expect([ + ssr.iso(), + ssr.serverOnly(), + await callServerFnThroughCallers(served, 'module.value', undefined, { + file: 'uses-mw.ts', + }), + ]).toEqual(['x', 'x', 'x']) }) - // Source: babel-dead-code-elimination "variable" > "within for...in" + // Source: babel-dead-code-elimination "variable" > "within for...in"; + // #8504 start-compiler-factories.test.ts (top-level block row) // Hook calls are different (dropping one changes the hook order; pinned - // separately); a plain server call like this one must go. - test('the client drops a var nested in a function block that only the server implementation reads', async () => { - const client = await compileCode( - 'client', - `${head}import { serverCall } from './db.server' + // separately); a plain server call like these must go. + test('the client drops vars nested in blocks that only the server implementation reads', async () => { + const served = await serve( + `${head}import { connect, serverCall } from './db.server' +if (typeof window === 'undefined') { + var connection = connect() +} export function getValue(flag: boolean) { if (flag) { var local = serverCall() } - const read = createIsomorphicFn().server(() => local).client(() => 'client') + const read = createIsomorphicFn().server(() => [connection, local]).client(() => 'client') return read() }`, + { + 'db.server.ts': `export const connect = () => 'connection'\nexport const serverCall = () => 'local'\n`, + }, ) - expect(await getModuleErrors(client!)).toEqual([]) - expect(importSources(client!)).toEqual([]) - expect(client).not.toContain('serverCall') + await expectClientFree(served) + expect(await inPage(served, 'return module.getValue(true)')).toBe('client') }) + /** A server fn whose handler declares an env-specific fn of each kind. */ + const envFnsInHandler = `import { createServerFn, createClientOnlyFn, createIsomorphicFn, createServerOnlyFn } from '@tanstack/react-start' +import { chart } from './chart.client' +import { db } from './db.server' +export const fn = createServerFn().handler(async () => { + const draw = createClientOnlyFn(() => chart()) + const now = createIsomorphicFn().server(() => db.now()).client(() => chart()) + const read = createServerOnlyFn(() => db.read()) + return [settle(draw), now(), read()] +}) +function settle(run: () => unknown) { + try { + return run() + } catch (error) { + const { name, message } = error as Error + return { thrown: { name, message } } + } +}` + + // Bug: the server leaves env-specific functions declared inside a server + // fn handler uncompiled, with the client-only module they read still + // imported. + // Impact: on the server, a client-only fn called by a handler runs its + // client implementation (the uncompiled factory returns it) instead of + // throwing, and the server bundle loads the client-only module (browser-only + // top-level code runs on the server; import protection rejects the + // `.client` import in the server build). + // Source: SolidStart directives plugin.ts transformFunction (directive + // functions nested in a server function are compiled too); #8504 + // start-compiler-factories.test.ts "the provider compiles env-specific + // functions inside a server fn handler" (red on main). + test.fails( + 'the server compiles env-specific functions inside a server fn handler', + async () => { + const loadedKey = '__startHostChartClientLoaded' + const global = globalThis as Record<string, unknown> + delete global[loadedKey] + try { + const served = await serve(envFnsInHandler, { + 'db.server.ts': `export const db = { now: () => 'now', read: () => 'read' }\n`, + // Records being loaded in the realm that loads it (the server's + // is this process). + 'chart.client.ts': `;(globalThis as any).${loadedKey} = true +export const chart = () => 'chart' +`, + }) + expect(await callFromClient(served, 'module.fn')).toEqual([ + { thrown: expect.anything() }, + 'now', + 'read', + ]) + expect(global[loadedKey], 'the server loaded chart.client').toBe( + undefined, + ) + } finally { + delete global[loadedKey] + } + }, + ) + // Source: Waku vite-plugin-allow-server.test.ts "skips files without a use // client directive even if the string exists", "does not require // allowServer to come from waku/client" (inverted) - test.each([ + test.each<{ + name: string + code: string + /** A JavaScript expression with the module as `module`. */ + read: string + expected: unknown + }>([ { name: 'only mentions the factories in strings and comments', code: `// createServerFn and createServerOnlyFn are not used here export const label = 'createServerFn().handler(async () => 1)' export const other = \`createClientOnlyFn(\${label})\``, + read: '[module.label, module.other]', + expected: [ + 'createServerFn().handler(async () => 1)', + 'createClientOnlyFn(createServerFn().handler(async () => 1))', + ], }, { + // (`./secret`, not `./secret.server`: import protection would deny a + // `.server` module on the client, which is another subject.) name: 'calls .handler() on an object that is not a server fn', code: `import { api } from './api' import { secret } from './secret.server' export const route = api.handler(async () => secret())`, + read: 'module.route()', + expected: 'secret', }, { name: 'declares a function named like a factory', @@ -213,271 +830,310 @@ export const route = api.handler(async () => secret())`, return fn } export const value = createServerOnlyFn(() => 'mine')`, + read: 'module.value()', + expected: 'mine', }, - ])('a module that $name is left untouched', async ({ code }) => { - for (const output of outputs) { - expect(await compileCode(output, code), output).toBeNull() - } - }) + ])( + 'a module that $name keeps its meaning', + async ({ code, read, expected }) => { + const served = await serve(code, { + 'api.ts': `export const api = { handler: (fn: () => unknown) => fn }\n`, + // A server-only file name: the module stays as written whatever its + // imports are called (import protection is off on this host) + 'secret.server.ts': `export const secret = () => 'secret'\n`, + }) + expect(await inPage(served, `return await (${read})`), 'client').toEqual( + expected, + ) + const readOnServer = new Function('module', `return (${read})`) as ( + module: Record<string, any>, + ) => unknown + expect(await readOnServer(await served.ssr()), 'ssr').toEqual(expected) + }, + ) + + // Malformed-input diagnostic controls (SPEC §8, G5): an env function + // without its implementation is a type error (tsc against the real + // declarations: TS2554 "Expected 1 arguments, but got 0" for each row). + // Where the missing implementation would run (the server: SSR; the + // client), compiling fails. Nothing is required + // of the other environment for such input. // Source: Waku vite-plugin-allow-server.test.ts "throws when allowServer - // receives zero arguments" - test.each([ + // receives zero arguments"; replaces envOnly.test.ts and + // createIsomorphicFn.test.ts "should error if implementation not provided" + test.each<{ code: string; api: string; runsOn: 'client' | 'ssr' }>([ { code: `export const none = createServerOnlyFn()`, - error: 'createServerOnlyFn() must be called with a function!', - rejectedBy: ['ssr', 'provider'], + api: 'createServerOnlyFn', + runsOn: 'ssr', }, { code: `export const none = createIsomorphicFn().server().client(() => 1)`, - error: - 'createIsomorphicFn().server(func) must be called with a function!', - rejectedBy: ['ssr', 'provider'], + api: 'createIsomorphicFn', + runsOn: 'ssr', + }, + { + code: `export const none = createClientOnlyFn()`, + api: 'createClientOnlyFn', + runsOn: 'client', + }, + { + code: `export const none = createIsomorphicFn().client()`, + api: 'createIsomorphicFn', + runsOn: 'client', }, ])( - 'a missing implementation is only rejected where it runs: $code', - async ({ code, error, rejectedBy }) => { - const rejected: Array<Output> = [] - for (const output of outputs) { - await compileCode(output, `${head}${code}`).catch((thrown: Error) => { - expect(thrown.message).toContain(error) - rejected.push(output) - }) - } - expect(rejected).toEqual(rejectedBy) + 'a missing implementation is rejected where it runs: $code', + async ({ code, runsOn }) => { + const source = `${head}${code}` + const startCase = await (await host()).case({ 'module.tsx': source }) + const error = await compileError(startCase, runsOn) + expectCompileError(error, { source, at: undefined }) }, ) }) describe('factories resolved through project modules', () => { - test.each<{ - name: string - output: Output - files: Record<string, string> - code: string - imports: Array<string> - serverFns: number - }>([ - { - name: 'a default-exported middleware builder imported as default', - output: 'client', - files: { - '/test/src/mw.ts': `import { createMiddleware } from '@tanstack/react-start' -export default createMiddleware({ type: 'function' })`, - }, - // Known limitation on main: middleware is detected by the - // `createMiddleware` text, so a module that only calls an imported - // builder is not compiled and needs this import. - code: `import { createMiddleware } from '@tanstack/react-start' -import mw from './mw' -import { db } from './db.server' -export const logged = mw.server(async ({ next }) => { - db.log() - return next() -})`, - imports: ['./mw'], - serverFns: 0, - }, - { - name: 'a default-exported server fn builder declared by identifier', - output: 'client', - files: { - '/test/src/builders.ts': `import { createServerFn } from '@tanstack/react-start' -const authed = createServerFn({ method: 'POST' }) -export default authed`, - }, - code: `import authed from './builders' -import { db } from './db.server' -export const fn = authed.handler(async () => db.x())`, - imports: ['./builders'], - serverFns: 1, - }, - ...(['client', 'ssr'] as const).map((output) => ({ - name: 'a namespace import of a module re-exporting the factories', - output, - files: { - '/test/src/factories.ts': `export { createServerFn, createIsomorphicFn } from '@tanstack/react-start'`, - }, - code: `import * as F from './factories' -import { db } from './db.server' -export const fn = F.createServerFn().handler(async () => db.x()) -export const iso = F.createIsomorphicFn().server(() => db.w()).client(() => 'client')`, - imports: - output === 'client' ? ['./factories'] : ['./db.server', './factories'], - serverFns: 1, - })), - { - name: 'renamed re-exports next to a type-only re-export', - output: 'client', - files: { - '/test/src/f.ts': `export { createServerFn as csf, createServerOnlyFn as so } from '@tanstack/react-start' -export type { Register } from '@tanstack/react-start'`, - }, - code: `import { csf, so } from './f' -import { db } from './db.server' -export const fn = csf().handler(async () => db.x()) -export const s = so(() => db.y())`, - imports: ['./f'], - serverFns: 1, - }, - { - // Only createServerOnlyFn appears in the source text. - name: 'an aliased re-export of createClientOnlyFn next to createServerOnlyFn', - output: 'ssr', - files: { - '/test/src/env.ts': `export { createClientOnlyFn as clientOnly } from '@tanstack/react-start'`, - }, - code: `import { createServerOnlyFn } from '@tanstack/react-start' -import { clientOnly } from './env' -import { secret } from './secret.server' -import { readWindow } from './browser' -export const serverValue = createServerOnlyFn(() => secret()) -export const clientValue = clientOnly(() => readWindow())`, - imports: ['./secret.server'], - serverFns: 0, - }, - ])('$output: $name', async ({ output, files, code, imports, serverFns }) => { - const compiled = await compileFor(output, code, { files }) - expect(await getModuleErrors(compiled.code!)).toEqual([]) - expect(importSources(compiled.code!)).toEqual(imports) - expect(Object.keys(compiled.serverFns)).toHaveLength(serverFns) - }) - - // Source: @vitejs/plugin-rsc expand-export-all fixtures (per row) - test.each<{ - name: string - files: Record<string, string> - code?: string - resolvesServerOnlyFn: boolean - }>([ - { - // expand-export-all/explicit-wins - name: 'a local export that overrides the star export', - files: { - '/test/src/start.ts': `export * from '@tanstack/react-start' -export function createServerOnlyFn(fn) { - return fn -}`, - }, - resolvesServerOnlyFn: false, - }, - { - // expand-export-all/nested-conflict-explicit-reexport-wins - name: 'an explicit re-export that overrides a star export', - files: { - '/test/src/start.ts': `export * from './custom' -export { createServerFn, createServerOnlyFn } from '@tanstack/react-start'`, - '/test/src/custom.ts': `export function createServerOnlyFn(fn) { - return fn -}`, - }, - resolvesServerOnlyFn: true, - }, - { - // expand-export-all/bad-resolve - name: 'an unresolvable star export next to the package', - files: { - '/test/src/start.ts': `export * from './missing' -export * from '@tanstack/react-start'`, - }, - resolvesServerOnlyFn: true, - }, - { - // expand-export-all/duplicate-star-same-source - name: 'the same module re-exported twice', - files: { - '/test/src/start.ts': `export * from './inner' -export * from './inner'`, - '/test/src/inner.ts': `export * from '@tanstack/react-start'`, - }, - resolvesServerOnlyFn: true, - }, - { - // expand-export-all/namespace-same-binding - name: 'two star exports that each forward part of the package', - files: { - '/test/src/start.ts': `export * from './a' -export * from './b'`, - '/test/src/a.ts': `export { createServerFn } from '@tanstack/react-start'`, - '/test/src/b.ts': `export { createServerOnlyFn } from '@tanstack/react-start'`, - }, - resolvesServerOnlyFn: true, - }, - { - // expand-export-all/string-export-name - name: 'string export names', - files: { - '/test/src/start.ts': `export { createServerFn as 'create server fn', createServerOnlyFn as 'server only' } from '@tanstack/react-start'`, - }, - code: `import { 'create server fn' as createServerFn, 'server only' as createServerOnlyFn } from './start'`, - resolvesServerOnlyFn: true, - }, - ])( - 'an export * chain with $name', - async ({ - files, - code = `import { createServerFn, createServerOnlyFn } from './start'`, - resolvesServerOnlyFn, - }) => { - const { code: client, serverFns } = await compileFor( - 'client', - `${code} -import { db } from './db.server' -export const fn = createServerFn().handler(async () => db.x()) -export const serverOnly = createServerOnlyFn(() => 'server-only-marker')`, - { files }, - ) - expect(await getModuleErrors(client!)).toEqual([]) - expect(Object.keys(serverFns)).toHaveLength(1) - expect(importSources(client!)).toEqual(['./start']) - expect(client!.includes('server-only-marker')).toBe(!resolvesServerOnlyFn) + test.each(factoryRows)( + '$output: $name', + async ({ output, files, code, serverFns }) => { + const served = await serve(code, { ...files, ...factoryDb }) + if (output === 'client') { + await expectClientFree(served) + } + // The module gives its importers that many server fns (public urls). + expect(await serverFnUrls(served)).toHaveLength(serverFns) + if ('iso' in (await served.ssr())) { + // Each environment runs its own isomorphic implementation. + expect( + output === 'client' + ? await inPage(served, 'return module.iso()') + : (await served.ssr()).iso(), + ).toBe(output === 'client' ? 'client' : 'w') + } + // The server fn is called from the client (through the server) and + // from server code, and runs the handler on the server. + if (serverFns > 0) { + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('x') + } }, ) - const factoryFiles = () => ({ - '/test/src/b.ts': `import { createServerFn } from '@tanstack/react-start' -export const base = createServerFn()`, - '/test/src/c.ts': `export * from './b'`, + // Only createServerOnlyFn appears in the source text; on the server, the + // client-only fn imported through an aliased re-export throws and the + // server-only fn runs. The SSR environment does not load the neutral + // module only the client-only fn reads (SPEC J4.11, G16). + test('ssr: an aliased re-export of createClientOnlyFn next to createServerOnlyFn', async () => { + const { 'module.tsx': code, ...files } = aliasedClientOnlyFiles + const served = await serve(code, files) + expectNotLoaded(await served.serverLoads(), ['./browser']) + const module = await served.ssr() + expect([module.serverValue(), settle(module.clientValue)]).toEqual([ + 'secret', + throwsError, + ]) }) - const importer = `import { base } from './c' + + test.each(exportStarRows)( + 'an export * chain with $name', + async ({ files, resolvesServerOnlyFn }) => { + const served = await serve(exportStarModule, { ...files, ...factoryDb }) + expect(await serverFnUrls(served)).toHaveLength(1) + await expectClientFree(served) + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('x') + // Where the project's own `createServerOnlyFn` wins, it is a plain + // function. + expect(await settleInPage(served, 'module.serverOnly')).toEqual( + resolvesServerOnlyFn ? throwsError : 'server-only-marker', + ) + }, + ) + + // Source: @vitejs/plugin-rsc expand-export-all/string-export-name. A + // string export name is a re-export form, which SPEC J4.5 lists among the + // recognised ones (supported, no rejection branch). Valid TypeScript: + // arbitrary module namespace names (tsc 7.0.2 accepts both modules + // against the real declarations). + test('builders re-exported under string export names are recognised', async () => { + const served = await serve( + `import { 'create server fn' as createServerFn, 'server only' as createServerOnlyFn } from './start' import { db } from './db.server' -export const fn = base.handler(async () => db.x())` - - test('dev: modules reaching a factory through imports and export * are its transitive importers', async () => { - const files = factoryFiles() - const { compiler, compile } = createStartCompiler({ - env: 'client', - mode: 'dev', - files, - }) - expect(await compile(importer, '/test/src/a.tsx')).not.toBeNull() - compiler.ingestModule({ - id: '/test/src/d.ts', - code: `import { base } from './c'\nexport const alias = base`, - }) - // Bundlers may report the changed module with a query suffix. - expect( - [...(await compiler.getTransitiveImporters('/test/src/b.ts?v=1'))].sort(), - ).toEqual(['/test/src/a.tsx', '/test/src/c.ts', '/test/src/d.ts']) +export const fn = createServerFn().handler(async () => db.x() ?? 'MARK_FN_HANDLER') +export const serverOnly = createServerOnlyFn(() => 'server-only-marker')`, + { + 'start.ts': `export { createServerFn as 'create server fn', createServerOnlyFn as 'server only' } from '@tanstack/react-start'`, + ...factoryDb, + }, + ) + await expectClientFree(served) + expect(served.code.client).not.toContain('MARK_FN_HANDLER') + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('x') + expect(await settleInPage(served, 'module.serverOnly')).toEqual(throwsError) + expect((await served.ssr()).serverOnly()).toBe('server-only-marker') }) - test('dev: invalidating a factory module recompiles its importers against the new code', async () => { - const files = factoryFiles() - const { compiler, compile } = createStartCompiler({ - env: 'client', - mode: 'dev', - files, + // Dev edits: the files are written through the dev server's watcher + // (`StartHost.edit`, a watched directory of the app) and requested again; + // the dev server invalidates what the edit changed, as in an app. Their + // own host: it writes no case directories (which its watcher ignores, and + // the edit settle would wait for). + describe('dev edits', () => { + // The edit directories exist before the dev server starts, so its + // watcher watches them from the start (as in an app) + const editHost = useStartHost({ + ...hostDefaults, + files: { + ...hostDefaults.files, + 'src/edits/factory/.keep': '', + 'src/edits/export-star/.keep': '', + }, }) - expect(await compile(importer, '/test/src/a.tsx')).not.toBeNull() - files['/test/src/b.ts'] = - `export const base = { handler: (fn: unknown) => fn }` - // Only modules the compiler knew are reported, without their query. - expect([ - ...compiler.invalidateModules([ - '/test/src/b.ts?v=2', - '/test/src/missing.ts', - ]), - ]).toEqual(['/test/src/b.ts']) - expect(await compile(importer, '/test/src/a.tsx')).toBeNull() + beforeAll(async () => { + await (await editHost()).page() + }, 60_000) + + /** + * Imports an app module in the host's page and runs `script` with it as + * `module` (again, on the new document, when an edit reloaded the page). + */ + async function inEditPage(url: string, script: string) { + const opened = await (await editHost()).page() + for (let attempt = 0; ; attempt++) { + try { + return await opened.page.evaluate( + `(async () => { const module = await import(${JSON.stringify(url)}); ${script} })()`, + ) + } catch (error) { + if (attempt === 2) { + throw error + } + await opened.page.waitForLoadState() + } + } + } + + // Bug: after a dev edit of a module a server fn builder comes from, the + // client keeps serving its importers compiled against the old builder: + // the importer is not compiled again (the dev server only refreshes its + // import timestamps), so its handler stays an RPC to a server fn the + // edited code no longer creates. The SSR environment, which compiles the + // importer afresh, gets it right. The former harness recompiled after an + // internal `invalidateModules` call, which hid this. + // Impact: until the dev server restarts, the page calls a server fn that + // no longer exists (here: Start's RPC fails), or keeps the old client + // behaviour of an edited factory. + // Reproduced through a Vite dev server and the public Start plugin; + // served code read for the diagnosis only. + test.fails( + 'dev: editing a factory module recompiles its importers against the new code', + async () => { + const started = await editHost() + const dir = 'src/edits/factory' + await started.edit({ + [`${dir}/b.ts`]: `import { createServerFn } from '@tanstack/react-start' +export const base = createServerFn()`, + [`${dir}/c.ts`]: `export * from './b'`, + // (`./db`, not `./db.server`: after the edit the handler is user + // code the client runs, and import protection would deny a `.server` + // module there.) + [`${dir}/db.ts`]: `export const db = { x: () => 'x' }\n`, + [`${dir}/a.tsx`]: `import { base } from './c' +import { db } from './db' +export const fn = base.handler(async () => db.x())`, + }) + // Before: a server fn (Start's fetcher), calling the server. + expect( + await inEditPage( + `/${dir}/a.tsx`, + 'return { url: typeof module.fn.url, result: await module.fn() }', + ), + ).toEqual({ url: 'string', result: 'x' }) + // `base` is no server fn builder anymore: the handler is user code. + await started.edit({ + [`${dir}/b.ts`]: `export const base = { handler: (fn: unknown) => fn }`, + }) + await (await started.page()).page.reload() + expect( + await inEditPage( + `/${dir}/a.tsx`, + `try { + return { url: typeof module.fn.url, result: await module.fn() } +} catch (error) { + return { url: typeof module.fn.url, threw: String(error && error.message) } +}`, + ), + ).toEqual({ url: 'undefined', result: 'x' }) + }, + 30_000, + ) + + test('dev: a server fn imported through an export * of the Start package compiles after an unrelated edit', async () => { + const started = await editHost() + const dir = 'src/edits/export-star' + const code = `import { createServerFn } from './start' +export const fn = createServerFn().handler(async () => 'secret-body')` + await started.edit({ + [`${dir}/start.ts`]: `export * from '@tanstack/react-start'`, + [`${dir}/other.ts`]: `export const x = 1`, + [`${dir}/a.ts`]: code, + }) + expect(await started.host.transform(`/${dir}/a.ts`)).not.toContain( + 'secret-body', + ) + await started.edit({ [`${dir}/other.ts`]: `export const x = 2` }) + await started.edit({ [`${dir}/b.ts`]: code }) + expect(await started.host.transform(`/${dir}/b.ts`)).not.toContain( + 'secret-body', + ) + // The client's server fn reaches its handler through the server. + expect(await inEditPage(`/${dir}/b.ts`, 'return await module.fn()')).toBe( + 'secret-body', + ) + }, 30_000) }) }) + +// SPEC J4.10, G12. A normal function's +// receiver comes from its caller, including through Function.prototype.call. +test.each([ + ['server', 'createServerOnlyFn'], + ['client', 'createClientOnlyFn'], +] as const)( + '%s: an env-only function keeps its call receiver', + async (env, factory) => { + const served = + await serve(`import { ${factory} } from '@tanstack/react-start' +export const read = ${factory}(function (this: { value: number }) { return this.value })`) + expect( + env === 'client' + ? await inPage(served, 'return module.read.call({ value: 7 })') + : (await served.ssr()).read.call({ value: 7 }), + ).toBe(7) + }, +) + +// SPEC J4.9, G12. No await in the body: +// the async contract itself must survive selection of either implementation. +test.each(['client', 'ssr'] as const)( + '%s: an async isomorphic implementation returns a promise', + async (env) => { + const served = await serve(`${head} +export const read = createIsomorphicFn().client(async () => 'client').server(async () => 'server')`) + expect( + env === 'client' + ? await inPage( + served, + `const result = module.read() +return { promise: result instanceof Promise, value: await result.then((value) => value) }`, + ) + : await (async () => { + const result = (await served.ssr()).read() + return { + promise: result instanceof Promise, + value: await result.then((value: string) => value), + } + })(), + ).toEqual({ promise: true, value: env === 'client' ? 'client' : 'server' }) + }, +) diff --git a/packages/start-plugin-core/tests/start-compiler-jsx-pragma.test.ts b/packages/start-plugin-core/tests/start-compiler-jsx-pragma.test.ts index a531efdddb..e0df858f63 100644 --- a/packages/start-plugin-core/tests/start-compiler-jsx-pragma.test.ts +++ b/packages/start-plugin-core/tests/start-compiler-jsx-pragma.test.ts @@ -1,36 +1,121 @@ -import { transformWithOxc } from 'vite' -import { expect, test } from 'vitest' -import { createHydrateCompilerPlugin } from '../src/hydrate-when-transform' -import { compileCode, compileHydrate } from './regression-helpers' - /** * A file-level JSX pragma decides which JSX runtime the bundler's own JSX * transform uses for the module. The Start compiler runs before that - * transform (`enforce: 'pre'`), so it must not drop the pragma when it removes - * the import statement the comment sits on. + * transform (`enforce: 'pre'`), so it must not drop the pragma when it + * removes the import statement the comment sits on, nor insert code above a + * pragma that must lead the file. + * + * Observed through the public Start host (`./start-host`: the Start plugin + * and `@vitejs/plugin-react`, whose Oxc JSX transform reads the pragmas): + * the pragma names `pragma-jsx`, a JSX runtime package of the app that + * wraps React's and marks every element it creates (`data-pragma`), so the + * effective runtime is visible on the elements a module's code creates, on + * the client (in the page), on the server and in a server fn's handler. + * (The former tests named `@emotion/react`; any JSX runtime package is the + * same input for the compiler.) */ -async function transformJsx(code: string) { - const result = await transformWithOxc(code, 'module.tsx', { - jsx: { runtime: 'automatic', importSource: 'react' }, - }) - return result.code +import { beforeAll, describe, expect, test } from 'vitest' +import { + callOnServer, + inPage, + serveCase, + useStartHost, +} from './regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, } -/** The JSX runtime Oxc (Vite 8's JSX transform) selects for compiled output. */ -async function jsxRuntimeOf(code: string) { - return (await transformJsx(code)).match( - /from ["']([^"']+\/jsx-(?:dev-)?runtime)["']/, - )?.[1] +/** A JSX runtime package: React's, marking the elements it creates. */ +const runtime = ( + react: string, + factory: string, +) => `import * as React from '${react}' +export const Fragment = React.Fragment +export function ${factory}(type, props, ...rest) { + return React.${factory}(type, { ...props, 'data-pragma': 'pragma-jsx' }, ...rest) +} +${ + factory === 'jsx' + ? `export function jsxs(type, props, ...rest) { + return React.jsxs(type, { ...props, 'data-pragma': 'pragma-jsx' }, ...rest) +}\n` + : '' +}` + +const host = useStartHost({ + start: hostDefaults.start, + files: { + ...hostDefaults.files, + 'node_modules/pragma-jsx/package.json': JSON.stringify({ + name: 'pragma-jsx', + type: 'module', + exports: { + './jsx-runtime': './jsx-runtime.js', + './jsx-dev-runtime': './jsx-dev-runtime.js', + }, + }), + 'node_modules/pragma-jsx/jsx-runtime.js': runtime( + 'react/jsx-runtime', + 'jsx', + ), + 'node_modules/pragma-jsx/jsx-dev-runtime.js': runtime( + 'react/jsx-dev-runtime', + 'jsxDEV', + ), + }, + config: { optimizeDeps: { exclude: ['pragma-jsx'] } }, +}) +beforeAll(async () => { + await (await host()).page() +}, 60_000) + +/** The runtime marker of the element an export returns, in the page. */ +async function clientPragma( + served: Awaited<ReturnType<typeof serveCase>>, + component: string, +) { + return inPage( + served, + `return module.${component}({})?.props?.['data-pragma'] ?? null`, + ) } -// Each comment form sits on the import of a factory the compiler removes; the -// factory and output only vary to show any removed import qualifies. +/** The runtime marker of the element an export returns, on the server. */ +async function serverPragma( + served: Awaited<ReturnType<typeof serveCase>>, + component: string, +) { + return (await served.ssr())[component]({})?.props?.['data-pragma'] ?? null +} + +// Each comment form sits on the import of a factory the compiler removes; +// the factory and environment only vary to show any removed import +// qualifies. test.each([ { name: 'a block comment', output: 'client', - kept: '@jsxImportSource @emotion/react', - code: `/** @jsxImportSource @emotion/react */ + component: 'Card', + code: `/** @jsxImportSource pragma-jsx */ import { createIsomorphicFn } from '@tanstack/react-start' const where = createIsomorphicFn() .server(() => 'server') @@ -42,8 +127,8 @@ export function Card() { { name: 'a line comment', output: 'ssr', - kept: '@jsxImportSource @emotion/react', - code: `// @jsxImportSource @emotion/react + component: 'Button', + code: `// @jsxImportSource pragma-jsx import { createClientOnlyFn } from '@tanstack/react-start' const track = createClientOnlyFn(() => window.alert('tracked')) export function Button() { @@ -53,10 +138,10 @@ export function Button() { { name: 'a file header comment', output: 'client', - kept: 'Copyright Example Corp.', + component: 'Panel', code: `/** * Copyright Example Corp. - * @jsxImportSource @emotion/react + * @jsxImportSource pragma-jsx */ import { createServerOnlyFn } from '@tanstack/react-start' const readSecret = createServerOnlyFn(() => process.env.SECRET) @@ -66,80 +151,186 @@ export function Panel() { }, ] as const)( '$output: a @jsxImportSource pragma in $name survives the removal of the import it sits on', - async ({ output, code, kept }) => { - const compiled = await compileCode(output, code) - expect(await jsxRuntimeOf(compiled!)).toBe('@emotion/react/jsx-runtime') - expect(compiled).toContain(kept) + async ({ output, component, code }) => { + const served = await serveCase(await host(), { 'module.tsx': code }) + expect( + output === 'client' + ? await clientPragma(served, component) + : await serverPragma(served, component), + ).toBe('pragma-jsx') }, ) test('client: classic @jsx and @jsxFrag pragmas survive the removal of the import they sit on', async () => { - const client = await compileCode( - 'client', - `/** @jsxRuntime classic */ + const served = await serveCase(await host(), { + 'module.tsx': `/** @jsxRuntime classic */ // @jsx h // @jsxFrag Fragment import { createIsomorphicFn } from '@tanstack/react-start' -import { h, Fragment } from 'preact' +import { h, Fragment } from './h' const where = createIsomorphicFn() .server(() => 'server') .client(() => 'client') export function List() { return <>{where()}</> }`, + // A classic JSX factory (as Preact's `h`): what it was called with. + 'h.ts': `export const Fragment = 'Fragment' +export function h(type: unknown, props: unknown, ...children: Array<unknown>) { + return { factory: 'h', type, children } +} +`, + }) + expect(await inPage(served, 'return module.List()')).toEqual({ + factory: 'h', + type: 'Fragment', + children: ['client'], + }) +}) + +// Oxc (Vite 8's JSX transform) only reads JSX pragmas from the comments that +// lead the file, so the imports the compiler inserts must stay below them. +// Bug: the server fn runtime import (RPC or `createServerRpc`) is inserted +// above the pragma comment that leads the file. +// Impact: with Vite 8, a module with a server fn compiles its JSX with the +// default runtime: `css` props (Emotion) are ignored. +// Source: #8504 start-compiler-jsx-pragma.test.ts (red on main); same root +// cause as the code splitter's pragma pin +// (router-plugin/tests/code-splitter-pragmas.test.ts). +describe('inserted server function imports stay below the @jsxImportSource pragma', () => { + const code = `/** @jsxImportSource pragma-jsx */ +import { createServerFn } from '@tanstack/react-start' +export const getGreeting = createServerFn().handler(async () => ( + <b css={{ color: 'hotpink' }}>hi</b> +)) +export function Card() { + return <div css={{ color: 'hotpink' }}>card</div> +}` + // The module on the client, the module on the server, and the server fn's + // handler (the element it returns, called from server code in a request). + test.fails.each(['client', 'ssr', 'handler'] as const)( + '%s', + async (where) => { + const served = await serveCase(await host(), { 'module.tsx': code }) + const pragma = + where === 'client' + ? await clientPragma(served, 'Card') + : where === 'ssr' + ? await serverPragma(served, 'Card') + : (( + (await callOnServer(served, 'module.getGreeting')) as { + props?: Record<string, unknown> + } + ).props?.['data-pragma'] ?? null) + expect(pragma).toBe('pragma-jsx') + }, ) - expect(await transformJsx(client!)).toMatch(/\bh\(Fragment\b/) }) test('client: a pragma after a directive stays ahead of inserted server function imports', async () => { - const client = await compileCode( - 'client', - `'use client' -/** @jsxImportSource @emotion/react */ + const served = await serveCase(await host(), { + 'module.tsx': `'use client' +/** @jsxImportSource pragma-jsx */ import { createServerFn } from '@tanstack/react-start' export const getGreeting = createServerFn().handler(async () => 'hi') export function Card() { return <div css={{ color: 'hotpink' }}>card</div> }`, - ) - expect(client!.match(/@jsxImportSource/g)).toHaveLength(1) - expect(await jsxRuntimeOf(client!)).toBe('@emotion/react/jsx-runtime') + }) + expect(await clientPragma(served, 'Card')).toBe('pragma-jsx') }) +/** + * Mounts `Card` of the case module in the page (React's `createRoot`) and + * waits until the `<Hydrate>` children rendered (`text` shows); gives the + * runtime marker of the element that shows it, read from the DOM. + */ +const mountFile = `import { createElement } from 'react' +import { createRoot } from 'react-dom/client' +import { Card } from './module' +export async function mount(text: string) { + const container = document.createElement('div') + document.body.append(container) + const root = createRoot(container) + root.render(createElement(Card)) + try { + for (let i = 0; i < 300; i++) { + const shown = [...container.querySelectorAll('*')].find( + (element) => element.textContent === text && element.children.length === 0, + ) + if (shown) { + return shown.getAttribute('data-pragma') + } + await new Promise((resolve) => setTimeout(resolve, 10)) + } + return 'not rendered: ' + container.innerHTML + } finally { + root.unmount() + container.remove() + } +} +` + test('client: a Hydrate chunk keeps the file-level @jsxImportSource pragma', async () => { - const { chunks } = await compileHydrate( - 'client', - `/** @jsxImportSource @emotion/react */ + const served = await serveCase(await host(), { + 'module.tsx': `/** @jsxImportSource pragma-jsx */ import { Hydrate } from '@tanstack/react-start' +import { load } from '@tanstack/react-start/hydration' export function Card() { return ( - <Hydrate> + <Hydrate when={load()}> <div css={{ color: 'hotpink' }}>card</div> </Hydrate> ) }`, - ) - expect(await jsxRuntimeOf(chunks[0]!)).toBe('@emotion/react/jsx-runtime') + 'mount.tsx': mountFile, + }) + expect( + await inPage(served, `return module.mount('card')`, { file: 'mount.tsx' }), + ).toBe('pragma-jsx') }) -test('client: the parent keeps the pragma when the import it sits on moves into a Hydrate chunk', async () => { - // Vite 7 and earlier transform JSX with esbuild, which honours the pragma - // wherever it appears; check the comment itself survives. - const parent = await compileCode( - 'client', - `/** @jsxImportSource @emotion/react */ -import { Widget } from './widget' -import { Hydrate } from '@tanstack/react-start' +const hydrateParent = (imports: string) => `/** @jsxImportSource pragma-jsx */ +${imports} +import { load } from '@tanstack/react-start/hydration' export function Card() { return ( <div css={{ color: 'hotpink' }}> - <Hydrate> + <Hydrate when={load()}> <Widget /> </Hydrate> </div> ) -}`, - { compilerPlugins: [createHydrateCompilerPlugin()] }, - ) - expect(parent).toContain('@jsxImportSource @emotion/react') -}) +}` +// The effective runtime decision is what counts (SPEC J2.16), read +// through Oxc, Vite 8's JSX transform; whether the comment text survives is +// free. +const hydrateParentImports = [ + { + name: 'moves into a Hydrate chunk', + imports: `import { Widget } from './widget' +import { Hydrate } from '@tanstack/react-start'`, + }, + { + name: 'stays in the parent', + imports: `import { Hydrate } from '@tanstack/react-start' +import { Widget } from './widget'`, + }, +] + +// Bug: the parent's Hydrate chunk loaders are inserted above the pragma +// comment that leads the file. +// Impact: with Vite 8 (Oxc only reads pragmas that lead the file), the +// parent compiles its JSX with the default runtime: `css` props are ignored. +// Source: #8504 start-compiler-jsx-pragma.test.ts (red on main); same root +// cause as the server fn pin above. +test.fails.each(hydrateParentImports)( + 'client: the parent keeps selecting the pragma JSX runtime when the import it sits on $name', + async ({ imports }) => { + const served = await serveCase(await host(), { + 'module.tsx': hydrateParent(imports), + 'widget.tsx': `export const Widget = () => <span>widget</span>\n`, + }) + expect(await clientPragma(served, 'Card')).toBe('pragma-jsx') + }, +) diff --git a/packages/start-plugin-core/tests/start-compiler-preserves-user-code.test.ts b/packages/start-plugin-core/tests/start-compiler-preserves-user-code.test.ts index fae6872b27..fc9b82c0ad 100644 --- a/packages/start-plugin-core/tests/start-compiler-preserves-user-code.test.ts +++ b/packages/start-plugin-core/tests/start-compiler-preserves-user-code.test.ts @@ -1,31 +1,140 @@ -import { describe, expect, test } from 'vitest' +import { pathToFileURL } from 'node:url' +import { beforeAll, describe, expect, test } from 'vitest' import { - compileCode, - evaluateModule, - importSources, + expectMapsTo, + positionAt, + tokenOffsets, +} from '@tanstack/compiler-test-utils/source-maps' +import { + callFromClient, + callServerFnThroughCallers, + inPage, + serveCase, + useStartHost, } from './regression-helpers' -import { declarationOf, getModuleErrors } from './validate-module' +import type { StartCase, StartHost } from './regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} // The compiler removes code that only served a transformed call. Everything // else is user code that must survive, even when nothing seems to read it. +// Observed through the public Start host (`./start-host`): the client in a +// real page, the server in the SSR environment and in real requests. + +const host = useStartHost({ + start: hostDefaults.start, + // Decorated classes are written for TypeScript's `experimentalDecorators` + files: { + 'tsconfig.json': JSON.stringify({ + compilerOptions: { + ...hostTsconfig.compilerOptions, + experimentalDecorators: true, + }, + }), + }, +}) +beforeAll(async () => { + await (await host()).page() +}, 60_000) + +/** Where the recording modules below record, in the realm they run in. */ +const effectsKey = '__startHostSideEffects' + +/** A recording function `name` (returning `value`) of a recording module. */ +const recorder = (name: string, value: string) => + `export const ${name} = (...args: Array<unknown>) => { + ;((globalThis as any).${effectsKey} ??= []).push([${JSON.stringify(name)}, ...args.filter((arg) => typeof arg === 'string')].join(':')) + return ${value} +} +` + +/** + * The modules of the side effects these tests run (`./persist`, + * `./registry`, `./analytics`, `./store`), each recording its calls, in + * order, and `recorder.ts`, which starts the record and replaces + * `setInterval` with a recording one (`restore()` puts it back). + */ +const effectFiles = { + 'persist.ts': recorder('createPersister', '{}'), + 'registry.ts': recorder('register', "'registered'"), + 'analytics.ts': recorder('registerAnalytics', '{}'), + 'store.ts': recorder('createStore', '{}'), + 'recorder.ts': `const original = { setInterval: globalThis.setInterval, clearInterval: globalThis.clearInterval } +;(globalThis as any).${effectsKey} = [] +;(globalThis as any).setInterval = (...args: Array<unknown>) => { + ;(globalThis as any).${effectsKey}.push('setInterval') + return 1 +} +;(globalThis as any).clearInterval = () => {} +export function restore() { + Object.assign(globalThis, original) +} +`, +} + +/** + * Imports the case module in the page after `recorder.ts`, runs `run` (a + * page script with the case module as `m`) and returns what ran, in order. + */ +async function recordClientSideEffects(startCase: StartCase, run = '') { + return inPage( + startCase, + `try { + const m = await load('module.tsx') + ${run} + return globalThis.${effectsKey} +} finally { + module.restore() +}`, + { file: 'recorder.ts' }, + ) +} + +/** A case of `code` with the recording modules. */ +async function effectCase(started: StartHost, code: string) { + return started.case({ 'module.tsx': code, ...effectFiles }) +} // A declaration that only references itself, or a sibling that references // it back, is still live: its initializer runs side effects. -test.each([ +test.each<{ + name: string + code: string + /** A page script with the module as `m`. */ + run?: string + calls: Array<string> +}>([ { name: 'a self-clearing interval', - sideEffect: 'setInterval(', - declared: ['interval'], code: `import { createServerFn } from '@tanstack/react-start' const interval = setInterval(() => { clearInterval(interval) }, 1000) export const fn = createServerFn().handler(async () => 1)`, + calls: ['setInterval'], }, { name: 'mutually-referencing declarations', - sideEffect: 'createPersister(', - declared: ['persister', 'restore'], code: `import { createServerFn } from '@tanstack/react-start' import { createPersister } from './persist' const persister = createPersister({ onRestore: () => restore() }) @@ -33,15 +142,78 @@ function restore() { persister.restore() } export const fn = createServerFn().handler(async () => 1)`, + calls: ['createPersister'], }, -])('keeps $name', async ({ code, sideEffect, declared }) => { - const client = await compileCode('client', code) - expect(client).toContain(sideEffect) - // The validator does not report references to undeclared names. - for (const name of declared) { - expect(client).toMatch(declarationOf(name)) + { + // Source: #8504 start-compiler-preserves-user-code.test.ts (inputs + // adapted from @babel/plugin-proposal-decorators + // 2023-11-misc/destructuring-transform-integration and TypeScript's + // conformance test classes/propertyMemberDeclarations/autoAccessor10.ts) + name: 'declarations only an unused local inside them reads', + code: `import { createServerFn } from '@tanstack/react-start' +import { register } from './registry' +const plugin = { + id: register('plugin'), + describe() { + const self = plugin + return 'plugin' + }, +} +class Widget { + static { + register('widget') } - expect(await getModuleErrors(client!)).toEqual([]) + render() { + const type = Widget + return 'widget' + } +} +export const fn = createServerFn().handler(async () => 1)`, + calls: ['register:plugin', 'register:widget'], + }, + { + // Source: #8504 start-compiler-preserves-user-code.test.ts (the + // destructuring runs the getter) + name: 'a destructuring only an unused local inside it reads', + code: `import { createServerFn } from '@tanstack/react-start' +import { register } from './registry' +const { plugin } = { + get plugin() { + register('getter') + return { + describe() { + const self = plugin + return 'plugin' + }, + } + }, +} +export const fn = createServerFn().handler(async () => 1)`, + calls: ['register:getter'], + }, + { + // Source: #8504 start-compiler-preserves-user-code.test.ts (the + // statement runs on every call of Page) + name: 'a statement in a function body that only an uncalled nested function reads', + code: `import { createServerFn } from '@tanstack/react-start' +import { register } from './registry' +export function Page() { + function describe() { + const self = describe + return effect + } + const effect = register('nested-effect') + return 'page' +} +export const fn = createServerFn().handler(async () => 1)`, + run: 'm.Page()', + calls: ['register:nested-effect'], + }, +])('keeps $name', async ({ code, run, calls }) => { + const startCase = await effectCase(await host(), code) + // The client serves a module that imports and runs + await startCase.served() + expect(await recordClientSideEffects(startCase, run)).toEqual(calls) }) // TypeScript erases type positions, so a declaration whose binding only @@ -50,9 +222,7 @@ export const fn = createServerFn().handler(async () => 1)`, describe('keeps a declaration only referenced from types', () => { const typeQuery = { name: 'a typeof type query', - marker: 'analytics-marker', - declared: 'analytics', - imported: './analytics', + call: 'registerAnalytics:analytics-marker', code: `import { createServerFn } from '@tanstack/react-start' import { registerAnalytics } from './analytics' const analytics = registerAnalytics('analytics-marker') @@ -64,9 +234,7 @@ export const getPosts = createServerFn().handler(async () => [])`, } const globalAugmentation = { name: 'a global augmentation', - marker: 'store-marker', - declared: 'store', - imported: './store', + call: 'createStore:store-marker', code: `import { createIsomorphicFn } from '@tanstack/react-start' import { createStore } from './store' const store = createStore('store-marker') @@ -80,63 +248,247 @@ export const getKind = createIsomorphicFn() .client(() => 'client')`, } - test.each([ - { output: 'client', ...typeQuery }, - { output: 'client', ...globalAugmentation }, - { output: 'provider', ...typeQuery }, - ] as const)( - '$output: $name', - async ({ output, code, marker, declared, imported }) => { - const compiled = await compileCode(output, code) - expect(compiled).toContain(marker) - expect(compiled).toMatch(declarationOf(declared)) - expect(importSources(compiled!)).toContain(imported) - expect(await getModuleErrors(compiled!)).toEqual([]) + test.each([typeQuery, globalAugmentation])( + 'client: $name', + async ({ code, call }) => { + const startCase = await effectCase(await host(), code) + expect(await recordClientSideEffects(startCase)).toEqual([call]) }, ) + + // Handling a server fn call runs the module's initializer, once: what the + // server records while it handles a client's call (the module is first + // evaluated by that request). + test(`server: ${typeQuery.name}`, async () => { + const startCase = await effectCase(await host(), typeQuery.code) + const global = globalThis as Record<string, unknown> + global[effectsKey] = [] + try { + expect(await callFromClient(startCase, 'module.getPosts')).toEqual([]) + expect(global[effectsKey]).toEqual([typeQuery.call]) + } finally { + delete global[effectsKey] + } + }) }) -test('accepts a TypeScript type and a value exported under the same name', async () => { - const client = await compileCode( - 'client', - `import { createServerFn } from '@tanstack/react-start' -export type User = { name: string } +test('accepts type-only namespace imports and exports, and a type and a value exported under the same name', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +import type * as Start from '@tanstack/react-start' +export type * as start from '@tanstack/react-start' +export type User = { name: string; register?: Start.Register } function User(name: string): User { return { name } } export { User } export const getUser = createServerFn().handler(async () => User('Ada'))`, - ) - const module = await evaluateModule(client!) - expect(module.User('Ada')).toEqual({ name: 'Ada' }) + }) + expect(await inPage(served, `return module.User('Ada')`)).toEqual({ + name: 'Ada', + }) }) -test('keeps a React import the classic JSX runtime needs', async () => { - // With the classic runtime the bundler compiles JSX to React.createElement - // after this compiler ran, so an import only used in types is still needed. - const client = await compileCode( - 'client', - `import * as React from 'react' +// With the classic runtime the bundler compiles JSX to React.createElement +// after this compiler ran, so an import the source only reads in types is +// still needed by the JSX (SPEC J4.17, G12). Checked by rendering the +// module of an app whose React plugin uses the classic runtime +// (`react({ jsxRuntime: 'classic' })`), with the real React. +describe('keeps working with the classic JSX runtime downstream', () => { + const classic = useStartHost({ + ...hostDefaults, + react: { jsxRuntime: 'classic' }, + }) + + test('the client and the server render it', async () => { + const served = await serveCase(await classic(), { + 'module.tsx': `import * as React from 'react' import { createServerFn } from '@tanstack/react-start' export const getGreeting = createServerFn().handler(async () => 'hi') export function Greeting({ children }: { children: React.ReactNode }) { return <p>{children}</p> }`, - ) - expect(importSources(client!)).toEqual(['react']) + 'render.tsx': `import * as React from 'react' +import { renderToStaticMarkup } from 'react-dom/server' +import { Greeting } from './module' +export const html = () => renderToStaticMarkup(<Greeting>hi</Greeting>) +`, + }) + expect( + await inPage( + served, + `const element = module.Greeting({ children: 'hi' }) +return { type: element.type, children: element.props.children }`, + ), + ).toEqual({ type: 'p', children: 'hi' }) + expect((await served.ssr('render.tsx')).html()).toBe('<p>hi</p>') + }) }) test('keeps a namespace only read through a TypeScript import alias', async () => { // `import red = Labels.red` compiles to `var red = Labels.red`. - const client = await compileCode( - 'client', - `import { createServerFn } from '@tanstack/react-start' + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' namespace Labels { export const red = 'red' } import red = Labels.red export const label = red export const fn = createServerFn().handler(async () => red)`, - ) - expect((await evaluateModule(client!)).label).toBe('red') + }) + expect(await inPage(served, 'return module.label')).toBe('red') }) + +// A JSON import written with the deprecated `assert` keyword (Node 22+ and +// the bundlers only read `with`) keeps working in every output (SPEC J2.17: +// `assert` stays supported; dropping it once nobody writes it is fine). +test('an import attribute written with assert keeps working in every output', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +import config from './config.json' assert { type: 'json' } +import secrets from './secrets.json' assert { type: 'json' } +export const theme = config.theme +export const fn = createServerFn().handler(async () => secrets.key)`, + 'config.json': `{ "theme": "dark" }`, + 'secrets.json': `{ "key": "MARK_KEY" }`, + }) + expect(await inPage(served, 'return module.theme')).toBe('dark') + expect(await callServerFnThroughCallers(served, 'module.fn')).toBe('MARK_KEY') +}) + +// Decorated classes (TypeScript `experimentalDecorators`) next to a server +// fn: every environment serves and evaluates the module (running them, +// decorators included, is checked through real builds too: +// integration/start-build-user-code.test.ts). +test('decorated classes next to a server fn compile to valid modules', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +const tag = (name: string) => (target: unknown) => target +@tag('repository') +class Repository { + read() { + return 'from repository' + } +} +@tag('widget') +export class Widget { + @tag('method') label() { + return 'widget' + } +} +export const fn = createServerFn().handler(async () => new Repository().read())`, + }) + expect(await inPage(served, 'return new module.Widget().label()')).toBe( + 'widget', + ) + expect(await callFromClient(served, 'module.fn')).toBe('from repository') +}) + +// Bug: the client output prints an asserted update operand without its +// parentheses (`count as number++`). +// Impact: the module fails to parse, so the build fails. +// Source: typescript-eslint type-assertion/increment/as-increment.js, +// type-assertion/increment/non-null-increment.js, type-assertion/satisfies.js; +// #8504 start-compiler-preserves-user-code.test.ts (red on main) +test.fails('keeps the parentheses of asserted update operands', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 1) +let count = 0 +export function bump() { + ;(count as number)++ + ;(count satisfies number)++ + count!++ + ;(count as any) += 1 + return count +}`, + }) + expect(await inPage(served, 'return module.bump()')).toBe(4) +}) + +// Bug: the client output prints a type assertion that is the test of a +// conditional whose branch starts with a unary minus without its parentheses +// (`a as any ? -x : y`), which does not parse (`any ? -x` reads as the start +// of a conditional type). The root cause is upstream: @babel/generator 7.29.8 +// drops the parentheses (parse+generate of `f = ((a) as any) ? -x : y` gives +// `f = a as any ? -x : y;`; no workaround here; router-utils/src/ast.ts:72 +// `generateFromAst` prints with it). The code splitter has the same bug (pin +// in router-plugin/tests/known-bugs-code-splitter.test.ts). +// Impact: the module fails to parse, so the build fails. +// Source: fuzzing. +test.fails( + 'keeps the parentheses of an asserted conditional test', + async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 1) +export function pick(flag: unknown, x: number, y: number) { + return ((flag) as any) ? -x : y +}`, + }) + expect(await inPage(served, 'return module.pick(true, 1, 2)')).toBe(-1) + }, +) + +// Parenthesized JSX keeps working. +test('client: keeps parenthesized JSX working', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 1) +export function Page() { + return (<p>page</p>) +}`, + 'render.client.tsx': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { Page } from './module' +export function html() { + const container = document.createElement('div') + const root = createRoot(container) + flushSync(() => root.render(createElement(Page))) + const markup = container.innerHTML + root.unmount() + return markup +} +`, + }) + expect( + await inPage(served, 'return module.html()', { + file: 'render.client.tsx', + }), + ).toBe('<p>page</p>') +}) + +// Where license comments end up is free outside the code splitter (SPEC G12, +// SPEC §6 OQ12). The `__NO_SIDE_EFFECTS__` annotations bundlers read are +// checked through a real production build +// (integration/start-build-user-code.test.ts). + +// Source maps point to the user's code (R6): the map each environment +// serves with the module (Vite's composed map of every plugin's transform). +// Source: #8504 start-compiler-preserves-user-code.test.ts +test.each(['client', 'ssr'] as const)( + '%s: maps the string value of a JSX attribute to its own source column', + async (environment) => { + const code = `import { createServerFn } from '@tanstack/react-start' +export const fn = createServerFn().handler(async () => 1) +export const Box = () => <div className="box" /> +` + const started = await host() + const startCase = await started.case({ 'module.tsx': code }) + const result = await started.host.dev.vite.environments[ + environment + ].transformRequest(startCase.url()) + expect(result, 'the served module').toBeTruthy() + const [generated] = tokenOffsets(result!.code, { string: 'box' }) + expect(generated, 'the attribute value in the output').toBeDefined() + const [original] = tokenOffsets(code, { string: 'box' }) + expectMapsTo(result!.map as never, positionAt(result!.code, generated!), { + file: startCase.file(), + root: started.root, + // Vite's map names its sources relative to the served module + mapUrl: pathToFileURL(startCase.file()).href, + ...positionAt(code, original!), + }) + }, +) diff --git a/packages/start-plugin-core/tests/start-compiler-runtime-contract.test.ts b/packages/start-plugin-core/tests/start-compiler-runtime-contract.test.ts new file mode 100644 index 0000000000..4b7bf12d15 --- /dev/null +++ b/packages/start-plugin-core/tests/start-compiler-runtime-contract.test.ts @@ -0,0 +1,169 @@ +/** + * One module through the whole of Start's runtime, served by the public + * Start host (`./start-host`): a server fn with a function middleware and + * an isomorphic fn, called from the client in a real page (Start's client + * RPC sends its request to the dev server, whose server entry runs the + * middleware and the handler) and from server code in a real request; and + * a failing handler, whose error reaches both callers. + * Source: review. + */ +import { beforeAll, describe, expect, test } from 'vitest' +import { + callFromClient, + callOnServer, + inPage, + serveCase, + useStartHost, +} from './regression-helpers' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +const host = useStartHost(hostDefaults) +beforeAll(async () => { + await (await host()).page() +}, 60_000) + +describe('a module with a server fn, a function middleware and an isomorphic fn', () => { + const code = `import { createIsomorphicFn, createMiddleware, createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +const where = createIsomorphicFn().server(() => 'server').client(() => 'client') +export const auth = createMiddleware({ type: 'function' }) + .validator((data: { n: number }) => ({ n: data.n + 1 })) + .client(({ next }) => next({ sendContext: { from: where() } })) + .server(({ next, context }) => next({ context: { user: db.user(context.from) ?? 'MARK_MIDDLEWARE_SERVER' } })) +export const getUser = createServerFn({ method: 'POST' }) + .middleware([auth]) + .handler(async ({ data, context, method, serverFnMeta }) => ({ + n: data.n, + user: context.user, + method, + name: serverFnMeta.name, + where: where(), + })) +export const env = () => where()` + const files = { + 'db.server.ts': `export const db = { user: (from: string) => \`user-from-\${from}\` }\n`, + } + + test('runs on Start’s runtime from the client and from server code', async () => { + const served = await serveCase(await host(), { + 'module.tsx': code, + ...files, + }) + expect(served.code.client).not.toContain('MARK_MIDDLEWARE_SERVER') + const expected = (from: string) => ({ + n: 2, + user: `user-from-${from}`, + method: 'POST', + name: 'getUser', + where: 'server', + }) + // The client: its middleware's `.client()` runs in the browser. + expect( + await inPage( + served, + `return { env: module.env(), url: typeof module.getUser.url }`, + ), + ).toEqual({ env: 'client', url: 'string' }) + expect(await callFromClient(served, 'module.getUser', { n: 1 })).toEqual( + expected('client'), + ) + // Server code: `.client()` runs on the server, then the handler. + expect((await served.ssr()).env()).toBe('server') + expect(await callOnServer(served, 'module.getUser', { n: 1 })).toEqual( + expected('server'), + ) + }) + + // An HTTP call by id without client context: a request that is not Start's + // client RPC, here the progressive-enhancement form post Start documents + // (`FormData` sent to the server fn's public `url`, as an HTML form without + // JavaScript does), so no client middleware runs and no client context is + // sent. Start's server entry finds the handler by the id in the URL and + // runs the server middleware and the handler with the request's data, + // method and an empty client context. The handler answers with a + // `Response` (documented "Raw Responses"), which reaches the caller as is. + // Source: the former leg "an HTTP call by id" of "runs on Start’s runtime + // from the client, the SSR caller and an HTTP call by id" (that leg called + // the provider's export directly, so it was dropped). + test('an HTTP call by id without client context runs the server middleware and the handler', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createIsomorphicFn, createMiddleware, createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +const where = createIsomorphicFn().server(() => 'server').client(() => 'client') +export const auth = createMiddleware({ type: 'function' }) + .client(({ next }) => next({ sendContext: { from: where() } })) + .server(({ next, context }) => next({ context: { user: db.user(context.from) ?? 'MARK_MIDDLEWARE_SERVER' } })) +export const submit = createServerFn({ method: 'POST' }) + .middleware([auth]) + .validator((data: FormData) => ({ n: Number(data.get('n')) + 1 })) + .handler(async ({ data, context, method, serverFnMeta }) => + Response.json({ + n: data.n, + user: context.user, + method, + name: serverFnMeta.name, + where: where(), + }), + )`, + ...files, + }) + expect(served.code.client).not.toContain('MARK_MIDDLEWARE_SERVER') + expect( + await inPage( + served, + `const body = new FormData() +body.set('n', '1') +const response = await fetch(module.submit.url, { method: 'POST', body }) +return { status: response.status, body: await response.json() }`, + ), + ).toEqual({ + status: 200, + body: { + n: 2, + user: 'user-from-undefined', + method: 'POST', + name: 'submit', + where: 'server', + }, + }) + }) + + // Source: the former test "a failing handler answers { error }, which + // Start’s handler rethrows" (the error reaching the callers is the + // concept; the `{ error }` answer of a provider export is internal). + test('a failing handler’s error reaches the client and the server caller', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `import { createServerFn } from '@tanstack/react-start' +export const fail = createServerFn().handler(async () => { + throw new Error('handler failed') +})`, + }) + await expect(callFromClient(served, 'module.fail')).rejects.toThrow( + 'handler failed', + ) + await expect(callOnServer(served, 'module.fail')).rejects.toThrow( + 'handler failed', + ) + }) +}) diff --git a/packages/start-plugin-core/tests/start-compiler-v2-inputs.test.ts b/packages/start-plugin-core/tests/start-compiler-v2-inputs.test.ts new file mode 100644 index 0000000000..94c66448df --- /dev/null +++ b/packages/start-plugin-core/tests/start-compiler-v2-inputs.test.ts @@ -0,0 +1,324 @@ +/** + * Inputs a review of real apps' code found untested at the compiler level: + * each is ordinary user code the docs or the public types + * allow, served by the public Start host (`./start-host`) and checked + * through what each environment loads and does (SPEC J4.1, J4.5, J4.8, + * J4.12, §2.1): the client in a real page, server fns called from the + * client through the dev server and from server code in a real request. + * The real builds of the same inputs are in + * `integration/start-build-v2-*.test.ts`. + */ +import { describe, expect, test } from 'vitest' +import { expectNotLoaded } from '@tanstack/compiler-test-utils/importers' +import { + callFromClient, + callOnServer, + inPage, + serveCase, + useStartHost, +} from './regression-helpers' +import type { Plugin } from 'vite' + +/** + * The host defaults these tests use: no import + * protection (its dev mock would hide a leaked server import from the + * client's loads) and an app tsconfig with `verbatimModuleSyntax` (without + * it, Vite's TypeScript transform drops unreferenced imports after the + * compiler and hides leaks). + */ +const hostTsconfig = { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + jsx: 'react-jsx', + strict: true, + verbatimModuleSyntax: true, + }, +} +const hostDefaults = { + start: { importProtection: { enabled: false } }, + files: { 'tsconfig.json': JSON.stringify(hostTsconfig) }, +} + +/** + * `cloudflare:workers` as a Workers platform plugin gives it to the server + * environments (a module the client cannot resolve). + */ +function workersPlatform(): Plugin { + const id = '\0cloudflare:workers' + return { + name: 'test:cloudflare-workers', + applyToEnvironment: (environment) => environment.name !== 'client', + resolveId: (source) => (source === 'cloudflare:workers' ? id : null), + load: (loaded) => + loaded === id + ? `export const env = { SECRET: 'MARK_ENV_SECRET' }\n` + : null, + } +} + +const host = useStartHost({ ...hostDefaults, plugins: [workersPlatform()] }) + +const head = `import { createMiddleware, createServerFn } from '@tanstack/react-start'\n` + +describe('server-only imports the client cannot resolve', () => { + // `cloudflare:workers` (common in real apps) and `node:*` resolve on the + // server only; the compiler removes them with the server code that reads + // them, before any bundler tries to resolve them for the client (SPEC + // J4.12). The server keeps them. + // Source: #6185, #7460, #3990. + const platform = `import { env } from 'cloudflare:workers' +import { readFileSync } from 'node:fs' +export const withEnv = createMiddleware({ type: 'function' }).server( + ({ next }) => next({ context: { secret: env.SECRET } }), +) +export const readConfig = createServerFn() + .middleware([withEnv]) + .handler(async ({ context }) => [ + context.secret, + readFileSync(new URL('./config.txt', import.meta.url)).toString(), + ]) +export const label = () => 'MARK_CLIENT_LABEL' +` + const unresolvable = ['cloudflare:workers', 'node:fs'] + + test('the client compiles and loads neither specifier; the server still reads them', async () => { + const served = await serveCase(await host(), { + 'module.tsx': `${head}${platform}`, + 'config.txt': 'MARK_FILE', + }) + const loads = await served.loads() + expectNotLoaded(loads, unresolvable) + expect( + loads.filter((loaded) => + /cloudflare|node:fs|__vite-browser-external/.test(loaded), + ), + ).toEqual([]) + expect( + await inPage( + served, + `return { label: module.label(), url: typeof module.readConfig.url }`, + ), + ).toEqual({ label: 'MARK_CLIENT_LABEL', url: 'string' }) + // The server runs the middleware and the handler with the platform + // modules: a call from the client reaches them through the server. + expect(await callFromClient(served, 'module.readConfig')).toEqual([ + 'MARK_ENV_SECRET', + 'MARK_FILE', + ]) + expect(await callOnServer(served, 'module.readConfig')).toEqual([ + 'MARK_ENV_SECRET', + 'MARK_FILE', + ]) + expect( + (await served.serverLoads()).some((loaded) => + loaded.includes('cloudflare:workers'), + ), + 'the SSR environment loads cloudflare:workers', + ).toBe(true) + }) +}) + +describe('a validator schema the client also uses', () => { + // A schema that validates a server fn's input and also validates a form + // on the client stays in the client with its behaviour (SPEC J4.1); a + // schema only a validator uses is gone (J4.12). + const files = { + 'post-schema.ts': `export interface Post { + title: string +} +export function PostSchema(input: unknown): Post { + if ( + typeof input !== 'object' || + input === null || + typeof (input as Post).title !== 'string' + ) { + throw new Error('MARK_INVALID_POST') + } + return { title: (input as Post).title } +} +`, + 'draft-schema.ts': `export function DraftSchema(input: unknown): { body: string } { + if (typeof (input as { body?: unknown }).body !== 'string') { + throw new Error('MARK_INVALID_DRAFT') + } + return { body: String((input as { body: string }).body) } +} +`, + 'db.server.ts': `export const save = (data: unknown) => ({ saved: data })\n`, + } + const code = `${head}import { PostSchema } from './post-schema' +import { DraftSchema } from './draft-schema' +import { save } from './db.server' +export const createPost = createServerFn({ method: 'POST' }) + .validator(PostSchema) + .handler(async ({ data }) => save(data)) +export const saveDraft = createServerFn({ method: 'POST' }) + .validator(DraftSchema) + .handler(async ({ data }) => save(data)) +export function validateForm(input: unknown) { + return PostSchema(input) +} +` + + test('the client form validates with the schema, the validator-only schema is not loaded, the server rejects invalid input', async () => { + const served = await serveCase(await host(), { + 'module.tsx': code, + ...files, + }) + expectNotLoaded(await served.loads(), ['./draft-schema', './db.server']) + expect( + await inPage( + served, + `return { + valid: module.validateForm({ title: 'hello' }), + invalid: await settle(() => module.validateForm({})), + urls: [typeof module.createPost.url, typeof module.saveDraft.url], +}`, + ), + ).toEqual({ + valid: { title: 'hello' }, + invalid: { + thrown: { name: 'Error', message: 'MARK_INVALID_POST' }, + }, + urls: ['string', 'string'], + }) + // The server validates: an invalid call is rejected, a valid one saved. + expect( + await callFromClient(served, 'module.createPost', { title: 'hello' }), + ).toEqual({ saved: { title: 'hello' } }) + await expect( + callFromClient(served, 'module.createPost', { nope: true }), + ).rejects.toThrow('MARK_INVALID_POST') + expect( + await callFromClient(served, 'module.saveDraft', { body: 'draft' }), + ).toEqual({ saved: { body: 'draft' } }) + }) +}) + +describe('.jsx modules', () => { + // Untyped `.jsx` files with JSX and a server fn (common in real apps) are + // compiled like `.tsx` ones (SPEC §2.1): the client gets the stub and no + // server code, the handler runs on the server, the JSX renders. + const code = `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +export const getUser = createServerFn().handler(async () => db.user()) +export function Badge({ name }) { + return <span className="badge">{name}</span> +} +` + + test('the client calls the server by id without the handler, and renders the JSX', async () => { + const served = await serveCase( + await host(), + { + 'fns.jsx': code, + 'db.server.ts': `export const db = { user: () => 'MARK_USER' }\n`, + 'render.server.tsx': `import { renderToStaticMarkup } from 'react-dom/server' +import { Badge } from './fns.jsx' +export const html = () => renderToStaticMarkup(<Badge name="Ada" />) +`, + 'render.client.tsx': `import { createElement } from 'react' +import { flushSync } from 'react-dom' +import { createRoot } from 'react-dom/client' +import { Badge } from './fns.jsx' +export function html() { + const container = document.createElement('div') + const root = createRoot(container) + flushSync(() => root.render(createElement(Badge, { name: 'Ada' }))) + const markup = container.innerHTML + root.unmount() + return markup +} +`, + }, + { file: 'fns.jsx' }, + ) + expectNotLoaded(await served.loads('fns.jsx'), ['./db.server']) + expect( + await callFromClient(served, 'module.getUser', undefined, { + file: 'fns.jsx', + }), + ).toBe('MARK_USER') + expect( + await inPage(served, 'return module.html()', { + file: 'render.client.tsx', + }), + 'client', + ).toBe('<span class="badge">Ada</span>') + expect((await served.ssr('render.server.tsx')).html(), 'ssr').toBe( + '<span class="badge">Ada</span>', + ) + }) +}) + +describe('a server fn builder reused as middleware', () => { + // `createServerFn().middleware([auth])` passed in another server fn's + // `.middleware([...])` contributes `auth` (SPEC J4.5): the client runs + // `auth.client()` and ships no `auth.server()` code; the server runs + // `auth.server()` before the handler (J4.8). + // Source: runtime createServerFn.ts TSS_SERVER_FUNCTION_FACTORY. + const code = `${head}import { audit } from './audit.server' +export const auth = createMiddleware({ type: 'function' }) + .client(({ next }) => next({ sendContext: { from: 'client' } })) + .server(({ next, context }) => + next({ context: { user: audit(context.from) } }), + ) +const authed = createServerFn().middleware([auth]) +export const whoAmI = createServerFn() + .middleware([authed]) + .handler(async ({ context }) => context.user) +` + + test('the client call runs auth.client(), the server runs auth.server() then the handler', async () => { + const served = await serveCase(await host(), { + 'module.tsx': code, + 'audit.server.ts': `export const audit = (from: string) => \`user(\${from})\`\n`, + }) + expectNotLoaded(await served.loads(), ['./audit.server']) + expect( + await inPage( + served, + `return { server: module.auth.options.server === undefined, client: typeof module.auth.options.client }`, + ), + ).toEqual({ server: true, client: 'function' }) + // `from: 'client'` reaches the server only when `auth.client()` ran. + expect(await callFromClient(served, 'module.whoAmI')).toBe('user(client)') + expect(await callOnServer(served, 'module.whoAmI')).toBe('user(client)') + }) +}) + +describe('createServerFn options by identifier or spread', () => { + // `createServerFn(opts)` and `createServerFn({ ...opts })` are ordinary + // input (SPEC J4.5): each env keeps the options' `method`, the client + // calls through the server, the server runs the handler. + const code = `import { createServerFn } from '@tanstack/react-start' +import { db } from './db.server' +const opts = { method: 'POST' } as const +export const byIdentifier = createServerFn(opts).handler(async () => db.x()) +export const bySpread = createServerFn({ ...opts }).handler(async () => db.x()) +` + + test.each(['byIdentifier', 'bySpread'])( + '%s: each env keeps the method, the client calls by id, the server runs the handler', + async (name) => { + const served = await serveCase(await host(), { + 'module.tsx': code, + 'db.server.ts': `export const db = { x: () => 'MARK_X' }\n`, + }) + expectNotLoaded(await served.loads(), ['./db.server']) + // Start exposes the declared method on the server fn. + expect( + await inPage( + served, + `return { method: module.${name}.method, url: typeof module.${name}.url }`, + ), + 'client', + ).toEqual({ method: 'POST', url: 'string' }) + expect((await served.ssr())[name].method, 'ssr').toBe('POST') + expect(await callFromClient(served, `module.${name}`)).toBe('MARK_X') + expect(await callOnServer(served, `module.${name}`)).toBe('MARK_X') + }, + ) +}) diff --git a/packages/start-plugin-core/tests/start-host.ts b/packages/start-plugin-core/tests/start-host.ts new file mode 100644 index 0000000000..79219391cf --- /dev/null +++ b/packages/start-plugin-core/tests/start-host.ts @@ -0,0 +1,1282 @@ +/** + * The public Start host of the fast tier: a Start app + * on disk, served by a real Vite dev server running the plugins a user + * configures, `tanstackStart()` of the built `@tanstack/<framework>-start` + * package (its `plugin/vite` export, `start-plugins.ts`) and the framework's own Vite plugin + * (`@vitejs/plugin-react`, `vite-plugin-solid`, `@vitejs/plugin-vue` and + * `@vitejs/plugin-vue-jsx`), through the public plugin + * host of `@tanstack/compiler-test-utils/plugin-host`. Nothing of the + * compiler is named: no class, module id, query, virtual module, report or + * emitted helper. Everything a test reads is what the app gives a user: + * + * - client code runs in a real Chromium page of the dev server (`client`): + * the page imports the case module as a browser imports any module of the + * app, and calling a server fn there sends Start's real request to the + * dev server, whose real server entry and resolver run the handler; + * - server code: the case module evaluated by the SSR environment's own + * module runner (`ssr`), and server fns called the way server code calls + * them, inside a real request of the app (`inRequest`: a server route of + * the app runs the callback, so Start's request context is the real one); + * - served code (`served`): what an environment serves for a case file, for + * checks of shipped text (a server-only marker string, a directive); + * - loads (`loads`): the case files and packages a client import reaches, as + * the browser requested them and as Vite's own client module graph + * resolved them (static and dynamic imports); + * - diagnostics: the dev server's merged channel (console, process streams, + * Vite's logger), and the error a failed transform throws. + * + * One host serves many cases. A case is a directory `src/cases/c<n>` of the + * app with its own files (`module.tsx` and its relative imports): new URLs + * for every case, so module instances never carry over from one case to + * another. The watcher ignores the case directories (they are written once, + * before anything requests them), so writing a case never reloads the page. + * Cases that need dev edits write their files with `edit`, which goes + * through the watcher and the dev server's bounded settle. + * + * Use `useStartHost(options)` in a test file: one host per file (taken in + * `beforeAll`, given back in `afterAll`: a later file of the same test + * process with the same plain options reuses it, see `freeHosts`), and + * `host().case(files)` per test. Page runs of concurrent tests each hold + * one of the host's pages (`hostPageLimit`). + */ +import { realpathSync } from 'node:fs' +import { mkdir, writeFile } from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' +import react from '@vitejs/plugin-react' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' +import solid from 'vite-plugin-solid' +import { mergeConfig, preview as vitePreview } from 'vite' +import { afterAll, beforeAll } from 'vitest' +import { openPage } from '@tanstack/compiler-test-utils/browser' +import { globalTrapSource } from '@tanstack/compiler-test-utils/global-trap' +import { createPluginHost } from '@tanstack/compiler-test-utils/plugin-host' +import { + workspacePackage, + workspacePackageLinks, +} from '@tanstack/compiler-test-utils/workspace-packages' +import { + inProbeRequest, + probeRoute, + probeRouteFile, + rootRouteFile, + routerFile, +} from './request-probe' +import { startPackages, startPluginFactory } from './start-plugins' +import type { StartFramework, StartPluginOptions } from './start-plugins' +import type { BrowserPage } from '@tanstack/compiler-test-utils/browser' +import type { ChannelDiagnostic } from '@tanstack/compiler-test-utils/diagnostic-channel' +import type { + HostBuild, + PluginHost, +} from '@tanstack/compiler-test-utils/plugin-host' +import type { InlineConfig, Plugin, PluginOption, PreviewServer } from 'vite' + +export type { StartFramework, StartPluginOptions } from './start-plugins' + +export interface StartHostOptions { + /** Default `react`. */ + framework?: StartFramework + /** Options of `tanstackStart(options)`. */ + start?: StartPluginOptions + /** + * The app's other Vite plugins, after Start's and the framework's (e.g. a + * user plugin serving virtual modules). + */ + plugins?: Array<PluginOption> + /** Vite configuration merged over the host's (a `vite.config` of the app). */ + config?: InlineConfig + /** Other app files by path relative to the app root. */ + files?: Record<string, string> + /** + * `false`: no dev server (a host for `build()` only). Default `true`. + */ + serve?: boolean + /** + * Other built workspace packages linked into the app's `node_modules`, as + * an installed app has them (e.g. `@tanstack/start-client-core`, which a + * third-party library of the app imports). + */ + links?: Array<string> + /** + * Options of the React app's `@vitejs/plugin-react` (`react(options)`), + * e.g. `{ jsxRuntime: 'classic' }`. + */ + react?: Parameters<typeof react>[0] +} + +const harnessDir = path.dirname(fileURLToPath(import.meta.url)) + +const routerPackages: Record<StartFramework, string> = { + react: '@tanstack/react-router', + solid: '@tanstack/solid-router', + vue: '@tanstack/vue-router', +} + +/** The framework's own Vite plugin, as a user configures it. */ +function frameworkPlugins( + framework: StartFramework, + options: StartHostOptions = {}, +): Array<PluginOption> { + if (framework === 'react') { + return [react(options.react)] + } + if (framework === 'solid') { + return [solid({ ssr: true })] + } + // Single-file components (`.vue`) and Vue's JSX, as a Vue Start app + // configures them. Babel's TypeScript transform of `.tsx` files keeps + // value imports nothing reads, as the app's `verbatimModuleSyntax` does + // for Vite's (`appTsconfig`), through the plugin's documented option. + return [vue(), vueJsx({ tsPluginOptions: { onlyRemoveTypeImports: true } })] +} + +/** + * The app's output directory, absolute (`<root>/dist`, the default + * layout): Start's preview server imports the server build from the + * configured output directory, which it resolves against the process's + * working directory, not the app root (the test process runs elsewhere). + */ +function absoluteOutDir( + root: string, + name: () => string = () => 'dist', +): Plugin { + return { + name: 'start-host:out-dir', + // Before Start's plugin (listed first, both `pre`), which derives its + // environments' output directories from it + enforce: 'pre', + config: () => ({ build: { outDir: path.join(root, name()) } }), + } +} + +/** + * The app's `tsconfig.json` (a test may give its own in `files`). It sets + * `verbatimModuleSyntax`, a common project setting that Vite's TypeScript + * transform honours: an import the compiler leaves in a module then stays + * and loads, so a leak is observable; without it the TypeScript transform, + * which runs after the compiler, would erase an import nothing reads and + * hide what the compiler kept. Without a file of its + * own the app would inherit this package's tsconfig. + * + * The host also turns Start's import protection off unless the test + * configures `importProtection` (a documented option): in dev it replaces a + * denied `*.server.*` import the compiler left in the client with a mock, + * so the page never requests the real module and a Start compiler leak + * (J4.12) would pass unseen. Import protection is a compiler of its own + * (J6), tested with it on in `importProtection/` and its integration suites. + */ +const appTsconfig = (framework: StartFramework) => + `${JSON.stringify( + { + compilerOptions: { + target: 'ES2022', + module: 'ESNext', + moduleResolution: 'Bundler', + // A Vue app's JSX is `@vitejs/plugin-vue-jsx`'s (the tsconfig of a + // Vue Start app) + ...(framework === 'vue' + ? { jsx: 'preserve', jsxImportSource: 'vue' } + : { jsx: 'react-jsx' }), + strict: true, + verbatimModuleSyntax: true, + }, + }, + null, + 2, + )}\n` + +/** How long one page run may take before the page is replaced. */ +const pageRunTimeout = 10_000 + +/** Pages of one host at most: runs of concurrent tests beyond take turns. */ +const hostPageLimit = 4 + +/** Where a case lives: `src/cases/c<n>`. */ +export const casesDir = 'src/cases' + +/** + * What the probe route (`request-probe.ts`) gives a callback of a + * production build host. + */ +interface ProbeContext { + /** A case module of the server build, by `c<n>/<file>`. */ + load: (file: string) => Promise<Record<string, any>> +} + +/** The page route of a production build host. */ +const pageRoutePath = '/harness-page' + +/** + * The globals of development-only support a production page must never + * touch (SPEC G7): React Refresh's registration hooks (what + * `@vitejs/plugin-react`'s dev transform emits and Start's dev preamble + * defines) and the router plugin's React Refresh bookkeeping. Not + * `__TSR_ROUTER__`: the router's own runtime sets and reads it in + * production. + */ +const devSupportGlobals = [ + '$RefreshReg$', + '$RefreshSig$', + '__TSR_REACT_REFRESH__', + '__vite_plugin_react_preamble_installed__', +] + +/** + * Init script of the production page: every read, write, probe (`in`, + * `hasOwnProperty`, ...) or definition of a `devSupportGlobals` name, from + * the page's first statement on, is recorded with its stack + * (`window.__harnessDevSupportTouches`; `globalTrapSource`). + */ +const devSupportTrap = `Object.defineProperty(window, '__harnessDevSupportTouches', { + get: ${globalTrapSource({ names: JSON.stringify(devSupportGlobals), stacks: true })}, +})` + +/** The case modules a production build includes (`import.meta.glob`). */ +const caseGlob = `../cases/*/*.{ts,tsx,js,jsx}` +/** + * The case modules each environment's glob takes: not the ones import + * protection denies there (`*.server.*` on the client, `*.client.*` on the + * server), which only the cases' own modules import. + */ +const clientCaseGlob = `['${caseGlob}', '!../cases/*/*.server.*']` +const serverCaseGlob = `['${caseGlob}', '!../cases/*/*.client.*']` + +/** + * The app files of a host: the router, its root route and the probe server + * route, which runs a callback of the test (by token) inside a real Start + * request. A host for production builds (`serve: false`, React) also gets + * a document shell and a page route, which give the page every case module + * through a lazy `import.meta.glob` (each one a chunk of the build, loaded + * on demand like any lazy import), and its probe route gives the callback + * the case modules of the server build the same way. + */ +function appFiles( + framework: StartFramework, + serve: boolean, +): Record<string, string> { + const router = routerPackages[framework] + const files: Record<string, string> = { + 'src/router.tsx': routerFile(router), + 'src/routes/__root.tsx': rootRouteFile(router), + [probeRouteFile]: serve + ? probeRoute(router) + : probeRoute(router, { + prelude: `const cases = import.meta.glob(${serverCaseGlob})\n`, + context: `{ load: (file: string) => cases['../cases/' + file]!() }`, + }), + } + if (!serve && framework === 'vue') { + // A build-only Vue host (`build()`; `preview()` serves React apps only): + // the client build takes every case module through a page route + files['src/routes/harness-page.ts'] = + `import { createFileRoute } from '${router}' +const cases = import.meta.glob(${clientCaseGlob}) +export const Route = createFileRoute('${pageRoutePath}')({ + component: () => { + Object.assign(window, { __harnessCases: cases, __harnessReady: true }) + return null + }, +}) +` + } + if (!serve && framework !== 'vue') { + if (framework !== 'react') { + throw new Error( + `production build hosts are React or Vue apps (not ${framework})`, + ) + } + files['src/routes/__root.tsx'] = + `import { HeadContent, Outlet, Scripts, createRootRoute } from '${router}' +export const Route = createRootRoute({ + component: () => <Outlet />, + shellComponent: ({ children }) => ( + <html> + <head> + <HeadContent /> + </head> + <body> + {children} + <Scripts /> + </body> + </html> + ), +}) +` + files['src/routes/harness-page.tsx'] = `import { useEffect } from 'react' +import { createFileRoute } from '${router}' +const cases = import.meta.glob(${clientCaseGlob}) +export const Route = createFileRoute('${pageRoutePath}')({ + component: function HarnessPage() { + useEffect(() => { + Object.assign(window, { __harnessCases: cases, __harnessReady: true }) + }, []) + return <main>harness</main> + }, +}) +` + } + return files +} + +/** + * The dependencies the dev server pre-bundles up front (`optimizeDeps` + * `include`, with discovery off, as router-plugin's `route-app.ts` does): + * the framework runtime and the router. With nothing left to discover, + * Vite's optimizer never reruns and reloads the page while a case runs. + * Start's own packages are not pre-bundled: the app serves them through + * Start's plugin, which gives each environment its own entries (a + * pre-bundle would take their server code into the client). + */ +function prebundledModules(framework: StartFramework): Array<string> { + const router = routerPackages[framework] + if (framework === 'react') { + return [ + 'react', + 'react-dom', + 'react/jsx-dev-runtime', + 'react/jsx-runtime', + 'react-dom/client', + router, + ] + } + if (framework === 'solid') { + return ['solid-js', 'solid-js/web', 'solid-js/store', router] + } + return ['vue', 'vue/jsx-runtime', 'vue/jsx-dev-runtime', router] +} + +/** + * The framework packages an app depends on itself, besides Start and the + * router: Vue (its JSX runtime and renderers, which the app's own modules + * import), linked as installed, the copy Start's Vue packages use. + */ +function frameworkLinks(framework: StartFramework): Record<string, string> { + if (framework !== 'vue') { + return {} + } + return { + 'node_modules/vue': realpathSync( + path.join(workspacePackage(startPackages.vue), 'node_modules/vue'), + ), + } +} + +/** + * Helpers every client script of a case has in scope: + * - `settle(run)`: `{ value }` (what `run` returns or resolves to; `run` + * itself when it is no function), or `{ thrown: { name, message } }` + * (what it throws or rejects with), JSON for the test (`fromPage` turns + * `thrown` back into a `Thrown`); + * - `serverFnUrls(namespace)`: the distinct `url`s of the server fns (the + * functions with a string `url`, Start's public fetcher property) among + * the values of an object, e.g. a module namespace. + */ +export const pagePrelude = `const settle = async (run) => { + if (typeof run !== 'function') { + return { value: run } + } + try { + return { value: await run() } + } catch (error) { + return { thrown: { name: error && error.name, message: String(error && error.message !== undefined ? error.message : error) } } + } +} +const serverFnUrls = (namespace) => [...new Set(Object.values(namespace ?? {}).filter((value) => typeof value === 'function' && typeof value.url === 'string').map((value) => value.url))]` + +/** What a page run of a case gives. */ +export interface ClientRun<T = unknown> { + /** The JSON value the script returned. */ + result: T + /** Uncaught errors of the page and its `console.error` output. */ + errors: Array<string> + /** The page's console messages during the run, as `type: text`. */ + console: Array<string> + /** + * What the page requested during the run, as app paths (`/src/...`, + * query stripped) or the requested URL for anything else. + */ + requests: Array<string> +} + +export interface StartCase { + /** The case directory, relative to the app root (`src/cases/c3`). */ + dir: string + /** URL of a case file on the dev server (default `module.tsx`). */ + url: (file?: string) => string + /** Absolute path of a case file. */ + file: (file?: string) => string + /** + * The code an environment (default `client`) serves for a case file + * (default `module.tsx`). A failed transform rejects with its error. + */ + served: (file?: string, environment?: 'client' | 'ssr') => Promise<string> + /** + * The case file (default `module.tsx`) evaluated by the SSR environment's + * module runner: its namespace, in this process. Calling a server fn needs + * a request: `inRequest`. + */ + ssr: (file?: string) => Promise<Record<string, any>> + /** + * Runs `run` inside a real request of the app (a server route of the app + * calls it, so Start's request context is the one of that request), and + * gives what it returns or throws. + */ + inRequest: <T>(run: () => T | Promise<T>) => Promise<T> + /** + * Imports the case file (default `module.tsx`) in the host's Chromium + * page and runs `script`, the body of an async function with the module's + * namespace as `module` and `load(file)` (imports another case file) in + * scope; its JSON value is `result`. A failed import or a throw of the + * script rejects. + */ + client: <T = unknown>( + script: string, + options?: { + file?: string + /** Reload the run's page first: a fresh document, no module instance kept. */ + fresh?: boolean + }, + ) => Promise<ClientRun<T>> + /** + * What importing the case file (default `module.tsx`) in the page loads: + * case files as `./name` (with and without their extension), packages by + * name, and other modules by URL; a module whose top-level code throws + * still counts (`loads` resolves). Static imports are what the browser + * requested and what Vite's client module graph holds for the module; + * dynamic imports, which nothing calls here, count by the module graph + * (they load when the code runs). A module that does not parse, fails to + * compile or does not link fails. + */ + loads: (file?: string) => Promise<Array<string>> + /** + * The case files that the SSR environment's module graph reaches from a + * case file (default `module.tsx`) once evaluated (`./name`, with and + * without their extension, packages by name), static and dynamic. A + * module the SSR environment fails to compile rejects. + */ + serverLoads: (file?: string) => Promise<Array<string>> + /** + * Everything the app's server reported so far, on every channel (the dev + * server's merged channel; on a production build, what the build + * reported). Mark a point with `.length`. + */ + diagnostics: () => Array<ChannelDiagnostic> +} + +export interface StartHost { + /** The app root. */ + root: string + framework: StartFramework + /** The public plugin host (dev server, `build()`). */ + host: PluginHost + /** Everything the dev server reported, on every channel. */ + diagnostics: Array<ChannelDiagnostic> + /** Writes a new case (files by path relative to the case directory). */ + case: (files: Record<string, string>) => Promise<StartCase> + /** + * Writes app files (relative to the app root) through the watcher and + * waits for the dev server's bounded settle (dev edits). + */ + edit: (files: Record<string, string | null>) => Promise<void> + /** + * Evaluates page code (an expression, e.g. an async function called at + * once) on a page of the host, as `StartCase.client` runs a case's: on a + * page the run holds alone, again on a fresh document if the page + * reloaded meanwhile. `fresh`: reload the page first. + */ + run: <T = unknown>( + source: string, + options?: { fresh?: boolean }, + ) => Promise<ClientRun<T>> + /** `vite build` of the app (`PluginHost.build`). */ + build: PluginHost['build'] + /** + * Production mode of a host created with `serve: false` (React): builds + * the app as `vite build` does, with every case written so far, and serves + * the build as `vite preview` does (Start's own preview server: the built + * server entry handles requests). From then on the cases run against the + * build: `client` in a page of the production app (the case module is a + * lazy chunk of the client build, loaded on demand), `ssr` and + * `inRequest` in the server build, inside its real requests. `served`, + * `loads` and `serverLoads` are dev-server checks and throw. Write every + * case first: the build includes the cases that exist when it runs. + */ + preview: (options?: { + /** + * Build and serve again (the same app root), e.g. after rewriting case + * files: the previous preview server and page are closed first. + */ + rebuild?: boolean + }) => Promise<StartPreview> + /** + * The host's first page (concurrent runs of `StartCase.client` run on up + * to `hostPageLimit` pages, one each). + */ + page: () => Promise<BrowserPage> + /** + * Whether a later test file may use the host (`useStartHost`): nothing + * changed the app its options give (no edit, build or preview). + */ + reusable: () => boolean + /** + * Production mode (`preview()`): every read or write of a development-only + * global (React Refresh's `$RefreshReg$`/`$RefreshSig$`, the router + * plugin's `__TSR_REACT_REFRESH__`, the dev preamble's flag) the + * production page made since it opened, with the stack that made it. + */ + devSupportTouches: () => Promise<Array<string>> + close: () => Promise<void> +} + +/** A production build of a host app, served (`StartHost.preview`). */ +export interface StartPreview { + /** The build: each environment's chunks and the merged diagnostics. */ + build: HostBuild + /** URL of the preview server. */ + url: string +} + +/** App path of a requested URL of the dev server, without its query. */ +function appPath(url: string, origin: string) { + if (!url.startsWith(origin)) { + return url + } + return decodeURIComponent(url.slice(origin.length).split('?')[0]!) +} + +/** Package name of a resolved file inside `node_modules` or the workspace. */ +function packageOf(file: string): string | undefined { + const normalized = file.split('?')[0]!.replace(/\\/g, '/') + const nodeModules = normalized.lastIndexOf('/node_modules/') + if (nodeModules !== -1) { + const rest = normalized.slice(nodeModules + '/node_modules/'.length) + if (rest.startsWith('.vite/deps/')) { + return undefined + } + const parts = rest.split('/') + return parts[0]!.startsWith('@') ? `${parts[0]}/${parts[1]}` : parts[0] + } + return undefined +} + +/** Package of a bare specifier id (an externalized server dependency). */ +function bareSpecifierPackage(id: string): string | undefined { + if (/^[@a-z0-9][\w.-]*(?:\/[\w.-]+)*$/i.test(id) && !id.startsWith('.')) { + const parts = id.split('/') + return id.startsWith('@') ? `${parts[0]}/${parts[1]}` : parts[0] + } + return undefined +} + +/** + * Starts a Start app on a dev server (see the module comment) and its page. + */ +export async function createStartHost( + options: StartHostOptions = {}, +): Promise<StartHost> { + const framework = options.framework ?? 'react' + const startFactory = await startPluginFactory(framework) + // Import protection off unless the test configures it (see `appTsconfig`) + const startOptions = { + importProtection: { enabled: false }, + ...options.start, + } + const userPlugins = options.plugins ?? [] + const serve = options.serve ?? true + /** + * The output directory of the next build: a rebuild writes elsewhere, as + * the process keeps the server build it imported from the previous one. + */ + let outDirName = 'dist' + let builds = 0 + const host = await createPluginHost({ + dir: harnessDir, + prefix: `.start-host-${framework}-`, + client: serve, + serve, + plugins: (app) => [ + ...(serve ? [] : [absoluteOutDir(app.root, () => outDirName)]), + startFactory(startOptions), + ...frameworkPlugins(framework, options), + ...userPlugins, + ], + config: { + ...options.config, + optimizeDeps: { + noDiscovery: true, + ...options.config?.optimizeDeps, + include: [ + ...prebundledModules(framework), + ...(options.config?.optimizeDeps?.include ?? []), + ], + }, + server: { + ...options.config?.server, + watch: { + ...options.config?.server?.watch, + // Cases are written once, before anything requests them + ignored: [`**/${casesDir}/**`], + }, + }, + }, + symlinks: { + ...workspacePackageLinks([ + startPackages[framework], + ...(framework === 'react' ? [] : [routerPackages[framework]]), + ...(options.links ?? []), + ]), + ...frameworkLinks(framework), + }, + files: { + 'tsconfig.json': appTsconfig(framework), + ...appFiles(framework, serve), + ...options.files, + }, + }) + const root = host.root + + /** A page of the host and what it requested so far. */ + interface HostPage { + opened: BrowserPage + requests: Array<string> + } + let previewState: + | { server: PreviewServer; url: string; build: HostBuild } + | undefined + /** Base URL of whatever serves the app now: the dev or preview server. */ + const baseUrl = () => { + if (previewState) { + return previewState.url + } + if (!serve) { + throw new Error( + 'this host serves nothing yet: call preview() after writing its cases', + ) + } + return host.dev.url! + } + const origin = () => new URL(baseUrl()).origin + /** + * Opens a page of the host: the production page of the preview server + * (once it hydrated), or the plugin host's page of the dev server. The + * page gives its scripts `window.__harnessInFlight()`: how many of its + * requests have not finished yet (Playwright's network events), so page + * code can wait for the code it requested. + */ + const openHostPage = async (): Promise<HostPage> => { + const requests: Array<string> = [] + const inFlight = new Set<unknown>() + const track = (opened: BrowserPage) => { + opened.page.on('request', (request) => { + requests.push(request.url()) + inFlight.add(request) + }) + opened.page.on('requestfinished', (request) => inFlight.delete(request)) + opened.page.on('requestfailed', (request) => inFlight.delete(request)) + // A new document (a reload) ends the old one: its requests in flight + // end with it, whether or not the browser reports them as finished + // or failed + opened.page.on('framenavigated', (frame) => { + if (frame === opened.page.mainFrame()) { + inFlight.clear() + } + }) + return opened.page.exposeFunction( + '__harnessInFlight', + () => inFlight.size, + ) + } + if (previewState) { + const opened = await openPage('about:blank', { + initScript: devSupportTrap, + }) + await track(opened) + await opened.page.goto(new URL(pageRoutePath, previewState.url).href) + try { + await opened.page.waitForFunction( + () => (window as unknown as Record<string, unknown>).__harnessReady, + undefined, + { timeout: 15_000 }, + ) + } catch (error) { + throw new Error( + [ + `the production page did not hydrate: ${(error as Error).message}`, + `html: ${(await opened.page.content()).slice(0, 2000)}`, + `errors:\n${opened.errors.join('\n') || '(none)'}`, + `console:\n${opened.console.join('\n') || '(none)'}`, + ].join('\n'), + ) + } + return { opened, requests } + } + const opened = await openPage('about:blank') + await track(opened) + await opened.page.goto( + new URL('/__plugin-host__/page.html', baseUrl()).href, + ) + return { opened, requests } + } + + // The host's pages: concurrent runs (concurrent tests) each hold one + // (`runInHostPage`), at most `hostPageLimit`; a page keeps its document + // from one run to the next (cases have their own URLs). `page()` gives + // the first one. + /** Pages open or opening. */ + let pageCount = 0 + /** Every open page. */ + let allPages = new Set<HostPage>() + let idlePages: Array<HostPage> = [] + let waitingForPage: Array<(page: Promise<HostPage>) => void> = [] + const openCounted = async (): Promise<HostPage> => { + pageCount++ + try { + const opened = await openHostPage() + allPages.add(opened) + return opened + } catch (error) { + pageCount-- + throw error + } + } + + /** The first page of the host (opened on first use). */ + const firstPage = async () => { + const [first] = allPages + if (first) { + return first.opened + } + const opened = await openCounted() + idlePages.push(opened) + return opened.opened + } + + /** A page no run holds (a new one while fewer than `hostPageLimit`). */ + const takePage = (): Promise<HostPage> => { + const idle = idlePages.shift() + if (idle) { + return Promise.resolve(idle) + } + if (pageCount < hostPageLimit) { + return openCounted() + } + return new Promise<Promise<HostPage>>((resolve) => + waitingForPage.push(resolve), + ).then((page) => page) + } + const givePage = (page: HostPage) => { + const next = waitingForPage.shift() + if (next) { + next(Promise.resolve(page)) + } else { + idlePages.push(page) + } + } + /** Closes a page; a run waiting for a page gets a new one. */ + const dropPage = (page: HostPage) => { + allPages.delete(page) + pageCount-- + void page.opened.close() + const next = waitingForPage.shift() + if (next) { + next(openCounted()) + } + } + /** Closes every page of the host. */ + const closePages = async () => { + const all = [...allPages] + allPages = new Set() + idlePages = [] + waitingForPage = [] + pageCount = 0 + for (const page of all) { + await page.opened.close() + } + } + + /** + * Runs page code on a page of the host the run holds alone (concurrent + * runs run on different pages), again on a fresh document if the page + * reloaded. `fresh`: reload the page first (a new document, no module + * instance kept). + */ + const runInHostPage = async <T>( + source: string, + runOptions: { fresh?: boolean } = {}, + ): Promise<ClientRun<T>> => { + const held = await takePage() + /** Whether the run's page was closed (a script that never settled). */ + const run = { dropped: false } + try { + const { opened, requests } = held + if (runOptions.fresh) { + await opened.page.reload() + } + let lastError: unknown + for (let attempt = 0; attempt < 3; attempt++) { + const loads = opened.loads() + const firstRequest = requests.length + const firstError = opened.errors.length + const firstConsole = opened.console.length + try { + let timer: ReturnType<typeof setTimeout> | undefined + const result = (await Promise.race([ + opened.page.evaluate(source), + new Promise((_, reject) => { + timer = setTimeout(() => { + // A script that never settles keeps the page busy: the next + // run gets a new page + run.dropped = true + dropPage(held) + reject( + new Error( + `the page run did not settle within ${pageRunTimeout} ms (the page is replaced)`, + ), + ) + }, pageRunTimeout) + }), + ]).finally(() => clearTimeout(timer))) as T + return { + result, + errors: opened.errors.slice(firstError), + console: opened.console.slice(firstConsole), + requests: requests + .slice(firstRequest) + .map((url) => appPath(url, origin())), + } + } catch (error) { + lastError = error + // A navigation destroys the run's context before the new document + // fires its load event + const navigated = + opened.loads() !== loads || + /Execution context was destroyed/.test((error as Error).message) + if (run.dropped || !navigated || previewState) { + const errors = opened.errors.slice(firstError) + throw new Error( + [ + `the page run failed: ${(error as Error).message}`, + `errors:\n${errors.join('\n') || '(none)'}`, + `console:\n${opened.console.slice(firstConsole).join('\n') || '(none)'}`, + ].join('\n'), + { cause: error }, + ) + } + // A reload (Vite pre-bundled a dependency the run discovered, or + // the dev server reloaded its pages): the document is new, so run + // again + await opened.page.waitForLoadState() + await host.dev.idle() + } + } + throw lastError + } finally { + if (!run.dropped) { + givePage(held) + } + } + } + + /** + * Runs `run` inside a real request of the app (the probe route, + * `request-probe.ts`), sent over HTTP to the dev or preview server. + */ + const inAppRequest = <T>( + run: (context?: ProbeContext) => T | Promise<T>, + ): Promise<T> => inProbeRequest((url) => fetch(new URL(url, baseUrl())), run) + + const devOnly = (what: string) => { + if (previewState || !serve) { + throw new Error(`${what} reads the dev server: not available on a build`) + } + } + + let cases = 0 + /** Whether the app changed from what its options give (edits, builds). */ + let changed = false + const createCase = async ( + files: Record<string, string>, + ): Promise<StartCase> => { + const dir = `${casesDir}/c${++cases}` + for (const [file, code] of Object.entries(files)) { + const absolute = path.join(root, dir, file) + await mkdir(path.dirname(absolute), { recursive: true }) + await writeFile(absolute, code) + } + const url = (file = 'module.tsx') => `/${dir}/${file}` + const caseFile = (file = 'module.tsx') => path.join(root, dir, file) + /** `./name` (and with its extension) of a case file at an app path. */ + const caseNames = (appFile: string): Array<string> => { + const prefix = `/${dir}/` + if (!appFile.startsWith(prefix)) { + return [] + } + const relative = appFile.slice(prefix.length) + const bare = relative.replace(/\.[cm]?[jt]sx?$/, '') + return [...new Set([`./${bare}`, `./${relative}`])] + } + /** Case files and packages a module graph reaches from `file`. */ + const graphLoads = (environment: 'client' | 'ssr', file: string) => { + const devEnvironment = host.dev.vite.environments[environment] + const graph = devEnvironment.moduleGraph + /** Packages by the file Vite's dependency optimizer bundled them to. */ + const optimized = new Map<string, string>() + const metadata = devEnvironment.depsOptimizer?.metadata + for (const deps of [metadata?.optimized, metadata?.discovered]) { + for (const [name, info] of Object.entries(deps ?? {})) { + optimized.set(path.resolve(info.file), name) + } + } + const start = graph.getModulesByFile(caseFile(file)) + const seen = new Set<unknown>() + const names = new Set<string>() + const queue = [...(start ?? [])] + while (queue.length > 0) { + const module = queue.shift()! + if (seen.has(module)) { + continue + } + seen.add(module) + for (const imported of module.importedModules) { + const id = imported.id ?? imported.url + const appFile = imported.file?.startsWith(root) + ? `/${path.relative(root, imported.file).split(path.sep).join('/')}` + : undefined + if (appFile) { + for (const name of caseNames(appFile)) { + names.add(name) + } + } + const optimizedName = imported.file + ? optimized.get(path.resolve(imported.file)) + : undefined + const pkg = optimizedName ?? packageOf(id) ?? bareSpecifierPackage(id) + if (pkg) { + names.add(pkg) + } else if (id.startsWith('\0') || !appFile) { + names.add(id) + } + queue.push(imported) + } + } + return names + } + /** The case file as a key of the build's case modules. */ + const buildKey = (file = 'module.tsx') => + `${dir.slice(casesDir.length + 1)}/${file}` + const startCase: StartCase = { + dir, + url, + file: caseFile, + served: async (file, environment = 'client') => { + devOnly('served()') + return host.transform(url(file), environment) + }, + ssr: async (file) => { + if (previewState) { + return inAppRequest((context) => context!.load(buildKey(file))) + } + return host.importServer(url(file), 'ssr') + }, + inRequest: (run) => inAppRequest(() => run()), + client: (script, clientOptions = {}) => + runInHostPage( + `(async () => { +${pagePrelude} +const load = ${ + previewState + ? `(file) => window.__harnessCases[${JSON.stringify(`../cases/${dir.slice(casesDir.length + 1)}/`)} + file]()` + : `(file) => import(${JSON.stringify(`/${dir}/`)} + file)` + } +const module = await load(${JSON.stringify(clientOptions.file ?? 'module.tsx')}) +${script} +})()`, + { fresh: clientOptions.fresh }, + ), + loads: async (file = 'module.tsx') => { + devOnly('loads()') + const run = await runInHostPage<{ error?: string; fatal?: boolean }>( + `(async () => { +try { + await import(${JSON.stringify(url(file))}) + return {} +} catch (error) { + // A module that did not compile, parse or link never ran: no outcome. + // A throw of a module's own code is one of its loads. + const fatal = error instanceof SyntaxError || /Failed to fetch dynamically imported module|error loading dynamically imported module/.test(String(error && error.message)) + return { error: String(error && (error.stack || error.message)), fatal } +} +})()`, + ) + if (run.result.fatal) { + throw new Error( + `${url(file)} did not load in the page: ${run.result.error}\n${run.errors.join('\n')}`, + ) + } + const names = new Set<string>() + for (const request of run.requests) { + for (const name of caseNames(request)) { + names.add(name) + } + } + for (const name of graphLoads('client', file)) { + names.add(name) + } + names.delete(`./${file.replace(/\.[cm]?[jt]sx?$/, '')}`) + names.delete(`./${file}`) + return [...names] + }, + diagnostics: () => + previewState ? previewState.build.diagnostics : host.diagnostics, + serverLoads: async (file = 'module.tsx') => { + devOnly('serverLoads()') + // A module the SSR environment cannot compile has no outcome (its + // graph would be empty): that fails, as in `loads()`. A throw of the + // module's own code still counts. + await host.transform(url(file), 'ssr') + await host.importServer(url(file), 'ssr').catch(() => {}) + const names = graphLoads('ssr', file) + names.delete(`./${file.replace(/\.[cm]?[jt]sx?$/, '')}`) + names.delete(`./${file}`) + return [...names] + }, + } + return startCase + } + + return { + root, + framework, + host, + get diagnostics() { + return host.diagnostics + }, + case: createCase, + reusable: () => !changed, + run: (source, runOptions) => runInHostPage(source, runOptions), + edit: async (files) => { + changed = true + if (cases > 0) { + // The dev server's settle owes an event to every app file the + // watcher has not reported, and it never reports the (ignored) + // case directories + throw new Error( + 'edit() on a host that has cases: use a host of its own for dev edits (files on disk before it starts, edits outside src/cases)', + ) + } + await host.edit(files) + }, + build: (buildOptions) => { + changed = true + return host.build(buildOptions) + }, + preview: async (previewOptions = {}) => { + changed = true + if (serve) { + throw new Error('preview() needs a host created with `serve: false`') + } + if (framework !== 'react') { + throw new Error( + `preview() serves React apps (not ${framework}): use build()`, + ) + } + if (previewState && previewOptions.rebuild) { + const previous = previewState + previewState = undefined + await closePages() + await previous.server.close() + outDirName = `dist-${++builds}` + } + if (previewState) { + return { build: previewState.build, url: previewState.url } + } + const build = await host.build() + const server = await vitePreview( + mergeConfig( + { + root, + configFile: false, + envDir: false, + publicDir: false, + logLevel: 'silent', + plugins: [ + absoluteOutDir(root, () => outDirName), + startFactory(startOptions), + ...frameworkPlugins(framework, options), + ...userPlugins, + ], + preview: { port: 0, host: '127.0.0.1' }, + } satisfies InlineConfig, + options.config ?? {}, + ), + ) + const url = server.resolvedUrls?.local[0] + if (!url) { + await server.close() + throw new Error('the preview server has no local URL') + } + previewState = { server, url, build } + return { build, url } + }, + page: firstPage, + devSupportTouches: async () => { + if (!previewState) { + throw new Error( + 'devSupportTouches() reads the production page: call preview() first', + ) + } + await firstPage() + const touches: Array<string> = [] + for (const { opened } of allPages) { + touches.push( + ...(await opened.page.evaluate( + () => + ( + window as unknown as { + __harnessDevSupportTouches: Array<string> + } + ).__harnessDevSupportTouches, + )), + ) + } + return touches + }, + close: async () => { + try { + await closePages() + } finally { + try { + await previewState?.server.close() + } finally { + await host.close() + } + } + }, + } +} + +/** + * Free hosts of this test process, by their options (`hostKey`), for later + * test files: a project that keeps its modules across test files + * (`isolate: false`) starts a host once per worker and options, not once per + * file. Each case of a host has its own directory and URLs, so module + * instances never carry over from one file's cases to another's; a host + * whose app changed (an edit, a build) is closed instead. What a host + * reported before a file is that file's to mark (`diagnostics.length`). + */ +const freeHosts = new Map<string, Array<StartHost>>() + +/** Free hosts a test process keeps, at most. */ +const freeHostLimit = 4 + +/** + * The options of a host as a key, when they are plain data (no plugins, no + * functions): only those hosts are shared between files. + */ +export function hostKey(value: unknown): string | undefined { + const found = { function: false } + const key = JSON.stringify(value, (_, item: unknown) => { + if (typeof item === 'function') { + found.function = true + } + return item + }) + return found.function ? undefined : key +} + +/** A free host of these options, or a new one (`start`). */ +export async function takeHost<T extends { close: () => Promise<void> }>( + key: string | undefined, + start: () => Promise<T>, +): Promise<T> { + const free = key === undefined ? undefined : freeHosts.get(key)?.pop() + return (free as T | undefined) ?? start() +} + +/** Gives a host back for later files (or closes it, see `freeHosts`). */ +export async function giveBackHost( + key: string | undefined, + host: { close: () => Promise<void>; reusable?: () => boolean }, +) { + if (key === undefined || host.reusable?.() === false) { + await host.close() + return + } + const list = freeHosts.get(key) ?? [] + list.push(host as StartHost) + freeHosts.set(key, list) + freeOrder.push({ key, host }) + while (freeOrder.length > freeHostLimit) { + const oldest = freeOrder.shift()! + const left = freeHosts.get(oldest.key) + const index = left?.indexOf(oldest.host as StartHost) ?? -1 + if (index !== -1) { + left!.splice(index, 1) + await oldest.host.close() + } + } +} +const freeOrder: Array<{ + key: string + host: { close: () => Promise<void> } +}> = [] + +/** + * One Start host per test file and options (`createStartHost`), taken before + * the file's tests (a free one an earlier file of the process gave back, or + * a new one) and given back after them. Returns the host getter. + */ +export function useStartHost( + options: StartHostOptions = {}, +): () => Promise<StartHost> { + const key = hostKey(options) + let started: Promise<StartHost> | undefined + beforeAll(() => { + started = takeHost(key, () => createStartHost(options)) + return started.then(() => {}) + }, 60_000) + afterAll(async () => { + const host = await started?.catch(() => undefined) + if (host) { + await giveBackHost(key, host) + } + }) + return () => { + if (!started) { + throw new Error('useStartHost: no host before beforeAll ran') + } + return started + } +} + +/** + * The hosts of a test file by framework, taken on first use and given back + * after the file's tests (a file whose cases run under several frameworks). + */ +export function useStartHosts( + options: Omit<StartHostOptions, 'framework'> = {}, +): (framework?: StartFramework) => Promise<StartHost> { + const started = new Map<StartFramework, Promise<StartHost>>() + const keyOf = (framework: StartFramework) => + hostKey({ ...options, framework }) + afterAll(async () => { + for (const [framework, host] of started) { + const resolved = await host.catch(() => undefined) + if (resolved) { + await giveBackHost(keyOf(framework), resolved) + } + } + }) + return (framework = 'react') => { + let host = started.get(framework) + if (!host) { + host = takeHost(keyOf(framework), () => + createStartHost({ ...options, framework }), + ) + started.set(framework, host) + } + return host + } +} diff --git a/packages/start-plugin-core/tests/start-plugins.ts b/packages/start-plugin-core/tests/start-plugins.ts new file mode 100644 index 0000000000..2b15785fc4 --- /dev/null +++ b/packages/start-plugin-core/tests/start-plugins.ts @@ -0,0 +1,191 @@ +/** + * Start's plugins as an app configures them: `tanstackStart(options)` of the + * built framework package (`@tanstack/<framework>-start/plugin/vite` or + * `/plugin/rsbuild`), resolved through the package's `exports` as an app's + * `vite.config.ts` or `rsbuild.config.ts` resolves it. The framework package + * passes Start's plugin its own options (framework, default entries, server + * fn provider) and adds its own configuration (React's `dedupe`, externals + * and pre-bundling, Solid's resolve conditions); the harnesses never pass + * Start's plugin anything an app cannot. + * + * A harness gives an app its entries through Start's documented options + * (`client.entry`, `server.entry`, relative to the source directory), and + * only those the app does not have itself (`src/client.*`, `src/server.*`): + * Start then uses the app's own, as in any app. + */ +import { existsSync, readFileSync, readdirSync } from 'node:fs' +import { createRequire } from 'node:module' +import path from 'node:path' +import { pathToFileURL } from 'node:url' +import { resolveModulePath } from 'exsolve' +import { workspacePackage } from '@tanstack/compiler-test-utils/workspace-packages' +import type { RsbuildPlugin } from '@rsbuild/core' +import type { PluginOption } from 'vite' + +/** The Start framework packages an app can use. */ +export type StartFramework = 'react' | 'solid' | 'vue' + +/** + * The options of `tanstackStart()` (the documented Start plugin options), as + * a test passes them. + */ +export type StartPluginOptions = Record<string, unknown> + +export const startPackages: Record<StartFramework, string> = { + react: '@tanstack/react-start', + solid: '@tanstack/solid-start', + vue: '@tanstack/vue-start', +} + +type ViteFactory = (options?: StartPluginOptions) => Array<PluginOption> +type RsbuildFactory = (options?: StartPluginOptions) => RsbuildPlugin + +const factories = new Map<string, Promise<unknown>>() + +/** + * `tanstackStart` of the built `@tanstack/<framework>-start/plugin/<bundler>`, + * resolved through the package's `exports`. + */ +function factory( + framework: StartFramework, + bundler: 'vite' | 'rsbuild', +): Promise<unknown> { + const key = `${framework}/${bundler}` + let loaded = factories.get(key) + if (!loaded) { + const pkg = startPackages[framework] + loaded = import( + pathToFileURL( + resolveModulePath(`${pkg}/plugin/${bundler}`, { + from: `${workspacePackage(pkg)}/`, + conditions: ['import', 'node', 'default'], + }), + ).href + ).then((module: { tanstackStart: unknown }) => module.tanstackStart) + factories.set(key, loaded) + } + return loaded +} + +/** `tanstackStart` of `@tanstack/<framework>-start/plugin/vite`. */ +export function startPluginFactory( + framework: StartFramework, +): Promise<ViteFactory> { + return factory(framework, 'vite') as Promise<ViteFactory> +} + +/** `tanstackStart` of `@tanstack/<framework>-start/plugin/rsbuild`. */ +export function startRsbuildPluginFactory( + framework: StartFramework, +): Promise<RsbuildFactory> { + return factory(framework, 'rsbuild') as Promise<RsbuildFactory> +} + +/** Entries a harness gives an app that has none of its own (absolute). */ +export interface HarnessEntries { + client?: string + server?: string +} + +/** + * The app's Start options with the harness's entries (`client.entry`, + * `server.entry`, relative to the app's source directory) where neither the + * test's options nor the app (a `<srcDirectory>/client.*` or `server.*` + * file, which Start finds by itself) give one. + */ +export function withHarnessEntries( + root: string, + start: StartPluginOptions, + entries: HarnessEntries, +): StartPluginOptions { + const srcDir = path.resolve( + root, + typeof start.srcDirectory === 'string' ? start.srcDirectory : 'src', + ) + const own = existsSync(srcDir) ? readdirSync(srcDir) : [] + const options: StartPluginOptions = { ...start } + for (const name of ['client', 'server'] as const) { + const entry = entries[name] + const configured = start[name] as { entry?: unknown } | undefined + if ( + !entry || + configured?.entry !== undefined || + own.some((file) => new RegExp(`^${name}\\.[cm]?[jt]sx?$`).test(file)) + ) { + continue + } + options[name] = { + ...configured, + entry: path.relative(srcDir, entry), + } + } + return options +} + +/** + * Start's Vite plugins of an app: `tanstackStart()` of the framework + * package, with the harness's entries where the app has none + * (`withHarnessEntries`). + */ +export async function startPlugins( + framework: StartFramework, + root: string, + start: StartPluginOptions = {}, + entries: HarnessEntries = {}, +): Promise<Array<PluginOption>> { + const tanstackStart = await startPluginFactory(framework) + return tanstackStart(withHarnessEntries(root, start, entries)) +} + +/** Start's Rsbuild plugin of an app (see `startPlugins`). */ +export async function startRsbuildPlugin( + framework: StartFramework, + root: string, + start: StartPluginOptions = {}, + entries: HarnessEntries = {}, +): Promise<RsbuildPlugin> { + const tanstackStart = await startRsbuildPluginFactory(framework) + return tanstackStart(withHarnessEntries(root, start, entries)) +} + +/** + * The file a package's `package.json` exports for `subpath` (its `import` + * condition), as Node resolves an app's import of it. + */ +function exportedFile(root: string, subpath: string): string { + const manifest = JSON.parse( + readFileSync(path.join(root, 'package.json'), 'utf8'), + ) as { + exports: Record<string, string | { import?: unknown; default?: unknown }> + } + const entry = manifest.exports[subpath]! + const target = + typeof entry === 'string' + ? entry + : typeof entry.import === 'string' + ? entry.import + : ((entry.import as { default?: string } | undefined)?.default ?? + (entry.default as string)) + return path.join(root, target) +} + +/** A dependency of `@tanstack/react-start-rsc`, by its package root. */ +export function rscDependency(name: string): string { + const rscPackage = workspacePackage('@tanstack/react-start-rsc') + return path.dirname( + createRequire(path.join(rscPackage, 'package.json')).resolve( + `${name}/package.json`, + ), + ) +} + +/** + * Vite's RSC plugin (`@vitejs/plugin-rsc`, as `@tanstack/react-start-rsc` + * installs it). + */ +export async function rscPluginFactory(): Promise<() => PluginOption> { + const { default: rsc } = (await import( + pathToFileURL(exportedFile(rscDependency('@vitejs/plugin-rsc'), '.')).href + )) as { default: () => PluginOption } + return rsc +} diff --git a/packages/start-plugin-core/tests/validate-module.ts b/packages/start-plugin-core/tests/validate-module.ts deleted file mode 100644 index 4e0884a436..0000000000 --- a/packages/start-plugin-core/tests/validate-module.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { stripVTControlCharacters } from 'node:util' -import { parseSync, transformWithOxc } from 'vite' - -/** - * Validates generated code the way a browser or bundler sees it, without using - * the compiler's own parser: erase TypeScript (keeping every value import) and - * parse the result as a JavaScript module with semantic checks. This rejects - * syntax errors, nameless function/class declarations, duplicate bindings - * (including an import redeclared by a local declaration) and exports of - * undeclared bindings. - * - * @returns the error messages; an empty array means the module is valid. - */ -export async function getModuleErrors( - code: string, - filename = 'module.tsx', -): Promise<Array<string>> { - let javascript: string - try { - const result = await transformWithOxc(code, filename, { - jsx: 'preserve', - typescript: { onlyRemoveTypeImports: true }, - }) - javascript = result.code - } catch (error) { - return [stripVTControlCharacters((error as Error).message)] - } - const { errors } = parseSync('module.jsx', javascript, { - sourceType: 'module', - showSemanticErrors: true, - }) - return errors.map((error) => error.message) -} - -/** Matches a declaration of `name` in generated code, however it is printed. */ -export function declarationOf(name: string): RegExp { - return new RegExp(String.raw`\b(?:const|let|var|function|class)\s+${name}\b`) -} diff --git a/packages/start-plugin-core/tests/vite/module-id.test.ts b/packages/start-plugin-core/tests/vite/module-id.test.ts deleted file mode 100644 index 003926a606..0000000000 --- a/packages/start-plugin-core/tests/vite/module-id.test.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - appendIdQueryFlag, - hasIdQueryFlag, - removeIdQueryFlag, -} from '../../src/vite/module-id' - -const flag = 'server-fn-module-lookup' - -describe('hasIdQueryFlag', () => { - test.each([ - ['/src/route.ts', false], - [`/src/route.ts?${flag}`, true], - [`/src/route.ts?mode=dev&${flag}`, true], - [`/src/route.ts?${flag}=enabled`, true], - [`/src/route.ts?mode=${flag}`, false], - [`/src/route.ts?${flag}-suffix`, false], - ])('checks the query parameter name in %s', (id, expected) => { - expect(hasIdQueryFlag(id, flag)).toBe(expected) - }) -}) - -describe('appendIdQueryFlag', () => { - test.each([ - ['/src/route.ts', `/src/route.ts?${flag}`], - ['/src/route.ts?mode=dev', `/src/route.ts?mode=dev&${flag}`], - ['/src/route.ts?', `/src/route.ts?&${flag}`], - ['/src/route.ts?mode=dev&', `/src/route.ts?mode=dev&${flag}`], - ])('appends the flag to %s', (id, expected) => { - expect(appendIdQueryFlag(id, flag)).toBe(expected) - }) -}) - -describe('removeIdQueryFlag', () => { - test.each([ - [`/src/route.ts?${flag}`, '/src/route.ts'], - [`/src/route.ts?mode=dev&${flag}`, '/src/route.ts?mode=dev'], - [`/src/route.ts?${flag}&mode=dev`, `/src/route.ts?${flag}&mode=dev`], - ['/src/route.ts?mode=dev', '/src/route.ts?mode=dev'], - ])('removes only an appended flag from %s', (id, expected) => { - expect(removeIdQueryFlag(id, flag)).toBe(expected) - }) -}) - -describe('module ID query flag round trip', () => { - test.each([ - '/src/route.ts', - '/src/route.ts?', - '/src/route.ts?variant=client', - '\0virtual:factory?variant=client&encoded=a%2Fb', - `/src/route.ts?${flag}`, - ])('preserves the original ID %s', (id) => { - const withFlag = appendIdQueryFlag(id, flag) - expect(removeIdQueryFlag(withFlag, flag)).toBe(id) - }) -}) diff --git a/packages/start-plugin-core/tests/vite/start-compiler-utils.test.ts b/packages/start-plugin-core/tests/vite/start-compiler-utils.test.ts deleted file mode 100644 index bf028a483e..0000000000 --- a/packages/start-plugin-core/tests/vite/start-compiler-utils.test.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { describe, expect, test } from 'vitest' -import { - createViteDevServerFnModuleSpecifierEncoder, - decodeViteDevServerModuleSpecifier, -} from '../../src/vite/start-compiler-plugin/module-specifier' -import { mergeHotUpdateModules } from '../../src/vite/start-compiler-plugin/hot-update' -import type { EnvironmentModuleNode } from 'vite' - -describe('Vite dev server module specifiers', () => { - test('encodes app files as root-relative dev server paths', () => { - const encode = createViteDevServerFnModuleSpecifierEncoder('/repo/app') - - const specifier = encode({ - extractedFilename: '/repo/app/src/routes/index.tsx', - root: '/repo/app', - }) - - expect(specifier).toBe('/src/routes/index.tsx') - expect(decodeViteDevServerModuleSpecifier(specifier)).toBe( - 'src/routes/index.tsx', - ) - }) - - test('preserves POSIX absolute /@fs paths outside the app root', () => { - const encode = createViteDevServerFnModuleSpecifierEncoder('/repo/app') - - const specifier = encode({ - extractedFilename: '/repo/shared/server-fn.ts', - root: '/repo/app', - }) - - expect(specifier).toBe('/@fs/repo/shared/server-fn.ts') - expect(decodeViteDevServerModuleSpecifier(`${specifier}?x=1`)).toBe( - '/repo/shared/server-fn.ts', - ) - }) - - test('preserves Windows drive-letter /@fs paths', () => { - const encode = createViteDevServerFnModuleSpecifierEncoder('C:/repo/app') - - const specifier = encode({ - extractedFilename: 'D:/repo/shared/server-fn.ts', - root: 'C:/repo/app', - }) - - expect(specifier).toBe('/@fs/D:/repo/shared/server-fn.ts') - expect(decodeViteDevServerModuleSpecifier(`${specifier}?x=1`)).toBe( - 'D:/repo/shared/server-fn.ts', - ) - }) -}) - -describe('mergeHotUpdateModules', () => { - test('returns undefined when no extra modules were added', () => { - const current = [{ id: '/src/route.tsx' }] as Array<EnvironmentModuleNode> - - expect(mergeHotUpdateModules(current, [])).toBeUndefined() - }) - - test('keeps native Vite modules and appends extra modules without duplicates', () => { - const route = { id: '/src/route.tsx' } as EnvironmentModuleNode - const provider = { - id: '/src/route.tsx?tss-serverfn-split', - } as EnvironmentModuleNode - - expect(mergeHotUpdateModules([route], [route, provider])).toEqual([ - route, - provider, - ]) - }) -}) diff --git a/packages/start-plugin-core/vite.config.ts b/packages/start-plugin-core/vite.config.ts index 0b33045be3..6fe6ef2b4c 100644 --- a/packages/start-plugin-core/vite.config.ts +++ b/packages/start-plugin-core/vite.config.ts @@ -1,37 +1,111 @@ +import path from 'node:path' +import os from 'node:os' +import { fileURLToPath } from 'node:url' import { configDefaults, defineConfig, mergeConfig } from 'vitest/config' import { tanstackViteConfig } from '@tanstack/vite-config' import packageJson from './package.json' +// Main's tests of features that are not compilers (Start manifest, sitemap, +// prerender, config schema, entries, build output, dev styles), at main's +// paths and unchanged: `test:noncompiler` runs them; the compiler test +// projects and ESLint leave them out. Paths relative to `tests/`. +import noncompilerTests from './tests/noncompiler-tests.json' with { type: 'json' } -/** The build output (`dist`) of this package and `@tanstack/react-start`. */ -const builtStartPackages = - /\/packages\/(?:start-plugin-core|react-start)\/dist\// +// Under Vitest: Node's compile cache for the test workers and the child +// Node runs they start (the harness passes this environment on). No outcome +// change; less time compiling the bundlers, jsdom and the built apps again. +if (process.env.VITEST) { + process.env.NODE_COMPILE_CACHE ??= path.join( + os.tmpdir(), + 'node-compile-cache', + ) +} + +/** This package's build output (`dist`), as its `exports` name it. */ +const builtPackage = new RegExp( + `^${path.join(path.dirname(fileURLToPath(import.meta.url)), 'dist').replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}/`, +) const config = defineConfig({ test: { name: packageJson.name, dir: './tests', watch: false, + // At most 4 test processes per Vitest run (measured): each + // runs real bundlers, dev servers and its own browser, and Nx runs several + // packages' tiers at once. More workers add swap and load flakes, not + // speed. `--maxWorkers` on the command line still overrides it. + maxWorkers: 4, + reporters: ['default', '@tanstack/compiler-test-utils/budget-reporter'], + globalSetup: ['@tanstack/compiler-test-utils/run-directory'], + setupFiles: [ + '@tanstack/compiler-test-utils/test-scope-setup', + '@tanstack/compiler-test-utils/pins-setup', + ], projects: [ { - // `test:unit` extends: true, test: { - name: 'unit', - exclude: [...configDefaults.exclude, 'integration/**'], + name: 'noncompiler', + include: noncompilerTests, typecheck: { enabled: true }, }, }, { - // `test:integration`: real builds and dev servers of Start apps - // (`tests/integration/start-app.ts`), with the built Start packages. - // Node loads them, as it loads an installed package, so the plugin - // and the loaders Rspack loads from the same `dist` share one module - // instance. + // Fast tier (`test:unit`): compiles and evaluates in process; a Vite + // dev server in middleware mode is allowed. + extends: true, + test: { + name: 'unit', + // A test process keeps its browser and the hosts a file gives + // back for later files (`useStartHost`; see `start-host.ts`) + isolate: false, + exclude: [ + ...configDefaults.exclude, + 'integration/**', + ...noncompilerTests, + ], + typecheck: { enabled: true }, + }, + }, + { + // Slow tier (`test:integration`): real builds, Rsbuild dev servers, + // child Node runs and browsers. extends: true, test: { name: 'integration', + // A test process keeps its modules (and its browser) across test + // files; the setup file gives each file the environment it + // started with (see `test-scope-setup`) + isolate: false, include: ['integration/**/*.test.ts'], - server: { deps: { external: [builtStartPackages] } }, + exclude: [...configDefaults.exclude, 'integration/pages/**'], + testTimeout: 30_000, + hookTimeout: 30_000, + // The tests import this package's built public entries + // (`@tanstack/start-plugin-core/vite`, `/rsbuild`): Node loads + // them, as it loads an installed package, so the plugin and the + // loaders Rspack loads from the same `dist` share one module + // instance. + server: { deps: { external: [builtPackage] } }, + }, + }, + { + // Slow tier too (`test:integration` runs both projects): `<Hydrate>` + // cases rendered and hydrated in pages of the Start host + // (`render.ts`), as the fast tier runs them, whose cost does not fit + // the fast tier's budget. The tests of a file run concurrently: each + // case has its own directory of the file's host, and each page run + // holds one of the host's pages alone (`start-host.ts`). A test + // process keeps its browser and the hosts a file gives back for + // later files (`isolate: false`). + extends: true, + test: { + name: 'integration-pages', + include: ['integration/pages/**/*.test.ts'], + sequence: { concurrent: true }, + isolate: false, + testTimeout: 30_000, + hookTimeout: 60_000, }, }, ], diff --git a/packages/start-server-core/CHANGELOG.md b/packages/start-server-core/CHANGELOG.md index fe54531e58..dc58d1672e 100644 --- a/packages/start-server-core/CHANGELOG.md +++ b/packages/start-server-core/CHANGELOG.md @@ -1,16 +1,5 @@ # @tanstack/start-server-core -## 1.169.45 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/start-client-core@1.170.39 - - @tanstack/start-storage-context@1.167.41 - ## 1.169.44 ### Patch Changes diff --git a/packages/start-server-core/package.json b/packages/start-server-core/package.json index 020747da69..dd11125a4a 100644 --- a/packages/start-server-core/package.json +++ b/packages/start-server-core/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/start-server-core", - "version": "1.169.45", + "version": "1.169.44", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/start-static-server-functions/CHANGELOG.md b/packages/start-static-server-functions/CHANGELOG.md index 9e64280e30..49924f602e 100644 --- a/packages/start-static-server-functions/CHANGELOG.md +++ b/packages/start-static-server-functions/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/start-static-server-functions -## 1.167.44 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/react-start@1.169.4 - - @tanstack/solid-start@1.169.4 - - @tanstack/start-client-core@1.170.39 - ## 1.167.43 ### Patch Changes diff --git a/packages/start-static-server-functions/package.json b/packages/start-static-server-functions/package.json index 603d7524fb..e4db81cc93 100644 --- a/packages/start-static-server-functions/package.json +++ b/packages/start-static-server-functions/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/start-static-server-functions", - "version": "1.167.44", + "version": "1.167.43", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/start-storage-context/CHANGELOG.md b/packages/start-storage-context/CHANGELOG.md index c8669ed975..981359454f 100644 --- a/packages/start-storage-context/CHANGELOG.md +++ b/packages/start-storage-context/CHANGELOG.md @@ -1,12 +1,5 @@ # @tanstack/start-storage-context -## 1.167.41 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - ## 1.167.40 ### Patch Changes diff --git a/packages/start-storage-context/package.json b/packages/start-storage-context/package.json index 083facb749..2c050d2ed1 100644 --- a/packages/start-storage-context/package.json +++ b/packages/start-storage-context/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/start-storage-context", - "version": "1.167.41", + "version": "1.167.40", "description": "Modern and scalable routing for React applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/vue-router-devtools/CHANGELOG.md b/packages/vue-router-devtools/CHANGELOG.md index ff72e56c32..275c8c9d48 100644 --- a/packages/vue-router-devtools/CHANGELOG.md +++ b/packages/vue-router-devtools/CHANGELOG.md @@ -1,12 +1,5 @@ # @tanstack/vue-router-devtools -## 1.167.3 - -### Patch Changes - -- Updated dependencies [[`bbf9b75`](https://github.com/TanStack/router/commit/bbf9b75808d8eee497a6dd1663f0cf08426512e0)]: - - @tanstack/router-devtools-core@1.168.3 - ## 1.167.2 ### Patch Changes diff --git a/packages/vue-router-devtools/package.json b/packages/vue-router-devtools/package.json index 411dd289be..4c8405dca7 100644 --- a/packages/vue-router-devtools/package.json +++ b/packages/vue-router-devtools/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-router-devtools", - "version": "1.167.3", + "version": "1.167.2", "description": "Modern and scalable routing for Vue applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/vue-router/CHANGELOG.md b/packages/vue-router/CHANGELOG.md index a9cdeb2b70..b407cbeea9 100644 --- a/packages/vue-router/CHANGELOG.md +++ b/packages/vue-router/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/vue-router -## 1.170.42 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - ## 1.170.41 ### Patch Changes diff --git a/packages/vue-router/package.json b/packages/vue-router/package.json index 93ae8fdeed..afe096a8d9 100644 --- a/packages/vue-router/package.json +++ b/packages/vue-router/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-router", - "version": "1.170.42", + "version": "1.170.41", "description": "Modern and scalable routing for Vue applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/vue-start-client/CHANGELOG.md b/packages/vue-start-client/CHANGELOG.md index 334da56ce7..b0924bcbd4 100644 --- a/packages/vue-start-client/CHANGELOG.md +++ b/packages/vue-start-client/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/vue-start-client -## 1.167.45 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/start-client-core@1.170.39 - - @tanstack/vue-router@1.170.42 - ## 1.167.44 ### Patch Changes diff --git a/packages/vue-start-client/package.json b/packages/vue-start-client/package.json index 74b8016924..ad6baefdaf 100644 --- a/packages/vue-start-client/package.json +++ b/packages/vue-start-client/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-start-client", - "version": "1.167.45", + "version": "1.167.44", "description": "Modern and scalable routing for Vue applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/vue-start-server/CHANGELOG.md b/packages/vue-start-server/CHANGELOG.md index 0963c82fe8..94b2d30c30 100644 --- a/packages/vue-start-server/CHANGELOG.md +++ b/packages/vue-start-server/CHANGELOG.md @@ -1,14 +1,5 @@ # @tanstack/vue-start-server -## 1.167.50 - -### Patch Changes - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c)]: - - @tanstack/router-core@1.171.39 - - @tanstack/start-server-core@1.169.45 - - @tanstack/vue-router@1.170.42 - ## 1.167.49 ### Patch Changes diff --git a/packages/vue-start-server/package.json b/packages/vue-start-server/package.json index 4fc4c1c9fd..32290dc5ba 100644 --- a/packages/vue-start-server/package.json +++ b/packages/vue-start-server/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-start-server", - "version": "1.167.50", + "version": "1.167.49", "description": "Modern and scalable routing for Vue applications", "author": "Tanner Linsley", "license": "MIT", diff --git a/packages/vue-start/CHANGELOG.md b/packages/vue-start/CHANGELOG.md index 2e781d8694..50669dce0e 100644 --- a/packages/vue-start/CHANGELOG.md +++ b/packages/vue-start/CHANGELOG.md @@ -1,37 +1,5 @@ # @tanstack/vue-start -## 1.169.6 - -### Patch Changes - -- Updated dependencies [[`3f22686`](https://github.com/TanStack/router/commit/3f226869e0af211ff7f1de5d7343e43462dbb101), [`559c7de`](https://github.com/TanStack/router/commit/559c7ded6e2a6eeda3f91c80d8c03f4cfeb9a206)]: - - @tanstack/start-plugin-core@1.171.57 - -## 1.169.5 - -### Patch Changes - -- [#8863](https://github.com/TanStack/router/pull/8863) [`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c) - The Rsbuild plugin keeps the app's `server.compress` setting instead of always setting it to `false`. Compression stays off by default: a compressed streamed page reaches the browser only once the stream ends. The optional `@rsbuild/core` peer is now `^2.0.5`, the first version whose compression keeps SSR response headers intact. - -- [#8869](https://github.com/TanStack/router/pull/8869) [`d05c6c6`](https://github.com/TanStack/router/commit/d05c6c66e7efc659286f37a56b3b1d4d267139e7) - Vite dev: Vue Start pre-bundles `@tanstack/vue-router > @tanstack/vue-store`, as React Start does for `@tanstack/react-store`. The first page load on a cold dependency cache no longer re-optimizes `vue` and reloads the page. - -- Updated dependencies [[`01fab5a`](https://github.com/TanStack/router/commit/01fab5a6c8aed70d61d82c64bc344cbac66c240c), [`c5320d7`](https://github.com/TanStack/router/commit/c5320d7ca23eca82d720ac5629d2bad5cf7d9b02), [`545a8d3`](https://github.com/TanStack/router/commit/545a8d3790989ca502153c3292c6b1e8063257f4), [`da8c28c`](https://github.com/TanStack/router/commit/da8c28c498230a5730ce75b2693baeeb3ef68ac1)]: - - @tanstack/start-plugin-core@1.171.56 - -## 1.169.4 - -### Patch Changes - -- [#8670](https://github.com/TanStack/router/pull/8670) [`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c) - Reference agent skills in other packages by their `intent load` identifier (`@tanstack/<package>#<skill>`) instead of relative file links that break once packages are installed. - -- Updated dependencies [[`32a3360`](https://github.com/TanStack/router/commit/32a3360cba0e0f884b3215813a48c63467f5a53c), [`ed55775`](https://github.com/TanStack/router/commit/ed5577593a749b8c7193cc7b5d945fd084bfac2f), [`63a886d`](https://github.com/TanStack/router/commit/63a886da9040c4b039ea3bf5b3a841771375cddb), [`d9b07e8`](https://github.com/TanStack/router/commit/d9b07e8d3b724cdbfac0aa2fba4c1f7a3a241100)]: - - @tanstack/start-client-core@1.170.39 - - @tanstack/start-server-core@1.169.45 - - @tanstack/vue-router@1.170.42 - - @tanstack/start-plugin-core@1.171.55 - - @tanstack/vue-start-client@1.167.45 - - @tanstack/vue-start-server@1.167.50 - ## 1.169.3 ### Patch Changes diff --git a/packages/vue-start/package.json b/packages/vue-start/package.json index bf6b79e636..0f02fe5763 100644 --- a/packages/vue-start/package.json +++ b/packages/vue-start/package.json @@ -1,6 +1,6 @@ { "name": "@tanstack/vue-start", - "version": "1.169.6", + "version": "1.169.3", "description": "Modern and scalable routing for Vue applications", "author": "Tanner Linsley", "license": "MIT", @@ -135,7 +135,7 @@ "rimraf": "catalog:" }, "peerDependencies": { - "@rsbuild/core": "^2.0.5", + "@rsbuild/core": "^2.0.0", "vite": ">=8.0.0", "vue": "^3.3.0" }, diff --git a/packages/vue-start/src/plugin/vite.ts b/packages/vue-start/src/plugin/vite.ts index d257ce7256..4af970a088 100644 --- a/packages/vue-start/src/plugin/vite.ts +++ b/packages/vue-start/src/plugin/vite.ts @@ -39,14 +39,6 @@ export function tanstackStart( '@tanstack/vue-router', '@tanstack/start-static-server-functions', ], - include: [ - // `@tanstack/vue-router` is excluded, so the scanner never - // sees its `@tanstack/vue-store` import; discovered while - // crawling, it imports `vue` and re-chunks the already - // optimized `vue`, which forces a full page reload on - // every cold start (and loses an in-flight page load). - '@tanstack/vue-router > @tanstack/vue-store', - ], } : undefined, } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4328f4fab6..bd72ae7f6a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,161 +1,3 @@ ---- -lockfileVersion: '9.0' - -importers: - - .: - configDependencies: {} - packageManagerDependencies: - pnpm: - specifier: 12.18.0 - version: 12.18.0 - -packages: - - '@pnpm/exe.android-arm64@12.18.0': - resolution: {integrity: sha512-fOF6IwgvnUKEmVedGqiAsNPfN2Ry8GvaqzSQOiF3RJFbpBfPKO/6YT54s1GjToyYinRxw9preHHPe4y2N3SzhA==} - cpu: [arm64] - os: [android] - - '@pnpm/exe.android-x64@12.18.0': - resolution: {integrity: sha512-6OiolnaCsB3/GcJ9XNrenbUH3zFHRJ+5QynrMUUEyThbgnnCzWxa199hpQlOmxN4rAXuYQ0IYgWFNUZxyzg31Q==} - cpu: [x64] - os: [android] - - '@pnpm/exe.darwin-arm64@12.18.0': - resolution: {integrity: sha512-zkq+4YzVIX39ETYLyC3W7LY7MpHEU/J3nRhHl4i2yPld2Cf2+rEKRh3ejJ4AmaQ77HHJLCktY4Z3jq0fpcxFXg==} - cpu: [arm64] - os: [darwin] - - '@pnpm/exe.darwin-x64@12.18.0': - resolution: {integrity: sha512-qMsL9qx92unOTa6hgkfiTJv8ceZaTx0IQg7InhYDVX2ZrTECujaVEEVypnJK5m3eGUsP1KD7Y4qIgleCwfRsYw==} - cpu: [x64] - os: [darwin] - - '@pnpm/exe.freebsd-x64@12.18.0': - resolution: {integrity: sha512-/9vy/4ms52cU4MjZ5NhHd6N2d9L9W0kARf5/ff2tweAHu0VeUzs/0qp/7ZHFuddm2Wa/m0AKQoPum9AVUCqKsw==} - cpu: [x64] - os: [freebsd] - - '@pnpm/exe.linux-arm64-musl@12.18.0': - resolution: {integrity: sha512-Vp+TIMPPyackVCXkOdEKH/RmAn/r07EcIyrgZYQK7VrkksqZOie0GnWIx+85mPqeFEYCRtXIZAFJ9L4ceTndDg==} - cpu: [arm64] - os: [linux] - libc: [musl] - - '@pnpm/exe.linux-arm64@12.18.0': - resolution: {integrity: sha512-2dpyVBCHT+FfpuQh9i+7MXAqNWYLCvD5vYr5p6Eimxoga8USLnjbUgyj72AOrO0hjc5ri3TEFP3jiyBHjkSZpQ==} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@pnpm/exe.linux-ppc64@12.18.0': - resolution: {integrity: sha512-BBOOOfNJ2QwIIya3eKqOjiN4WNTszfRz7HCvw9XggcT7+ftMjNP8XJ/GfW+ltCBeUFR9d8WBVsr2m/NLjX2CZQ==} - cpu: [ppc64] - os: [linux] - libc: [glibc] - - '@pnpm/exe.linux-riscv64@12.18.0': - resolution: {integrity: sha512-7kMN77xSOYJX8GPSH5RbNAc5oM61LMmcSUukDDUwllnZPXm8GRPskCNsTWy8SCw01Kr1FB+5SwGNMiTdiziLNQ==} - cpu: [riscv64] - os: [linux] - libc: [glibc] - - '@pnpm/exe.linux-s390x@12.18.0': - resolution: {integrity: sha512-htuSCpEcmDzhKoJqXbPkvfr176dBHU0QIF5mWcRiqxRXAB/1JoYiMYotfjWpk+ztgpB9qlx4XnWlLFAf7gzc6g==} - cpu: [s390x] - os: [linux] - libc: [glibc] - - '@pnpm/exe.linux-x64-musl@12.18.0': - resolution: {integrity: sha512-Uj+vzfIQ62kDP10x36yHZIXVs5ohdNtiPYwn5FhCLlNScHPo0OAI+ShGDtLofiBXKE7umu71Jmjm7N8a8zVcDw==} - cpu: [x64] - os: [linux] - libc: [musl] - - '@pnpm/exe.linux-x64@12.18.0': - resolution: {integrity: sha512-OJ+X2wcraldCwj75pCIerWARQSRpdfj0eBTs/2ODyhfeW46ylOnjTIE/GKra6Mn6E72/gBmXS8igrUioa+F9fQ==} - cpu: [x64] - os: [linux] - libc: [glibc] - - '@pnpm/exe.win32-arm64@12.18.0': - resolution: {integrity: sha512-wEY6jiACGcbhhi5yD59doHqNTndS7AaujaPmtWAu1DKkHru2hy5fJ9yUGecW72Ypaw2/I3BEprfMOopap2NQtw==} - cpu: [arm64] - os: [win32] - - '@pnpm/exe.win32-x64@12.18.0': - resolution: {integrity: sha512-5FJkghO7RLRkQpWxeVEygW9XsmnNuxzPfXbgwFWCHsFyFhpDn/vOdL88ToQEM0Kt5igdW5s6U0/IDH8Dvkt3pg==} - cpu: [x64] - os: [win32] - - pnpm@12.18.0: - resolution: {integrity: sha512-nXiC1dyCFH7PxOBiqjSDTgrQKWcQoYN6ERWuASEn02txCeMhrBWYod0KZVl2gbHpmRfhLtDXSerpEYeUM2O+sw==} - engines: {node: '>=18'} - hasBin: true - -snapshots: - - '@pnpm/exe.android-arm64@12.18.0': - optional: true - - '@pnpm/exe.android-x64@12.18.0': - optional: true - - '@pnpm/exe.darwin-arm64@12.18.0': - optional: true - - '@pnpm/exe.darwin-x64@12.18.0': - optional: true - - '@pnpm/exe.freebsd-x64@12.18.0': - optional: true - - '@pnpm/exe.linux-arm64-musl@12.18.0': - optional: true - - '@pnpm/exe.linux-arm64@12.18.0': - optional: true - - '@pnpm/exe.linux-ppc64@12.18.0': - optional: true - - '@pnpm/exe.linux-riscv64@12.18.0': - optional: true - - '@pnpm/exe.linux-s390x@12.18.0': - optional: true - - '@pnpm/exe.linux-x64-musl@12.18.0': - optional: true - - '@pnpm/exe.linux-x64@12.18.0': - optional: true - - '@pnpm/exe.win32-arm64@12.18.0': - optional: true - - '@pnpm/exe.win32-x64@12.18.0': - optional: true - - pnpm@12.18.0: - optionalDependencies: - '@pnpm/exe.android-arm64': 12.18.0 - '@pnpm/exe.android-x64': 12.18.0 - '@pnpm/exe.darwin-arm64': 12.18.0 - '@pnpm/exe.darwin-x64': 12.18.0 - '@pnpm/exe.freebsd-x64': 12.18.0 - '@pnpm/exe.linux-arm64': 12.18.0 - '@pnpm/exe.linux-arm64-musl': 12.18.0 - '@pnpm/exe.linux-ppc64': 12.18.0 - '@pnpm/exe.linux-riscv64': 12.18.0 - '@pnpm/exe.linux-s390x': 12.18.0 - '@pnpm/exe.linux-x64': 12.18.0 - '@pnpm/exe.linux-x64-musl': 12.18.0 - '@pnpm/exe.win32-arm64': 12.18.0 - '@pnpm/exe.win32-x64': 12.18.0 - ---- lockfileVersion: '9.0' settings: @@ -177,8 +19,8 @@ catalogs: specifier: ^1.26.2 version: 1.26.2 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.2.5 + version: 2.2.5 '@tanstack/vite-config': specifier: 0.5.2 version: 0.5.2 @@ -244,8 +86,8 @@ overrides: '@types/babel__traverse': ^7.28.0 vite-plugin-dts: 4.2.3 solid-js: 1.9.12 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 eslint: ^9.22.0 @@ -306,17 +148,17 @@ importers: specifier: ^2.30.0 version: 2.30.0(@types/node@25.0.9) '@nx/devkit': - specifier: 24.0.0 - version: 24.0.0(nx@24.0.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2))(@swc/core@1.15.33(@swc/helpers@0.5.23))) + specifier: 23.2.0 + version: 23.2.0(nx@23.2.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0))(@swc/core@1.15.33(@swc/helpers@0.5.23))) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@swc-node/register': specifier: ^1.11.1 - version: 1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2) + version: 1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0) '@tanstack/eslint-config': specifier: 0.4.0 - version: 0.4.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + version: 0.4.0(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -325,16 +167,16 @@ importers: version: typescript@7.0.2 eslint: specifier: ^9.22.0 - version: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + version: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) eslint-plugin-unused-imports: specifier: ^4.1.4 - version: 4.1.4(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) + version: 4.1.4(@typescript-eslint/eslint-plugin@8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) markdown-link-extractor: specifier: ^4.0.3 version: 4.0.3 nx: - specifier: 24.0.0 - version: 24.0.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2))(@swc/core@1.15.33(@swc/helpers@0.5.23)) + specifier: 23.2.0 + version: 23.2.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0))(@swc/core@1.15.33(@swc/helpers@0.5.23)) prettier: specifier: ^3.8.0 version: 3.8.1 @@ -358,13 +200,13 @@ importers: version: typescript@5.9.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) benchmarks/bundle-size: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../packages/react-router @@ -387,11 +229,11 @@ importers: specifier: workspace:* version: link:../../packages/vue-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) solid-js: specifier: 1.9.12 version: 1.9.12 @@ -400,11 +242,11 @@ importers: version: 3.5.25(@typescript/typescript6@6.0.2) devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../packages/router-plugin @@ -419,22 +261,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) benchmarks/client-nav: dependencies: @@ -454,11 +296,11 @@ importers: specifier: workspace:* version: link:../../packages/vue-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) solid-js: specifier: 1.9.12 version: 1.9.12 @@ -468,7 +310,7 @@ importers: devDependencies: '@codspeed/vitest-plugin': specifier: ^6.0.1 - version: 6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) + version: 6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) '@platformatic/flame': specifier: ^1.6.0 version: 1.6.0 @@ -477,7 +319,7 @@ importers: version: link:../../packages/router-plugin '@testing-library/react': specifier: ^16.2.0 - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/jsdom': specifier: 28.0.0 version: 28.0.0 @@ -492,13 +334,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: ^29.1.1 version: 29.1.1(@noble/hashes@2.0.1) @@ -507,13 +349,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) benchmarks/memory/client: dependencies: @@ -530,11 +372,11 @@ importers: specifier: workspace:* version: link:../../../packages/vue-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) solid-js: specifier: 1.9.12 version: 1.9.12 @@ -544,7 +386,7 @@ importers: devDependencies: '@codspeed/vitest-plugin': specifier: ^6.0.1 - version: 6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) + version: 6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) '@datadog/pprof': specifier: ^5.13.2 version: 5.13.2 @@ -553,7 +395,7 @@ importers: version: 1.6.0 '@testing-library/react': specifier: ^16.2.0 - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/jsdom': specifier: 28.0.0 version: 28.0.0 @@ -568,13 +410,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 29.1.1 version: 29.1.1(@noble/hashes@2.0.1) @@ -583,13 +425,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) benchmarks/memory/server: dependencies: @@ -612,11 +454,11 @@ importers: specifier: workspace:* version: link:../../../packages/vue-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) solid-js: specifier: 1.9.12 version: 1.9.12 @@ -626,7 +468,7 @@ importers: devDependencies: '@codspeed/vitest-plugin': specifier: ^6.0.1 - version: 6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) + version: 6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) '@datadog/pprof': specifier: ^5.13.2 version: 5.13.2 @@ -641,10 +483,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 29.1.1 version: 29.1.1(@noble/hashes@2.0.1) @@ -653,13 +495,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) benchmarks/ssr: dependencies: @@ -682,11 +524,11 @@ importers: specifier: workspace:* version: link:../../packages/vue-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) solid-js: specifier: 1.9.12 version: 1.9.12 @@ -696,7 +538,7 @@ importers: devDependencies: '@codspeed/vitest-plugin': specifier: ^6.0.1 - version: 6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) + version: 6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -705,10 +547,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 29.1.1 version: 29.1.1(@noble/hashes@2.0.1) @@ -720,13 +562,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/e2e-utils: devDependencies: @@ -741,13 +583,13 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/eslint-plugin-start: devDependencies: @@ -773,14 +615,14 @@ importers: specifier: ^9.22.0 version: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 typescript: specifier: ^5.7.2 version: 5.9.2 vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/react-router/basepath-file-based: dependencies: @@ -794,11 +636,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -814,16 +656,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -831,20 +673,17 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 tailwindcss: specifier: ^4.2.2 version: 4.2.2 - zod: - specifier: 'catalog:' - version: 4.5.4 devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -860,10 +699,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-esbuild-file-based: dependencies: @@ -877,11 +716,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -909,7 +748,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -920,11 +759,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -949,19 +788,19 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-file-based-code-splitting: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -972,11 +811,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1001,22 +840,22 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-react-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1024,11 +863,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1050,22 +889,22 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-react-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1076,11 +915,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1105,16 +944,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-scroll-restoration: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1123,13 +962,13 @@ importers: version: link:../../../packages/react-router-devtools '@tanstack/react-virtual': specifier: ^3.13.0 - version: 3.13.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 3.13.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1151,19 +990,19 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: ~5.9.0 version: 5.9.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-virtual-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1177,11 +1016,11 @@ importers: specifier: workspace:* version: link:../../../packages/virtual-file-routes react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1206,16 +1045,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/basic-virtual-named-export-config-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1229,11 +1068,11 @@ importers: specifier: workspace:* version: link:../../../packages/virtual-file-routes react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1258,10 +1097,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/escaped-special-strings: dependencies: @@ -1272,11 +1111,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -1292,16 +1131,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/generator-cli-only: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1312,11 +1151,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-cli react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1338,25 +1177,25 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/i18n-paraglide: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -1387,13 +1226,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/issue-4759: dependencies: @@ -1401,11 +1240,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -1421,10 +1260,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/issue-7120: dependencies: @@ -1435,11 +1274,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -1455,16 +1294,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/issue-7457: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1472,11 +1311,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -1492,16 +1331,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/js-only-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1509,11 +1348,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1538,10 +1377,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/match-params: dependencies: @@ -1549,11 +1388,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -1569,7 +1408,7 @@ importers: version: 19.2.3(@types/react@19.2.9) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/react-compiler: dependencies: @@ -1577,11 +1416,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@babel/core': specifier: ^7.29.0 @@ -1591,7 +1430,7 @@ importers: version: 1.63.0 '@rolldown/plugin-babel': specifier: ^0.2.0 - version: 0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -1603,13 +1442,13 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) babel-plugin-react-compiler: specifier: ^1.0.0 version: 1.0.0 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/rspack-basic-file-based: dependencies: @@ -1620,11 +1459,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1633,11 +1472,11 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -1675,11 +1514,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1688,11 +1527,11 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -1728,7 +1567,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1739,11 +1578,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1768,16 +1607,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/sentry-integration: dependencies: '@sentry/react': specifier: ^10.32.0 - version: 10.32.0(react@19.2.9) + version: 10.32.0(react@19.2.3) '@sentry/tracing': specifier: ^7.120.4 version: 7.120.4 @@ -1786,7 +1625,7 @@ importers: version: 4.6.1(supports-color@10.2.2) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1794,11 +1633,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1820,16 +1659,16 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-router/view-transitions: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1840,11 +1679,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1872,13 +1711,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/basic: dependencies: @@ -1904,11 +1743,11 @@ importers: specifier: ^3.0.5 version: 3.0.5 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -1920,17 +1759,17 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -1951,7 +1790,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -1966,7 +1805,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) zod: specifier: ^4.4.3 version: 4.4.3 @@ -1981,7 +1820,7 @@ importers: version: 7.0.0 '@prisma/client': specifier: ^7.0.0 - version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -1995,11 +1834,11 @@ importers: specifier: ^9.0.1 version: 9.0.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -2012,7 +1851,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2030,13 +1869,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) dotenv: specifier: ^17.2.3 version: 17.2.3 prisma: specifier: ^7.0.0 - version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -2045,7 +1884,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/basic-cloudflare: dependencies: @@ -2059,21 +1898,21 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2091,7 +1930,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -2100,7 +1939,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -2109,10 +1948,10 @@ importers: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -2126,11 +1965,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -2146,7 +1985,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2164,7 +2003,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2176,7 +2015,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/basic-tsr-config: dependencies: @@ -2187,11 +2026,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tanstack/router-e2e-utils': specifier: workspace:^ @@ -2219,13 +2058,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/clerk-basic: dependencies: '@clerk/tanstack-react-start': specifier: ^0.19.0 - version: 0.19.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 0.19.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -2236,11 +2075,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -2253,7 +2092,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2271,7 +2110,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -2280,7 +2119,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/csp: dependencies: @@ -2291,11 +2130,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -2323,7 +2162,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/css-inline: dependencies: @@ -2337,11 +2176,11 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2350,11 +2189,11 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2372,13 +2211,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/css-modules: dependencies: @@ -2389,27 +2228,27 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.2.5 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@rsbuild/plugin-sass': specifier: ^2.0.1 - version: 2.0.1(@rsbuild/core@2.3.1) + version: 2.0.1(@rsbuild/core@2.2.5) '@tanstack/router-e2e-utils': specifier: workspace:* version: link:../../e2e-utils @@ -2427,19 +2266,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - cf: - specifier: 1.0.0-beta.28 - version: 1.0.0-beta.28(@types/node@25.0.9) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta - rsbuild-plugin-cloudflare: - specifier: ^0.0.4 - version: 0.0.4(@rsbuild/core@2.3.1)(@types/node@25.0.9)(workerd@1.20261104.1) sass: - specifier: ^1.97.2 - version: 1.97.2 + specifier: ^1.105.1 + version: 1.105.1 srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2448,7 +2281,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -2468,11 +2301,11 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -2482,7 +2315,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2503,7 +2336,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) cross-env: specifier: ^10.0.0 version: 10.0.0 @@ -2521,7 +2354,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/custom-server-rsbuild: dependencies: @@ -2535,21 +2368,21 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -2596,18 +2429,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2625,7 +2458,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2634,7 +2467,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/dev-ssr-styles: dependencies: @@ -2645,11 +2478,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -2674,7 +2507,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta @@ -2686,7 +2519,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) zod: specifier: ^4.4.3 version: 4.4.3 @@ -2700,11 +2533,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -2729,7 +2562,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) node-forge: specifier: ^1.3.1 version: 1.3.1 @@ -2744,7 +2577,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/flamegraph-bench: dependencies: @@ -2755,11 +2588,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2772,7 +2605,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) autocannon: specifier: ^8.0.0 version: 8.0.0 @@ -2787,7 +2620,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/hmr: dependencies: @@ -2798,27 +2631,27 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2836,7 +2669,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -2845,7 +2678,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/i18n-paraglide: dependencies: @@ -2859,11 +2692,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@inlang/paraglide-js': specifier: ^2.4.0 @@ -2873,7 +2706,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2891,7 +2724,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -2900,7 +2733,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/import-protection: dependencies: @@ -2911,24 +2744,24 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) react-tweet: specifier: ^3.3.0 - version: 3.3.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 3.3.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -2946,7 +2779,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -2955,7 +2788,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/import-protection-custom-config: dependencies: @@ -2966,11 +2799,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -2992,7 +2825,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3001,7 +2834,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/issue-8049: dependencies: @@ -3012,11 +2845,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -3032,19 +2865,19 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/query-integration: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -3058,11 +2891,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -3075,7 +2908,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3093,7 +2926,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -3102,7 +2935,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/response-reconciliation: dependencies: @@ -3113,21 +2946,21 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.0.8 + version: 2.2.5 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3142,7 +2975,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3151,7 +2984,7 @@ importers: version: 6.0.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/root-document-hydration: dependencies: @@ -3162,11 +2995,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -3188,7 +3021,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3197,7 +3030,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/rsbuild: dependencies: @@ -3208,21 +3041,21 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3254,21 +3087,21 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/eslint-plugin-start': specifier: workspace:^ version: link:../../../packages/eslint-plugin-start @@ -3289,10 +3122,10 @@ importers: version: 8.44.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@5.9.2) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-rsc': - specifier: ^0.5.39 - version: 0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + specifier: ^0.5.37 + version: 0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint: specifier: ^9.22.0 version: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) @@ -3304,7 +3137,7 @@ importers: version: 5.9.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/rsc-deferred-hydration: dependencies: @@ -3315,11 +3148,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -3341,10 +3174,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-rsc': - specifier: ^0.5.39 - version: 0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + specifier: ^0.5.37 + version: 0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3353,16 +3186,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/rsc-query: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -3376,11 +3209,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -3399,10 +3232,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-rsc': - specifier: ^0.5.39 - version: 0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + specifier: ^0.5.37 + version: 0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3411,7 +3244,7 @@ importers: version: 5.9.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/rsc-rsbuild: dependencies: @@ -3422,21 +3255,21 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3468,11 +3301,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -3488,7 +3321,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3506,7 +3339,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -3521,7 +3354,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/selective-ssr: dependencies: @@ -3535,18 +3368,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) zod: specifier: ^4.4.3 version: 4.4.3 devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3564,7 +3397,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3576,7 +3409,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/serialization-adapters: dependencies: @@ -3590,18 +3423,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) zod: specifier: ^4.4.3 version: 4.4.3 devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3619,7 +3452,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3631,13 +3464,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/server-functions: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -3654,11 +3487,11 @@ importers: specifier: ^3.0.5 version: 3.0.5 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -3673,17 +3506,17 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3704,7 +3537,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -3719,7 +3552,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/server-functions-global-middleware: dependencies: @@ -3730,18 +3563,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3759,7 +3592,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3771,13 +3604,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/server-routes: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -3794,11 +3627,11 @@ importers: specifier: ^3.0.5 version: 3.0.5 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -3814,7 +3647,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3835,7 +3668,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -3850,7 +3683,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/server-routes-global-middleware: dependencies: @@ -3861,18 +3694,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3890,7 +3723,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3902,7 +3735,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/session-handling: dependencies: @@ -3925,21 +3758,21 @@ importers: specifier: 9.0.1 version: 9.0.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.0.8 + version: 2.2.5 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -3954,7 +3787,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -3963,7 +3796,7 @@ importers: version: 6.0.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/spa-mode: dependencies: @@ -3977,15 +3810,15 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -4009,7 +3842,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/split-base-and-basepath: dependencies: @@ -4023,11 +3856,11 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -4049,7 +3882,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -4058,7 +3891,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/start-manifest: dependencies: @@ -4069,11 +3902,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -4095,7 +3928,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta @@ -4104,7 +3937,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/static-server-functions: dependencies: @@ -4121,11 +3954,11 @@ importers: specifier: ^3.0.260903-beta version: 3.0.260903-beta react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -4147,19 +3980,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/streaming-ssr: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -4170,11 +4003,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -4196,7 +4029,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -4205,7 +4038,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/transform-asset-urls: dependencies: @@ -4219,11 +4052,11 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -4245,7 +4078,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -4254,7 +4087,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/virtual-routes: dependencies: @@ -4271,11 +4104,11 @@ importers: specifier: workspace:* version: link:../../../packages/virtual-file-routes react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -4291,7 +4124,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -4309,7 +4142,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -4324,7 +4157,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/react-start/website: dependencies: @@ -4338,11 +4171,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: 'catalog:' version: 0.5.1 @@ -4358,7 +4191,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -4376,7 +4209,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -4388,7 +4221,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/solid-router/basepath-file-based: dependencies: @@ -4413,16 +4246,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -4447,10 +4280,10 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-esbuild-file-based: dependencies: @@ -4484,13 +4317,13 @@ importers: version: 0.27.4 esbuild-plugin-solid: specifier: ^0.6.0 - version: 0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@10.2.2) + version: 0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@7.2.0) e2e/solid-router/basic-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4524,16 +4357,16 @@ importers: version: 1.1.11 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-file-based-code-splitting: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4564,16 +4397,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-scroll-restoration: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -4604,16 +4437,16 @@ importers: version: 5.9.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-solid-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) @@ -4644,16 +4477,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-solid-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4690,16 +4523,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-virtual-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4733,16 +4566,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/basic-virtual-named-export-config-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4776,16 +4609,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/generator-cli-only: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-cli': specifier: workspace:* version: link:../../../packages/router-cli @@ -4813,16 +4646,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/js-only-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -4850,10 +4683,10 @@ importers: version: link:../../../packages/router-plugin vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/rspack-basic-file-based: dependencies: @@ -4874,14 +4707,14 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-solid': - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2) + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -4923,14 +4756,14 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-solid': - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2) + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -4960,7 +4793,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -4991,10 +4824,10 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/sentry-integration: dependencies: @@ -5006,10 +4839,10 @@ importers: version: 7.120.4 '@sentry/vite-plugin': specifier: ^4.6.1 - version: 4.6.1(supports-color@10.2.2) + version: 4.6.1(supports-color@7.2.0) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -5034,16 +4867,16 @@ importers: version: link:../../e2e-utils vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-router/view-transitions: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -5080,10 +4913,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/basic: dependencies: @@ -5122,20 +4955,20 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-solid': - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2) + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5162,10 +4995,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/basic-auth: dependencies: @@ -5177,7 +5010,7 @@ importers: version: 7.0.0 '@prisma/client': specifier: ^7.0.0 - version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/solid-router': specifier: workspace:^ version: link:../../../packages/solid-router @@ -5205,7 +5038,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5220,7 +5053,7 @@ importers: version: 17.2.3 prisma: specifier: ^7.0.0 - version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -5232,10 +5065,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/basic-cloudflare: dependencies: @@ -5254,13 +5087,13 @@ importers: devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5278,10 +5111,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -5324,7 +5157,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5345,10 +5178,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/basic-tsr-config: dependencies: @@ -5385,10 +5218,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/csp: dependencies: @@ -5422,10 +5255,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/css-modules: dependencies: @@ -5452,8 +5285,8 @@ importers: specifier: npm:typescript@^7.0.2 version: typescript@7.0.2 sass: - specifier: ^1.97.2 - version: 1.97.2 + specifier: ^1.105.1 + version: 1.105.1 srvx: specifier: ^1.0.0 version: 1.0.5 @@ -5462,10 +5295,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/custom-basepath: dependencies: @@ -5493,7 +5326,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5523,10 +5356,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/deferred-hydration: dependencies: @@ -5541,14 +5374,14 @@ importers: version: 1.9.12 devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-solid': - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2) + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5566,10 +5399,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/dev-ssr-styles: dependencies: @@ -5606,10 +5439,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/query-integration: dependencies: @@ -5646,7 +5479,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5664,10 +5497,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/scroll-restoration: dependencies: @@ -5698,7 +5531,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5722,10 +5555,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/selective-ssr: dependencies: @@ -5744,7 +5577,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5762,10 +5595,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/serialization-adapters: dependencies: @@ -5787,7 +5620,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5808,10 +5641,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/server-functions: dependencies: @@ -5851,7 +5684,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5878,10 +5711,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/server-routes: dependencies: @@ -5921,7 +5754,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -5948,10 +5781,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/solid-query-layout-suspense: dependencies: @@ -5985,10 +5818,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/spa-mode: dependencies: @@ -6010,7 +5843,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -6025,10 +5858,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/start-manifest: dependencies: @@ -6062,10 +5895,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/streaming-ssr: dependencies: @@ -6105,10 +5938,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/virtual-routes: dependencies: @@ -6142,7 +5975,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -6166,10 +5999,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/solid-start/website: dependencies: @@ -6200,7 +6033,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -6221,16 +6054,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) e2e/vue-router/basepath-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6264,16 +6097,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6282,7 +6115,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/vue-router': specifier: workspace:* version: link:../../../packages/vue-router @@ -6307,13 +6140,13 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6365,7 +6198,7 @@ importers: version: 0.27.4 esbuild-plugin-vue3: specifier: ^0.5.1 - version: 0.5.1(cheerio@1.0.0)(sass@1.97.2)(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 0.5.1(cheerio@1.0.0)(sass@1.105.1)(vue@3.5.25(@typescript/typescript6@6.0.2)) eslint-plugin-vue: specifier: ^9.33.0 version: 9.33.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -6383,7 +6216,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6423,10 +6256,10 @@ importers: version: 8.44.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@5.8.3) '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) eslint-plugin-vue: specifier: ^9.33.0 version: 9.33.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -6435,7 +6268,7 @@ importers: version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-eslint-parser: specifier: ^9.4.3 version: 9.4.3(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -6447,7 +6280,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6478,16 +6311,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6496,7 +6329,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/vue-router': specifier: workspace:* version: link:../../../packages/vue-router @@ -6524,16 +6357,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3)) typescript: specifier: ~5.9.0 version: 5.9.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.9.3) @@ -6542,7 +6375,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6579,16 +6412,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6597,7 +6430,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6634,16 +6467,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6652,7 +6485,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/vue-query': specifier: ^5.102.0 version: 5.102.0(vue@3.5.25(typescript@5.8.3)) @@ -6683,16 +6516,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6701,7 +6534,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6738,16 +6571,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6756,7 +6589,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-cli': specifier: workspace:* version: link:../../../packages/router-cli @@ -6784,16 +6617,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -6802,16 +6635,16 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/vue-query': specifier: ^5.102.0 - version: 5.102.0(vue@3.5.25(typescript@6.0.2)) + version: 5.102.0(vue@3.5.25(typescript@7.0.2)) '@tanstack/vue-query-devtools': specifier: ^6.1.2 - version: 6.1.2(@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@6.0.2)))(vue@3.5.25(typescript@6.0.2)) + version: 6.1.2(@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@7.0.2)))(vue@3.5.25(typescript@7.0.2)) '@tanstack/vue-router': specifier: workspace:* version: link:../../../packages/vue-router @@ -6826,7 +6659,7 @@ importers: version: 4.2.2 vue: specifier: ^3.5.16 - version: 3.5.25(typescript@6.0.2) + version: 3.5.25(typescript@7.0.2) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -6836,13 +6669,13 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@7.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@7.0.2)) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-router/rspack-basic-file-based: dependencies: @@ -6863,17 +6696,17 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-vue': specifier: ^1.2.7 - version: 1.2.7(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 1.2.7(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) '@rsbuild/plugin-vue-jsx': specifier: ^2.0.0 - version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -6921,17 +6754,17 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-vue': specifier: ^1.2.7 - version: 1.2.7(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 1.2.7(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) '@rsbuild/plugin-vue-jsx': specifier: ^2.0.0 - version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 @@ -6964,7 +6797,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -6995,16 +6828,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -7016,13 +6849,13 @@ importers: version: 7.120.4 '@sentry/vite-plugin': specifier: ^4.6.1 - version: 4.6.1(supports-color@10.2.2) + version: 4.6.1(supports-color@7.2.0) '@sentry/vue': specifier: ^10.32.0 version: 10.32.0(@tanstack/vue-router@packages+vue-router)(vue@3.5.25(typescript@5.8.3)) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/vue-router': specifier: workspace:* version: link:../../../packages/vue-router @@ -7047,13 +6880,13 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -7062,7 +6895,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -7096,16 +6929,16 @@ importers: version: link:../../e2e-utils '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -7147,23 +6980,23 @@ importers: specifier: ^1.63.0 version: 1.63.0 '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-vue': specifier: ^1.2.7 - version: 1.2.7(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 1.2.7(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) '@rsbuild/plugin-vue-jsx': specifier: ^2.0.0 - version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@tailwindcss/postcss': specifier: ^4.2.2 version: 4.2.2 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7178,10 +7011,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -7196,7 +7029,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/basic-auth: dependencies: @@ -7208,7 +7041,7 @@ importers: version: 7.0.0 '@prisma/client': specifier: ^7.0.0 - version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/vue-router': specifier: workspace:* version: link:../../../packages/vue-router @@ -7236,7 +7069,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7248,16 +7081,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) dotenv: specifier: ^17.2.3 version: 17.2.3 prisma: specifier: ^7.0.0 - version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7269,7 +7102,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/basic-cloudflare: dependencies: @@ -7288,13 +7121,13 @@ importers: devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@playwright/test': specifier: ^1.63.0 version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7306,10 +7139,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -7318,7 +7151,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -7349,10 +7182,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) rimraf: specifier: 'catalog:' version: 6.1.2 @@ -7364,7 +7197,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/basic-vue-query: dependencies: @@ -7404,7 +7237,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7416,10 +7249,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7431,7 +7264,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/css-modules: dependencies: @@ -7459,10 +7292,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) sass: - specifier: ^1.97.2 - version: 1.97.2 + specifier: ^1.105.1 + version: 1.105.1 srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7471,7 +7304,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/custom-basepath: dependencies: @@ -7499,7 +7332,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7514,10 +7347,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) cross-env: specifier: ^10.0.0 version: 10.0.0 @@ -7535,7 +7368,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/dev-ssr-styles: dependencies: @@ -7566,10 +7399,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7578,7 +7411,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/query-integration: dependencies: @@ -7615,7 +7448,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7627,10 +7460,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -7639,7 +7472,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/scroll-restoration: dependencies: @@ -7670,7 +7503,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7682,10 +7515,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -7700,7 +7533,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/selective-ssr: dependencies: @@ -7719,7 +7552,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7728,10 +7561,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7743,7 +7576,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(@typescript/typescript6@6.0.2) @@ -7768,7 +7601,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7777,10 +7610,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -7792,7 +7625,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(@typescript/typescript6@6.0.2) @@ -7835,7 +7668,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7850,10 +7683,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -7868,7 +7701,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/server-routes: dependencies: @@ -7908,7 +7741,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7923,10 +7756,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -7941,7 +7774,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/spa-mode: dependencies: @@ -7963,7 +7796,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -7972,10 +7805,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -7984,7 +7817,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/start-manifest: dependencies: @@ -8012,7 +7845,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -8021,7 +7854,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/streaming-ssr: dependencies: @@ -8055,7 +7888,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -8064,7 +7897,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/virtual-routes: dependencies: @@ -8098,7 +7931,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -8110,10 +7943,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) combinate: specifier: ^1.1.11 version: 1.1.11 @@ -8128,7 +7961,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) e2e/vue-start/website: dependencies: @@ -8159,7 +7992,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-e2e-utils': specifier: workspace:^ version: link:../../e2e-utils @@ -8171,10 +8004,10 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) srvx: specifier: ^1.0.0 version: 1.0.5 @@ -8186,13 +8019,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/authenticated-routes: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8203,11 +8036,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8229,19 +8062,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/authenticated-routes-firebase: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8255,11 +8088,11 @@ importers: specifier: ^11.4.0 version: 11.4.0 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8284,19 +8117,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8304,11 +8137,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8327,22 +8160,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-default-search-params: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8350,11 +8183,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8376,25 +8209,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-devtools-panel: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.67.2 - version: 5.67.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.67.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8402,11 +8235,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8425,19 +8258,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8448,11 +8281,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8474,19 +8307,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-non-nested-devtools: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8494,11 +8327,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8517,25 +8350,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-react-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8543,11 +8376,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8566,25 +8399,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-react-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8595,11 +8428,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8621,13 +8454,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-ssr-file-based: dependencies: @@ -8650,11 +8483,11 @@ importers: specifier: ^3.3.2 version: 3.3.2 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tanstack/react-router-devtools': specifier: workspace:^ @@ -8673,13 +8506,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-ssr-streaming-file-based: dependencies: @@ -8702,11 +8535,11 @@ importers: specifier: ^3.3.2 version: 3.3.2 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tanstack/react-router-devtools': specifier: workspace:^ @@ -8725,19 +8558,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-virtual-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8751,11 +8584,11 @@ importers: specifier: workspace:* version: link:../../../packages/virtual-file-routes react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8777,19 +8610,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/basic-virtual-inside-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8803,11 +8636,11 @@ importers: specifier: workspace:* version: link:../../../packages/virtual-file-routes react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8829,19 +8662,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/deferred-data: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8849,11 +8682,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8875,19 +8708,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/i18n-paraglide: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8895,11 +8728,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -8921,19 +8754,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/kitchen-sink: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8944,11 +8777,11 @@ importers: specifier: ^10.1.1 version: 10.1.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -8970,19 +8803,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/kitchen-sink-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -8996,11 +8829,11 @@ importers: specifier: ^10.1.1 version: 10.1.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9022,25 +8855,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/kitchen-sink-react-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9051,11 +8884,11 @@ importers: specifier: ^10.1.1 version: 10.1.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9077,25 +8910,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/kitchen-sink-react-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9109,11 +8942,11 @@ importers: specifier: ^10.1.1 version: 10.1.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9135,22 +8968,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/large-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9161,11 +8994,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9187,25 +9020,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/location-masking: dependencies: '@radix-ui/react-dialog': specifier: ^1.1.6 - version: 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9213,11 +9046,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9236,22 +9069,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/navigation-blocking: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9259,11 +9092,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9282,19 +9115,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/quickstart: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9302,11 +9135,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -9322,13 +9155,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/quickstart-esbuild-file-based: dependencies: @@ -9342,11 +9175,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9368,7 +9201,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9379,11 +9212,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9405,13 +9238,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/quickstart-rspack-file-based: dependencies: @@ -9428,21 +9261,21 @@ importers: specifier: ^8.5.1 version: 8.5.3 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -9468,11 +9301,11 @@ importers: specifier: workspace:^ version: link:../../../packages/react-router-devtools react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@swc/core': specifier: ^1.15.33 @@ -9509,16 +9342,16 @@ importers: version: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.97.1) webpack-dev-server: specifier: ^5.2.4 - version: 5.2.4(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) + version: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) examples/react/router-monorepo-react-query: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -9529,11 +9362,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9552,16 +9385,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-react-query/packages/app: dependencies: @@ -9573,17 +9406,17 @@ importers: version: link:../router '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router-devtools': specifier: workspace:^ version: link:../../../../../packages/react-router-devtools @@ -9598,7 +9431,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -9607,10 +9440,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-react-query/packages/post-feature: dependencies: @@ -9622,13 +9455,13 @@ importers: version: link:../router '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@types/react': specifier: ^19.2.8 @@ -9641,22 +9474,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-react-query/packages/post-query: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9669,13 +9502,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/router-monorepo-react-query/packages/router: dependencies: @@ -9687,7 +9520,7 @@ importers: version: link:../../../../../packages/history '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../../../packages/react-router @@ -9695,11 +9528,11 @@ importers: specifier: workspace:* version: link:../../../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9718,16 +9551,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple: dependencies: @@ -9741,11 +9574,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9764,16 +9597,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple-lazy: dependencies: @@ -9787,11 +9620,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9810,16 +9643,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple-lazy/packages/app: dependencies: @@ -9830,15 +9663,15 @@ importers: specifier: workspace:* version: link:../router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router-devtools': specifier: workspace:^ version: link:../../../../../packages/react-router-devtools @@ -9853,7 +9686,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -9862,10 +9695,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple-lazy/packages/post-feature: dependencies: @@ -9874,13 +9707,13 @@ importers: version: link:../router '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@types/react': specifier: ^19.2.8 @@ -9893,16 +9726,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple-lazy/packages/router: dependencies: @@ -9916,11 +9749,11 @@ importers: specifier: workspace:* version: link:../../../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -9939,16 +9772,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple/packages/app: dependencies: @@ -9959,15 +9792,15 @@ importers: specifier: workspace:* version: link:../router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router-devtools': specifier: workspace:^ version: link:../../../../../packages/react-router-devtools @@ -9982,7 +9815,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -9991,10 +9824,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple/packages/post-feature: dependencies: @@ -10002,11 +9835,11 @@ importers: specifier: workspace:* version: link:../router react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@types/react': specifier: ^19.2.8 @@ -10019,16 +9852,16 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/router-monorepo-simple/packages/router: dependencies: @@ -10042,11 +9875,11 @@ importers: specifier: workspace:* version: link:../../../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10065,22 +9898,22 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/scroll-restoration: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10089,13 +9922,13 @@ importers: version: link:../../../packages/react-router-devtools '@tanstack/react-virtual': specifier: ^3.13.0 - version: 3.13.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 3.13.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10111,25 +9944,25 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/search-validator-adapters: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/arktype-adapter': specifier: workspace:* version: link:../../../packages/arktype-adapter '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10149,11 +9982,11 @@ importers: specifier: ^2.1.7 version: 2.1.7 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10169,7 +10002,7 @@ importers: version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) '@testing-library/react': specifier: ^16.2.0 - version: 16.2.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.2.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -10181,7 +10014,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) jsdom: specifier: ^27.0.0 version: 27.0.0(supports-color@10.2.2) @@ -10190,10 +10023,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: ^5.0.4 - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/react/start-bare: dependencies: @@ -10207,11 +10040,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) zod: specifier: ^4.4.3 version: 4.4.3 @@ -10230,13 +10063,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-basic: dependencies: @@ -10250,11 +10083,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -10264,7 +10097,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10279,7 +10112,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta @@ -10291,7 +10124,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-basic-auth: dependencies: @@ -10303,7 +10136,7 @@ importers: version: 7.0.0 '@prisma/client': specifier: ^7.0.0 - version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10317,11 +10150,11 @@ importers: specifier: ^9.0.1 version: 9.0.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10331,7 +10164,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10346,13 +10179,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) dotenv: specifier: ^17.2.3 version: 17.2.3 prisma: specifier: ^7.0.0 - version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10361,7 +10194,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-basic-authjs: dependencies: @@ -10378,11 +10211,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) start-authjs: specifier: ^1.0.0 version: 1.0.0(@auth/core@0.41.1) @@ -10392,7 +10225,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10407,7 +10240,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10416,7 +10249,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-basic-cloudflare: dependencies: @@ -10430,18 +10263,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10456,7 +10289,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10465,7 +10298,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -10474,10 +10307,10 @@ importers: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10491,11 +10324,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10508,7 +10341,7 @@ importers: version: 1.63.0 '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10523,7 +10356,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10532,7 +10365,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-basic-rsbuild: dependencies: @@ -10546,11 +10379,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -10559,14 +10392,14 @@ importers: version: 4.4.3 devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.0.11 + version: 2.0.14 '@rsbuild/plugin-react': specifier: ^2.0.0 - version: 2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23)) + version: 2.0.0(@rsbuild/core@2.0.14)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@rsbuild/plugin-tailwindcss': specifier: ^2.0.3 - version: 2.0.3(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(webpack@5.110.3) + version: 2.0.3(@rsbuild/core@2.0.14)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(webpack@5.110.3) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10605,13 +10438,13 @@ importers: version: link:../../../packages/start-static-server-functions '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10621,7 +10454,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10642,16 +10475,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-bun: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-devtools': specifier: ^0.7.0 - version: 0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12) + version: 0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10668,24 +10501,24 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 devDependencies: '@tanstack/eslint-config': specifier: ^0.3.2 - version: 0.3.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + version: 0.3.2(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) '@testing-library/dom': specifier: ^10.4.1 version: 10.4.1 '@testing-library/react': specifier: ^16.3.0 - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/bun': specifier: ^1.2.22 version: 1.2.22(@types/react@19.2.9) @@ -10703,7 +10536,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) jsdom: specifier: ^27.0.0 version: 27.0.0(supports-color@10.2.2) @@ -10715,10 +10548,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: ^5.0.4 - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) web-vitals: specifier: ^5.1.0 version: 5.1.0 @@ -10727,7 +10560,7 @@ importers: dependencies: '@clerk/tanstack-react-start': specifier: ^0.27.14 - version: 0.27.14(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 0.27.14(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10739,13 +10572,13 @@ importers: version: link:../../../packages/react-start '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10758,7 +10591,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10779,19 +10612,19 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-convex-trellaux: dependencies: '@convex-dev/react-query': specifier: 0.0.0-alpha.8 - version: 0.0.0-alpha.8(@tanstack/react-query@5.102.0(react@19.2.9))(convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 0.0.0-alpha.8(@tanstack/react-query@5.102.0(react@19.2.3))(convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10809,7 +10642,7 @@ importers: version: 8.2.2 convex: specifier: ^1.19.0 - version: 1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3) ky: specifier: ^1.7.4 version: 1.7.4 @@ -10817,14 +10650,14 @@ importers: specifier: ^2.7.0 version: 2.7.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) react-hot-toast: specifier: ^2.5.1 - version: 2.5.1(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 2.5.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10837,7 +10670,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10852,7 +10685,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10861,7 +10694,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-counter: dependencies: @@ -10875,11 +10708,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@types/node': specifier: 25.0.9 @@ -10895,19 +10728,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-i18n-paraglide: dependencies: '@tanstack/react-devtools': specifier: ^0.7.0 - version: 0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12) + version: 0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10918,18 +10751,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@inlang/paraglide-js': specifier: ^2.4.0 version: 2.4.0(babel-plugin-macros@3.1.0) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -10944,7 +10777,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -10953,13 +10786,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-large: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -10970,11 +10803,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -10987,7 +10820,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -11002,7 +10835,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -11011,7 +10844,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-material-ui: dependencies: @@ -11020,16 +10853,16 @@ importers: version: 11.14.0 '@emotion/react': specifier: 11.14.0 - version: 11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + version: 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) '@emotion/styled': specifier: 11.14.0 - version: 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + version: 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) '@fontsource-variable/roboto': specifier: 5.2.5 version: 5.2.5 '@mui/material': specifier: 6.4.7 - version: 6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11040,11 +10873,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) zod: specifier: ^4.4.3 version: 4.4.3 @@ -11063,13 +10896,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-next-migration: dependencies: @@ -11084,13 +10917,13 @@ importers: version: 9.0.1 next: specifier: 16.3.4 - version: 16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.97.2) + version: 16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@playwright/test': specifier: ^1.63.0 @@ -11106,7 +10939,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta @@ -11115,7 +10948,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-rscs: dependencies: @@ -11132,11 +10965,11 @@ importers: specifier: ^4.0.10 version: 4.2.1 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -11145,11 +10978,11 @@ importers: version: 4.4.3 zustand: specifier: ^5.0.10 - version: 5.0.12(@types/react@19.2.9)(immer@10.1.1)(react@19.2.9)(use-sync-external-store@1.6.0(react@19.2.9)) + version: 5.0.12(@types/react@19.2.9)(immer@10.1.1)(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3)) devDependencies: '@tailwindcss/vite': specifier: ^4.1.18 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -11161,10 +10994,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-rsc': - specifier: ^0.5.39 - version: 0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + specifier: ^0.5.37 + version: 0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) nitro: specifier: ^3.0.260903-beta version: 3.0.260903-beta @@ -11176,7 +11009,7 @@ importers: version: 5.9.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-streaming-data-from-server-functions: dependencies: @@ -11190,11 +11023,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) zod: specifier: ^4.4.3 version: 4.4.3 @@ -11213,13 +11046,13 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-supabase-basic: dependencies: @@ -11239,18 +11072,18 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -11262,7 +11095,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -11271,7 +11104,7 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-tailwind-v4: dependencies: @@ -11285,11 +11118,11 @@ importers: specifier: workspace:* version: link:../../../packages/react-start react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) tailwind-merge: specifier: ^3.6.0 version: 3.6.0 @@ -11299,7 +11132,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -11314,7 +11147,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -11323,16 +11156,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-trellaux: dependencies: '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11352,14 +11185,14 @@ importers: specifier: ^2.7.0 version: 2.7.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) react-hot-toast: specifier: ^2.5.1 - version: 2.5.1(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 2.5.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -11372,7 +11205,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -11387,7 +11220,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -11396,13 +11229,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/start-workos: dependencies: '@radix-ui/themes': specifier: ^3.3.0 - version: 3.3.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 3.3.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11414,13 +11247,13 @@ importers: version: link:../../../packages/react-start '@workos/authkit-tanstack-react-start': specifier: ^0.5.0 - version: 0.5.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 0.5.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) devDependencies: '@types/react': specifier: ^19.2.8 @@ -11433,19 +11266,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/view-transitions: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11456,11 +11289,11 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -11482,19 +11315,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/with-framer-motion: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11503,13 +11336,13 @@ importers: version: link:../../../packages/react-router-devtools framer-motion: specifier: ^11.18.2 - version: 11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -11531,19 +11364,19 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/with-trpc: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11563,11 +11396,11 @@ importers: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -11589,25 +11422,25 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tsx: specifier: ^4.20.3 version: 4.20.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/react/with-trpc-react-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-query-devtools': specifier: ^5.90.0 - version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9) + version: 5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../../../packages/react-router @@ -11625,16 +11458,16 @@ importers: version: 11.4.3(@typescript/typescript6@6.0.2) '@trpc/tanstack-react-query': specifier: ^11.4.3 - version: 11.4.3(@tanstack/react-query@5.102.0(react@19.2.9))(@trpc/client@11.4.3(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2))(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 11.4.3(@tanstack/react-query@5.102.0(react@19.2.3))(@trpc/client@11.4.3(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2))(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) express: specifier: ^5.2.1 version: 5.2.1(supports-color@10.2.2) react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -11656,24 +11489,24 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: ^6.0.1 - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) tsx: specifier: ^4.20.3 version: 4.20.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) examples/solid/authenticated-routes: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11699,21 +11532,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/authenticated-routes-firebase: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11745,18 +11578,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11785,21 +11618,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-default-search-params: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11825,18 +11658,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-devtools-panel: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11859,18 +11692,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11899,18 +11732,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-non-nested-devtools: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11939,16 +11772,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-solid-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) @@ -11956,7 +11789,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -11982,16 +11815,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-solid-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) @@ -11999,7 +11832,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12028,10 +11861,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-ssr-file-based: dependencies: @@ -12039,7 +11872,7 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router compression: specifier: ^1.8.0 @@ -12071,18 +11904,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-ssr-streaming-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12126,21 +11959,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-virtual-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12169,21 +12002,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/basic-virtual-inside-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12212,18 +12045,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/deferred-data: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12249,21 +12082,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/i18n-paraglide: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router solid-js: specifier: 1.9.12 @@ -12286,18 +12119,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/kitchen-sink: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12326,18 +12159,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/kitchen-sink-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12369,16 +12202,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/kitchen-sink-solid-query: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) @@ -12386,7 +12219,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12415,16 +12248,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/kitchen-sink-solid-query-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -12435,7 +12268,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12464,16 +12297,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/large-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -12481,7 +12314,7 @@ importers: specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12507,21 +12340,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/location-masking: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12544,21 +12377,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/navigation-blocking: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-query': specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12581,18 +12414,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/quickstart: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12612,10 +12445,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/quickstart-esbuild-file-based: dependencies: @@ -12623,7 +12456,7 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12646,15 +12479,15 @@ importers: version: 0.27.4 esbuild-plugin-solid: specifier: ^0.6.0 - version: 0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@10.2.2) + version: 0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@7.2.0) examples/solid/quickstart-file-based: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12683,10 +12516,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/quickstart-rspack-file-based: dependencies: @@ -12694,7 +12527,7 @@ importers: specifier: ^4.2.2 version: 4.2.2 '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12710,14 +12543,14 @@ importers: version: 4.2.2 devDependencies: '@rsbuild/core': - specifier: ^2.3.1 - version: 2.3.1 + specifier: ^2.1.0 + version: 2.1.1 '@rsbuild/plugin-babel': specifier: ^1.1.2 - version: 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + version: 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@rsbuild/plugin-solid': - specifier: ^1.1.1 - version: 1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2) + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -12731,7 +12564,7 @@ importers: examples/solid/quickstart-webpack-file-based: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12781,13 +12614,13 @@ importers: version: '@typescript/typescript6@6.0.2' webpack: specifier: ^5.97.1 - version: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + version: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) webpack-cli: specifier: ^5.1.4 version: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.97.1) webpack-dev-server: specifier: ^5.2.4 - version: 5.2.4(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) + version: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) examples/solid/router-monorepo-simple: dependencies: @@ -12795,7 +12628,7 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12818,13 +12651,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/router-monorepo-simple-lazy: dependencies: @@ -12832,7 +12665,7 @@ importers: specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12855,13 +12688,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/router-monorepo-solid-query: dependencies: @@ -12875,7 +12708,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12898,21 +12731,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-dts: specifier: 4.2.3 - version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/scroll-restoration: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12935,16 +12768,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/search-validator-adapters: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/arktype-adapter': specifier: workspace:* version: link:../../../packages/arktype-adapter @@ -12955,7 +12788,7 @@ importers: specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -12999,18 +12832,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: ^5.0.4 - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13030,7 +12863,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13048,10 +12881,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-auth: dependencies: @@ -13063,9 +12896,9 @@ importers: version: 7.0.0 '@prisma/client': specifier: ^7.0.0 - version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + version: 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13088,7 +12921,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13100,7 +12933,7 @@ importers: version: 17.2.3 prisma: specifier: ^7.0.0 - version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) tailwindcss: specifier: ^4.2.2 version: 4.2.2 @@ -13109,10 +12942,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-authjs: dependencies: @@ -13120,7 +12953,7 @@ importers: specifier: ^0.41.1 version: 0.41.1 '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13140,7 +12973,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13155,15 +12988,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-cloudflare: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13177,10 +13010,10 @@ importers: devDependencies: '@cloudflare/vite-plugin': specifier: ^1.29.0 - version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0) + version: 1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13195,10 +13028,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) wrangler: specifier: ^4.74.0 version: 4.75.0 @@ -13206,7 +13039,7 @@ importers: examples/solid/start-basic-netlify: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13220,10 +13053,10 @@ importers: devDependencies: '@netlify/vite-plugin-tanstack-start': specifier: ^1.3.19 - version: 1.3.19(@tanstack/solid-start@packages+solid-start)(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 1.3.19(@tanstack/solid-start@packages+solid-start)(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13238,15 +13071,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-nitro: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13260,7 +13093,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13278,10 +13111,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-solid-query: dependencies: @@ -13292,7 +13125,7 @@ importers: specifier: ^5.90.0 version: 5.90.4(@tanstack/solid-query@5.102.0(solid-js@1.9.12))(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13315,7 +13148,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13330,15 +13163,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-basic-static: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13361,7 +13194,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13376,16 +13209,16 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-bun: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -13393,7 +13226,7 @@ importers: specifier: ^0.7.0 version: 0.7.14(csstype@3.2.3)(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13416,7 +13249,7 @@ importers: version: 0.8.10(solid-js@1.9.12) '@tanstack/eslint-config': specifier: ^0.3.2 - version: 0.3.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + version: 0.3.2(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) '@testing-library/dom': specifier: ^10.4.1 version: 10.4.1 @@ -13440,13 +13273,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: ^5.0.4 - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) web-vitals: specifier: ^5.1.0 version: 5.1.0 @@ -13455,12 +13288,12 @@ importers: dependencies: '@convex-dev/better-auth': specifier: ^0.9.7 - version: 0.9.7(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)))(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9))(hono@4.13.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 0.9.7(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)))(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3))(hono@4.13.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13470,16 +13303,16 @@ importers: version: link:../../../packages/solid-start better-auth: specifier: ^1.6.19 - version: 1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)) clsx: specifier: ^2.1.1 version: 2.1.1 convex: specifier: ^1.28.2 - version: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9) + version: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3) convex-solidjs: specifier: ^0.0.3 - version: 0.0.3(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9)(solid-js@1.9.12) + version: 0.0.3(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3)(solid-js@1.9.12) redaxios: specifier: ^0.5.1 version: 0.5.1 @@ -13510,15 +13343,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-counter: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13553,10 +13386,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-i18n-paraglide: dependencies: @@ -13564,7 +13397,7 @@ importers: specifier: ^0.7.0 version: 0.7.14(csstype@3.2.3)(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13581,7 +13414,7 @@ importers: version: 2.4.0(babel-plugin-macros@3.1.0) '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13596,10 +13429,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-large: dependencies: @@ -13607,7 +13440,7 @@ importers: specifier: ^5.102.0 version: 5.102.0(solid-js@1.9.12) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13630,7 +13463,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13645,15 +13478,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-streaming-data-from-server-functions: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13679,10 +13512,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-supabase-basic: dependencies: @@ -13693,7 +13526,7 @@ importers: specifier: ^2.48.1 version: 2.48.1 '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13710,7 +13543,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13725,15 +13558,15 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/start-tailwind-v4: dependencies: '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13753,7 +13586,7 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -13768,21 +13601,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/view-transitions: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13808,18 +13641,18 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/with-framer-motion: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13848,21 +13681,21 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/solid/with-trpc: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin '@tanstack/solid-router': - specifier: ^1.170.43 + specifier: ^1.170.42 version: link:../../../packages/solid-router '@tanstack/solid-router-devtools': specifier: workspace:^ @@ -13897,10 +13730,10 @@ importers: version: 4.20.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: ^2.11.11 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) examples/vue/basic: dependencies: @@ -13922,22 +13755,22 @@ importers: devDependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@typescript/native': specifier: npm:typescript@^7.0.2 version: typescript@7.0.2 '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) typescript: specifier: npm:@typescript/typescript6@^6.0.2 version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(@typescript/typescript6@6.0.2) @@ -13946,7 +13779,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -13980,10 +13813,10 @@ importers: version: 8.44.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@5.8.3) '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) eslint-plugin-vue: specifier: ^9.33.0 version: 9.33.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -13992,7 +13825,7 @@ importers: version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-eslint-parser: specifier: ^9.4.3 version: 9.4.3(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -14004,7 +13837,7 @@ importers: dependencies: '@tailwindcss/vite': specifier: ^4.2.2 - version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/router-plugin': specifier: workspace:* version: link:../../../packages/router-plugin @@ -14029,16 +13862,16 @@ importers: devDependencies: '@vitejs/plugin-vue': specifier: ^6.0.5 - version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) '@vitejs/plugin-vue-jsx': specifier: ^5.1.5 - version: 5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) + version: 5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3)) typescript: specifier: ~5.8.3 version: 5.8.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue-tsc: specifier: ^3.3.8 version: 3.3.8(typescript@5.8.3) @@ -14053,13 +13886,13 @@ importers: version: link:../react-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -14076,20 +13909,54 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + + packages/compiler-test-utils: + dependencies: + '@jridgewell/trace-mapping': + specifier: ^0.3.31 + version: 0.3.31 + '@playwright/test': + specifier: ^1.63.0 + version: 1.63.0 + '@rsbuild/core': + specifier: 'catalog:' + version: 2.2.5 + esbuild: + specifier: ^0.28.2 + version: 0.28.2 + globals: + specifier: ^16.2.0 + version: 16.4.0 + vite: + specifier: ^8.3.4 + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitest: + specifier: 'catalog:' + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + webpack: + specifier: ^5.104.1 + version: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + devDependencies: + '@types/node': + specifier: 25.0.9 + version: 25.0.9 + yuku: + specifier: ^0.22.1 + version: 0.22.1 packages/eslint-plugin-router: dependencies: @@ -14102,7 +13969,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@typescript-eslint/rule-tester': specifier: ^8.23.0 version: 8.23.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -14120,10 +13987,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/eslint-plugin-start: dependencies: @@ -14139,7 +14006,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(rollup@4.63.1)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@typescript-eslint/rule-tester': specifier: ^8.44.1 version: 8.53.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(typescript@5.9.2) @@ -14157,7 +14024,7 @@ importers: version: 5.9.2 vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/history: devDependencies: @@ -14166,7 +14033,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -14178,10 +14045,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-router: dependencies: @@ -14190,7 +14057,7 @@ importers: version: link:../history '@tanstack/react-store': specifier: ^0.11.2 - version: 0.11.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 0.11.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/router-core': specifier: workspace:* version: link:../router-core @@ -14206,16 +14073,16 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14227,7 +14094,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) combinate: specifier: 'catalog:' version: 1.1.11 @@ -14241,20 +14108,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) zod: specifier: 'catalog:' version: 4.5.4 @@ -14279,7 +14146,7 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14291,7 +14158,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14302,20 +14169,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-router-ssr-query: dependencies: @@ -14334,13 +14201,13 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/react-query': specifier: ^5.102.0 - version: 5.102.0(react@19.2.9) + version: 5.102.0(react@19.2.3) '@tanstack/react-router': specifier: workspace:* version: link:../react-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -14349,7 +14216,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14360,20 +14227,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-start: dependencies: @@ -14406,7 +14273,7 @@ importers: version: 2.0.3 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) devDependencies: '@arethetypeswrong/cli': specifier: 'catalog:' @@ -14416,10 +14283,10 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@rsbuild/core': specifier: 'catalog:' - version: 2.3.1 + version: 2.2.5 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14439,17 +14306,17 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-start-client: dependencies: @@ -14471,10 +14338,10 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14486,7 +14353,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14497,20 +14364,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-start-rsc: dependencies: @@ -14545,15 +14412,21 @@ importers: '@eslint-react/eslint-plugin': specifier: 'catalog:' version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) + '@rsbuild/plugin-react': + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) '@rspack/core': specifier: 2.2.7 version: 2.2.7(@swc/helpers@0.5.23) + '@tanstack/compiler-test-utils': + specifier: workspace:* + version: link:../compiler-test-utils '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -14562,10 +14435,10 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-rsc': - specifier: ^0.5.39 - version: 0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + specifier: ^0.5.37 + version: 0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14576,20 +14449,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) react-server-dom-rspack: - specifier: ^0.1.1 - version: 0.1.1(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + specifier: ^0.0.2 + version: 0.0.2(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-dom@19.2.3(react@19.2.3))(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/react-start-server: dependencies: @@ -14611,7 +14484,7 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -14623,7 +14496,7 @@ importers: version: typescript@7.0.2 '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14634,11 +14507,11 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 @@ -14647,10 +14520,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-cli: dependencies: @@ -14669,7 +14542,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14681,10 +14554,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-core: dependencies: @@ -14709,7 +14582,7 @@ importers: version: 0.11.2 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -14727,10 +14600,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-devtools: dependencies: @@ -14752,7 +14625,7 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -14761,7 +14634,7 @@ importers: version: 19.2.3(@types/react@19.2.9) '@vitejs/plugin-react': specifier: 'catalog:' - version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-react-hooks: specifier: 'catalog:' version: 5.1.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) @@ -14769,20 +14642,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-devtools-core: dependencies: @@ -14804,7 +14677,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) @@ -14822,13 +14695,13 @@ importers: version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-generator: dependencies: @@ -14860,33 +14733,60 @@ importers: '@arethetypeswrong/cli': specifier: 'catalog:' version: 0.18.4 + '@tanstack/compiler-test-utils': + specifier: workspace:* + version: link:../compiler-test-utils '@tanstack/react-router': specifier: workspace:* version: link:../react-router + '@tanstack/solid-router': + specifier: workspace:* + version: link:../solid-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@tanstack/vue-router': + specifier: workspace:* + version: link:../vue-router '@types/node': specifier: 25.0.9 version: 25.0.9 '@types/react': specifier: ^19.2.8 version: 19.2.9 + '@types/react-dom': + specifier: ^19.2.3 + version: 19.2.3(@types/react@19.2.9) + '@vitejs/plugin-vue': + specifier: ^6.0.5 + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) publint: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 + react-dom: + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 + solid-js: + specifier: 1.9.12 + version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-solid: + specifier: 'catalog:' + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vue: + specifier: 'catalog:' + version: 3.5.25(@typescript/typescript6@6.0.2) packages/router-plugin: dependencies: @@ -14915,14 +14815,11 @@ importers: specifier: 'catalog:' version: 5.0.0 unplugin: - specifier: ^3.5.0 - version: 3.7.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(esbuild@0.28.1)(rolldown@1.2.13)(rollup@4.63.1)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(webpack@5.110.3) + specifier: ^3.3.0 + version: 3.3.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.13)(rollup@4.63.1)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(webpack@5.110.3) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-solid: - specifier: ^2.11.10 || ^3.0.0-0 - version: 2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) zod: specifier: 'catalog:' version: 4.5.4 @@ -14930,12 +14827,45 @@ importers: '@arethetypeswrong/cli': specifier: 'catalog:' version: 0.18.4 + '@babel/preset-typescript': + specifier: ^7.28.5 + version: 7.28.5(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@emotion/react': + specifier: ^11.14.0 + version: 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) + '@rolldown/plugin-babel': + specifier: ^0.2.0 + version: 0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@rsbuild/core': specifier: 'catalog:' - version: 2.3.1 + version: 2.2.5 + '@rsbuild/plugin-babel': + specifier: ^1.1.2 + version: 1.1.2(@rsbuild/core@2.2.5)(supports-color@10.2.2) + '@rsbuild/plugin-react': + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) + '@rsbuild/plugin-solid': + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.2.5)(solid-js@1.9.12)(supports-color@10.2.2) + '@rsbuild/plugin-vue': + specifier: ^1.2.7 + version: 1.2.7(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + '@rsbuild/plugin-vue-jsx': + specifier: ^2.0.0 + version: 2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.2.5)(supports-color@10.2.2) + '@tanstack/compiler-test-utils': + specifier: workspace:* + version: link:../compiler-test-utils + '@tanstack/solid-router': + specifier: workspace:* + version: link:../solid-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@tanstack/vue-router': + specifier: workspace:* + version: link:../vue-router '@types/babel__core': specifier: ^7.20.5 version: 7.20.5 @@ -14951,30 +14881,54 @@ importers: '@types/react-dom': specifier: ^19.2.3 version: 19.2.3(@types/react@19.2.9) - jsdom: + '@vitejs/plugin-react': specifier: 'catalog:' - version: 25.0.1(supports-color@10.2.2) - prettier: - specifier: ^3.9.6 - version: 3.9.6 + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitejs/plugin-vue-jsx': + specifier: 'catalog:' + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + babel-loader: + specifier: ^10.0.0 + version: 10.0.0(@babel/core@7.29.7(supports-color@10.2.2))(webpack@5.110.3) + babel-plugin-react-compiler: + specifier: ^1.0.0 + version: 1.0.0 + babel-preset-solid: + specifier: ^1.9.10 + version: 1.9.10(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) publint: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) + react-error-boundary: + specifier: ^6.1.6 + version: 6.1.6(@types/react@19.2.9)(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 + solid-js: + specifier: 1.9.12 + version: 1.9.12 + vite-plugin-solid: + specifier: 'catalog:' + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vue: + specifier: 'catalog:' + version: 3.5.25(@typescript/typescript6@6.0.2) webpack: specifier: ^5.104.1 - version: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + version: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack-dev-server: + specifier: ^5.2.4 + version: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3) packages/router-ssr-query-core: devDependencies: @@ -14989,7 +14943,7 @@ importers: version: link:../router-core '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -15001,10 +14955,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/router-utils: dependencies: @@ -15038,7 +14992,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/babel__generator': specifier: ^7.27.0 version: 7.27.0 @@ -15053,10 +15007,7 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitest: - specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) packages/router-vite-plugin: dependencies: @@ -15069,7 +15020,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) publint: specifier: 'catalog:' version: 0.3.17 @@ -15078,10 +15029,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/solid-router: dependencies: @@ -15109,7 +15060,7 @@ importers: version: 0.8.10(solid-js@1.9.12) '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) @@ -15133,13 +15084,13 @@ importers: version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) zod: specifier: 'catalog:' version: 4.5.4 @@ -15161,7 +15112,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15176,13 +15127,13 @@ importers: version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/solid-router-ssr-query: dependencies: @@ -15204,7 +15155,7 @@ importers: version: link:../solid-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) eslint-plugin-solid: specifier: ^0.14.5 version: 0.14.5(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -15222,13 +15173,13 @@ importers: version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/solid-start: dependencies: @@ -15265,13 +15216,13 @@ importers: version: 1.26.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)(ts-api-utils@2.4.0(@typescript/typescript6@6.0.2)) '@rsbuild/core': specifier: 'catalog:' - version: 2.3.1 + version: 2.2.5 '@tanstack/router-utils': specifier: workspace:* version: link:../router-utils '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15289,10 +15240,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/solid-start-client: dependencies: @@ -15314,7 +15265,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) @@ -15329,13 +15280,13 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/solid-start-server: dependencies: @@ -15354,7 +15305,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@typescript/native': specifier: npm:typescript@^7.0.2 version: typescript@7.0.2 @@ -15375,13 +15326,13 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vite-plugin-solid: specifier: 'catalog:' - version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-client-core: dependencies: @@ -15403,7 +15354,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15418,10 +15369,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-fn-stubs: devDependencies: @@ -15430,7 +15381,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) publint: specifier: 'catalog:' version: 0.3.17 @@ -15439,10 +15390,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-plugin-core: dependencies: @@ -15475,7 +15426,7 @@ importers: version: link:../start-server-core exsolve: specifier: ^1.1.3 - version: 1.2.0 + version: 1.1.3 lightningcss: specifier: ^1.33.0 version: 1.33.0 @@ -15502,7 +15453,7 @@ importers: version: 1.6.4 vitefu: specifier: ^1.1.3 - version: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) xmlbuilder2: specifier: ^4.0.3 version: 4.0.3 @@ -15513,12 +15464,33 @@ importers: '@arethetypeswrong/cli': specifier: 'catalog:' version: 0.18.4 + '@mdx-js/loader': + specifier: ^3.1.1 + version: 3.1.1(supports-color@10.2.2)(webpack@5.110.3) + '@mdx-js/rollup': + specifier: ^3.1.1 + version: 3.1.1(rollup@4.63.1)(supports-color@10.2.2) '@rsbuild/core': specifier: 'catalog:' - version: 2.3.1 + version: 2.2.5 + '@rsbuild/plugin-babel': + specifier: ^1.1.2 + version: 1.1.2(@rsbuild/core@2.2.5)(supports-color@10.2.2) + '@rsbuild/plugin-react': + specifier: ^2.0.0 + version: 2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23)) + '@rsbuild/plugin-solid': + specifier: ^1.2.2 + version: 1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.2.5)(solid-js@1.9.12)(supports-color@10.2.2) + '@tanstack/compiler-test-utils': + specifier: workspace:* + version: link:../compiler-test-utils + '@tanstack/react-router': + specifier: workspace:* + version: link:../react-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/babel__code-frame': specifier: ^7.0.6 version: 7.0.6 @@ -15531,21 +15503,45 @@ importers: '@types/picomatch': specifier: ^4.0.2 version: 4.0.2 - prettier: - specifier: ^3.9.6 - version: 3.9.6 + '@vitejs/plugin-react': + specifier: 'catalog:' + version: 6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitejs/plugin-vue': + specifier: ^6.0.5 + version: 6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + '@vitejs/plugin-vue-jsx': + specifier: 'catalog:' + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + miniflare: + specifier: 4.20260317.0 + version: 4.20260317.0 publint: specifier: 'catalog:' version: 0.3.17 + react: + specifier: ^19.2.3 + version: 19.2.3 + react-dom: + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 + solid-js: + specifier: 1.9.12 + version: 1.9.12 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-solid: + specifier: 'catalog:' + version: 2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: + specifier: ^6.1.1 + version: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-server-core: dependencies: @@ -15579,7 +15575,7 @@ importers: version: 1.0.0 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15597,10 +15593,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-static-server-functions: dependencies: @@ -15622,7 +15618,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15637,10 +15633,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/start-storage-context: dependencies: @@ -15653,7 +15649,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 @@ -15668,10 +15664,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/valibot-adapter: devDependencies: @@ -15683,13 +15679,13 @@ importers: version: link:../react-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -15703,23 +15699,23 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 valibot: specifier: 1.0.0-beta.15 - version: 1.0.0-beta.15(@typescript/typescript6@6.0.2) + version: 1.0.0-beta.15(typescript@7.0.2) vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/virtual-file-routes: devDependencies: @@ -15728,7 +15724,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -15740,10 +15736,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) packages/vue-router: dependencies: @@ -15768,7 +15764,7 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) @@ -15780,7 +15776,7 @@ importers: version: 25.0.9 '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) '@vitest/ui': specifier: 'catalog:' version: 5.0.4(vitest@5.0.4) @@ -15798,10 +15794,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -15822,20 +15818,20 @@ importers: version: link:../vue-router vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) devDependencies: '@arethetypeswrong/cli': specifier: 'catalog:' version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) publint: specifier: 'catalog:' version: 0.3.17 @@ -15844,7 +15840,7 @@ importers: version: 6.1.2 vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -15866,13 +15862,13 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@tanstack/vue-router': specifier: workspace:* version: link:../vue-router '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) publint: specifier: 'catalog:' version: 0.3.17 @@ -15881,10 +15877,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -15918,19 +15914,19 @@ importers: version: 0.18.4 '@rsbuild/core': specifier: 'catalog:' - version: 2.3.1 + version: 2.2.5 '@tanstack/router-utils': specifier: workspace:* version: link:../router-utils '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@types/node': specifier: 25.0.9 version: 25.0.9 '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -15942,10 +15938,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -15967,10 +15963,10 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -15982,10 +15978,10 @@ importers: version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -16007,13 +16003,13 @@ importers: version: 0.18.4 '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@typescript/native': specifier: npm:typescript@^7.0.2 version: typescript@7.0.2 '@vitejs/plugin-vue-jsx': specifier: 'catalog:' - version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) + version: 4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2)) jsdom: specifier: 'catalog:' version: 25.0.1(supports-color@10.2.2) @@ -16028,10 +16024,10 @@ importers: version: '@typescript/typescript6@6.0.2' vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: specifier: 'catalog:' version: 3.5.25(@typescript/typescript6@6.0.2) @@ -16046,13 +16042,13 @@ importers: version: link:../react-router '@tanstack/vite-config': specifier: 'catalog:' - version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@testing-library/jest-dom': specifier: 'catalog:' version: 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) '@testing-library/react': specifier: 'catalog:' - version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + version: 16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@types/react': specifier: ^19.2.8 version: 19.2.9 @@ -16066,20 +16062,20 @@ importers: specifier: 'catalog:' version: 0.3.17 react: - specifier: ~19.2.9 - version: 19.2.9 + specifier: ^19.2.3 + version: 19.2.3 react-dom: - specifier: ~19.2.9 - version: 19.2.9(react@19.2.9) + specifier: ^19.2.3 + version: 19.2.3(react@19.2.3) rimraf: specifier: 'catalog:' version: 6.1.2 vite: specifier: ^8.3.4 - version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + version: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vitest: specifier: 'catalog:' - version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + version: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) zod: specifier: ^3.24.2 version: 3.25.57 @@ -16188,6 +16184,10 @@ packages: resolution: {integrity: sha512-fXSwMQqitTGeHLBC08Eq5yXz2m37E4pJX1qAU1+2cNedz/ifv/bVXft90VeSav5nFO61EcNgwr0aJxbyPaWBPg==} engines: {node: '>=6.9.0'} + '@babel/helper-annotate-as-pure@7.29.7': + resolution: {integrity: sha512-OoK6239jHPuSQOoS0kfTVKn0b/rVTk0seKq4Gd2UMLtmOVLjDC0ki3e+c90Trqv2gMfvJFqkiljrr568+qddiw==} + engines: {node: '>=6.9.0'} + '@babel/helper-compilation-targets@7.27.2': resolution: {integrity: sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==} engines: {node: '>=6.9.0'} @@ -16212,6 +16212,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-create-class-features-plugin@7.29.7': + resolution: {integrity: sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-globals@7.28.0': resolution: {integrity: sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==} engines: {node: '>=6.9.0'} @@ -16228,6 +16234,10 @@ packages: resolution: {integrity: sha512-cwM7SBRZcPCLgl8a7cY0soT1SptSzAlMH39vwiRpOQkJlh53r5hdHwLSCZpQdVLT39sZt+CRpNwYG4Y2v77atg==} engines: {node: '>=6.9.0'} + '@babel/helper-member-expression-to-functions@7.29.7': + resolution: {integrity: sha512-j+7JYmk1JYDtACIGj0QJqqWZjoUpMoEikQGADMaHgCMCSDqd2+P32rfcibUNrGOMWrlzK1WJBdxrB3JJQZwWtg==} + engines: {node: '>=6.9.0'} + '@babel/helper-module-imports@7.18.6': resolution: {integrity: sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==} engines: {node: '>=6.9.0'} @@ -16266,6 +16276,10 @@ packages: resolution: {integrity: sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==} engines: {node: '>=6.9.0'} + '@babel/helper-optimise-call-expression@7.29.7': + resolution: {integrity: sha512-+kmGVjcT9RGYzoDwdwEqEvGgKe3BYq+O1iGzjFubaNgZHwYHP6lsF2Yghf4kEuv9BV7tYDZ913aBW9am6YKong==} + engines: {node: '>=6.9.0'} + '@babel/helper-plugin-utils@7.27.1': resolution: {integrity: sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==} engines: {node: '>=6.9.0'} @@ -16274,6 +16288,10 @@ packages: resolution: {integrity: sha512-S9gzZ/bz83GRysI7gAD4wPT/AI3uCnY+9xn+Mx/KPs2JwHJIz1W8PZkg2cqyt3RNOBM8ejcXhV6y8Og7ly/Dug==} engines: {node: '>=6.9.0'} + '@babel/helper-plugin-utils@7.29.7': + resolution: {integrity: sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==} + engines: {node: '>=6.9.0'} + '@babel/helper-replace-supers@7.27.1': resolution: {integrity: sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==} engines: {node: '>=6.9.0'} @@ -16286,10 +16304,20 @@ packages: peerDependencies: '@babel/core': ^7.0.0 + '@babel/helper-replace-supers@7.29.7': + resolution: {integrity: sha512-atfGXWSeCiF4DnKZIfmJfQRkSw9b9gNNXR1kqKjbhG4pGYCOnkp8OcTB8E3NXjBu8NpheSnOeNKz8KT7UNFTmQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0 + '@babel/helper-skip-transparent-expression-wrappers@7.27.1': resolution: {integrity: sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==} engines: {node: '>=6.9.0'} + '@babel/helper-skip-transparent-expression-wrappers@7.29.7': + resolution: {integrity: sha512-brcMGQaVzIeUb+6/bs1Av0f8YuNNjKY2JyvfRCsFuFsdKccEQ5Ges2y74D74NZ1Rz8lKJ9ksJkfqwQFJ/iNEyQ==} + engines: {node: '>=6.9.0'} + '@babel/helper-string-parser@7.29.7': resolution: {integrity: sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==} engines: {node: '>=6.9.0'} @@ -16346,6 +16374,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-jsx@7.29.7': + resolution: {integrity: sha512-TSu8+mHCoEaaCDEZ0I3+6mvTBYR4PCxQwf2z9/r5Tbztv6NaLR3B9thGTTxX2WGuGHJqRiAbKPeGTJ5XWXVg6A==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-typescript@7.27.1': resolution: {integrity: sha512-xfYCBMxveHrRMnAWl1ZlPXOZjzkN82THFvLhQhFXFt81Z5HnN+EtUkZhv/zcKpmT3fzmWZB0ywiBrbC3vogbwQ==} engines: {node: '>=6.9.0'} @@ -16358,18 +16392,36 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-syntax-typescript@7.29.7': + resolution: {integrity: sha512-ngr+82Sh0xMz25TPCZi+nC2iTzjfCdWS2ONXTp/PtSCHCgaCNBpdMqgvJ2ccdLlClVZ7sisIgB914j/JFe+RZA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-class-properties@7.28.6': resolution: {integrity: sha512-dY2wS3I2G7D697VHndN91TJr8/AAfXQNt5ynCTI/MpxMsSzHp+52uNivYT5wCPax3whc47DR8Ba7cmlQMg24bw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-class-properties@7.29.7': + resolution: {integrity: sha512-GtcpjFvanPfzNQi3eTitsCqtRRmmqzpy/A+yhTR1HaZo1Ly3EA8ZXxlPyHdR8/IuRMYc3E4wdGBewB2QKQjAaA==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-modules-commonjs@7.27.1': resolution: {integrity: sha512-OJguuwlTYlN0gBZFRPqwOGNWssZjfIUdS7HMYtN8c1KmwpwHFBwTeFZrg9XZa+DFTitWOW5iTAG7tyCUPsCCyw==} engines: {node: '>=6.9.0'} peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-modules-commonjs@7.29.7': + resolution: {integrity: sha512-j0vCldybPC5b5dwCQOJ21uKtHzt7hxLygJTg9eF1ScfaikEDNfzn94XoW5Fi+seBR0nCyL23xaBFFkq7dTM8XQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-typescript@7.27.1': resolution: {integrity: sha512-Q5sT5+O4QUebHdbwKedFBEwRLb02zJ7r4A5Gg2hUoLuU3FjdMcyqcywqUrLCaDsFCxzokf7u9kuy7qz51YUuAg==} engines: {node: '>=6.9.0'} @@ -16382,6 +16434,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/plugin-transform-typescript@7.29.9': + resolution: {integrity: sha512-FFwIwzU+7SCOuxxV4YtJql6T9981ZVTm+FHO5GhVsRqCTdy0WwrEZh3l42ARpXruJUDGOptdduHW6Zr7pNPLNg==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/preset-typescript@7.27.1': resolution: {integrity: sha512-l7WfQfX0WK4M0v2RudjuQK4u99BS6yLHYEmdtVPP7lKV013zr9DygFuWNlnbvQ9LR+LS0Egz/XAvGx5U9MX0fQ==} engines: {node: '>=6.9.0'} @@ -16394,6 +16452,12 @@ packages: peerDependencies: '@babel/core': ^7.0.0-0 + '@babel/preset-typescript@7.29.7': + resolution: {integrity: sha512-/Foi8vKY2EVbed/1eZx0gJEEwHAIxogrySI7rULcRIvhZzbvoE/b5qG5Ghc0WKAFKOHA9SD1x7RsFlOYdutIiQ==} + engines: {node: '>=6.9.0'} + peerDependencies: + '@babel/core': ^7.0.0-0 + '@babel/runtime@7.26.7': resolution: {integrity: sha512-AOPI3D+a8dXnja+iwsUqGRjr1BbZIe771sXdapOtYI531gSqpi92vXivKcq2asu/DFpdl1ceFAKZyRzK2PCVcQ==} engines: {node: '>=6.9.0'} @@ -16610,23 +16674,23 @@ packages: engines: {node: '>=18.17.0'} deprecated: 'This package is no longer supported. Please use @clerk/react instead. See the upgrade guide for more info: https://clerk.com/docs/guides/development/upgrading/upgrade-guides/core-3' peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@clerk/clerk-react@5.59.3': resolution: {integrity: sha512-r1gmAYxhXs+QkXjDwj5Eqvm0Io8PtJ4FKkA45khiAzIQXcaQLFq/wFy7d1K8OSIYAIdFbuO0bnIOU/FdgWOc+A==} engines: {node: '>=18.17.0'} deprecated: 'This package is no longer supported. Please use @clerk/react instead. See the upgrade guide for more info: https://clerk.com/docs/guides/development/upgrading/upgrade-guides/core-3' peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@clerk/shared@3.28.2': resolution: {integrity: sha512-BfBCPaoPoLCiU0b0MhQUfCjs+bWRRLkdHw0vBffSjtsFLxp1b5IL5D8nKgDPIKIIv7DmCCmO15tr+GqG3CGpYQ==} engines: {node: '>=18.17.0'} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: react: optional: true @@ -16637,8 +16701,8 @@ packages: resolution: {integrity: sha512-sJUur/7jnHHlAsdoDosxpOmfV05VR7K5rvqlFskj3GaAMFEJrvdOztw0hmhBGVSWiCpjTZfdGITegton8mo7mQ==} engines: {node: '>=18.17.0'} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: react: optional: true @@ -16651,8 +16715,8 @@ packages: peerDependencies: '@tanstack/react-router': workspace:* '@tanstack/react-start': workspace:* - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@clerk/tanstack-react-start@0.27.14': resolution: {integrity: sha512-So+pchhM3NUIY0sFqxh3yv2hG9bifPUqkCIDUKVzq0+korMhHTsMXBwcsbt2LpQ9UBXob1dW5v1WxtdWkqELFw==} @@ -16660,8 +16724,8 @@ packages: peerDependencies: '@tanstack/react-router': workspace:* '@tanstack/react-start': workspace:* - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@clerk/types@4.101.10': resolution: {integrity: sha512-qlmgnAm/IeK02RKEKVN8/Glx07xw/Lcv67jBfikM8HXhHc5v7bfYLD8UiWTr6H2RGtvB09cIt9JezRRlsuVBew==} @@ -16673,19 +16737,10 @@ packages: engines: {node: '>=18.17.0'} deprecated: 'This package is no longer supported. Please import types from @clerk/shared/types instead. See the upgrade guide for more info: https://clerk.com/docs/guides/development/upgrading/upgrade-guides/core-3' - '@cloudflare/build-output-utils@0.9.10': - resolution: {integrity: sha512-9F6RSV0FJnF0zQLIoMVgxc0ub57FrZBGKZ8oUQHyVAbbjodlcIHk0BF5fd3B89N/Y4cE+FSqzWfpq3RzFy3tjA==} - - '@cloudflare/config@0.30.2': - resolution: {integrity: sha512-YTasjo8Kvfn3SlVs5gHZ6fy73BNQafY2Y8aosasicO8CTRVj2h8K7h+IJnjHK+tzM00Qi96VcOCfefCNLuMauw==} - '@cloudflare/kv-asset-handler@0.4.2': resolution: {integrity: sha512-SIOD2DxrRRwQ+jgzlXCqoEFiKOFqaPjhnNTGKXSRLvp1HiOvapLaFG2kEr9dYQTYe8rKrd9uvDUzmAITeNyaHQ==} engines: {node: '>=18.0.0'} - '@cloudflare/runtime-types@0.1.23': - resolution: {integrity: sha512-uQVuBfVlJqGFryfyiMG+62KKS6NNC/EKYqbHGnNE2ExhcPNUihfYp3hWtTKshikZe7STTmIaLpDqT+h7J8Fdrw==} - '@cloudflare/unenv-preset@2.15.0': resolution: {integrity: sha512-EGYmJaGZKWl+X8tXxcnx4v2bOZSjQeNI5dWFeXivgX9+YCT69AkzHHwlNbVpqtEUTbew8eQurpyOpeN8fg00nw==} peerDependencies: @@ -16695,15 +16750,6 @@ packages: workerd: optional: true - '@cloudflare/unenv-preset@2.16.2': - resolution: {integrity: sha512-JBP1+Z7ZSNG/d4mRP+y8VC5dka3tZVMLEZRvS+rzQ4DGV1EoxRFQckcJTTkXbHSQiTj0DtNI01Zwb/V2fX0mvQ==} - peerDependencies: - unenv: 2.0.0-rc.24 - workerd: '>1.20260305.0 <2.0.0-0' - peerDependenciesMeta: - workerd: - optional: true - '@cloudflare/vite-plugin@1.29.1': resolution: {integrity: sha512-HTbVG43olzk3KTZD8b0nlmJTI3G6sQdFTmuD9HMJy7bkQbxKppkt16jayFo/NWAAs1GJXpFjLkC8udRdyn3aEg==} peerDependencies: @@ -16716,60 +16762,30 @@ packages: cpu: [x64] os: [darwin] - '@cloudflare/workerd-darwin-64@1.20261104.1': - resolution: {integrity: sha512-5Bl+P1HT1/Ezk7Yrhyd+QkJ4VC/3naO0L3so/AkpgdaAHG3bmUmcCJBAtwH7O4JdVt8SMfm6EV89seiPpdjHJQ==} - engines: {node: '>=16'} - cpu: [x64] - os: [darwin] - '@cloudflare/workerd-darwin-arm64@1.20260317.1': resolution: {integrity: sha512-M/MnNyvO5HMgoIdr3QHjdCj2T1ki9gt0vIUnxYxBu9ISXS/jgtMl6chUVPJ7zHYBn9MyYr8ByeN6frjYxj0MGg==} engines: {node: '>=16'} cpu: [arm64] os: [darwin] - '@cloudflare/workerd-darwin-arm64@1.20261104.1': - resolution: {integrity: sha512-2fM+0klAjspAQ3Jl0iw0gVyGpNnkvPiZ50WHigPLhWQRiS+zhabFXVR07zz1RaPGkJHrMjEpWoEfjjm8nU5IOg==} - engines: {node: '>=16'} - cpu: [arm64] - os: [darwin] - '@cloudflare/workerd-linux-64@1.20260317.1': resolution: {integrity: sha512-1ltuEjkRcS3fsVF7CxsKlWiRmzq2ZqMfqDN0qUOgbUwkpXsLVJsXmoblaLf5OP00ELlcgF0QsN0p2xPEua4Uug==} engines: {node: '>=16'} cpu: [x64] os: [linux] - '@cloudflare/workerd-linux-64@1.20261104.1': - resolution: {integrity: sha512-VgpZIOooZHjSxjEZIJ1hkyt/jTfL3KeavkWCc0x7xxVu9zgkplaJF78Iv6CzoCTamQXyZeBaRQHS2bbAc70Vgg==} - engines: {node: '>=16'} - cpu: [x64] - os: [linux] - '@cloudflare/workerd-linux-arm64@1.20260317.1': resolution: {integrity: sha512-3QrNnPF1xlaNwkHpasvRvAMidOvQs2NhXQmALJrEfpIJ/IDL2la8g499yXp3eqhG3hVMCB07XVY149GTs42Xtw==} engines: {node: '>=16'} cpu: [arm64] os: [linux] - '@cloudflare/workerd-linux-arm64@1.20261104.1': - resolution: {integrity: sha512-uEBJJHh2SbeQauRGrad7tIFIrpUQ5LUqZX40l7IKwYd0yeemvsno8f57w34Bx/pPpaSsNYVcV5oNFVbv+v/BOw==} - engines: {node: '>=16'} - cpu: [arm64] - os: [linux] - '@cloudflare/workerd-windows-64@1.20260317.1': resolution: {integrity: sha512-MfZTz+7LfuIpMGTa3RLXHX8Z/pnycZLItn94WRdHr8LPVet+C5/1Nzei399w/jr3+kzT4pDKk26JF/tlI5elpQ==} engines: {node: '>=16'} cpu: [x64] os: [win32] - '@cloudflare/workerd-windows-64@1.20261104.1': - resolution: {integrity: sha512-b/fnEU1leVm8UrI2EHQ4MSrK2vmnWdR1jefRyEUDZe3ucpKY0PWi4bVxWh5niZdlL0MIc4C5tXNXTlAMZpKDdA==} - engines: {node: '>=16'} - cpu: [x64] - os: [win32] - '@codspeed/core@6.0.1': resolution: {integrity: sha512-p6yrZIoz/Bf5vW/QfGhiPOCKccGPES3jQ8NA+03qGcUYR3/U0tZ9h6ZkxVg2zLN10YaHrABEY4GtmTEEE5xF5Q==} @@ -16793,8 +16809,8 @@ packages: peerDependencies: better-auth: 1.3.27 convex: '>=1.28.2 <1.35.0' - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@convex-dev/react-query@0.0.0-alpha.8': resolution: {integrity: sha512-Rv/q7/CplU75f7ckBd2vh+HoeeQ0tOrjwMl14Hk7D/03e55oUIU0TV5JYYzC79ZQyyAtoj7CmCo5ZxcmtKNv1Q==} @@ -16906,12 +16922,24 @@ packages: '@electric-sql/pglite@0.3.2': resolution: {integrity: sha512-zfWWa+V2ViDCY/cmUfRqeWY1yLto+EpxjXnZzenB1TyxsTiXaTWeZFIZw6mac52BsuQm0RjCnisjBtdBaXOI6w==} + '@emnapi/core@1.10.0': + resolution: {integrity: sha512-yq6OkJ4p82CAfPl0u9mQebQHKPJkY7WrIuk205cTYnYe+k2Z8YBh11FrbRG/H6ihirqcacOgl2BIO8oyMQLeXw==} + + '@emnapi/core@1.11.1': + resolution: {integrity: sha512-RSvbQmHzdKzNsLYa/wHrbc3KN4sYLKAdPZxqiM2HATqv/SBk2/ENSHpvXGaLOMcsAyz0poEGqkmmKYG3OWiJEQ==} + '@emnapi/core@1.11.3': resolution: {integrity: sha512-zLpS5asjEb7lq8jYLq37N6XKaE41DIexlY1rF/z4/tIl3wo13Sqm28fRyfIsKZD+NZ8mM5RoKkpW/rBcuoSZSg==} '@emnapi/core@1.4.5': resolution: {integrity: sha512-XsLw1dEOpkSX/WucdqUhPWP7hDxSvZiY+fsUC14h+FtQ2Ifni4znbBt8punRX+Uj2JG/uDb8nEHVKvrVlvdZ5Q==} + '@emnapi/runtime@1.10.0': + resolution: {integrity: sha512-ewvYlk86xUoGI0zQRNq/mC+16R1QeDlKQy21Ki3oSYXNgLb45GV1P6A0M+/s6nyCuNDqe5VpaY84BzXGwVbwFA==} + + '@emnapi/runtime@1.11.1': + resolution: {integrity: sha512-vgj7R3y3Wgx24IQaGPA/R6YFXLHVMOZ0uVEyIQPaWs+rd1AzfEMXlAC22FYwO1XkKR6NPsq7mUandH8oIRdZFw==} + '@emnapi/runtime@1.11.3': resolution: {integrity: sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==} @@ -16921,6 +16949,12 @@ packages: '@emnapi/wasi-threads@1.0.4': resolution: {integrity: sha512-PJR+bOmMOPH8AtcTGAyYNiuJ3/Fcoj2XN/gBEWzDIKh254XO+mM9XoXHk5GNEhodxeMznbg7BlRojVbKN+gC6g==} + '@emnapi/wasi-threads@1.2.1': + resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==} + + '@emnapi/wasi-threads@1.2.2': + resolution: {integrity: sha512-c95qOXkHdydNKhscBTebqEC1CVAZpyqOfVfBzQ1qgzyl3gfeldUjIggDbIZgDKsHLgnsM+igH7TJ/eAasaVuMA==} + '@emnapi/wasi-threads@1.2.3': resolution: {integrity: sha512-ELEBe8PsLvvJ6QMr0zLt8ffvOHW/dc1m3CEzNMg7aJUv3bMaoDtw2TXyDAwkYBuroxxuHEwhRTLJSe5sya547g==} @@ -16943,7 +16977,7 @@ packages: resolution: {integrity: sha512-O000MLDBDdk/EohJPFUqvnp4qnHeYkVP5B0xEG0D/L7cOKP9kefu2DXn8dj74cQfsEzUqh+sr1RzFqiL1o+PpA==} peerDependencies: '@types/react': '*' - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -16959,7 +16993,7 @@ packages: peerDependencies: '@emotion/react': ^11.0.0-rc.0 '@types/react': '*' - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -16970,7 +17004,7 @@ packages: '@emotion/use-insertion-effect-with-fallbacks@1.2.0': resolution: {integrity: sha512-yJMtVdH59sxi/aVJBpk9FQq+OR8ll5GT8oWd57UpeaKEVGab41JWaCFA7FRLoMLloOZF/c/wsPoe+bfGmRKgDg==} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 '@emotion/utils@1.4.2': resolution: {integrity: sha512-3vLclRofFziIa3J2wDh9jjbkUz9qk5Vi3IZ/FSTKViB0k+ef0fPV7dYrUIugbgupYDx7v9ud/SjrtEP8Y4xLoA==} @@ -17021,6 +17055,12 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.28.2': + resolution: {integrity: sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.23.0': resolution: {integrity: sha512-EuHFUYkAVfU4qBdyivULuu03FhJO4IJN9PGuABGrFy4vUuzk91P2d+npxHcFdpUnfYKy0PuV+n6bKIpHOB3prQ==} engines: {node: '>=18'} @@ -17057,6 +17097,12 @@ packages: cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.28.2': + resolution: {integrity: sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.23.0': resolution: {integrity: sha512-+KuOHTKKyIKgEEqKbGTK8W7mPp+hKinbMBeEnNzjJGyFcWsfrXjSTNluJHCY1RqhxFurdD8uNXQDei7qDlR6+g==} engines: {node: '>=18'} @@ -17093,6 +17139,12 @@ packages: cpu: [arm] os: [android] + '@esbuild/android-arm@0.28.2': + resolution: {integrity: sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.23.0': resolution: {integrity: sha512-WRrmKidLoKDl56LsbBMhzTTBxrsVwTKdNbKDalbEZr0tcsBgCLbEtoNthOW6PX942YiYq8HzEnb4yWQMLQuipQ==} engines: {node: '>=18'} @@ -17129,6 +17181,12 @@ packages: cpu: [x64] os: [android] + '@esbuild/android-x64@0.28.2': + resolution: {integrity: sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.23.0': resolution: {integrity: sha512-YLntie/IdS31H54Ogdn+v50NuoWF5BDkEUFpiOChVa9UnKpftgwzZRrI4J132ETIi+D8n6xh9IviFV3eXdxfow==} engines: {node: '>=18'} @@ -17165,6 +17223,12 @@ packages: cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.28.2': + resolution: {integrity: sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.23.0': resolution: {integrity: sha512-IMQ6eme4AfznElesHUPDZ+teuGwoRmVuuixu7sv92ZkdQcPbsNHzutd+rAfaBKo8YK3IrBEi9SLLKWJdEvJniQ==} engines: {node: '>=18'} @@ -17201,6 +17265,12 @@ packages: cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.28.2': + resolution: {integrity: sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.23.0': resolution: {integrity: sha512-0muYWCng5vqaxobq6LB3YNtevDFSAZGlgtLoAc81PjUfiFz36n4KMpwhtAd4he8ToSI3TGyuhyx5xmiWNYZFyw==} engines: {node: '>=18'} @@ -17237,6 +17307,12 @@ packages: cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.28.2': + resolution: {integrity: sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.23.0': resolution: {integrity: sha512-XKDVu8IsD0/q3foBzsXGt/KjD/yTKBCIwOHE1XwiXmrRwrX6Hbnd5Eqn/WvDekddK21tfszBSrE/WMaZh+1buQ==} engines: {node: '>=18'} @@ -17273,6 +17349,12 @@ packages: cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.28.2': + resolution: {integrity: sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.23.0': resolution: {integrity: sha512-j1t5iG8jE7BhonbsEg5d9qOYcVZv/Rv6tghaXM/Ug9xahM0nX/H2gfu6X6z11QRTMT6+aywOMA8TDkhPo8aCGw==} engines: {node: '>=18'} @@ -17309,6 +17391,12 @@ packages: cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.28.2': + resolution: {integrity: sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.23.0': resolution: {integrity: sha512-SEELSTEtOFu5LPykzA395Mc+54RMg1EUgXP+iw2SJ72+ooMwVsgfuwXo5Fn0wXNgWZsTVHwY2cg4Vi/bOD88qw==} engines: {node: '>=18'} @@ -17345,6 +17433,12 @@ packages: cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.28.2': + resolution: {integrity: sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.23.0': resolution: {integrity: sha512-P7O5Tkh2NbgIm2R6x1zGJJsnacDzTFcRWZyTTMgFdVit6E98LTxO+v8LCCLWRvPrjdzXHx9FEOA8oAZPyApWUA==} engines: {node: '>=18'} @@ -17381,6 +17475,12 @@ packages: cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.28.2': + resolution: {integrity: sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.23.0': resolution: {integrity: sha512-InQwepswq6urikQiIC/kkx412fqUZudBO4SYKu0N+tGhXRWUqAx+Q+341tFV6QdBifpjYgUndV1hhMq3WeJi7A==} engines: {node: '>=18'} @@ -17417,6 +17517,12 @@ packages: cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.28.2': + resolution: {integrity: sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.23.0': resolution: {integrity: sha512-J9rflLtqdYrxHv2FqXE2i1ELgNjT+JFURt/uDMoPQLcjWQA5wDKgQA4t/dTqGa88ZVECKaD0TctwsUfHbVoi4w==} engines: {node: '>=18'} @@ -17453,6 +17559,12 @@ packages: cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.28.2': + resolution: {integrity: sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.23.0': resolution: {integrity: sha512-cShCXtEOVc5GxU0fM+dsFD10qZ5UpcQ8AM22bYj0u/yaAykWnqXJDpd77ublcX6vdDsWLuweeuSNZk4yUxZwtw==} engines: {node: '>=18'} @@ -17489,6 +17601,12 @@ packages: cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.28.2': + resolution: {integrity: sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.23.0': resolution: {integrity: sha512-HEtaN7Y5UB4tZPeQmgz/UhzoEyYftbMXrBCUjINGjh3uil+rB/QzzpMshz3cNUxqXN7Vr93zzVtpIDL99t9aRw==} engines: {node: '>=18'} @@ -17525,6 +17643,12 @@ packages: cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.28.2': + resolution: {integrity: sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.23.0': resolution: {integrity: sha512-WDi3+NVAuyjg/Wxi+o5KPqRbZY0QhI9TjrEEm+8dmpY9Xir8+HE/HNx2JoLckhKbFopW0RdO2D72w8trZOV+Wg==} engines: {node: '>=18'} @@ -17561,6 +17685,12 @@ packages: cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.28.2': + resolution: {integrity: sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.23.0': resolution: {integrity: sha512-a3pMQhUEJkITgAw6e0bWA+F+vFtCciMjW/LPtoj99MhVt+Mfb6bbL9hu2wmTZgNd994qTAEw+U/r6k3qHWWaOQ==} engines: {node: '>=18'} @@ -17597,6 +17727,12 @@ packages: cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.28.2': + resolution: {integrity: sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-arm64@0.25.10': resolution: {integrity: sha512-AKQM3gfYfSW8XRk8DdMCzaLUFB15dTrZfnX8WXQoOUpUBQ+NaAFCP1kPS/ykbbGYz7rxn0WS48/81l9hFl3u4A==} engines: {node: '>=18'} @@ -17627,6 +17763,12 @@ packages: cpu: [arm64] os: [netbsd] + '@esbuild/netbsd-arm64@0.28.2': + resolution: {integrity: sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-x64@0.23.0': resolution: {integrity: sha512-cRK+YDem7lFTs2Q5nEv/HHc4LnrfBCbH5+JHu6wm2eP+d8OZNoSMYgPZJq78vqQ9g+9+nMuIsAO7skzphRXHyw==} engines: {node: '>=18'} @@ -17663,6 +17805,12 @@ packages: cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.28.2': + resolution: {integrity: sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + '@esbuild/openbsd-arm64@0.23.0': resolution: {integrity: sha512-suXjq53gERueVWu0OKxzWqk7NxiUWSUlrxoZK7usiF50C6ipColGR5qie2496iKGYNLhDZkPxBI3erbnYkU0rQ==} engines: {node: '>=18'} @@ -17699,6 +17847,12 @@ packages: cpu: [arm64] os: [openbsd] + '@esbuild/openbsd-arm64@0.28.2': + resolution: {integrity: sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.23.0': resolution: {integrity: sha512-6p3nHpby0DM/v15IFKMjAaayFhqnXV52aEmv1whZHX56pdkK+MEaLoQWj+H42ssFarP1PcomVhbsR4pkz09qBg==} engines: {node: '>=18'} @@ -17735,6 +17889,12 @@ packages: cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.28.2': + resolution: {integrity: sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/openharmony-arm64@0.25.10': resolution: {integrity: sha512-AVTSBhTX8Y/Fz6OmIVBip9tJzZEUcY8WLh7I59+upa5/GPhh2/aM6bvOMQySspnCCHvFi79kMtdJS1w0DXAeag==} engines: {node: '>=18'} @@ -17759,6 +17919,12 @@ packages: cpu: [arm64] os: [openharmony] + '@esbuild/openharmony-arm64@0.28.2': + resolution: {integrity: sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/sunos-x64@0.23.0': resolution: {integrity: sha512-BFelBGfrBwk6LVrmFzCq1u1dZbG4zy/Kp93w2+y83Q5UGYF1d8sCzeLI9NXjKyujjBBniQa8R8PzLFAUrSM9OA==} engines: {node: '>=18'} @@ -17795,6 +17961,12 @@ packages: cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.28.2': + resolution: {integrity: sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.23.0': resolution: {integrity: sha512-lY6AC8p4Cnb7xYHuIxQ6iYPe6MfO2CC43XXKo9nBXDb35krYt7KGhQnOkRGar5psxYkircpCqfbNDB4uJbS2jQ==} engines: {node: '>=18'} @@ -17831,6 +18003,12 @@ packages: cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.28.2': + resolution: {integrity: sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.23.0': resolution: {integrity: sha512-7L1bHlOTcO4ByvI7OXVI5pNN6HSu6pUQq9yodga8izeuB1KcT2UkHaH6118QJwopExPn0rMHIseCTx1CRo/uNA==} engines: {node: '>=18'} @@ -17867,6 +18045,12 @@ packages: cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.28.2': + resolution: {integrity: sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.23.0': resolution: {integrity: sha512-Arm+WgUFLUATuoxCJcahGuk6Yj9Pzxd6l11Zb/2aAuv5kWWvvfhLFo2fni4uSK5vzlUdCGZ/BdV5tH8klj8p8g==} engines: {node: '>=18'} @@ -17903,6 +18087,12 @@ packages: cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.28.2': + resolution: {integrity: sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@eslint-community/eslint-utils@4.4.1': resolution: {integrity: sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -18256,8 +18446,8 @@ packages: '@floating-ui/react-dom@2.1.2': resolution: {integrity: sha512-06okr5cgPzMNBy+Ycse2A6udMi4bqwW/zgBF/rwjcNqWkyr82Mcg8b0vjX8OJpZFy/FKjJmw6wV7t44kK6kW7A==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@floating-ui/utils@0.2.9': resolution: {integrity: sha512-MDWhGtE+eHw5JW7lq4qhc5yRLS11ERl1c7Z6Xd0a58DozHES6EnNNwUWbMiG4J9Cgj053Bhk8zvlhFYKVhULwg==} @@ -18325,12 +18515,6 @@ packages: cpu: [arm64] os: [darwin] - '@img/sharp-darwin-arm64@0.35.5': - resolution: {integrity: sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==} - engines: {node: '>=20.9.0'} - cpu: [arm64] - os: [darwin] - '@img/sharp-darwin-x64@0.34.5': resolution: {integrity: sha512-YNEFAF/4KQ/PeW0N+r+aVVsoIY0/qxxikF2SWdp+NRkmMB7y9LBZAVqQ4yhGCm/H3H270OSykqmQMKLBhBJDEw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18343,22 +18527,11 @@ packages: cpu: [x64] os: [darwin] - '@img/sharp-darwin-x64@0.35.5': - resolution: {integrity: sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==} - engines: {node: '>=20.9.0'} - cpu: [x64] - os: [darwin] - '@img/sharp-freebsd-wasm32@0.35.4': resolution: {integrity: sha512-lIsKw/BU+kjB4eZjxrYrZmwOJYi3Ajrv66iAlBmUPyKc3HpnloevB1g3wxGD9P/5BbQ1brBGl65VRRrCvQDEqA==} engines: {node: '>=20.9.0'} os: [freebsd] - '@img/sharp-freebsd-wasm32@0.35.5': - resolution: {integrity: sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==} - engines: {node: '>=20.9.0'} - os: [freebsd] - '@img/sharp-libvips-darwin-arm64@1.2.4': resolution: {integrity: sha512-zqjjo7RatFfFoP0MkQ51jfuFZBnVE2pRiaydKJ1G/rHZvnsrHAOcQALIi9sA5co5xenQdTugCvtb1cuf78Vf4g==} cpu: [arm64] @@ -18369,11 +18542,6 @@ packages: cpu: [arm64] os: [darwin] - '@img/sharp-libvips-darwin-arm64@1.3.4': - resolution: {integrity: sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==} - cpu: [arm64] - os: [darwin] - '@img/sharp-libvips-darwin-x64@1.2.4': resolution: {integrity: sha512-1IOd5xfVhlGwX+zXv2N93k0yMONvUlANylbJw1eTah8K/Jtpi15KC+WSiaX/nBmbm2HxRM1gZ0nSdjSsrZbGKg==} cpu: [x64] @@ -18384,11 +18552,6 @@ packages: cpu: [x64] os: [darwin] - '@img/sharp-libvips-darwin-x64@1.3.4': - resolution: {integrity: sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==} - cpu: [x64] - os: [darwin] - '@img/sharp-libvips-linux-arm64@1.2.4': resolution: {integrity: sha512-excjX8DfsIcJ10x1Kzr4RcWe1edC9PquDRRPx3YVCvQv+U5p7Yin2s32ftzikXojb1PIFc/9Mt28/y+iRklkrw==} cpu: [arm64] @@ -18401,12 +18564,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-arm64@1.3.4': - resolution: {integrity: sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==} - cpu: [arm64] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linux-arm@1.2.4': resolution: {integrity: sha512-bFI7xcKFELdiNCVov8e44Ia4u2byA+l3XtsAj+Q8tfCwO6BQ8iDojYdvoPMqsKDkuoOo+X6HZA0s0q11ANMQ8A==} cpu: [arm] @@ -18419,12 +18576,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-arm@1.3.4': - resolution: {integrity: sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==} - cpu: [arm] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linux-ppc64@1.2.4': resolution: {integrity: sha512-FMuvGijLDYG6lW+b/UvyilUWu5Ayu+3r2d1S8notiGCIyYU/76eig1UfMmkZ7vwgOrzKzlQbFSuQfgm7GYUPpA==} cpu: [ppc64] @@ -18437,12 +18588,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-ppc64@1.3.4': - resolution: {integrity: sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==} - cpu: [ppc64] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linux-riscv64@1.2.4': resolution: {integrity: sha512-oVDbcR4zUC0ce82teubSm+x6ETixtKZBh/qbREIOcI3cULzDyb18Sr/Wcyx7NRQeQzOiHTNbZFF1UwPS2scyGA==} cpu: [riscv64] @@ -18455,12 +18600,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-riscv64@1.3.4': - resolution: {integrity: sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==} - cpu: [riscv64] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linux-s390x@1.2.4': resolution: {integrity: sha512-qmp9VrzgPgMoGZyPvrQHqk02uyjA0/QrTO26Tqk6l4ZV0MPWIW6LTkqOIov+J1yEu7MbFQaDpwdwJKhbJvuRxQ==} cpu: [s390x] @@ -18473,12 +18612,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-s390x@1.3.4': - resolution: {integrity: sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==} - cpu: [s390x] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linux-x64@1.2.4': resolution: {integrity: sha512-tJxiiLsmHc9Ax1bz3oaOYBURTXGIRDODBqhveVHonrHJ9/+k89qbLl0bcJns+e4t4rvaNBxaEZsFtSfAdquPrw==} cpu: [x64] @@ -18491,12 +18624,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-libvips-linux-x64@1.3.4': - resolution: {integrity: sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==} - cpu: [x64] - os: [linux] - libc: [glibc] - '@img/sharp-libvips-linuxmusl-arm64@1.2.4': resolution: {integrity: sha512-FVQHuwx1IIuNow9QAbYUzJ+En8KcVm9Lk5+uGUQJHaZmMECZmOlix9HnH7n1TRkXMS0pGxIJokIVB9SuqZGGXw==} cpu: [arm64] @@ -18509,12 +18636,6 @@ packages: os: [linux] libc: [musl] - '@img/sharp-libvips-linuxmusl-arm64@1.3.4': - resolution: {integrity: sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==} - cpu: [arm64] - os: [linux] - libc: [musl] - '@img/sharp-libvips-linuxmusl-x64@1.2.4': resolution: {integrity: sha512-+LpyBk7L44ZIXwz/VYfglaX/okxezESc6UxDSoyo2Ks6Jxc4Y7sGjpgU9s4PMgqgjj1gZCylTieNamqA1MF7Dg==} cpu: [x64] @@ -18527,12 +18648,6 @@ packages: os: [linux] libc: [musl] - '@img/sharp-libvips-linuxmusl-x64@1.3.4': - resolution: {integrity: sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==} - cpu: [x64] - os: [linux] - libc: [musl] - '@img/sharp-linux-arm64@0.34.5': resolution: {integrity: sha512-bKQzaJRY/bkPOXyKx5EVup7qkaojECG6NLYswgktOZjaXecSAeCWiZwwiFf3/Y+O1HrauiE3FVsGxFg8c24rZg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18547,13 +18662,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-arm64@0.35.5': - resolution: {integrity: sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==} - engines: {node: '>=20.9.0'} - cpu: [arm64] - os: [linux] - libc: [glibc] - '@img/sharp-linux-arm@0.34.5': resolution: {integrity: sha512-9dLqsvwtg1uuXBGZKsxem9595+ujv0sJ6Vi8wcTANSFpwV/GONat5eCkzQo/1O6zRIkh0m/8+5BjrRr7jDUSZw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18568,13 +18676,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-arm@0.35.5': - resolution: {integrity: sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==} - engines: {node: '>=20.9.0'} - cpu: [arm] - os: [linux] - libc: [glibc] - '@img/sharp-linux-ppc64@0.34.5': resolution: {integrity: sha512-7zznwNaqW6YtsfrGGDA6BRkISKAAE1Jo0QdpNYXNMHu2+0dTrPflTLNkpc8l7MUP5M16ZJcUvysVWWrMefZquA==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18589,13 +18690,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-ppc64@0.35.5': - resolution: {integrity: sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==} - engines: {node: '>=20.9.0'} - cpu: [ppc64] - os: [linux] - libc: [glibc] - '@img/sharp-linux-riscv64@0.34.5': resolution: {integrity: sha512-51gJuLPTKa7piYPaVs8GmByo7/U7/7TZOq+cnXJIHZKavIRHAP77e3N2HEl3dgiqdD/w0yUfiJnII77PuDDFdw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18610,13 +18704,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-riscv64@0.35.5': - resolution: {integrity: sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==} - engines: {node: '>=20.9.0'} - cpu: [riscv64] - os: [linux] - libc: [glibc] - '@img/sharp-linux-s390x@0.34.5': resolution: {integrity: sha512-nQtCk0PdKfho3eC5MrbQoigJ2gd1CgddUMkabUj+rBevs8tZ2cULOx46E7oyX+04WGfABgIwmMC0VqieTiR4jg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18631,13 +18718,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-s390x@0.35.5': - resolution: {integrity: sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==} - engines: {node: '>=20.9.0'} - cpu: [s390x] - os: [linux] - libc: [glibc] - '@img/sharp-linux-x64@0.34.5': resolution: {integrity: sha512-MEzd8HPKxVxVenwAa+JRPwEC7QFjoPWuS5NZnBt6B3pu7EG2Ge0id1oLHZpPJdn3OQK+BQDiw9zStiHBTJQQQQ==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18652,13 +18732,6 @@ packages: os: [linux] libc: [glibc] - '@img/sharp-linux-x64@0.35.5': - resolution: {integrity: sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==} - engines: {node: '>=20.9.0'} - cpu: [x64] - os: [linux] - libc: [glibc] - '@img/sharp-linuxmusl-arm64@0.34.5': resolution: {integrity: sha512-fprJR6GtRsMt6Kyfq44IsChVZeGN97gTD331weR1ex1c1rypDEABN6Tm2xa1wE6lYb5DdEnk03NZPqA7Id21yg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18673,13 +18746,6 @@ packages: os: [linux] libc: [musl] - '@img/sharp-linuxmusl-arm64@0.35.5': - resolution: {integrity: sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==} - engines: {node: '>=20.9.0'} - cpu: [arm64] - os: [linux] - libc: [musl] - '@img/sharp-linuxmusl-x64@0.34.5': resolution: {integrity: sha512-Jg8wNT1MUzIvhBFxViqrEhWDGzqymo3sV7z7ZsaWbZNDLXRJZoRGrjulp60YYtV4wfY8VIKcWidjojlLcWrd8Q==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18694,13 +18760,6 @@ packages: os: [linux] libc: [musl] - '@img/sharp-linuxmusl-x64@0.35.5': - resolution: {integrity: sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==} - engines: {node: '>=20.9.0'} - cpu: [x64] - os: [linux] - libc: [musl] - '@img/sharp-wasm32@0.34.5': resolution: {integrity: sha512-OdWTEiVkY2PHwqkbBI8frFxQQFekHaSSkUIJkwzclWZe64O1X4UlUjqqqLaPbUpMOQk6FBu/HtlGXNblIs0huw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18710,20 +18769,11 @@ packages: resolution: {integrity: sha512-zQnl4Kwp7Q6NHsENtU2T/00Zi+w3AQNwz3+UaTyVBy2FpXrzXzGjndpK61onhZjRtRpQXxCTeqw19bVyXOh7jA==} engines: {node: '>=20.9.0'} - '@img/sharp-wasm32@0.35.5': - resolution: {integrity: sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==} - engines: {node: '>=20.9.0'} - '@img/sharp-webcontainers-wasm32@0.35.4': resolution: {integrity: sha512-ESfNkywmCfPNyaZjxooddJQiQ+l/nTpGEOGthxiLnIHXC/CmcBixnfwUleX9mCz9ovrUUvKMap/pm8RYbzfwaA==} engines: {node: '>=20.9.0'} cpu: [wasm32] - '@img/sharp-webcontainers-wasm32@0.35.5': - resolution: {integrity: sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==} - engines: {node: '>=20.9.0'} - cpu: [wasm32] - '@img/sharp-win32-arm64@0.34.5': resolution: {integrity: sha512-WQ3AgWCWYSb2yt+IG8mnC6Jdk9Whs7O0gxphblsLvdhSpSTtmu69ZG1Gkb6NuvxsNACwiPV6cNSZNzt0KPsw7g==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18736,12 +18786,6 @@ packages: cpu: [arm64] os: [win32] - '@img/sharp-win32-arm64@0.35.5': - resolution: {integrity: sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==} - engines: {node: '>=20.9.0'} - cpu: [arm64] - os: [win32] - '@img/sharp-win32-ia32@0.34.5': resolution: {integrity: sha512-FV9m/7NmeCmSHDD5j4+4pNI8Cp3aW+JvLoXcTUo0IqyjSfAZJ8dIUmijx1qaJsIiU+Hosw6xM5KijAWRJCSgNg==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18754,12 +18798,6 @@ packages: cpu: [ia32] os: [win32] - '@img/sharp-win32-ia32@0.35.5': - resolution: {integrity: sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==} - engines: {node: ^20.9.0} - cpu: [ia32] - os: [win32] - '@img/sharp-win32-x64@0.34.5': resolution: {integrity: sha512-+29YMsqY2/9eFEiW93eqWnuLcWcufowXewwSNIT6UwZdUUCrM3oFjMWH/Z6/TMmb4hlFenmfAVbpWeup2jryCw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} @@ -18772,12 +18810,6 @@ packages: cpu: [x64] os: [win32] - '@img/sharp-win32-x64@0.35.5': - resolution: {integrity: sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==} - engines: {node: '>=20.9.0'} - cpu: [x64] - os: [win32] - '@import-maps/resolve@2.0.0': resolution: {integrity: sha512-RwzRTpmrrS6Q1ZhQExwuxJGK1Wqhv4stt+OF2JzS+uawewpwNyU7EJL1WpBex7aDiiGLs4FsXGkfUBdYuX7xiQ==} @@ -19050,6 +19082,22 @@ packages: engines: {node: '>=18'} hasBin: true + '@mdx-js/loader@3.1.1': + resolution: {integrity: sha512-0TTacJyZ9mDmY+VefuthVshaNIyCGZHJG2fMnGaDttCt8HmjUF7SizlHJpaCDoGnN635nK1wpzfpx/Xx5S4WnQ==} + peerDependencies: + webpack: '>=5' + peerDependenciesMeta: + webpack: + optional: true + + '@mdx-js/mdx@3.1.1': + resolution: {integrity: sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==} + + '@mdx-js/rollup@3.1.1': + resolution: {integrity: sha512-v8satFmBB+DqDzYohnm1u2JOvxx6Hl3pUvqzJvfs2Zk/ngZ1aRUhsWpXvwPkNeGN9c2NCm/38H29ZqXQUjf8dw==} + peerDependencies: + rollup: '>=2' + '@microsoft/api-extractor-model@7.29.6': resolution: {integrity: sha512-gC0KGtrZvxzf/Rt9oMYD2dHvtN/1KPEYsrQPyMKhLHnlVuO/f4AFN3E4toqZzD2pt4LhkKoYmL2H9tX3yCOyRw==} @@ -19113,8 +19161,8 @@ packages: '@emotion/styled': ^11.3.0 '@mui/material-pigment-css': ^6.4.7 '@types/react': ^19.2.8 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@emotion/react': optional: true @@ -19130,7 +19178,7 @@ packages: engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -19141,7 +19189,7 @@ packages: peerDependencies: '@emotion/react': ^11.4.1 '@emotion/styled': ^11.3.0 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@emotion/react': optional: true @@ -19155,7 +19203,7 @@ packages: '@emotion/react': ^11.5.0 '@emotion/styled': ^11.3.0 '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@emotion/react': optional: true @@ -19177,7 +19225,7 @@ packages: engines: {node: '>=14.0.0'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -19195,6 +19243,18 @@ packages: '@napi-rs/wasm-runtime@0.2.4': resolution: {integrity: sha512-9zESzOO5aDByvhIAsOy9TbpZ0Ur2AJbUI7UT73kcUTS2mxAMHOBaa1st/jAymNoCtvrit99kkzT1FZuXVcgfIQ==} + '@napi-rs/wasm-runtime@1.1.4': + resolution: {integrity: sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==} + peerDependencies: + '@emnapi/core': ^1.7.1 + '@emnapi/runtime': ^1.7.1 + + '@napi-rs/wasm-runtime@1.1.5': + resolution: {integrity: sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==} + peerDependencies: + '@emnapi/core': ^1.7.1 + '@emnapi/runtime': ^1.7.1 + '@napi-rs/wasm-runtime@1.1.6': resolution: {integrity: sha512-ZLv/JdUfkvOy9eCnnBaGfiO+XimbjebAeO+MRQqD/B+FR1tnRN0tpKSJHRbE8sFfS6aqsXZ67TQjfwfsxULVbg==} peerDependencies: @@ -19426,62 +19486,62 @@ packages: resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==} engines: {node: '>= 8'} - '@nx/devkit@24.0.0': - resolution: {integrity: sha512-t5E5VOCoNECLFMMp6qUczUx5kYduyvMMsHFGvuXPCKX32Ny4aFbeIrYNqCrsNKr9KgzMr0tOvRA+EMT0v7BXEA==} + '@nx/devkit@23.2.0': + resolution: {integrity: sha512-srj04UsYqq2nG7Z9DxM00D8XpSpmSM7XQafCkD4FIOE2NPMCu0QvypJLe8S7a1/YAW9rqlnYrdadaQte687eAw==} peerDependencies: - nx: '>= 23 <= 25 || ^24.0.0-0' + nx: '>= 22 <= 24 || ^23.0.0-0' - '@nx/nx-darwin-arm64@24.0.0': - resolution: {integrity: sha512-ZHXmqkMVF7aA6QShvc5lVkCU6JHjGV19m8eplw0pL06AFgNdQ9u16013HJPm+Ys6fKnltYDWl/Ef7meQjT+u3Q==} + '@nx/nx-darwin-arm64@23.2.0': + resolution: {integrity: sha512-nael5WwtqBX/YZDU0iv8M4rJ8auF9kF+sU5pYpronIbvu/LdDptq31vWT06ivW8eXRaLxDqFmpXR8tS5IYDmdw==} cpu: [arm64] os: [darwin] - '@nx/nx-darwin-x64@24.0.0': - resolution: {integrity: sha512-a+cpg/VQvD/vF7BJsl70vulc1GxCamtU0XwzkGOzzDATn3JcKBNpBFx0Iqp5frJYN0X00Supz4zhgCEe9LpCow==} + '@nx/nx-darwin-x64@23.2.0': + resolution: {integrity: sha512-jZ7c6ktp8Wdroru6lj8WxvYDiK70B2cE3GdV9pcgCcVQvK6PLJXgOaHvQjALMINraYhzlsWX/FkWMy4eMMlJzg==} cpu: [x64] os: [darwin] - '@nx/nx-freebsd-x64@24.0.0': - resolution: {integrity: sha512-PAGVaLbJxEzBXSQvg82g/8mDoqoMQFIX/EchuJbJGekIiz3BM2Xgyiy5qAD2/2meLVOTFtbkBQR+4ZSymgqGWw==} + '@nx/nx-freebsd-x64@23.2.0': + resolution: {integrity: sha512-5MDLl4q0kYZcX6CLu5x1YEq5YUUmo6CqoWApgC/2Ky2kEX9Kz+9fuTJlKlwwSlAxlb3TyQVKXrjGfwF0M30ygA==} cpu: [x64] os: [freebsd] - '@nx/nx-linux-arm-gnueabihf@24.0.0': - resolution: {integrity: sha512-WOWBIlTb+1FNP86GcodUF4BHdjVyGCwrVH/lqUvNAmT/FPopirCzVLdoj1P5kfWC/F0II/qAu7X698yKzIu71A==} + '@nx/nx-linux-arm-gnueabihf@23.2.0': + resolution: {integrity: sha512-YBY7VGEyrzWNPG6M1knOjykMbsHmX/uN5TywwtLYp2mp6PaDC9MNO9z2BDaVmdS+Y8u030RrDpESwLkB0f9d4g==} cpu: [arm] os: [linux] - '@nx/nx-linux-arm64-gnu@24.0.0': - resolution: {integrity: sha512-vASWIfOijXd5cdOn0Z6Wcd2iwtFxlBoBre6w+c8wuLLLPN3r4SRQyL+jAEB+eHkUHz39mMxSwa8DY+VlS9luVw==} + '@nx/nx-linux-arm64-gnu@23.2.0': + resolution: {integrity: sha512-CzDkhtI+HYKGWPbjfMhslrgGpWer/qGd6MOFwkjxI8JYdqRV0BYivnAuqogsyPpBDNzalxK8xM55MD/f+edQ+w==} cpu: [arm64] os: [linux] libc: [glibc] - '@nx/nx-linux-arm64-musl@24.0.0': - resolution: {integrity: sha512-ZiG9Kjq1AvYmFK3p03OOjCcYXwiBpF2Z7Ih/QnKsRMcnT7GbjDpfuO3FkSMtuE0OWoAdAt9Kb2yXBP3L9IZc6w==} + '@nx/nx-linux-arm64-musl@23.2.0': + resolution: {integrity: sha512-poDmLBCX4WHcYwlklFingeqHVSaTdeUe5jhuQhR6BygDpFdVk4kibovEHh4A5LRkPag4SACNRy1VRBKoaoEyUA==} cpu: [arm64] os: [linux] libc: [musl] - '@nx/nx-linux-x64-gnu@24.0.0': - resolution: {integrity: sha512-FstnaQtRkxD0RGYtCJb7QYq9Sgzu+vCKYO+p3/uq+q2kKLwlu4ovvzUeDctTuCIjx1tFamp/Uu8n+bHavUE7KQ==} + '@nx/nx-linux-x64-gnu@23.2.0': + resolution: {integrity: sha512-8E8IAkJJw1+eF9UNZKZnc1UDDNOmRaGQbb/AXL8Ix0MP3LObDjIyX9NLYxrtcb9HUcWrygcuKsySum+E5C4s3w==} cpu: [x64] os: [linux] libc: [glibc] - '@nx/nx-linux-x64-musl@24.0.0': - resolution: {integrity: sha512-dBFcWaSOhl17ZzZ+ybi9ctPlYPwDTlJjGgkpV5e/O6D7V9MFziJ4xZG/mVgacYbW3f5HS6QRVno9yPtSyLj2MA==} + '@nx/nx-linux-x64-musl@23.2.0': + resolution: {integrity: sha512-X/i1GfhqeOM1pGNBDDeIDKhtpXKnYjBR8hv8YoVW9pHQXAJ2iUux6SCP1Gg5tIKUYTdZRvsknf0g7KEw3p1sug==} cpu: [x64] os: [linux] libc: [musl] - '@nx/nx-win32-arm64-msvc@24.0.0': - resolution: {integrity: sha512-u2t4v71qCT7Nj4QbxuJ8X3iii881goaXJ7fjTcYw4EhSk1FemF6lh7mlSaHSczQ+/JFbiVppu649NYaVlIxGcw==} + '@nx/nx-win32-arm64-msvc@23.2.0': + resolution: {integrity: sha512-MSXbpHVSduWYnCu8MyPs88H6XnbU20jHWUvtPFDFkxgA8Slhl09hzpp2xq8TS4M8dS2OxK4QWcZyszqRMkwQrw==} cpu: [arm64] os: [win32] - '@nx/nx-win32-x64-msvc@24.0.0': - resolution: {integrity: sha512-Rv464/mLVw3lKdsxhFJXk3WI2KyaCoGbTNUzLi8nlzEuZ0ZcBK4VKxAxlvVCAVrxPIZkbUFDYE7vRvdZ2DGikg==} + '@nx/nx-win32-x64-msvc@23.2.0': + resolution: {integrity: sha512-OZKEU4d5YmOht1id5wyWhVfvuNEo0hl4DYRFzDh/r94nbTqfNEPcY0bTDfvtjZ79ZM5tPC1Z1k8/L4dkhMpFhw==} cpu: [x64] os: [win32] @@ -19555,14 +19615,12 @@ packages: '@opentelemetry/sdk-trace-base@2.10.0': resolution: {integrity: sha512-GuYQQT7QD2EeO8lcZLRQzcbOyhqAzL+6WWTKTU9mSUBYBazkEDl+VrQcXQhbB08OWM9anD1aHleVadzulpOaUQ==} engines: {node: ^18.19.0 || >=20.6.0} - deprecated: Use @opentelemetry/sdk-trace package peerDependencies: '@opentelemetry/api': '>=1.3.0 <1.10.0' '@opentelemetry/sdk-trace-node@2.10.0': resolution: {integrity: sha512-GZK/G6oZyBLGlH1pUgeDch7D91KoHd2uotUGIkWCPi9GI5T9X0p4L7nNAMDR1BQjkRYoDqo+ddfVx9t5Uhys+Q==} engines: {node: ^18.19.0 || >=20.6.0} - deprecated: Use @opentelemetry/sdk-trace package peerDependencies: '@opentelemetry/api': '>=1.0.0 <1.10.0' @@ -19913,8 +19971,8 @@ packages: resolution: {integrity: sha512-SXCcgFvo/SC6/11kEOaQghJgCWNEWZUvPYKn/gpvMB9HLSG/5M8If7dWZtEQHhchvl8bh9A89Hw6mEKpsXFimA==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@protobufjs/aspromise@1.1.2': resolution: {integrity: sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ==} @@ -19964,8 +20022,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -19977,8 +20035,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -19990,8 +20048,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20003,8 +20061,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20016,8 +20074,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20029,8 +20087,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20042,8 +20100,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20055,8 +20113,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20068,8 +20126,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20080,7 +20138,7 @@ packages: resolution: {integrity: sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20090,8 +20148,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20102,7 +20160,7 @@ packages: resolution: {integrity: sha512-jCi/QKUM2r1Ju5a3J64TH2A5SpKAgh0LpknyqdQ4m6DCV0xJ2HG1xARRwNGPQfi1SLdLWZ1OJz6F4OMBBNiGJA==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20112,8 +20170,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20124,7 +20182,7 @@ packages: resolution: {integrity: sha512-1UEWRX6jnOA2y4H5WczZ44gOOjTEmlqv1uNW4GAJEO5+bauCBhv8snY65Iw5/VOS/ghKN9gr2KjnLKxrsvoMVw==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20134,8 +20192,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20147,8 +20205,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20159,7 +20217,7 @@ packages: resolution: {integrity: sha512-fyjAACV62oPV925xFCrH8DR5xWhg9KYtJT4s3u54jxp+L/hbpTY2kIeEFFbFe+a/HCE94zGQMZLIpVTPVZDhaA==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20169,8 +20227,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20182,8 +20240,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20195,8 +20253,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20207,7 +20265,7 @@ packages: resolution: {integrity: sha512-kGkGegYIdQsOb4XjsfM97rXsiHaBwco+hFI66oO4s9LU+PLAC5oJ7khdOVFxkhsmlbpUqDAvXw11CluXP+jkHg==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20217,8 +20275,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20230,8 +20288,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20243,8 +20301,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20256,8 +20314,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20269,8 +20327,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20282,8 +20340,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20295,8 +20353,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20308,8 +20366,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20321,8 +20379,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20334,8 +20392,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20347,8 +20405,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20360,8 +20418,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20373,8 +20431,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20386,8 +20444,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20399,8 +20457,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20412,8 +20470,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20424,7 +20482,7 @@ packages: resolution: {integrity: sha512-ujc+V6r0HNDviYqIK3rW4ffgYiZ8g5DEHrGJVk4x7kTlLXRDILnKX9vAUYeIsLOoDpDJ0ujpqMkjH4w2ofuo6w==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20434,8 +20492,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20447,8 +20505,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20460,8 +20518,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20473,8 +20531,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20486,8 +20544,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20499,8 +20557,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20512,8 +20570,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20524,7 +20582,7 @@ packages: resolution: {integrity: sha512-FkBMwD+qbGQeMu1cOHnuGB6x4yzPjho8ap5WtbEJ26umhgqVXbhekKUQO+hZEL1vU92a3wHwdp0HAcqAUF5iDg==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20533,7 +20591,7 @@ packages: resolution: {integrity: sha512-YnEXIy8/ga01Y1PN0VfaNH//MhA91JlEGVBDxDzROqwrAtG5Yr2QGEPz8A/rJA3C7ZAHryOYGaUv8fLSW2H/mg==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20542,7 +20600,7 @@ packages: resolution: {integrity: sha512-Il0+boE7w/XebUHyBjroE+DbByORGR9KKmITzbR7MyQ4akpORYP/ZmbhAr0DG7RmmBqoOnZdy2QlvajJ2QA59g==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20551,7 +20609,7 @@ packages: resolution: {integrity: sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20560,7 +20618,7 @@ packages: resolution: {integrity: sha512-2dHfToCj/pzca2Ck724OZ5L0EVrr3eHRNsG/b3xQJLA2hZpVCS99bLAX+hm1IHXDEnzU6by5z/5MIY794/a8NQ==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20569,7 +20627,7 @@ packages: resolution: {integrity: sha512-QTYuDesS0VtuHNNvMh+CjlKJ4LJickCMUAqjlE3+j8w+RlRpwyX3apEQKGFzbZGdo7XNG1tXa+bQqIE7HIXT2w==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20578,7 +20636,7 @@ packages: resolution: {integrity: sha512-ewrXRDTAqAXlkl6t/fkXWNAhFX9I+CkKlw6zjEwk86RSPKwZr3xpBRso655aqYafwtnbpHLj6toFzmd6xdVptQ==} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20588,8 +20646,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20604,8 +20662,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -20884,8 +20942,28 @@ packages: cpu: [x64] os: [win32] - '@rsbuild/core@2.3.1': - resolution: {integrity: sha512-dv5tL7djb8ex5z4sqnDmUbd5PnGNr/CXuFfiMD4RkUsF1JEZZkGH8lc+QW4fqYQIHM7RTvcMUakgvwVU/O9WMw==} + '@rsbuild/core@2.0.14': + resolution: {integrity: sha512-SSPer6vM+v82CV6JXIOzyyT++A1ECgsVvvUuveD5rfGxX/W58vWGnB+zWcYbMfYOjTntD+9ve6QGGh6kBjPx6A==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + core-js: '>= 3.0.0' + peerDependenciesMeta: + core-js: + optional: true + + '@rsbuild/core@2.1.1': + resolution: {integrity: sha512-s6Cc+pHCJK9RP6Yk4LwsQWHxxxasrk5kmo9nkZK7j1iObp4w2PLivsUdP6HtkeoXuxcnK3QKH8/r49plNBjaQw==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + peerDependencies: + core-js: '>= 3.0.0' + peerDependenciesMeta: + core-js: + optional: true + + '@rsbuild/core@2.2.5': + resolution: {integrity: sha512-nf34ri1iZduYhHUr5Vc79L7Eml+IlN0nFIaF/g3OW4WR/gShxuf5wVXS69/H8FTHJYN4SdYlNcefSZQluEMKgA==} engines: {node: ^20.19.0 || >=22.12.0} hasBin: true peerDependencies: @@ -20902,6 +20980,14 @@ packages: '@rsbuild/core': optional: true + '@rsbuild/plugin-babel@1.2.1': + resolution: {integrity: sha512-6Zad7Ff/RUNc91AtftemJcJ1wcZRGOiwuJy349qlLJl9F++oRYwUhx+MxLSpNnVeIywWx2mKdZZBtD1hLqfj9w==} + peerDependencies: + '@rsbuild/core': ^1.0.0 || ^2.0.0-0 + peerDependenciesMeta: + '@rsbuild/core': + optional: true + '@rsbuild/plugin-react@2.0.0': resolution: {integrity: sha512-/1gzt39EGUSFEqB83g46QoOwsgv172HI18i6au1b6lgIaX4sv9stuX4ijdHbHCp8PqYEq+MyQ99jIQMO6I+etg==} peerDependencies: @@ -20918,10 +21004,10 @@ packages: '@rsbuild/core': optional: true - '@rsbuild/plugin-solid@1.1.1': - resolution: {integrity: sha512-IMlxjAVDrgPPx7KHQXyiJiQn5x11jibC7WIVIkZg7uxkcgBuHyE6InmVNc+C6M3Y1djXYL7GG2M7CH4Jdg+RUw==} + '@rsbuild/plugin-solid@1.2.2': + resolution: {integrity: sha512-N4xruop/R393bs6OieICQaU0SQp3u5T3g42yr+olCdDT3TolT9S2sQI/bpWuVPNo0t59sDeuFYjnbXIG/bY+FQ==} peerDependencies: - '@rsbuild/core': ^1.0.0 || ^2.0.0-0 + '@rsbuild/core': ^1.0.0 || ^2.0.0 peerDependenciesMeta: '@rsbuild/core': optional: true @@ -20950,14 +21036,29 @@ packages: '@rsbuild/core': optional: true + '@rspack/binding-darwin-arm64@2.0.8': + resolution: {integrity: sha512-vCgbgH7B7qom+uID+RCZsTCOYFb9wC4/4+1U6rMfytrXGVJ72eNQs2tbdjOl0lb18CT3N/n+VkWynUiLk84GwA==} + cpu: [arm64] + os: [darwin] + + '@rspack/binding-darwin-arm64@2.1.1': + resolution: {integrity: sha512-6K8jA3pZphBwLt5DU78wl0IzY1myHrqNSvFVCd9CHa+szlOwv2iMQpZdYdpupIBxwiZ39rrDyQKtoZw7lsAG8w==} + cpu: [arm64] + os: [darwin] + '@rspack/binding-darwin-arm64@2.2.7': resolution: {integrity: sha512-m0ijteZwZfUZeFcbyxwTe6N+I7aceV5/iW39b7fIIoMN/mSv9zL0ieeRzwuFe7mTYGwCuwNieDZHXfMFdp2Q2w==} cpu: [arm64] os: [darwin] - '@rspack/binding-darwin-arm64@2.3.1': - resolution: {integrity: sha512-koLyL2r8PUcLD0StjuZ/n5XM6GJ0C8dzJN0IuIV9d7nQcibJxwjjSAWEPGVz6bm8WuzypvuVKNoa1+GGAHeMQA==} - cpu: [arm64] + '@rspack/binding-darwin-x64@2.0.8': + resolution: {integrity: sha512-satPm2PD4B7jDTVlVAdvMVdUszwLvWUEnUDzLb77mvVkezKNDZmuhb+e8s+FfKs8hJpNbZ9VAejuA2rr8o985w==} + cpu: [x64] + os: [darwin] + + '@rspack/binding-darwin-x64@2.1.1': + resolution: {integrity: sha512-RdqtEfIbSe5ucLNVvMac1k88UwmL4Gil8uXqlEFcSZ3VC2jTOkecadd+B0RYqJ+PirSInrRmKm1cr0740zppOA==} + cpu: [x64] os: [darwin] '@rspack/binding-darwin-x64@2.2.7': @@ -20965,10 +21066,17 @@ packages: cpu: [x64] os: [darwin] - '@rspack/binding-darwin-x64@2.3.1': - resolution: {integrity: sha512-YK39JLiu1YC6+3BMxkP7e848pHD7e2T/0OSNogDi7whfiZNg95wa9Ncd7I5ppAf0nhmV+FNew/sCBIFp5h67Jw==} - cpu: [x64] - os: [darwin] + '@rspack/binding-linux-arm64-gnu@2.0.8': + resolution: {integrity: sha512-pSI+npPQE/uDtiboqvcOIRJbEV2+B+H1xffmko/gw50la92oTUW60kVULFwsb6L0+GVCzIcwX3yq60GtYIn+Ug==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rspack/binding-linux-arm64-gnu@2.1.1': + resolution: {integrity: sha512-ROKtqXoLpbZO1vYEcNxQg6COvRhdlJcoib1Z4pzG1nIyctEAUuFmnD7pIvJiVe6M7YuJNXW+1p0BhpptT2XEUQ==} + cpu: [arm64] + os: [linux] + libc: [glibc] '@rspack/binding-linux-arm64-gnu@2.2.7': resolution: {integrity: sha512-uGEX6kY/Pi3wPZgaEk6vTevZOHjKw8qmd5pqWVwRmpLhwvPB7LGqVqx5BMnNYBjsndVUWJQQRlGL8DoVG5IXXQ==} @@ -20976,20 +21084,20 @@ packages: os: [linux] libc: [glibc] - '@rspack/binding-linux-arm64-gnu@2.3.1': - resolution: {integrity: sha512-Q+RCA/KM2tn6m6R5U4lktXDs5cCRm3SyleQk86iqqUFX7wKzVRUvr5BTsreg6K9of3gpYmQ6+g1PGT5cwo0rLA==} - cpu: [arm64] - os: [linux] - libc: [glibc] - - '@rspack/binding-linux-arm64-musl@2.2.7': - resolution: {integrity: sha512-qBvztXsOgdi69zi8BhIUz+yc/alqR/wQVmcdCh+1SbhcsNpMsFUndxvVoR1tOboBsEo//gxOG4GxH8zlemhbUA==} + '@rspack/binding-linux-arm64-musl@2.0.8': + resolution: {integrity: sha512-igjJ43yxWQ72GZqjDDZSSHax9/Vg+6rLMmOvFglTJUkQpB4Tyvu/YjW+WRjYj2xRw6blOjLxUSJWASvuSqqlvg==} cpu: [arm64] os: [linux] libc: [musl] - '@rspack/binding-linux-arm64-musl@2.3.1': - resolution: {integrity: sha512-He+muVDON1fohGtdYamh3zHVwf6/E6fZu/+iEAkxjclE0P94bsCfYVcZW/a4/l1tJ2zvLZtB4jD7Qr6r4vG/WA==} + '@rspack/binding-linux-arm64-musl@2.1.1': + resolution: {integrity: sha512-QdQpG9dK0GfPASjBd/8rUwDNW0ShfFfYJfcoGLNTM6A8EqmgvWwklXDiCVF5dXALbZIksAuRznIKnLDsUoXi9Q==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rspack/binding-linux-arm64-musl@2.2.7': + resolution: {integrity: sha512-qBvztXsOgdi69zi8BhIUz+yc/alqR/wQVmcdCh+1SbhcsNpMsFUndxvVoR1tOboBsEo//gxOG4GxH8zlemhbUA==} cpu: [arm64] os: [linux] libc: [musl] @@ -21000,9 +21108,9 @@ packages: os: [linux] libc: [glibc] - '@rspack/binding-linux-ppc64-gnu@2.3.1': - resolution: {integrity: sha512-blIZUgyPt4FcSHkZL6sJ2xbzc7ACgDeU49An4mXLSebwdgnlhTzxeSFnh2VeJDlGza8CUaZYB/zS/6oZ2kCDcw==} - cpu: [ppc64] + '@rspack/binding-linux-riscv64-gnu@2.1.1': + resolution: {integrity: sha512-LGdYCAvblZp2qtHk9UseYftIRyaBzSWqEzd1toaS08sYESXERm+YBbrYKKiyq1yXiU1L7BkhMUxiWc3GCYmKcA==} + cpu: [riscv64] os: [linux] libc: [glibc] @@ -21012,20 +21120,14 @@ packages: os: [linux] libc: [glibc] - '@rspack/binding-linux-riscv64-gnu@2.3.1': - resolution: {integrity: sha512-3FtW2DUFmXxhBORUA3zSc+ot4d6R/1/U6z/48TDN4jeIYDUG9VqYBF6LUohX4vBY6IP0DCyXb2N9WayD/9QXoA==} - cpu: [riscv64] - os: [linux] - libc: [glibc] - - '@rspack/binding-linux-riscv64-musl@2.2.7': - resolution: {integrity: sha512-ywcmeNAC59HtVJ4a5jy5cEUA4JNa19QlVtTW09Pzh0+luNEasWaDfOaXJpYJTGWcycVwzMm3A9aNN3MqvO87EQ==} + '@rspack/binding-linux-riscv64-musl@2.1.1': + resolution: {integrity: sha512-87phiiPGFT1p4gy3Oz6YdNijCPXdjJy43LFdE8AFiZsV4ChFXQPqnVCF2aMRLybYa51A+9wGYlTvxt09yUQUww==} cpu: [riscv64] os: [linux] libc: [musl] - '@rspack/binding-linux-riscv64-musl@2.3.1': - resolution: {integrity: sha512-+5qNgdNdXzp/K8f8BjgJ3m7tcbBKPENN7WPDfBcSHvWb5GF4+o/pbrX26c0+LEugo0bYUOAoitBNd94AwcNvpA==} + '@rspack/binding-linux-riscv64-musl@2.2.7': + resolution: {integrity: sha512-ywcmeNAC59HtVJ4a5jy5cEUA4JNa19QlVtTW09Pzh0+luNEasWaDfOaXJpYJTGWcycVwzMm3A9aNN3MqvO87EQ==} cpu: [riscv64] os: [linux] libc: [musl] @@ -21036,9 +21138,15 @@ packages: os: [linux] libc: [glibc] - '@rspack/binding-linux-s390x-gnu@2.3.1': - resolution: {integrity: sha512-yNcg/y1+MV0wZ984CVU4d1HAYYwMcDPXoQO0xynU+K5YuBxPWALHOxuRRCKCcykBdL1GIEshAIewEFrsW/cmJg==} - cpu: [s390x] + '@rspack/binding-linux-x64-gnu@2.0.8': + resolution: {integrity: sha512-zrkoEOnqj1hOEBO5T2I/2Ts2HSJsYFh1qXwMpK4dMJFGGNWDfNeUa6/LF5uq3VINF3JUl7RL47AgrucoSZJXPA==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rspack/binding-linux-x64-gnu@2.1.1': + resolution: {integrity: sha512-om0/PvZzxISsnyz3hdmI3xBi3Qsn6faRGrfp6WJpGHa5JYYaRVWz1MJ9fe+/cQE9ON9r32HpMOeuataCLv+Owg==} + cpu: [x64] os: [linux] libc: [glibc] @@ -21048,11 +21156,17 @@ packages: os: [linux] libc: [glibc] - '@rspack/binding-linux-x64-gnu@2.3.1': - resolution: {integrity: sha512-ffclKBuH8wwimOBd6xGUxrBfVKKY5Ow4E7OFdHZeg4xffm2O8auGszmOgvFu1eoDoOYHaVJn+cEV6UD0KwZk8A==} + '@rspack/binding-linux-x64-musl@2.0.8': + resolution: {integrity: sha512-6CtDaGZjNDvJd9TBp7a9zABbrPORO21W96+3ZcGBn0YNUPUk4ARxIxrTTpeJ/1F41QDM8AYIkGDdqEYMqTYBsA==} cpu: [x64] os: [linux] - libc: [glibc] + libc: [musl] + + '@rspack/binding-linux-x64-musl@2.1.1': + resolution: {integrity: sha512-YgAyTOM5ZWvWT0Exwcg7QkGUv9PsHT4yIsEyJbH+a99uAKliGMwkHIOP/aJgrCF8G+lTfigY2wyl9cWo4TA4aw==} + cpu: [x64] + os: [linux] + libc: [musl] '@rspack/binding-linux-x64-musl@2.2.7': resolution: {integrity: sha512-atJn62IgXnc/RhWiFgEiNx7IHAJbHunttzjMpWJLjWiFuJ2c+tLQrTBIiqO3VAIXh+haN1jZLHXuMVj5/J+edA==} @@ -21060,28 +21174,41 @@ packages: os: [linux] libc: [musl] - '@rspack/binding-linux-x64-musl@2.3.1': - resolution: {integrity: sha512-qcDwwuyxR7TMtrW+r5Y9RIW25boXd1Ip/9jz04jhdq/OiU/Am7rCP2X90CH8sWdzovIF9UNmsGjY4KklR0F2Mg==} - cpu: [x64] - os: [linux] - libc: [musl] + '@rspack/binding-wasm32-wasi@2.0.8': + resolution: {integrity: sha512-Yf4SiqTUroT5Ju+te0YAY2xxKOb35tECsO21v7hYyGa705wrgoAK/MmF7enOvs9GR1iZIqgiLD/wxsIxl8GjJw==} + cpu: [wasm32] + + '@rspack/binding-wasm32-wasi@2.1.1': + resolution: {integrity: sha512-OicgaB3Dcd+KXsH/I3DkJG7XQyREJScg/jLkCtycFn9BhT0IVJvgi37F8QNJKl8Bp9YZIGehsqK9HpQWav6SLw==} + cpu: [wasm32] '@rspack/binding-wasm32-wasi@2.2.7': resolution: {integrity: sha512-SRDYrqWnD8Y+VNj8+11KggFaVMFSbyu+9WC2f9sygzjFu78GmF0kLKaHNQMaJv6MUMSBk/OhtEbUB4hmH7czVQ==} cpu: [wasm32] - '@rspack/binding-wasm32-wasi@2.3.1': - resolution: {integrity: sha512-3dr6zjFaCK3A920ftCriSJkiRhEfhHtat7LtBdj6g0mcV5Rt+iealmli0vjeAvD0UdpE1u8EKWlfw82JLgFLSQ==} - cpu: [wasm32] + '@rspack/binding-win32-arm64-msvc@2.0.8': + resolution: {integrity: sha512-8NCuiQsAhXrwRBy57QZoypqrws/zLBkaQVGiB8hksr6v++8hNigNjqpQARLbd0iyMuHsQQ++8+auGk6xlDXmzw==} + cpu: [arm64] + os: [win32] + + '@rspack/binding-win32-arm64-msvc@2.1.1': + resolution: {integrity: sha512-fwL4P3SsC0r/vVGgnmexnc4vkvf+9vWMcGw5fdlPBJNR/zWlZRSXR5V6eXcHrpYVLhBsLYvZYE3NZa9paIUGxw==} + cpu: [arm64] + os: [win32] '@rspack/binding-win32-arm64-msvc@2.2.7': resolution: {integrity: sha512-etHFjzSP/jnnrVYuim9C/nhSlN0/tQowVz0CSJOUHtDH7ZZiUsvWtkH9Zx3tDaZOB7sAw9cbL36mbmdkb4U6cw==} cpu: [arm64] os: [win32] - '@rspack/binding-win32-arm64-msvc@2.3.1': - resolution: {integrity: sha512-AZbuLPylt1xvWssN93AsirbYs3WgfcrA8tMsqHmVJIHahLu9E+JPKZ3Gmsw6IYEZk3EfnV3ujQzeQ1/VfF0Vsw==} - cpu: [arm64] + '@rspack/binding-win32-ia32-msvc@2.0.8': + resolution: {integrity: sha512-bxiekytbX7V9KFAra+HkwtNWC6pYfHEBBZFpiT0xUs3mCFOmAAFVBsBSQsoCP9AdCEXoMAvNdnrHNw3iov4OZw==} + cpu: [ia32] + os: [win32] + + '@rspack/binding-win32-ia32-msvc@2.1.1': + resolution: {integrity: sha512-j3BISXbjPyI57HeHxW9Jx+UP7RebNQ4t62uCbRP29caf9aghYJP+ZA5nJ2X7pol7N5Je2/V6WNahuNd0zQFDOA==} + cpu: [ia32] os: [win32] '@rspack/binding-win32-ia32-msvc@2.2.7': @@ -21089,9 +21216,14 @@ packages: cpu: [ia32] os: [win32] - '@rspack/binding-win32-ia32-msvc@2.3.1': - resolution: {integrity: sha512-R5NVU68TePZcgRdYUzrQX9YFNxmcyXZEPwaPv40AAgsqNyacG3iRaYVmV79jt3rWYfa0QJaqvRLUchDe2SZ6zQ==} - cpu: [ia32] + '@rspack/binding-win32-x64-msvc@2.0.8': + resolution: {integrity: sha512-7zPs8YCe/ZVJTwd+5lpB0CP0tkn2pONf/T1ycmVY76u21Nrwt8mXQGc/2yH2eWP4B7fikYBr3hGr7mpR2fajqQ==} + cpu: [x64] + os: [win32] + + '@rspack/binding-win32-x64-msvc@2.1.1': + resolution: {integrity: sha512-aPNNFuZT5iBM8+S9J4P5ywJbf3tUvZN3Ppe6mXJ8/jTVDUDhe0YVj3AgD/AuxnUvl+yHrLfQkN1nNwUfIcomfA==} + cpu: [x64] os: [win32] '@rspack/binding-win32-x64-msvc@2.2.7': @@ -21099,19 +21231,17 @@ packages: cpu: [x64] os: [win32] - '@rspack/binding-win32-x64-msvc@2.3.1': - resolution: {integrity: sha512-5T9DYjNPQpLbrNXjCssGd2B6xMQPlc3LxVOKHGUA1O0GV+88vBkTXAcryJ+Fo+yVEMPCzp4VvwBMGAVDpCjcSA==} - cpu: [x64] - os: [win32] + '@rspack/binding@2.0.8': + resolution: {integrity: sha512-3uZ+y8aQxq33ty2srMxg2Nu0XuBI6vVrG50rkDaXqwWqOohfgGUSfFuQK7EnSUNy4aFUQlCG6NHialQHJov0wg==} + + '@rspack/binding@2.1.1': + resolution: {integrity: sha512-6062hZP33fn1w51ClpQnum19GGXl/3eS754xrRYbQ7wwBNZk94HVwfSyiqcNCtY/pB1lsFjnaTKiW/Q+jv0axQ==} '@rspack/binding@2.2.7': resolution: {integrity: sha512-opY7Sw6iwtBa23CeNj18GOqKBlaJUZXp52kNIGyNq+7jpCQKrJYeX5wiK7uBn8/ZpHQfhwNL2xxu5yzG4JFH1g==} - '@rspack/binding@2.3.1': - resolution: {integrity: sha512-pfCJGBFNK2tnNnoDP6ZoTbOjxbKr1U2eGFDJ8bIuZQai4FBNhWQlKFmNup+X5K935XYRulZBomIBAL6GL6W2YQ==} - - '@rspack/core@2.2.7': - resolution: {integrity: sha512-kWKd4lYp13GPAQy2eQITLTvPbl+ST7ffG/MCGHoX138o5eTetMQMe/oc7UAZAfjervAM6UOzEhiiCirPTpRBUQ==} + '@rspack/core@2.0.8': + resolution: {integrity: sha512-+NLGJf8gZxihDmMFzjlly3toc2SMjeDmuvz0/Cai9AMdV4F+Pqcnt2BA9V4e3SY2jmhJQtPwgyyLtR1RiJO77g==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 @@ -21122,8 +21252,20 @@ packages: '@swc/helpers': optional: true - '@rspack/core@2.3.1': - resolution: {integrity: sha512-9BWfaiEJLgLK9U53Q4WVruBZ19Mu/XWHXHEu0UFla4lUtH8Z+/ET2m044tiqbtyIgqQyG58fMrxHeVIAiXMXHg==} + '@rspack/core@2.1.1': + resolution: {integrity: sha512-Rgz6xZcD0rm7ejZhYNi13qvW2dSnIQQt/7D3xbYoT5hOU838JbkF0P3SAMFGKE+FyLZswnyRpxGfnYHZQqDmJA==} + engines: {node: ^20.19.0 || >=22.12.0} + peerDependencies: + '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 + '@swc/helpers': ^0.5.23 + peerDependenciesMeta: + '@module-federation/runtime-tools': + optional: true + '@swc/helpers': + optional: true + + '@rspack/core@2.2.7': + resolution: {integrity: sha512-kWKd4lYp13GPAQy2eQITLTvPbl+ST7ffG/MCGHoX138o5eTetMQMe/oc7UAZAfjervAM6UOzEhiiCirPTpRBUQ==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@module-federation/runtime-tools': ^0.24.1 || ^2.0.0 @@ -21264,7 +21406,7 @@ packages: resolution: {integrity: sha512-vMfGz7x3Ahplcdm0RlEtTNUZ08qpUSr3NRJMQ6duUDxxe0Mqo6DisyQWNQKSROZ7BtLCJUfio6/LRGpkRUoo8A==} engines: {node: '>=18'} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 '@sentry/solid@10.32.0': resolution: {integrity: sha512-T+i0L+uB67Z+ttJJwETLQuXhBOor3mC82YqXBBxFX8H4hLZ0Idpbuw2Vmqd5+E1vQFxgsoHnuu3uBR6LblafFQ==} @@ -21851,37 +21993,37 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@tanstack/react-query-devtools@5.67.2': resolution: {integrity: sha512-cmj2DxBc+/9btQ66n5xI8wTtAma2BLVa403K7zIYiguzJ/kV201jnGensYqJeu1Rd8uRMLLRM74jLVMLDWNRJA==} peerDependencies: '@tanstack/react-query': ^5.102.0 - react: ~19.2.9 + react: ^19.2.3 '@tanstack/react-query-devtools@5.90.2': resolution: {integrity: sha512-vAXJzZuBXtCQtrY3F/yUNJCV4obT/A/n81kb3+YqLbro5Z2+phdAbceO+deU3ywPw8B42oyJlp4FhO0SoivDFQ==} peerDependencies: '@tanstack/react-query': ^5.102.0 - react: ~19.2.9 + react: ^19.2.3 '@tanstack/react-query@5.102.0': resolution: {integrity: sha512-0GyVyEcGt9M7jHPCua16hNVtstUXE2R4HsnNubFYcDs7DJaLzh1dSiXsADDU/cNn/SqrLfa0vRKyjUmbx4rZLA==} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 '@tanstack/react-store@0.11.2': resolution: {integrity: sha512-oj5O5DmiMWE+ih+SioX2ayC1kbK7d3fpLx0B75fPJr9nY3zU+hoW010yr64qXsY/9fyiLVE2bn5mGNV3owm8RQ==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@tanstack/react-virtual@3.13.0': resolution: {integrity: sha512-CchF0NlLIowiM2GxtsoKBkXA4uqSnY2KvnXo+kyUFD4a4ll6+J0qzoRsUPMwXV/H26lRsxgJIr/YmjYum2oEjg==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@tanstack/solid-devtools@0.7.14': resolution: {integrity: sha512-hyaB29d1fU2n9v2XeFEB6t2k5gKionK8mxxb9MNtF7qJheZ6z9259jU8OsBdA/f6v2oYck1K1Ia9+ooJsdy4jg==} @@ -21987,8 +22129,8 @@ packages: '@testing-library/dom': ^10.0.0 '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -22002,8 +22144,8 @@ packages: '@testing-library/dom': ^10.0.0 '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -22037,10 +22179,13 @@ packages: '@tanstack/react-query': ^5.102.0 '@trpc/client': 11.4.3 '@trpc/server': 11.4.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 typescript: '>=5.7.2' + '@tybys/wasm-util@0.10.2': + resolution: {integrity: sha512-RoBvJ2X0wuKlWFIjrwffGw1IqZHKQqzIchKaadZZfnNpsAYp2mM0h36JtPCjNDAHGgYez/15uMBpfGwchhiMgg==} + '@tybys/wasm-util@0.10.3': resolution: {integrity: sha512-F3fo1MYrRJYL3zER0OUOmkutjr1Vp23m7OsSgp7nq4SP6OqX6C/56XFIPAl5bt3zaBRjmW7SGz3u/6LwFpYcOg==} @@ -22089,6 +22234,9 @@ packages: '@types/cookie@0.6.0': resolution: {integrity: sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==} + '@types/debug@4.1.13': + resolution: {integrity: sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==} + '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} @@ -22098,6 +22246,9 @@ packages: '@types/eslint@9.6.1': resolution: {integrity: sha512-FXx2pKgId/WyYo2jXw63kk7/+TY7u7AziEJxJAnSFzHlqTAS3Ync6SvgYAN/k4/PQpnnVuzoMuVnByKK2qp0ag==} + '@types/estree-jsx@1.0.5': + resolution: {integrity: sha512-52CcUVNFyfb1A2ALocQw/Dd1BQFNmSdkuC3BkZ6iqhdMfQz7JWOFRuJFloOzjk+6WijU56m9oKXFAXc7o3Towg==} + '@types/estree@1.0.7': resolution: {integrity: sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==} @@ -22119,6 +22270,9 @@ packages: '@types/express@5.0.6': resolution: {integrity: sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==} + '@types/hast@3.0.5': + resolution: {integrity: sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==} + '@types/html-minifier-terser@6.1.0': resolution: {integrity: sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==} @@ -22137,9 +22291,18 @@ packages: '@types/json-schema@7.0.15': resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + '@types/mdast@4.0.4': + resolution: {integrity: sha512-kGaNbPh1k7AFzgpud/gMdvIm5xuECykRR+JnWKQno9TAXVa6WIVCGTPvYGekIDL4uwCZQSYbUxNBSb1aUo79oA==} + + '@types/mdx@2.0.14': + resolution: {integrity: sha512-T48PeuJtvLosNTPVhfnIp3i/n3a4g4Bad7YCq5k64D4u7NwDrAotikQ+5+sjtUvBmxCMlbo3dVL+C2dP0rWHzg==} + '@types/mime@1.3.5': resolution: {integrity: sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==} + '@types/ms@2.1.0': + resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==} + '@types/node-forge@1.3.14': resolution: {integrity: sha512-mhVF2BnD4BO+jtOp7z1CdzaK4mbuK0LLQYAvdOLqHTavxFNq4zA1EmYkpnFjP8HOUzedfQkRnp0E2ulSAYSzAw==} @@ -22213,6 +22376,12 @@ packages: '@types/triple-beam@1.3.5': resolution: {integrity: sha512-6WaYesThRMCl19iryMYP7/x2OVgCtbIVflDGFpWnb9irXI3UjYE4AzmYuiUKY1AJstGijoY+MgUszMgRxIYTYw==} + '@types/unist@2.0.11': + resolution: {integrity: sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==} + + '@types/unist@3.0.3': + resolution: {integrity: sha512-ko/gIFJRv177XgZsZcBwnqJN5x/Gien8qNOn0D5bQU/zAzVf9Zt3BlcUiLqhV9y4ARk0GbT3tnUiPNgnTXzc/Q==} + '@types/ws@8.5.14': resolution: {integrity: sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw==} @@ -22539,6 +22708,9 @@ packages: resolution: {integrity: sha512-mbCddXd+jm7hfx7w2YU64/Av4/NqqeG3GoRZgxPcgoTxYjhrcfJRw9ULch71SS4G+Q3bOXFhRvPqjguN0Hyp5w==} hasBin: true + '@ungap/structured-clone@1.4.0': + resolution: {integrity: sha512-1mEZtMKPM09vDmQt5y7YvmN2+DFTP7Tg0EWXdic8/C6VRnpb33e4ghisCIE3WZjsE2N8mf+QV1Zqh7ZFYLWInQ==} + '@unrs/resolver-binding-android-arm-eabi@1.11.1': resolution: {integrity: sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw==} cpu: [arm] @@ -22660,11 +22832,11 @@ packages: babel-plugin-react-compiler: optional: true - '@vitejs/plugin-rsc@0.5.39': - resolution: {integrity: sha512-hRa6CK119r1NkwgPWlPRiDP8e4rELCsIZwjGmQK0sOnayAkYPBkyJMip0GhYEt2ukBZaO0Uw3ICHHO9T692OFw==} + '@vitejs/plugin-rsc@0.5.37': + resolution: {integrity: sha512-4BUmLYKjDDJXEonK8QL034IsqXHFjtaKVUBs9syJsTOoKKUad8JkaYwQdyaCyplVccjuAQOLC86e9sE4fwP+NQ==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 react-server-dom-webpack: '*' vite: ^8.3.4 peerDependenciesMeta: @@ -22964,8 +23136,8 @@ packages: peerDependencies: '@tanstack/react-router': workspace:* '@tanstack/react-start': workspace:* - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@xtuc/ieee754@1.2.0': resolution: {integrity: sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==} @@ -23107,6 +23279,7 @@ packages: ansi-html-community@0.0.8: resolution: {integrity: sha512-1APHAyr3+PCamwNw3bXCPp4HFLONZt/yIH0sZp0/469KWNTEy+qN5jQ3GVX6DMZ1UXAi34yVwtTeaG/HpBuuzw==} + engines: {'0': node >= 0.8.0} hasBin: true ansi-regex@5.0.1: @@ -23189,6 +23362,10 @@ packages: resolution: {integrity: sha512-WHw67kLXYbZuHTmcdbIrVArCq5wxo6NEuj3hiYAWr8mwJeC+C2mMCIBIWCiDoCye/OF/xelc+teJ1ERoWmnEIA==} engines: {node: '>=18'} + astring@1.9.0: + resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==} + hasBin: true + async-mutex@0.5.0: resolution: {integrity: sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==} @@ -23239,6 +23416,11 @@ packages: '@babel/core': ^7.12.0 webpack: '>=5.61.0' + babel-plugin-jsx-dom-expressions@0.40.11: + resolution: {integrity: sha512-k7TkOv7uVYnrq/bYyVvG5cWOC9IObAGfmyW3aMkG8l2sq2qt/5THkUBja69PMLEGGi8G+fXB2Fh7eS4OwZRBoQ==} + peerDependencies: + '@babel/core': ^7.20.12 + babel-plugin-jsx-dom-expressions@0.40.3: resolution: {integrity: sha512-5HOwwt0BYiv/zxl7j8Pf2bGL6rDXfV6nUhLs8ygBX+EFJXzBPHM/euj9j/6deMZ6wa52Wb2PBaAV5U/jKwIY1w==} peerDependencies: @@ -23263,6 +23445,18 @@ packages: solid-js: optional: true + babel-preset-solid@1.9.16: + resolution: {integrity: sha512-+0h40Qk2oBfkQ4OGDBHIDtvq/XQiOnCfzjNHmMxriAr8MmdsaIbyJgqYglDs4d70sF8O08sSpx61TKdpUt3oRw==} + peerDependencies: + '@babel/core': ^7.0.0 + solid-js: 1.9.12 + peerDependenciesMeta: + solid-js: + optional: true + + bail@2.0.2: + resolution: {integrity: sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw==} + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -23348,8 +23542,8 @@ packages: next: ^14.0.0 || ^15.0.0 || ^16.0.0 pg: ^8.0.0 prisma: ^5.0.0 || ^6.0.0 || ^7.0.0 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 solid-js: 1.9.12 svelte: ^4.0.0 || ^5.0.0 vitest: ^2.0.0 || ^3.0.0 || ^4.0.0 @@ -23448,10 +23642,6 @@ packages: brace-expansion@2.1.1: resolution: {integrity: sha512-WR1cURNjuvBLMZBMbqM0UoE+WAfdUcEV1ccD8PVBVOI+Z3ND4+SZbN8RsfT2bMuG1qwz5RFvPukSZm5fF2D5eA==} - brace-expansion@5.0.12: - resolution: {integrity: sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==} - engines: {node: 20 || >=22} - brace-expansion@5.0.9: resolution: {integrity: sha512-ScQ4IuvIEF1TMlP7Zt+vjJ//9zlPb2SDcxWxM3bk8s6t6GGdJ7KO1dCcTidOPJKePW30LE/2cT7wCyPho9/Wxg==} engines: {node: 20 || >=22} @@ -23543,10 +23733,8 @@ packages: caniuse-lite@1.0.30001760: resolution: {integrity: sha512-7AAMPcueWELt1p3mi13HR/LHH0TJLT11cnwDJEs3xA4+CK/PLKeO9Kl1oru24htkyUKtkGCvAx4ohB0Ttry8Dw==} - cf@1.0.0-beta.28: - resolution: {integrity: sha512-sMt4G50Mvz0+wvp6ScckPmmJSrEtfN3BeYJbtJ9yN5wAgECgFUGy0twoup1KySG9Md4Ow4ifSkllPLBFQV9ePw==} - engines: {node: ^22.23.0 || ^24.22.0 || ^26.12.0} - hasBin: true + ccount@2.0.1: + resolution: {integrity: sha512-eyrF0jiFpY+3drT6383f1qhkbGsLSifNAjA61IUjZjmLCWjItY6LB9ft9YhoDgwfmclB2zhu51Lc7+95b8NRAg==} chai@6.3.0: resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} @@ -23575,6 +23763,18 @@ packages: char-spinner@1.0.1: resolution: {integrity: sha512-acv43vqJ0+N0rD+Uw3pDHSxP30FHrywu2NO6/wBaHChJIizpDeBUd6NjqhNhy9LGaEAhZAXn46QzmlAvIWd16g==} + character-entities-html4@2.1.0: + resolution: {integrity: sha512-1v7fgQRj6hnSwFpq1Eu0ynr/CDEw0rXo2B61qXrLNdHZmPKgb7fqS1a2JwF0rISo9q77jDI8VMEHoApn8qDoZA==} + + character-entities-legacy@3.0.0: + resolution: {integrity: sha512-RpPp0asT/6ufRm//AJVwpViZbGM/MkjQFxJccQRHmISF/22NBtsHqAWmL+/pmkPWoIUJdWyeVleTl1wydHATVQ==} + + character-entities@2.0.2: + resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + + character-reference-invalid@2.0.1: + resolution: {integrity: sha512-iBZ4F4wRbyORVsu0jPV7gXkOsGYjGHPmAyv+HiHG8gi5PtC9KI2j1+v8/tlibRvjoWX027ypmG/n0HtO5t7unw==} + chardet@2.1.1: resolution: {integrity: sha512-PsezH1rqdV9VvyNhxxOW32/d75r01NY7TQCmOqomRo15ZSOKbpTFVsfjghxo6JloQUCGnH4k1LGu0R4yCLlWQQ==} @@ -23678,6 +23878,9 @@ packages: resolution: {integrity: sha512-rwHwUfXL40Chm1r08yrhU3qpUvdVlgkKNeyeGPOxnW8/SyVDvgRaed/Uz54AqWNaTCAThlj6QAs3TZcKI0xDEw==} engines: {node: '>=0.10.0'} + collapse-white-space@2.1.0: + resolution: {integrity: sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==} + color-convert@2.0.1: resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} engines: {node: '>=7.0.0'} @@ -23718,6 +23921,9 @@ packages: resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} engines: {node: '>= 0.8'} + comma-separated-tokens@2.0.3: + resolution: {integrity: sha512-Fu4hJdvzeylCfQPp9SGWidpzrMs7tTrlu6Vb8XGaRGck8QSNZJJp538Wrb60Lax4fPwR64ViY468OIUTbRlGZg==} + commander@10.0.1: resolution: {integrity: sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==} engines: {node: '>=14'} @@ -23833,7 +24039,7 @@ packages: '@standard-schema/spec': ^1.0.0 convex: ^1.24.0 hono: ^4.0.5 - react: ~19.2.9 + react: ^19.2.3 typescript: ^5.5 zod: ^3.22.4 || ^4.0.15 peerDependenciesMeta: @@ -23861,8 +24067,8 @@ packages: peerDependencies: '@auth0/auth0-react': ^2.0.1 '@clerk/clerk-react': ^4.12.8 || ^5.0.0 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@auth0/auth0-react': optional: true @@ -23880,7 +24086,7 @@ packages: peerDependencies: '@auth0/auth0-react': ^2.0.1 '@clerk/clerk-react': ^4.12.8 || ^5.0.0 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@auth0/auth0-react': optional: true @@ -24085,6 +24291,9 @@ packages: decimal.js@10.6.0: resolution: {integrity: sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==} + decode-named-character-reference@1.3.0: + resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==} + dedent@1.5.1: resolution: {integrity: sha512-+LxW+KLWxu3HW3M2w2ympwtqPrqYRzU8fqi6Fhd18fBALe15blJPI/I4+UHveMVG6lJqB4JNd4UG0S5cnVHwIg==} peerDependencies: @@ -24116,6 +24325,10 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} + default-browser-id@5.0.0: + resolution: {integrity: sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==} + engines: {node: '>=18'} + default-browser-id@5.0.1: resolution: {integrity: sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==} engines: {node: '>=18'} @@ -24245,6 +24458,9 @@ packages: dettle@1.0.5: resolution: {integrity: sha512-ZVyjhAJ7sCe1PNXEGveObOH9AC8QvMga3HJIghHawtG7mE4K5pW9nz/vDGAr/U7a3LWgdOzEE7ac9MURnyfaTA==} + devlop@1.1.0: + resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + dexie@4.2.1: resolution: {integrity: sha512-Ckej0NS6jxQ4Po3OrSQBFddayRhTCic2DoCAG5zacOfOVB9P2Q5Xc5uL/nVa7ZVs+HdMnvUPzLFCB/JwpB6Csg==} @@ -24473,8 +24689,9 @@ packages: es-module-lexer@3.0.3: resolution: {integrity: sha512-yWGe1O/j+almnV4hOYrmZo8u58JdnmXEMneRQAYkWtqSiT86yoMIEKF4rpqEDj52tbYl3xceBD3DQIBwcsC9Pw==} - es-module-lexer@3.0.4: - resolution: {integrity: sha512-BldNY5mwkVu+cQ5Ymn3e6hB9Sx8XHx4ZevWbiUyZbfKxJxYO27Hf0wfzkxIaD5CAJMaGl3YspKELj0ff/7nCMA==} + es-object-atoms@1.1.1: + resolution: {integrity: sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==} + engines: {node: '>= 0.4'} es-object-atoms@1.1.2: resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} @@ -24484,6 +24701,12 @@ packages: resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} engines: {node: '>= 0.4'} + esast-util-from-estree@2.0.0: + resolution: {integrity: sha512-4CyanoAudUSBAn5K13H4JhsMH6L9ZP7XbLVe/dKybkxMO7eDyLsT8UHl9TRNrU2Gr9nz+FovfSIjuXWJ81uVwQ==} + + esast-util-from-js@2.0.1: + resolution: {integrity: sha512-8Ja+rNJ0Lt56Pcf3TAmpBZjmx8ZcK5Ts4cAzIOjsjevg9oSXJnl6SUQ2EevU8tv3h6ZLWmoKL5H4fgWvdvfETw==} + esbuild-plugin-solid@0.6.0: resolution: {integrity: sha512-V1FvDALwLDX6K0XNYM9CMRAnMzA0+Ecu55qBUT9q/eAJh1KIDsTMFoOzMSgyHqbOfvrVfO3Mws3z7TW2GVnIZA==} peerDependencies: @@ -24538,6 +24761,11 @@ packages: engines: {node: '>=18'} hasBin: true + esbuild@0.28.2: + resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==} + engines: {node: '>=18'} + hasBin: true + escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -24763,6 +24991,24 @@ packages: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} + estree-util-attach-comments@3.0.0: + resolution: {integrity: sha512-cKUwm/HUcTDsYh/9FgnuFqpfquUbwIqwKM26BVCGDPVgvaCl/nDCCjUfiLlx6lsEZ3Z4RFxNbOQ60pkaEwFxGw==} + + estree-util-build-jsx@3.0.1: + resolution: {integrity: sha512-8U5eiL6BTrPxp/CHbs2yMgP8ftMhR5ww1eIKoWRMlqvltHF8fZn5LRDvTKuxD3DUn+shRbLGqXemcP51oFCsGQ==} + + estree-util-is-identifier-name@3.0.0: + resolution: {integrity: sha512-hFtqIDZTIUZ9BXLb8y4pYGyk6+wekIivNVTcmvk8NoOh+VeRn5y6cEHzbURrWbfp1fIqdVipilzj+lfaadNZmg==} + + estree-util-scope@1.0.1: + resolution: {integrity: sha512-B0np3dcdxqILX5e9nEi5/Fr4K7gL4oYFVPV1zRa2e9wRCbQoZZNWOZFYyoInvXUPJXBXjss+QXlWLJChDEHDkA==} + + estree-util-to-js@2.0.0: + resolution: {integrity: sha512-WDF+xj5rRWmD5tj6bIqRi6CkLIXbbNQUcxQHzGysQzvHmdYG2G7p/Tf0J0gpxGgkeMZNTIjT/AoSvC9Xehcgdg==} + + estree-util-visit@2.0.0: + resolution: {integrity: sha512-m5KgiH85xAhhW8Wta0vShLcUvOsh3LLPI2YVwcbio1l7E09NTLL1EyMZFM1OyWowoH0skScNbhOPl4kcBgzTww==} + estree-walker@2.0.2: resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} @@ -24807,11 +25053,11 @@ packages: resolution: {integrity: sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==} engines: {node: '>= 18'} - exsolve@1.1.1: - resolution: {integrity: sha512-9U/jZUgjnSGyntRr6y5Muu1MJcwFl6kPu7k8qLF0IMNfLqvw0NZ4nnVDq0RVoZ0RvCyumib4Ez3KYrVfilrw+g==} + exsolve@1.1.3: + resolution: {integrity: sha512-kuzL9zherLQoqDeQaS55AiiIg1kb4KYXaSusTtgZTPlvKP2gGCI82LNmBNh5RjDVUXIcmgx+/Mx7vPwRzBbhJA==} - exsolve@1.2.0: - resolution: {integrity: sha512-h1pQPR9XoeSMdntRNCjyTznaume4UpfXrULBnlkZ2CUM/G5eSa+pBByGldO5uR8dxbPC+OuJXsPPNf+JZ81ADg==} + extend@3.0.2: + resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} extendable-error@0.1.7: resolution: {integrity: sha512-UOiS2in6/Q0FK0R0q6UY9vYpQ21mr/Qn1KOnte7vsACuNJf514WvCCUHSRCPcgjPT2bAhNIJdlE6bVap1GKmeg==} @@ -25010,8 +25256,8 @@ packages: resolution: {integrity: sha512-5F5Och7wrvtLVElIpclDT0CBzMVg3dL22B64aZwHtsIY8RB4mXICLrkajK4G9R+ieSAGcgrLeae2SeUTg2pr6w==} peerDependencies: '@emotion/is-prop-valid': '*' - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@emotion/is-prop-valid': optional: true @@ -25232,6 +25478,15 @@ packages: resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} engines: {node: '>= 0.4'} + hast-util-to-estree@3.1.3: + resolution: {integrity: sha512-48+B/rJWAp0jamNbAAf9M7Uf//UVqAoMmgXhBdxTDJLGKY+LRnZ99qcG+Qjl5HfMpYNzS5v4EAwVEF34LeAj7w==} + + hast-util-to-jsx-runtime@2.3.6: + resolution: {integrity: sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==} + + hast-util-whitespace@3.0.0: + resolution: {integrity: sha512-88JUN06ipLwsnv+dVn+OIYOvAuvBMy/Qoi6O7mQHxdPXpjy+Cd6xRkWwux7DKO+4sYILtLBRIKgsdpS2gQc7qw==} + hdr-histogram-js@3.0.1: resolution: {integrity: sha512-l3GSdZL1Jr1C0kyb461tUjEdrRPZr8Qry7jByltf5JGrA0xvqOSrxRBfcrJqqV/AMEtqqhHhC6w8HW0gn76tRQ==} engines: {node: '>=14'} @@ -25426,10 +25681,6 @@ packages: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} - ignore@7.0.12: - resolution: {integrity: sha512-/8UvqAPU9DGTI9k4mxtf49U37Isfwr8Uts96+SBHIkFxPJnHS0Ew4f00sM4Scd8V8EjM0jUNtVDdv1kPdt35lg==} - engines: {node: '>= 4'} - ignore@7.0.5: resolution: {integrity: sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==} engines: {node: '>= 4'} @@ -25440,9 +25691,6 @@ packages: immer@10.1.1: resolution: {integrity: sha512-s2MPrmjovJcoMaHtx6K11Ra7oD05NT97w1IC5zpMkT6Atjr7H8LjaDd81iIxUYpMKSRRNMJE703M1Fhr/TctHw==} - immutable@5.1.4: - resolution: {integrity: sha512-p6u1bG3YSnINT5RQmx/yRZBpenIl30kVxkTLDyHLIMk0gict704Q9n+thfDI7lTRm9vXdDYutVzXhzcThxTnXA==} - immutable@5.1.9: resolution: {integrity: sha512-m8nVez3rwrgmWxtLMt1ZYXB2Lv7OKYn/disyxAlSDYAlKSlFoPPfIAmAM/M5xqL4m4C/wAPw7S2/CNaUii1Hxg==} @@ -25491,6 +25739,9 @@ packages: inline-style-parser@0.2.4: resolution: {integrity: sha512-0aO8FkhNZlj/ZIbNi7Lxxr12obT7cL1moPfE4tg1LkX7LlLfC6DeX4l2ZEud1ukP9jNQyNnfzQVqwbwmAATY4Q==} + inline-style-parser@0.2.7: + resolution: {integrity: sha512-Nb2ctOyNR8DqQoR0OwRG95uNWIC0C1lCgf5Naz5H6Ji72KZ8OcFZLz2P5sNgwlyoJ8Yif11oMuYs5pBQa86csA==} + internal-slot@1.1.0: resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==} engines: {node: '>= 0.4'} @@ -25525,6 +25776,12 @@ packages: iron-webcrypto@2.0.0: resolution: {integrity: sha512-rtffZKDUHciZElM8mjFCufBC7nVhCxHYyWHESqs89OioEDz4parOofd8/uhrejh/INhQFfYQfByS22LlezR9sQ==} + is-alphabetical@2.0.1: + resolution: {integrity: sha512-FWyyY60MeTNyeSRpkM2Iry0G9hpr7/9kD40mD/cGQEuilcZYS4okz8SN2Q6rLCJ8gbCt6fN+rC+6tMGS99LaxQ==} + + is-alphanumerical@2.0.1: + resolution: {integrity: sha512-hmbYhX/9MUMF5uh7tOXyK/n0ZvWpad5caBA17GsC6vyuCqaWliRG5K1qS9inmUhEMaOBIW7/whAnSwveW/LtZw==} + is-arguments@1.2.0: resolution: {integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==} engines: {node: '>= 0.4'} @@ -25560,6 +25817,9 @@ packages: resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} engines: {node: '>= 0.4'} + is-decimal@2.0.1: + resolution: {integrity: sha512-AAB9hiomQs5DXWcRB1rqsxGUstbRroFOPPVAomNk/3XHR5JyEZChOyTWe2oayKnsSsr/kcGqF+z6yuH6HHpN0A==} + is-docker@3.0.0: resolution: {integrity: sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} @@ -25577,6 +25837,9 @@ packages: resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} engines: {node: '>=0.10.0'} + is-hexadecimal@2.0.1: + resolution: {integrity: sha512-DgZQp241c8oO6cA1SbTEWiXeoxV42vlcJxgH+B3hi1AiqqKruZR3ZGF8In3fj4+/y/7rHvlOZLZtgJ/4ttYGZg==} + is-html@2.0.0: resolution: {integrity: sha512-S+OpgB5i7wzIue/YSE5hg0e5ZYfG3hhpNh9KGl6ayJ38p7ED6wxQLd1TV91xHpcTvw90KMJ9EwN3F/iNflHBVg==} engines: {node: '>=8'} @@ -26192,6 +26455,9 @@ packages: long@5.3.1: resolution: {integrity: sha512-ka87Jz3gcx/I7Hal94xaN2tZEOPoUOEVftkQqZx2EeQRN7LGdfLlI3FvZ+7WDplm+vK2Urx9ULrvSowtdCieng==} + longest-streak@3.1.0: + resolution: {integrity: sha512-9Ri+o0JYgehTaVBBDoMqIl8GXtbWg711O3srftcHhZ0dqnETqLaoIK0x17fUw9rFSlK/0NlsKe0Ahhyl5pXE2g==} + loose-envify@1.4.0: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true @@ -26239,9 +26505,6 @@ packages: magic-string@1.4.3: resolution: {integrity: sha512-z12OxmaPGE0F4xlpGdjuAUckipLpQlTAuAmyGhNoD7ODpYUzvDfvtxUbjM/jwznyP178oju/KDdyi220wNJ0RQ==} - magic-string@1.4.5: - resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==} - manage-path@2.0.0: resolution: {integrity: sha512-NJhyB+PJYTpxhxZJ3lecIGgh4kwIY2RAh44XvAz9UlqthlQwtPBf62uBVR8XaD8CRuSjQ6TnZH2lNJkbLPZM2A==} @@ -26249,6 +26512,10 @@ packages: resolution: {integrity: sha512-K6K2NgKnTXimT3779/4KxSvobxOtMmx1LBZ3NwRxT/MDIR3Br/fQ4Q+WCX5QxjyUR8zg5+RV9Tbf2c5pAWTD2A==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + markdown-extensions@2.0.0: + resolution: {integrity: sha512-o5vL7aDWatOTX8LzaS1WMoaoxIiLRQJuIKKe2wAw6IeULDHaqbiqiggmx+pKvZDb1Sj+pE46Sn1T7lCqfFtg1Q==} + engines: {node: '>=16'} + markdown-link-extractor@4.0.3: resolution: {integrity: sha512-aEltJiQ4/oC0h6Jbw/uuATGSHZPkcH8DIunNH1A0e+GSFkvZ6BbBkdvBTVfIV8r6HapCU3yTd0eFdi3ZeM1eAQ==} @@ -26272,6 +26539,33 @@ packages: resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} engines: {node: '>= 0.4'} + mdast-util-from-markdown@2.1.0: + resolution: {integrity: sha512-KRLgmPaP2H1ul2bpoJkOS+9pAcDAAj9Nu1mqLnh8NLeJG5tlvj42TH80PIGBpROWlRXLk0lDrWNuZCFy/tsB4A==} + + mdast-util-mdx-expression@2.0.1: + resolution: {integrity: sha512-J6f+9hUp+ldTZqKRSg7Vw5V6MqjATc+3E4gf3CFNcuZNWD8XdyI6zQ8GqH7f8169MM6P7hMBRDVGnn7oHB9kXQ==} + + mdast-util-mdx-jsx@3.2.0: + resolution: {integrity: sha512-lj/z8v0r6ZtsN/cGNNtemmmfoLAFZnjMbNyLzBafjzikOM+glrjNHPlf6lQDOTccj9n5b0PPihEBbhneMyGs1Q==} + + mdast-util-mdx@3.0.0: + resolution: {integrity: sha512-JfbYLAW7XnYTTbUsmpu0kdBUVe+yKVJZBItEjwyYJiDJuZ9w4eeaqks4HQO+R7objWgS2ymV60GYpI14Ug554w==} + + mdast-util-mdxjs-esm@2.0.1: + resolution: {integrity: sha512-EcmOpxsZ96CvlP03NghtH1EsLtr0n9Tm4lPUJUBccV9RwUOneqSycg19n5HGzCf+10LozMRSObtVr3ee1WoHtg==} + + mdast-util-phrasing@4.1.0: + resolution: {integrity: sha512-TqICwyvJJpBwvGAMZjj4J2n0X8QWp21b9l0o7eXyVJ25YNWYbJDVIyD1bZXE6WtV6RmKJVYmQAKWa0zWOABz2w==} + + mdast-util-to-hast@13.2.1: + resolution: {integrity: sha512-cctsq2wp5vTsLIcaymblUriiTcZd0CwWtCbLvrOzYCDZoWyMNV8sZ7krj09FSnsiJi3WVsHLM4k6Dq/yaPyCXA==} + + mdast-util-to-markdown@2.2.0: + resolution: {integrity: sha512-2Jn/ADrHFFyyniBMi0bncTbJqU78K3/TEYvzvwrWWzD9MYPUa/Gm4r3nOeKFQg/PDM5BsbDYdc8ackW4NTY6NA==} + + mdast-util-to-string@4.0.0: + resolution: {integrity: sha512-0H44vDimn51F0YwvxSJSm0eCDOJTRlmN0R1yBh4HLj9wiV1Dn0QoXGbvFAWj2hSItVTlCmBF1hqKlIyUBVFLPg==} + mdn-data@2.0.28: resolution: {integrity: sha512-aylIc7Z9y4yzHYAJNuESG3hfhC+0Ibp/MAMiaOZgNv4pmEdFyfZhhhny4MNiAfWdBQ1RQ2mfDWmM1x8SvGyp8g==} @@ -26316,6 +26610,93 @@ packages: resolution: {integrity: sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==} engines: {node: '>= 0.6'} + micromark-core-commonmark@2.0.4: + resolution: {integrity: sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w==} + + micromark-extension-mdx-expression@3.0.1: + resolution: {integrity: sha512-dD/ADLJ1AeMvSAKBwO22zG22N4ybhe7kFIZ3LsDI0GlsNr2A3KYxb0LdC1u5rj4Nw+CHKY0RVdnHX8vj8ejm4Q==} + + micromark-extension-mdx-jsx@3.0.2: + resolution: {integrity: sha512-e5+q1DjMh62LZAJOnDraSSbDMvGJ8x3cbjygy2qFEi7HCeUT4BDKCvMozPozcD6WmOt6sVvYDNBKhFSz3kjOVQ==} + + micromark-extension-mdx-md@2.0.0: + resolution: {integrity: sha512-EpAiszsB3blw4Rpba7xTOUptcFeBFi+6PY8VnJ2hhimH+vCQDirWgsMpz7w1XcZE7LVrSAUGb9VJpG9ghlYvYQ==} + + micromark-extension-mdxjs-esm@3.0.0: + resolution: {integrity: sha512-DJFl4ZqkErRpq/dAPyeWp15tGrcrrJho1hKK5uBS70BCtfrIFg81sqcTVu3Ta+KD1Tk5vAtBNElWxtAa+m8K9A==} + + micromark-extension-mdxjs@3.0.0: + resolution: {integrity: sha512-A873fJfhnJ2siZyUrJ31l34Uqwy4xIFmvPY1oj+Ean5PHcPBYzEsvqvWGaWcfEIr11O5Dlw3p2y0tZWpKHDejQ==} + + micromark-factory-destination@2.0.1: + resolution: {integrity: sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==} + + micromark-factory-label@2.0.1: + resolution: {integrity: sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==} + + micromark-factory-mdx-expression@2.0.3: + resolution: {integrity: sha512-kQnEtA3vzucU2BkrIa8/VaSAsP+EJ3CKOvhMuJgOEGg9KDC6OAY6nSnNDVRiVNRqj7Y4SlSzcStaH/5jge8JdQ==} + + micromark-factory-space@2.1.0: + resolution: {integrity: sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q==} + + micromark-factory-title@2.0.1: + resolution: {integrity: sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==} + + micromark-factory-whitespace@2.0.1: + resolution: {integrity: sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==} + + micromark-util-character@2.1.1: + resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==} + + micromark-util-chunked@2.0.1: + resolution: {integrity: sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==} + + micromark-util-classify-character@2.0.1: + resolution: {integrity: sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==} + + micromark-util-combine-extensions@2.0.1: + resolution: {integrity: sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==} + + micromark-util-decode-numeric-character-reference@2.0.2: + resolution: {integrity: sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==} + + micromark-util-decode-string@2.0.1: + resolution: {integrity: sha512-nDV/77Fj6eH1ynwscYTOsbK7rR//Uj0bZXBwJZRfaLEJ1iGBR6kIfNmlNqaqJf649EP0F3NWNdeJi03elllNUQ==} + + micromark-util-edit-map@1.0.0: + resolution: {integrity: sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==} + + micromark-util-encode@2.0.1: + resolution: {integrity: sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==} + + micromark-util-events-to-acorn@2.0.3: + resolution: {integrity: sha512-jmsiEIiZ1n7X1Rr5k8wVExBQCg5jy4UXVADItHmNk1zkwEVhBuIUKRu3fqv+hs4nxLISi2DQGlqIOGiFxgbfHg==} + + micromark-util-html-tag-name@2.0.1: + resolution: {integrity: sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==} + + micromark-util-normalize-identifier@2.0.1: + resolution: {integrity: sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==} + + micromark-util-resolve-all@2.0.1: + resolution: {integrity: sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==} + + micromark-util-sanitize-uri@2.0.1: + resolution: {integrity: sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==} + + micromark-util-subtokenize@2.1.0: + resolution: {integrity: sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==} + + micromark-util-symbol@2.0.1: + resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==} + + micromark-util-types@2.0.3: + resolution: {integrity: sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==} + + micromark@4.0.3: + resolution: {integrity: sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==} + micromatch@4.0.8: resolution: {integrity: sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==} engines: {node: '>=8.6'} @@ -26362,10 +26743,6 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - miniflare@5.20261104.0-beta: - resolution: {integrity: sha512-pYZ2n85+FYUb7s0oIVcQxO63/+wgaknm+A/kQjctJqshvHPJs3UtnzaIZ7xrrHMOk8atD7yAfauf6G9VAv7Upg==} - engines: {node: '>=22.0.0'} - minimalistic-assert@1.0.1: resolution: {integrity: sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A==} @@ -26592,8 +26969,8 @@ packages: '@opentelemetry/api': ^1.1.0 '@playwright/test': ^1.63.0 babel-plugin-react-compiler: '*' - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 sass: ^1.3.0 peerDependenciesMeta: '@opentelemetry/api': @@ -26717,8 +27094,8 @@ packages: nwsapi@2.2.16: resolution: {integrity: sha512-F1I/bimDpj3ncaNDhfyMWuFqmQDBwDB0Fogc2qpL3BWvkQteFD/8BzWuIRl83rq0DXfm8SGt/HFhLXZyljTXcQ==} - nx@24.0.0: - resolution: {integrity: sha512-LchM3SyEUYL6qjHUneiSuyYlUscv8t6qpAYWUqnUY5OoSQSLIOLT/xrerLCKUTTcu7Yq1o/TDo9TiwhaBLvM4Q==} + nx@23.2.0: + resolution: {integrity: sha512-EWscwgKDr40bpsy2Dpijx0+wdkQjF8Z5Gvo91qLh3Ot2qkoYCznAzrqT2hXkkc1USC1TvX64t5IgsQq0Wtg1nA==} hasBin: true peerDependencies: '@swc-node/register': ^1.11.1 @@ -26902,6 +27279,9 @@ packages: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} + parse-entities@4.0.2: + resolution: {integrity: sha512-GG2AQYWoLgL877gQIKeRPGO1xF9+eG1ujIb5soS5gPvLQ1y2o8FL90w2QWNdf9I361Mpp7726c+lj3U0qK1uGw==} + parse-gitignore@2.0.0: resolution: {integrity: sha512-RmVuCHWsfu0QPNW+mraxh/xjQVw/lhUCUru8Zni3Ctq3AoMhpDTq0OVdKS6iesd6Kqb7viCV3isAL43dciOSog==} engines: {node: '>=14'} @@ -27252,6 +27632,9 @@ packages: proper-lockfile@4.1.2: resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==} + property-information@7.2.0: + resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==} + proto-list@1.2.4: resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==} @@ -27324,8 +27707,8 @@ packages: peerDependencies: '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -27353,17 +27736,26 @@ packages: rc9@2.1.2: resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} - react-dom@19.2.9: - resolution: {integrity: sha512-YceU74W21fXEHszKBLj16MY0CmvpFKOs60iVrIyW/cCgOPsZJNaB6GVJEtIUqt6AG6EjzKLui5lPRrxAeS328Q==} + react-dom@19.2.3: + resolution: {integrity: sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 + + react-error-boundary@6.1.6: + resolution: {integrity: sha512-CDXPnXDGyFIbkwaaJ6u+xgsRmJhSi6YdgUDW1vnyKHfXp1a9pfAlM+ZET2CDu80/A+8iRcmXN0NSY9BCCoWP5A==} + peerDependencies: + '@types/react': ^19.2.8 + react: ^19.2.3 + peerDependenciesMeta: + '@types/react': + optional: true react-hot-toast@2.5.1: resolution: {integrity: sha512-54Gq1ZD1JbmAb4psp9bvFHjS7lje+8ubboUmvKZkCsQBLH6AOpZ9JemfRvIdHcfb9AZXRaFLrb3qUobGYDJhFQ==} engines: {node: '>=10'} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} @@ -27387,7 +27779,7 @@ packages: engines: {node: '>=10'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -27397,25 +27789,25 @@ packages: engines: {node: '>=10'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true - react-server-dom-rspack@0.1.1: - resolution: {integrity: sha512-pgL4M/D3jFzn/2Dv8ppgFPrauyJjP29sFCV5EjSCLI29+NHIhumkhxnkiK8x0h5SQLPqUVVZfiAu3dn7Bl1RNg==} + react-server-dom-rspack@0.0.2: + resolution: {integrity: sha512-PowIm+Z65LkvC3yk4t3YrH2nMejwL361jiBT0BMW2bQCDUaNQknDHMPH0aTgMtJ9ZZ1Gc7KFgBvwB0itSzzELQ==} engines: {node: '>=0.10.0'} peerDependencies: - '@rspack/core': ^2.2.0-0 - react: ~19.2.9 - react-dom: ~19.2.9 + '@rspack/core': ^2.0.0-0 + react: ^19.2.3 + react-dom: ^19.2.3 react-style-singleton@2.2.3: resolution: {integrity: sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==} engines: {node: '>=10'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -27423,17 +27815,17 @@ packages: react-transition-group@4.4.5: resolution: {integrity: sha512-pZcd1MCJoiKiBR2NRxeCRg13uCXbydPnmB4EOeRrY7480qNWO8IIgQG6zlDkm6uRMsURXPuKq0GWtiM59a5Q6g==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 react-tweet@3.3.0: resolution: {integrity: sha512-gSIG2169ZK7UH6rBzuU+j1xnQbH3IlOTLEkuGrRiJJTMgETik+h+26yHyyVKrLkzwrOaYPk4K3OtEKycqKgNLw==} peerDependencies: - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 - react@19.2.9: - resolution: {integrity: sha512-RuLdAokXv3sRmZa2/N8QH0KmTBIgDKC+buRUikGqow31+mGSGidLCX2o4XFq8OV+xBFWfhM9DVgTq1PPHADH4w==} + react@19.2.3: + resolution: {integrity: sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==} engines: {node: '>=0.10.0'} read-package-up@11.0.0: @@ -27491,6 +27883,20 @@ packages: resolution: {integrity: sha512-/vxpCXddiX8NGfGO/mTafwjq4aFa/71pvamip0++IQk3zG8cbCj0fifNPrjjF1XMXUne91jL9OoxmdykoEtifQ==} engines: {node: '>= 10.13.0'} + recma-build-jsx@1.0.0: + resolution: {integrity: sha512-8GtdyqaBcDfva+GUKDr3nev3VpKAhup1+RvkMvUxURHpW7QyIvk9F5wz7Vzo06CEMSilw6uArgRqhpiUcWp8ew==} + + recma-jsx@1.0.1: + resolution: {integrity: sha512-huSIy7VU2Z5OLv6oFLosQGGDqPqdO1iq6bWNAdhzMxSJP7RAso4fCZ1cKu8j9YHCZf3TPrq4dw3okhrylgcd7w==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + recma-parse@1.0.0: + resolution: {integrity: sha512-OYLsIGBB5Y5wjnSnQW6t3Xg7q3fQ7FWbw/vcXtORTnyaSFscOtABg+7Pnz6YZ6c27fG1/aN8CjfwoUEUIdwqWQ==} + + recma-stringify@1.0.0: + resolution: {integrity: sha512-cjwII1MdIIVloKvC9ErQ+OgAtwHBmcZ0Bg4ciz78FtbT8In39aAYbaA7zvxQ61xVMSPE8WxhLwLbhif4Js2C+g==} + redaxios@0.5.1: resolution: {integrity: sha512-FSD2AmfdbkYwl7KDExYQlVvIrFz6Yd83pGfaGjBzM9F6rpq8g652Q4Yq5QD4c+nf4g2AgeElv1y+8ajUPiOYMg==} @@ -27509,6 +27915,9 @@ packages: reduce-configs@1.1.1: resolution: {integrity: sha512-EYtsVGAQarE8daT54cnaY1PIknF2VB78ug6Zre2rs36EsJfC40EG6hmTU2A2P1ZuXnKAt2KI0fzOGHcX7wzdPw==} + reduce-configs@1.1.2: + resolution: {integrity: sha512-AgBP55V8FC7NaqoOP2RCbTpu6LE+YuX3LUZkNAoitcfyS3/PIC8Obg/TJrBzTkJ+lDvZv0TTAeDpLkzjTtYlbw==} + reduce-configs@2.0.1: resolution: {integrity: sha512-H9KTCWTEb1YM1OoOz0f6TeGZYlW82sIT1viNg3W8CjjY0pD3WI4MHs8GifKt5FKTVIfHh/DenfJqqY+FP9jF2A==} @@ -27525,6 +27934,9 @@ packages: resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} engines: {node: '>= 0.4'} + rehype-recma@1.0.0: + resolution: {integrity: sha512-lqA4rGUf1JmacCNWWZx0Wv1dHqMwxzsDWYMTowuplHF3xH0N/MmrZ/G3BDZnzAkRmxDadujCjaKM2hqYdCBOGw==} + reinterval@1.1.0: resolution: {integrity: sha512-QIRet3SYrGp0HUHO88jVskiG6seqUGC5iAG7AwI/BV4ypGcuqk9Du6YQBUOUqm9c8pw1eyLoIaONifRua1lsEQ==} @@ -27532,6 +27944,15 @@ packages: resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} engines: {node: '>= 0.10'} + remark-mdx@3.1.1: + resolution: {integrity: sha512-Pjj2IYlUY3+D8x00UJsIOg5BEvfMyeI+2uLPn9VO9Wg4MEtN/VTIq2NEJQfde9PnX15KgtHyl9S0BcTnWrIuWg==} + + remark-parse@11.0.0: + resolution: {integrity: sha512-FCxlKLNGknS5ba/1lmpYijMUzX2esxW5xQqjWxw2eHFfS2MSdaHVINFmhjo+qN1WhZhNimq0dZATN9pH0IDrpA==} + + remark-rehype@11.1.2: + resolution: {integrity: sha512-Dh7l57ianaEoIpzbp0PC9UKAdCSVklD8E5Rpw7ETfbTl3FqcOOgq5q2LVDhgGCkaBv7p24JXikPdvhhmHvKMsw==} + remeda@2.21.3: resolution: {integrity: sha512-XXrZdLA10oEOQhLLzEJEiFFSKi21REGAkHdImIb4rt/XXy8ORGXh5HCcpUOsElfPNDb+X6TA/+wkh+p2KffYmg==} @@ -27661,11 +28082,6 @@ packages: rrweb-cssom@0.8.0: resolution: {integrity: sha512-guoltQEx+9aMf2gDZ0s62EcV8lsXR+0w8915TC3ITdn2YueuNjdAYh/levpU9nFaoChh9RUS5ZdQMrKfVEN9tw==} - rsbuild-plugin-cloudflare@0.0.4: - resolution: {integrity: sha512-YIKJGwcvMJNMo922/kNCdK/P7tk+D861SG41sMl1Y/M/BnlzX3b0UMoJZcPeEV1sfDrDBLYCPaqsBPEYC5Ya1g==} - peerDependencies: - '@rsbuild/core': ^2.2.10 - rspack-vue-loader@17.5.0: resolution: {integrity: sha512-hJrL2+jytfTs6ORHBOKTh5lU7BVZvmv7afELuQfyEpGC1ll7MKj1BxlgAIbhd6pZwoEwfdH79Lewtwe4VOlfCQ==} peerDependencies: @@ -27680,6 +28096,10 @@ packages: vue: optional: true + run-applescript@7.0.0: + resolution: {integrity: sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==} + engines: {node: '>=18'} + run-applescript@7.1.0: resolution: {integrity: sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==} engines: {node: '>=18'} @@ -27839,11 +28259,6 @@ packages: engines: {node: '>=20.19.0'} hasBin: true - sass@1.97.2: - resolution: {integrity: sha512-y5LWb0IlbO4e97Zr7c3mlpabcbBtS+ieiZ9iwDooShpFKWXf62zz5pEPdwrLYm+Bxn1fnbwFGzHuCLSA9tBmrw==} - engines: {node: '>=14.0.0'} - hasBin: true - sax@1.4.1: resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} @@ -27896,6 +28311,11 @@ packages: engines: {node: '>=10'} hasBin: true + semver@7.8.4: + resolution: {integrity: sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==} + engines: {node: '>=10'} + hasBin: true + semver@7.8.5: resolution: {integrity: sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==} engines: {node: '>=10'} @@ -27984,15 +28404,6 @@ packages: '@types/node': optional: true - sharp@0.35.5: - resolution: {integrity: sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==} - engines: {node: '>=20.9.0'} - peerDependencies: - '@types/node': '*' - peerDependenciesMeta: - '@types/node': - optional: true - shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -28061,10 +28472,6 @@ packages: resolution: {integrity: sha512-dWUG8F5sIIARXih1DTaQAX4SsiTXhInKf1buxdY9DIg4ZYPZK5nGM1VRIYmEbDbsHt7USo99xSLFu5Q1IqTmsg==} engines: {node: '>= 18'} - smol-toml@1.9.0: - resolution: {integrity: sha512-hpd+HLON7HdZXqYchMM/+LaTTbdK0AU3NngIJ4KVyWbY9bfQqdL9cD+4yf6dUoU2Ap4VsU0JkQi6FxAI1B2mXQ==} - engines: {node: '>= 18'} - sockjs@0.3.24: resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==} @@ -28081,11 +28488,6 @@ packages: peerDependencies: solid-js: 1.9.12 - solid-refresh@0.7.8: - resolution: {integrity: sha512-iG442T3HXJp5jEebCy8okETrWnmX7CnxNOKrJQVeufh6WXSn+xtLXaptUXXMHTWcRqTJOJwQ8UwzxrRtVFSIzA==} - peerDependencies: - solid-js: 1.9.12 - sonic-boom@4.2.0: resolution: {integrity: sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==} @@ -28112,6 +28514,9 @@ packages: resolution: {integrity: sha512-i5uvt8C3ikiWeNZSVZNWcfZPItFQOsYTUAOkcUPGd8DqDy1uOUikjt5dG+uRlwyvR108Fb9DOd4GvXfT0N2/uQ==} engines: {node: '>= 12'} + space-separated-tokens@2.0.2: + resolution: {integrity: sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==} + spawn-command@0.0.2: resolution: {integrity: sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==} @@ -28158,11 +28563,6 @@ packages: engines: {node: '>=20.16.0'} hasBin: true - srvx@1.0.8: - resolution: {integrity: sha512-ngFS/J6St4PJfHRHGjr78xkPPtbyXtdMOLNE4x/XZunEK3OhV7aGUWMHf9WTUEy6wm1U0W4okkd82ZFFWRVQTw==} - engines: {node: '>=20.16.0'} - hasBin: true - stable-hash-x@0.2.0: resolution: {integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==} engines: {node: '>=12.0.0'} @@ -28244,6 +28644,9 @@ packages: string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + stringify-entities@4.0.4: + resolution: {integrity: sha512-IwfBptatlO+QCJUo19AqvrPNqlVMpW9YEL2LIVY+Rpv2qsjCGxaDLNRgeGsQWJhfItebuJhsGSLjaBbNSQ+ieg==} + strip-ansi@6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} engines: {node: '>=8'} @@ -28283,6 +28686,12 @@ packages: peerDependencies: webpack: ^5.27.0 + style-to-js@1.1.21: + resolution: {integrity: sha512-RjQetxJrrUJLQPHbLku6U/ocGtzyjbJMP9lCNK7Ag0CNh690nSH8woqWH9u16nMjYBAok+i7JO1NP2pOy8IsPQ==} + + style-to-object@1.0.14: + resolution: {integrity: sha512-LIN7rULI0jBscWQYaSswptyderlarFkjQ+t79nzty8tcIAceVomEVlLzH5VP4Cmsv6MtKhs7qaAiwlcp+Mgaxw==} + style-to-object@1.0.8: resolution: {integrity: sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==} @@ -28292,7 +28701,7 @@ packages: peerDependencies: '@babel/core': '*' babel-plugin-macros: '*' - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@babel/core': optional: true @@ -28336,7 +28745,7 @@ packages: swr@2.3.4: resolution: {integrity: sha512-bYd2lrhc+VarcpkgWclcUi92wYCpOgMws9Sd1hG1ntAu0NEy+14CbotuFjshBU2kt9rYj9TSmDcybpxpeTU1fg==} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 symbol-tree@3.2.4: resolution: {integrity: sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==} @@ -28559,10 +28968,16 @@ packages: resolution: {integrity: sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==} hasBin: true + trim-lines@3.0.1: + resolution: {integrity: sha512-kRj8B+YHZCc9kQYdWfJB2/oUl9rA99qbowYYBtr4ui4mZyAQ2JpvVBd/6U2YloATfqBhBTSMhTpgBHtU0Mf3Rg==} + triple-beam@1.4.1: resolution: {integrity: sha512-aZbgViZrg1QNcG+LULa7nhZpJTZSLm/mXnHXnbAbjmN5aSa0y7V+wvv6+4WaBtpISJzThKy+PIPxc1Nq1EJ9mg==} engines: {node: '>= 14.0.0'} + trough@2.2.0: + resolution: {integrity: sha512-tmMpK00BjZiUyVyvrBK7knerNgmgvcV/KLVyuma/SC+TQN167GrMRciANTz09+k3zW8L8t60jWO1GpfkZdjTaw==} + ts-api-utils@2.1.0: resolution: {integrity: sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==} engines: {node: '>=18.12'} @@ -28740,14 +29155,6 @@ packages: resolution: {integrity: sha512-uZsKNuzQxDMUY6M3pIMvy5tvlGmtq8XJ2oLAkfRKGNu+1VQAIvLy2xIVG5ATZl5wDXl/tddByAWCizRbOme+TA==} engines: {node: '>=20.18.1'} - undici@7.29.0: - resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==} - engines: {node: '>=20.18.1'} - - undici@7.30.1: - resolution: {integrity: sha512-03KrMbjIFDWQR5RNPrSw3bd1r12JpyFQl9/yxjUbJtqkjmllqC5lFjZh6ujeuJCKr8EOQvRW872Oy/az+nLYxg==} - engines: {node: '>=20.18.1'} - unenv@2.0.0-rc.24: resolution: {integrity: sha512-i7qRCmY42zmCwnYlh9H2SvLEypEFGye5iRmEMKjcGi7zk9UquigRjFtTLz0TYqr0ZGLZhaMHl/foy1bZR+Cwlw==} @@ -28763,6 +29170,27 @@ packages: resolution: {integrity: sha512-wH590V9VNgYH9g3lH9wWjTrUoKsjLF6sGLjhR4sH1LWpLmCOH0Zf7PukhDA8BiS7KHe4oPNkcTHqYkj7SOGUOw==} engines: {node: '>=20'} + unified@11.0.5: + resolution: {integrity: sha512-xKvGhPWw3k84Qjh8bI3ZeJjqnyadK+GEFtazSfZv/rKeTkTjOJho6mFqh2SM96iIcZokxiOpg78GazTSg8+KHA==} + + unist-util-is@6.0.1: + resolution: {integrity: sha512-LsiILbtBETkDz8I9p1dQ0uyRUWuaQzd/cuEeS1hoRSyW5E5XGmTzlwY1OrNzzakGowI9Dr/I8HVaw4hTtnxy8g==} + + unist-util-position-from-estree@2.0.0: + resolution: {integrity: sha512-KaFVRjoqLyF6YXCbVLNad/eS4+OfPQQn2yOd7zF/h5T/CSL2v8NpN6a5TPvtbXthAGw5nG+PuTtq+DdIZr+cRQ==} + + unist-util-position@5.0.0: + resolution: {integrity: sha512-fucsC7HjXvkB5R3kTCO7kUjRdrS0BJt3M/FPxmHMBOm8JQi2BsHAHFsy27E0EolP8rp0NzXsJ+jNPyDWvOJZPA==} + + unist-util-stringify-position@4.0.0: + resolution: {integrity: sha512-0ASV06AAoKCDkS2+xw5RXJywruurpbC4JZSm7nr7MOt1ojAzvyyaO+UxZf18j8FCF6kmzCZKcAgN/yu2gm2XgQ==} + + unist-util-visit-parents@6.0.2: + resolution: {integrity: sha512-goh1s1TBrqSqukSc8wrjwWhL0hiJxgA8m4kFxGlQ+8FYQ3C/m11FcTs4YYem7V664AhHVvgoQLk890Ssdsr2IQ==} + + unist-util-visit@5.1.0: + resolution: {integrity: sha512-m+vIdyeCOpdr/QeQCu2EzxX/ohgS8KbnPDgFni4dQsfSCtpz8UqDyY5GjRru8PDKuYn7Fq19j1CQ+nJSsGKOzg==} + universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} @@ -28786,12 +29214,11 @@ packages: resolution: {integrity: sha512-5uKD0nqiYVzlmCRs01Fhs2BdkEgBS3SAVP6ndrBsuK42iC2+JHyxM05Rm9G8+5mkmRtzMZGY8Ct5+mliZxU/Ww==} engines: {node: '>=18.12.0'} - unplugin@3.7.0: - resolution: {integrity: sha512-GrM2uq3DQo3hvLU2FjeYhooJ8BY9N6j1Fbzgx7Pta3VVJevsD3VP4dPjZkZOS0mLvN8w9zzr9OlP+31bSMyuLw==} + unplugin@3.3.0: + resolution: {integrity: sha512-qa66K+crbfyE6JK10GjvbJeRrOsuC/JpbnHctfyp/i4oBTxWOzJfRZyDiOk1PtErMFRu8JhsU/wPvOdBNWe5Rg==} engines: {node: ^20.19.0 || >=22.12.0} peerDependencies: '@farmfe/core': '*' - '@rsbuild/core': '*' '@rspack/core': '*' bun-types-no-globals: '*' esbuild: '*' @@ -28803,8 +29230,6 @@ packages: peerDependenciesMeta: '@farmfe/core': optional: true - '@rsbuild/core': - optional: true '@rspack/core': optional: true bun-types-no-globals: @@ -28929,7 +29354,7 @@ packages: engines: {node: '>=10'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -28939,7 +29364,7 @@ packages: engines: {node: '>=10'} peerDependencies: '@types/react': ^19.2.8 - react: ~19.2.9 + react: ^19.2.3 peerDependenciesMeta: '@types/react': optional: true @@ -28947,7 +29372,7 @@ packages: use-sync-external-store@1.6.0: resolution: {integrity: sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==} peerDependencies: - react: ~19.2.9 + react: ^19.2.3 util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -29002,6 +29427,12 @@ packages: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} + vfile-message@4.0.3: + resolution: {integrity: sha512-QTHzsGd1EhbZs4AsQ20JX1rC3cOlt/IWJruk893DfLRr57lcnOeMaWG4K0JrRta4mIJZKth2Au3mM3u03/JWKw==} + + vfile@6.0.3: + resolution: {integrity: sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==} + vite-plugin-dts@4.2.3: resolution: {integrity: sha512-O5NalzHANQRwVw1xj8KQun3Bv8OSDAlNJXrnqoAz10BOuW8FVvY5g4ygj+DlJZL5mtSPuMu9vd3OfrdW5d4k6w==} engines: {node: ^14.18.0 || >=16.0.0} @@ -29443,11 +29874,6 @@ packages: engines: {node: '>=16'} hasBin: true - workerd@1.20261104.1: - resolution: {integrity: sha512-JuiKY9k/4V4UE2xsupaTvZ1SF6o2a8sg+/zfq/DaSDwvH+o7t2ZEFuIWNEnryfeFdP47/tz/p828Kvl4ptPlrA==} - engines: {node: '>=16'} - hasBin: true - wrangler@4.75.0: resolution: {integrity: sha512-Efk1tcnm4eduBYpH1sSjMYydXMnIFPns/qABI3+fsbDrUk5GksNYX8nYGVP4sFygvGPO7kJc36YJKB5ooA7JAg==} engines: {node: '>=20.0.0'} @@ -29497,18 +29923,6 @@ packages: utf-8-validate: optional: true - ws@8.21.0: - resolution: {integrity: sha512-Vsp28b7DRcimFQvrqu2Wek3z1iYxDCWqHYB8Qsnk/S4RfaCQzPGPyBNuVjJV3cd6UiKtUtp6sNM77gWvzcCH+g==} - engines: {node: '>=10.0.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: '>=5.0.2' - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - xml-name-validator@4.0.0: resolution: {integrity: sha512-ICP2e+jsHvAj2E2lIHxa5tjXRlKDJo4IdvPvCXbXQGdzSfmSpNVyIKMvoZHjDY9DP0zV17iI85o90vRFXNccRw==} engines: {node: '>=12'} @@ -29590,6 +30004,10 @@ packages: youch@4.1.0-beta.10: resolution: {integrity: sha512-rLfVLB4FgQneDr0dv1oddCVZmKjcJ6yX6mS4pU82Mq/Dt9a3cLZQ62pDBL4AUO+uVrCvtWz3ZFUL2HFAFJ/BXQ==} + yuku@0.22.1: + resolution: {integrity: sha512-aY9bJiNKR46RyulhwZxh1L6DlXuRWEub9uXjvrjhP/AKQFC5DwGdri4mJaQH9Jmv+ijnsduWoBTXtEfKy2aehw==} + engines: {node: '>=16.4.0'} + zeptomatch@2.0.2: resolution: {integrity: sha512-H33jtSKf8Ijtb5BW6wua3G5DhnFjbFML36eFu+VdOoVY4HD9e7ggjqdM6639B+L87rjnR6Y+XeRzBXZdy52B/g==} @@ -29609,16 +30027,13 @@ packages: zod@4.5.4: resolution: {integrity: sha512-sC95tT5iHHH9gtpj6A81kh+NEaRAUFN+qlUPDUbRfOMvNf5QCBqsb3WgvnpVtK5Y+4UfA6KqufotuTvMGiTlsA==} - zod@4.6.6: - resolution: {integrity: sha512-4UmzQUF5fxvfcYHlbjBmejU+w+hbDnWFx4aS8kBx7nPBHcO2SqPbpAG8snbdg+Xse4pRefR98hgjFgIMCI/UhA==} - zustand@5.0.12: resolution: {integrity: sha512-i77ae3aZq4dhMlRhJVCYgMLKuSiZAaUPAct2AksxQ+gOtimhGMdXljRT21P5BNpeT4kXlLIckvkPM029OljD7g==} engines: {node: '>=12.20.0'} peerDependencies: '@types/react': ^19.2.8 immer: '>=9.0.6' - react: ~19.2.9 + react: ^19.2.3 use-sync-external-store: '>=1.2.0' peerDependenciesMeta: '@types/react': @@ -29630,6 +30045,9 @@ packages: use-sync-external-store: optional: true + zwitch@2.0.4: + resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} + snapshots: '@adobe/css-tools@4.4.1': {} @@ -29655,7 +30073,7 @@ snapshots: cjs-module-lexer: 1.4.3 fflate: 0.8.3 lru-cache: 11.5.1 - semver: 7.8.5 + semver: 7.8.2 typescript: 5.6.1-rc validate-npm-package-name: 5.0.1 @@ -29791,6 +30209,26 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/core@7.29.7(supports-color@7.2.0)': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.8 + '@babel/helper-compilation-targets': 7.29.7 + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helpers': 7.29.7 + '@babel/parser': 7.29.8 + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + '@jridgewell/remapping': 2.3.5 + convert-source-map: 2.0.0 + debug: 4.4.3(supports-color@7.2.0) + gensync: 1.0.0-beta.2 + json5: 2.2.3 + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + '@babel/generator@7.29.8': dependencies: '@babel/parser': 7.29.8 @@ -29803,6 +30241,10 @@ snapshots: dependencies: '@babel/types': 7.29.8 + '@babel/helper-annotate-as-pure@7.29.7': + dependencies: + '@babel/types': 7.29.8 + '@babel/helper-compilation-targets@7.27.2': dependencies: '@babel/compat-data': 7.27.5 @@ -29840,15 +30282,15 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/helper-create-class-features-plugin@7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + '@babel/helper-create-class-features-plugin@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/helper-annotate-as-pure': 7.27.3 - '@babel/helper-member-expression-to-functions': 7.27.1(supports-color@10.2.2) + '@babel/helper-member-expression-to-functions': 7.27.1(supports-color@7.2.0) '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/helper-replace-supers': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@10.2.2) - '@babel/traverse': 7.29.8(supports-color@10.2.2) + '@babel/helper-replace-supers': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/traverse': 7.29.8(supports-color@7.2.0) semver: 6.3.1 transitivePeerDependencies: - supports-color @@ -29866,6 +30308,32 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-create-class-features-plugin@7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0) + '@babel/helper-optimise-call-expression': 7.27.1 + '@babel/helper-replace-supers': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/traverse': 7.29.8(supports-color@7.2.0) + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + + '@babel/helper-create-class-features-plugin@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-annotate-as-pure': 7.29.7 + '@babel/helper-member-expression-to-functions': 7.29.7(supports-color@10.2.2) + '@babel/helper-optimise-call-expression': 7.29.7 + '@babel/helper-replace-supers': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/helper-skip-transparent-expression-wrappers': 7.29.7(supports-color@10.2.2) + '@babel/traverse': 7.29.8(supports-color@10.2.2) + semver: 6.3.1 + transitivePeerDependencies: + - supports-color + '@babel/helper-globals@7.28.0': {} '@babel/helper-globals@7.29.7': {} @@ -29877,6 +30345,13 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-member-expression-to-functions@7.27.1(supports-color@7.2.0)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + '@babel/helper-member-expression-to-functions@7.28.5(supports-color@10.2.2)': dependencies: '@babel/traverse': 7.29.8(supports-color@10.2.2) @@ -29884,6 +30359,20 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-member-expression-to-functions@7.28.5(supports-color@7.2.0)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + + '@babel/helper-member-expression-to-functions@7.29.7(supports-color@10.2.2)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@10.2.2) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + '@babel/helper-module-imports@7.18.6': dependencies: '@babel/types': 7.29.8 @@ -29895,6 +30384,13 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-module-imports@7.27.1(supports-color@7.2.0)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + '@babel/helper-module-imports@7.28.6(supports-color@10.2.2)': dependencies: '@babel/traverse': 7.29.8(supports-color@10.2.2) @@ -29909,6 +30405,13 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-module-imports@7.29.7(supports-color@7.2.0)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + '@babel/helper-module-transforms@7.28.3(@babel/core@7.28.5(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) @@ -29945,14 +30448,29 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-module-transforms@7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) + '@babel/helper-validator-identifier': 7.29.7 + '@babel/traverse': 7.29.8(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + '@babel/helper-optimise-call-expression@7.27.1': dependencies: '@babel/types': 7.29.8 + '@babel/helper-optimise-call-expression@7.29.7': + dependencies: + '@babel/types': 7.29.8 + '@babel/helper-plugin-utils@7.27.1': {} '@babel/helper-plugin-utils@7.28.6': {} + '@babel/helper-plugin-utils@7.29.7': {} + '@babel/helper-replace-supers@7.27.1(@babel/core@7.28.5(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) @@ -29962,12 +30480,12 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/helper-replace-supers@7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + '@babel/helper-replace-supers@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0) '@babel/helper-optimise-call-expression': 7.27.1 - '@babel/traverse': 7.29.8(supports-color@10.2.2) + '@babel/traverse': 7.29.8(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -29980,6 +30498,24 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-replace-supers@7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-member-expression-to-functions': 7.28.5(supports-color@7.2.0) + '@babel/helper-optimise-call-expression': 7.27.1 + '@babel/traverse': 7.29.8(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + + '@babel/helper-replace-supers@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-member-expression-to-functions': 7.29.7(supports-color@10.2.2) + '@babel/helper-optimise-call-expression': 7.29.7 + '@babel/traverse': 7.29.8(supports-color@10.2.2) + transitivePeerDependencies: + - supports-color + '@babel/helper-skip-transparent-expression-wrappers@7.27.1(supports-color@10.2.2)': dependencies: '@babel/traverse': 7.29.8(supports-color@10.2.2) @@ -29987,6 +30523,20 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/helper-skip-transparent-expression-wrappers@7.27.1(supports-color@7.2.0)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + + '@babel/helper-skip-transparent-expression-wrappers@7.29.7(supports-color@10.2.2)': + dependencies: + '@babel/traverse': 7.29.8(supports-color@10.2.2) + '@babel/types': 7.29.8 + transitivePeerDependencies: + - supports-color + '@babel/helper-string-parser@7.29.7': {} '@babel/helper-validator-identifier@7.29.7': {} @@ -30042,21 +30592,41 @@ snapshots: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-syntax-jsx@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.27.1 + + '@babel/plugin-syntax-jsx@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.28.5(supports-color@10.2.2))': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) - '@babel/helper-plugin-utils': 7.27.1 + '@babel/helper-plugin-utils': 7.28.6 - '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.29.7(supports-color@10.2.2))': + '@babel/plugin-syntax-typescript@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/helper-plugin-utils': 7.27.1 + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.28.6 '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.7(supports-color@10.2.2))': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/helper-plugin-utils': 7.28.6 + '@babel/plugin-syntax-typescript@7.28.6(@babel/core@7.29.7(supports-color@7.2.0))': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.28.6 + + '@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/plugin-transform-class-properties@7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) @@ -30065,6 +30635,14 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/plugin-transform-class-properties@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + transitivePeerDependencies: + - supports-color + '@babel/plugin-transform-modules-commonjs@7.27.1(@babel/core@7.28.5(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) @@ -30081,6 +30659,22 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/plugin-transform-modules-commonjs@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.27.1 + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-modules-commonjs@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-module-transforms': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + transitivePeerDependencies: + - supports-color + '@babel/plugin-transform-typescript@7.27.1(@babel/core@7.28.5(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) @@ -30092,14 +30686,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/plugin-transform-typescript@7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + '@babel/plugin-transform-typescript@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/helper-annotate-as-pure': 7.27.3 - '@babel/helper-create-class-features-plugin': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/helper-create-class-features-plugin': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.27.1 - '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@10.2.2) - '@babel/plugin-syntax-typescript': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2)) + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0)) transitivePeerDependencies: - supports-color @@ -30114,6 +30708,28 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/plugin-transform-typescript@7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-annotate-as-pure': 7.27.3 + '@babel/helper-create-class-features-plugin': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.28.6 + '@babel/helper-skip-transparent-expression-wrappers': 7.27.1(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0)) + transitivePeerDependencies: + - supports-color + + '@babel/plugin-transform-typescript@7.29.9(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-annotate-as-pure': 7.29.7 + '@babel/helper-create-class-features-plugin': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/helper-skip-transparent-expression-wrappers': 7.29.7(supports-color@10.2.2) + '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2)) + transitivePeerDependencies: + - supports-color + '@babel/preset-typescript@7.27.1(@babel/core@7.28.5(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) @@ -30125,28 +30741,39 @@ snapshots: transitivePeerDependencies: - supports-color - '@babel/preset-typescript@7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + '@babel/preset-typescript@7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.27.1 '@babel/helper-validator-option': 7.27.1 - '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2)) - '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - '@babel/plugin-transform-typescript': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@babel/plugin-transform-typescript': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color '@babel/preset-typescript@7.28.5(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/helper-plugin-utils': 7.27.1 - '@babel/helper-validator-option': 7.27.1 + '@babel/helper-plugin-utils': 7.28.6 + '@babel/helper-validator-option': 7.29.7 '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2)) '@babel/plugin-transform-modules-commonjs': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) transitivePeerDependencies: - supports-color + '@babel/preset-typescript@7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.29.7 + '@babel/helper-validator-option': 7.29.7 + '@babel/plugin-syntax-jsx': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2)) + '@babel/plugin-transform-modules-commonjs': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/plugin-transform-typescript': 7.29.9(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + transitivePeerDependencies: + - supports-color + '@babel/runtime@7.26.7': dependencies: regenerator-runtime: 0.14.1 @@ -30193,6 +30820,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@babel/traverse@7.29.8(supports-color@7.2.0)': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/generator': 7.29.8 + '@babel/helper-globals': 7.29.7 + '@babel/parser': 7.29.8 + '@babel/template': 7.29.7 + '@babel/types': 7.29.8 + debug: 4.4.3(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + '@babel/types@7.29.8': dependencies: '@babel/helper-string-parser': 7.29.7 @@ -30234,13 +30873,13 @@ snapshots: '@better-auth/core': 1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0) '@better-auth/utils': 0.4.2 - '@better-auth/prisma-adapter@1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))': + '@better-auth/prisma-adapter@1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))': dependencies: '@better-auth/core': 1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0) '@better-auth/utils': 0.4.2 optionalDependencies: - '@prisma/client': 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) - prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@prisma/client': 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) + prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@better-auth/telemetry@1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)': dependencies: @@ -30289,7 +30928,7 @@ snapshots: outdent: 0.5.0 prettier: 2.8.8 resolve-from: 5.0.0 - semver: 7.8.5 + semver: 7.8.2 '@changesets/assemble-release-plan@6.0.9': dependencies: @@ -30298,7 +30937,7 @@ snapshots: '@changesets/should-skip-package': 0.1.2 '@changesets/types': 6.1.0 '@manypkg/get-packages': 1.1.3 - semver: 7.8.5 + semver: 7.8.2 '@changesets/changelog-git@0.2.1': dependencies: @@ -30363,7 +31002,7 @@ snapshots: '@changesets/types': 6.1.0 '@manypkg/get-packages': 1.1.3 picocolors: 1.1.1 - semver: 7.8.5 + semver: 7.8.2 '@changesets/get-github-info@0.8.0': dependencies: @@ -30460,9 +31099,9 @@ snapshots: fast-wrap-ansi: 0.2.0 sisteransi: 1.0.5 - '@clerk/backend@2.18.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/backend@2.18.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/shared': 3.28.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/shared': 3.28.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@clerk/types': 4.95.0 cookie: 1.0.2 standardwebhooks: 1.0.0 @@ -30471,82 +31110,82 @@ snapshots: - react - react-dom - '@clerk/backend@2.29.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/backend@2.29.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/shared': 3.42.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/types': 4.101.10(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/shared': 3.42.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/types': 4.101.10(react-dom@19.2.3(react@19.2.3))(react@19.2.3) standardwebhooks: 1.0.0 tslib: 2.8.1 transitivePeerDependencies: - react - react-dom - '@clerk/clerk-react@5.53.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/clerk-react@5.53.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/shared': 3.28.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/shared': 3.28.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@clerk/types': 4.95.0 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) tslib: 2.8.1 - '@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/shared': 3.42.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@clerk/shared': 3.42.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) tslib: 2.8.1 - '@clerk/shared@3.28.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/shared@3.28.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@clerk/types': 4.95.0 dequal: 2.0.3 glob-to-regexp: 0.4.1 js-cookie: 3.0.5 std-env: 3.10.0 - swr: 2.3.4(react@19.2.9) + swr: 2.3.4(react@19.2.3) optionalDependencies: - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) - '@clerk/shared@3.42.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/shared@3.42.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: csstype: 3.1.3 dequal: 2.0.3 glob-to-regexp: 0.4.1 js-cookie: 3.0.5 std-env: 3.10.0 - swr: 2.3.4(react@19.2.9) + swr: 2.3.4(react@19.2.3) optionalDependencies: - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) - '@clerk/tanstack-react-start@0.19.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/tanstack-react-start@0.19.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/backend': 2.18.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/clerk-react': 5.53.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/shared': 3.28.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/backend': 2.18.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/clerk-react': 5.53.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/shared': 3.28.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@clerk/types': 4.95.0 '@tanstack/react-router': link:packages/react-router '@tanstack/react-start': link:packages/react-start - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) tslib: 2.8.1 - '@clerk/tanstack-react-start@0.27.14(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/tanstack-react-start@0.27.14(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/backend': 2.29.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/clerk-react': 5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/shared': 3.42.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@clerk/types': 4.101.10(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/backend': 2.29.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/clerk-react': 5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/shared': 3.42.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@clerk/types': 4.101.10(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@tanstack/react-router': link:packages/react-router '@tanstack/react-start': link:packages/react-start - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) tslib: 2.8.1 - '@clerk/types@4.101.10(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@clerk/types@4.101.10(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@clerk/shared': 3.42.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@clerk/shared': 3.42.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3) transitivePeerDependencies: - react - react-dom @@ -30555,62 +31194,20 @@ snapshots: dependencies: csstype: 3.1.3 - '@cloudflare/build-output-utils@0.9.10': - dependencies: - '@cloudflare/config': 0.30.2 - - '@cloudflare/config@0.30.2': - dependencies: - zod: 4.6.6 - '@cloudflare/kv-asset-handler@0.4.2': {} - '@cloudflare/runtime-types@0.1.23(@types/node@25.0.9)': - dependencies: - miniflare: 5.20261104.0-beta(@types/node@25.0.9) - workerd: 1.20261104.1 - transitivePeerDependencies: - - '@types/node' - - bufferutil - - utf-8-validate - '@cloudflare/unenv-preset@2.15.0(unenv@2.0.0-rc.24)(workerd@1.20260317.1)': dependencies: unenv: 2.0.0-rc.24 optionalDependencies: workerd: 1.20260317.1 - '@cloudflare/unenv-preset@2.15.0(unenv@2.0.0-rc.24)(workerd@1.20261104.1)': - dependencies: - unenv: 2.0.0-rc.24 - optionalDependencies: - workerd: 1.20261104.1 - - '@cloudflare/unenv-preset@2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261104.1)': - dependencies: - unenv: 2.0.0-rc.24 - optionalDependencies: - workerd: 1.20261104.1 - - '@cloudflare/vite-plugin@1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0)': + '@cloudflare/vite-plugin@1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20260317.1)(wrangler@4.75.0)': dependencies: '@cloudflare/unenv-preset': 2.15.0(unenv@2.0.0-rc.24)(workerd@1.20260317.1) miniflare: 4.20260317.0 unenv: 2.0.0-rc.24 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - wrangler: 4.75.0 - ws: 8.18.0 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - - workerd - - '@cloudflare/vite-plugin@1.29.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(workerd@1.20261104.1)(wrangler@4.75.0)': - dependencies: - '@cloudflare/unenv-preset': 2.15.0(unenv@2.0.0-rc.24)(workerd@1.20261104.1) - miniflare: 4.20260317.0 - unenv: 2.0.0-rc.24 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) wrangler: 4.75.0 ws: 8.18.0 transitivePeerDependencies: @@ -30621,36 +31218,21 @@ snapshots: '@cloudflare/workerd-darwin-64@1.20260317.1': optional: true - '@cloudflare/workerd-darwin-64@1.20261104.1': - optional: true - '@cloudflare/workerd-darwin-arm64@1.20260317.1': optional: true - '@cloudflare/workerd-darwin-arm64@1.20261104.1': - optional: true - '@cloudflare/workerd-linux-64@1.20260317.1': optional: true - '@cloudflare/workerd-linux-64@1.20261104.1': - optional: true - '@cloudflare/workerd-linux-arm64@1.20260317.1': optional: true - '@cloudflare/workerd-linux-arm64@1.20261104.1': - optional: true - '@cloudflare/workerd-windows-64@1.20260317.1': optional: true - '@cloudflare/workerd-windows-64@1.20261104.1': - optional: true - - '@codspeed/core@6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)': + '@codspeed/core@6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)': dependencies: - axios: 1.18.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2) + axios: 1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2) form-data: 4.0.6 node-gyp-build: 4.8.4 stack-trace: 1.0.0-pre2 @@ -30658,12 +31240,12 @@ snapshots: - debug - supports-color - '@codspeed/vitest-plugin@6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4)': + '@codspeed/vitest-plugin@6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(tinybench@6.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vitest@5.0.4)': dependencies: - '@codspeed/core': 6.0.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2) + '@codspeed/core': 6.0.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2) tinybench: 6.2.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) transitivePeerDependencies: - debug - supports-color @@ -30673,15 +31255,15 @@ snapshots: '@colors/colors@1.6.0': {} - '@convex-dev/better-auth@0.9.7(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)))(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9))(hono@4.13.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@convex-dev/better-auth@0.9.7(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)))(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3))(hono@4.13.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - better-auth: 1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)) + better-auth: 1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)) common-tags: 1.8.2 - convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9) - convex-helpers: 0.1.104(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9))(hono@4.13.9)(react@19.2.9)(zod@3.25.76) + convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3) + convex-helpers: 0.1.104(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3))(hono@4.13.9)(react@19.2.3)(zod@3.25.76) jose: 6.1.0 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) remeda: 2.32.0 semver: 7.7.3 type-fest: 4.41.0 @@ -30691,10 +31273,10 @@ snapshots: - hono - typescript - '@convex-dev/react-query@0.0.0-alpha.8(@tanstack/react-query@5.102.0(react@19.2.9))(convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9))': + '@convex-dev/react-query@0.0.0-alpha.8(@tanstack/react-query@5.102.0(react@19.2.3))(convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3))': dependencies: - '@tanstack/react-query': 5.102.0(react@19.2.9) - convex: 1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@tanstack/react-query': 5.102.0(react@19.2.3) + convex: 1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3) '@cspotcode/source-map-support@0.8.1': dependencies: @@ -30783,6 +31365,18 @@ snapshots: '@electric-sql/pglite@0.3.2': {} + '@emnapi/core@1.10.0': + dependencies: + '@emnapi/wasi-threads': 1.2.1 + tslib: 2.8.1 + optional: true + + '@emnapi/core@1.11.1': + dependencies: + '@emnapi/wasi-threads': 1.2.2 + tslib: 2.8.1 + optional: true + '@emnapi/core@1.11.3': dependencies: '@emnapi/wasi-threads': 1.2.3 @@ -30793,6 +31387,16 @@ snapshots: '@emnapi/wasi-threads': 1.0.4 tslib: 2.8.1 + '@emnapi/runtime@1.10.0': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.11.1': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/runtime@1.11.3': dependencies: tslib: 2.8.1 @@ -30805,6 +31409,16 @@ snapshots: dependencies: tslib: 2.8.1 + '@emnapi/wasi-threads@1.2.1': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.2.2': + dependencies: + tslib: 2.8.1 + optional: true + '@emnapi/wasi-threads@1.2.3': dependencies: tslib: 2.8.1 @@ -30841,17 +31455,17 @@ snapshots: '@emotion/memoize@0.9.0': {} - '@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2)': + '@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2)': dependencies: '@babel/runtime': 7.26.7 '@emotion/babel-plugin': 11.13.5(supports-color@10.2.2) '@emotion/cache': 11.14.0 '@emotion/serialize': 1.3.3 - '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.9) + '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.3) '@emotion/utils': 1.4.2 '@emotion/weak-memoize': 0.4.0 hoist-non-react-statics: 3.3.2 - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 transitivePeerDependencies: @@ -30867,16 +31481,16 @@ snapshots: '@emotion/sheet@1.4.0': {} - '@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2)': + '@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2)': dependencies: '@babel/runtime': 7.26.7 '@emotion/babel-plugin': 11.13.5(supports-color@10.2.2) '@emotion/is-prop-valid': 1.3.1 - '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) '@emotion/serialize': 1.3.3 - '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.9) + '@emotion/use-insertion-effect-with-fallbacks': 1.2.0(react@19.2.3) '@emotion/utils': 1.4.2 - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 transitivePeerDependencies: @@ -30884,9 +31498,9 @@ snapshots: '@emotion/unitless@0.10.0': {} - '@emotion/use-insertion-effect-with-fallbacks@1.2.0(react@19.2.9)': + '@emotion/use-insertion-effect-with-fallbacks@1.2.0(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 '@emotion/utils@1.4.2': {} @@ -30917,6 +31531,9 @@ snapshots: '@esbuild/aix-ppc64@0.28.1': optional: true + '@esbuild/aix-ppc64@0.28.2': + optional: true + '@esbuild/android-arm64@0.23.0': optional: true @@ -30935,6 +31552,9 @@ snapshots: '@esbuild/android-arm64@0.28.1': optional: true + '@esbuild/android-arm64@0.28.2': + optional: true + '@esbuild/android-arm@0.23.0': optional: true @@ -30953,6 +31573,9 @@ snapshots: '@esbuild/android-arm@0.28.1': optional: true + '@esbuild/android-arm@0.28.2': + optional: true + '@esbuild/android-x64@0.23.0': optional: true @@ -30971,6 +31594,9 @@ snapshots: '@esbuild/android-x64@0.28.1': optional: true + '@esbuild/android-x64@0.28.2': + optional: true + '@esbuild/darwin-arm64@0.23.0': optional: true @@ -30989,6 +31615,9 @@ snapshots: '@esbuild/darwin-arm64@0.28.1': optional: true + '@esbuild/darwin-arm64@0.28.2': + optional: true + '@esbuild/darwin-x64@0.23.0': optional: true @@ -31007,6 +31636,9 @@ snapshots: '@esbuild/darwin-x64@0.28.1': optional: true + '@esbuild/darwin-x64@0.28.2': + optional: true + '@esbuild/freebsd-arm64@0.23.0': optional: true @@ -31025,6 +31657,9 @@ snapshots: '@esbuild/freebsd-arm64@0.28.1': optional: true + '@esbuild/freebsd-arm64@0.28.2': + optional: true + '@esbuild/freebsd-x64@0.23.0': optional: true @@ -31043,6 +31678,9 @@ snapshots: '@esbuild/freebsd-x64@0.28.1': optional: true + '@esbuild/freebsd-x64@0.28.2': + optional: true + '@esbuild/linux-arm64@0.23.0': optional: true @@ -31061,6 +31699,9 @@ snapshots: '@esbuild/linux-arm64@0.28.1': optional: true + '@esbuild/linux-arm64@0.28.2': + optional: true + '@esbuild/linux-arm@0.23.0': optional: true @@ -31079,6 +31720,9 @@ snapshots: '@esbuild/linux-arm@0.28.1': optional: true + '@esbuild/linux-arm@0.28.2': + optional: true + '@esbuild/linux-ia32@0.23.0': optional: true @@ -31097,6 +31741,9 @@ snapshots: '@esbuild/linux-ia32@0.28.1': optional: true + '@esbuild/linux-ia32@0.28.2': + optional: true + '@esbuild/linux-loong64@0.23.0': optional: true @@ -31115,6 +31762,9 @@ snapshots: '@esbuild/linux-loong64@0.28.1': optional: true + '@esbuild/linux-loong64@0.28.2': + optional: true + '@esbuild/linux-mips64el@0.23.0': optional: true @@ -31133,6 +31783,9 @@ snapshots: '@esbuild/linux-mips64el@0.28.1': optional: true + '@esbuild/linux-mips64el@0.28.2': + optional: true + '@esbuild/linux-ppc64@0.23.0': optional: true @@ -31151,6 +31804,9 @@ snapshots: '@esbuild/linux-ppc64@0.28.1': optional: true + '@esbuild/linux-ppc64@0.28.2': + optional: true + '@esbuild/linux-riscv64@0.23.0': optional: true @@ -31169,6 +31825,9 @@ snapshots: '@esbuild/linux-riscv64@0.28.1': optional: true + '@esbuild/linux-riscv64@0.28.2': + optional: true + '@esbuild/linux-s390x@0.23.0': optional: true @@ -31187,6 +31846,9 @@ snapshots: '@esbuild/linux-s390x@0.28.1': optional: true + '@esbuild/linux-s390x@0.28.2': + optional: true + '@esbuild/linux-x64@0.23.0': optional: true @@ -31205,6 +31867,9 @@ snapshots: '@esbuild/linux-x64@0.28.1': optional: true + '@esbuild/linux-x64@0.28.2': + optional: true + '@esbuild/netbsd-arm64@0.25.10': optional: true @@ -31220,6 +31885,9 @@ snapshots: '@esbuild/netbsd-arm64@0.28.1': optional: true + '@esbuild/netbsd-arm64@0.28.2': + optional: true + '@esbuild/netbsd-x64@0.23.0': optional: true @@ -31238,6 +31906,9 @@ snapshots: '@esbuild/netbsd-x64@0.28.1': optional: true + '@esbuild/netbsd-x64@0.28.2': + optional: true + '@esbuild/openbsd-arm64@0.23.0': optional: true @@ -31256,6 +31927,9 @@ snapshots: '@esbuild/openbsd-arm64@0.28.1': optional: true + '@esbuild/openbsd-arm64@0.28.2': + optional: true + '@esbuild/openbsd-x64@0.23.0': optional: true @@ -31274,6 +31948,9 @@ snapshots: '@esbuild/openbsd-x64@0.28.1': optional: true + '@esbuild/openbsd-x64@0.28.2': + optional: true + '@esbuild/openharmony-arm64@0.25.10': optional: true @@ -31286,6 +31963,9 @@ snapshots: '@esbuild/openharmony-arm64@0.28.1': optional: true + '@esbuild/openharmony-arm64@0.28.2': + optional: true + '@esbuild/sunos-x64@0.23.0': optional: true @@ -31304,6 +31984,9 @@ snapshots: '@esbuild/sunos-x64@0.28.1': optional: true + '@esbuild/sunos-x64@0.28.2': + optional: true + '@esbuild/win32-arm64@0.23.0': optional: true @@ -31322,6 +32005,9 @@ snapshots: '@esbuild/win32-arm64@0.28.1': optional: true + '@esbuild/win32-arm64@0.28.2': + optional: true + '@esbuild/win32-ia32@0.23.0': optional: true @@ -31340,6 +32026,9 @@ snapshots: '@esbuild/win32-ia32@0.28.1': optional: true + '@esbuild/win32-ia32@0.28.2': + optional: true + '@esbuild/win32-x64@0.23.0': optional: true @@ -31358,6 +32047,9 @@ snapshots: '@esbuild/win32-x64@0.28.1': optional: true + '@esbuild/win32-x64@0.28.2': + optional: true + '@eslint-community/eslint-utils@4.4.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))': dependencies: eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) @@ -31368,11 +32060,21 @@ snapshots: eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) eslint-visitor-keys: 3.4.3 + '@eslint-community/eslint-utils@4.9.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))': + dependencies: + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-visitor-keys: 3.4.3 + '@eslint-community/eslint-utils@4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))': dependencies: eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) eslint-visitor-keys: 3.4.3 + '@eslint-community/eslint-utils@4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))': + dependencies: + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-visitor-keys: 3.4.3 + '@eslint-community/regexpp@4.12.1': {} '@eslint-community/regexpp@4.12.2': {} @@ -31478,6 +32180,14 @@ snapshots: transitivePeerDependencies: - supports-color + '@eslint/config-array@0.19.2(supports-color@7.2.0)': + dependencies: + '@eslint/object-schema': 2.1.6 + debug: 4.4.3(supports-color@7.2.0) + minimatch: 3.1.2 + transitivePeerDependencies: + - supports-color + '@eslint/config-helpers@0.1.0': {} '@eslint/core@0.12.0': @@ -31498,9 +32208,23 @@ snapshots: transitivePeerDependencies: - supports-color - '@eslint/js@10.0.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))': + '@eslint/eslintrc@3.3.0(supports-color@7.2.0)': + dependencies: + ajv: 6.12.6 + debug: 4.4.3(supports-color@7.2.0) + espree: 10.4.0 + globals: 14.0.0 + ignore: 5.3.2 + import-fresh: 3.3.0 + js-yaml: 4.1.1 + minimatch: 3.1.2 + strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color + + '@eslint/js@10.0.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))': optionalDependencies: - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) '@eslint/js@9.22.0': {} @@ -31522,7 +32246,7 @@ snapshots: '@fastify/ajv-compiler@4.0.5': dependencies: ajv: 8.17.1 - ajv-formats: 3.0.1 + ajv-formats: 3.0.1(ajv@8.17.1) fast-uri: 3.0.6 '@fastify/busboy@3.1.1': {} @@ -31871,11 +32595,11 @@ snapshots: '@floating-ui/core': 1.6.9 '@floating-ui/utils': 0.2.9 - '@floating-ui/react-dom@2.1.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@floating-ui/react-dom@2.1.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@floating-ui/dom': 1.6.13 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) '@floating-ui/utils@0.2.9': {} @@ -31929,11 +32653,6 @@ snapshots: '@img/sharp-libvips-darwin-arm64': 1.3.3 optional: true - '@img/sharp-darwin-arm64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-darwin-arm64': 1.3.4 - optional: true - '@img/sharp-darwin-x64@0.34.5': optionalDependencies: '@img/sharp-libvips-darwin-x64': 1.2.4 @@ -31944,111 +32663,71 @@ snapshots: '@img/sharp-libvips-darwin-x64': 1.3.3 optional: true - '@img/sharp-darwin-x64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-darwin-x64': 1.3.4 - optional: true - '@img/sharp-freebsd-wasm32@0.35.4': dependencies: '@img/sharp-wasm32': 0.35.4 optional: true - '@img/sharp-freebsd-wasm32@0.35.5': - dependencies: - '@img/sharp-wasm32': 0.35.5 - optional: true - '@img/sharp-libvips-darwin-arm64@1.2.4': optional: true '@img/sharp-libvips-darwin-arm64@1.3.3': optional: true - '@img/sharp-libvips-darwin-arm64@1.3.4': - optional: true - '@img/sharp-libvips-darwin-x64@1.2.4': optional: true '@img/sharp-libvips-darwin-x64@1.3.3': optional: true - '@img/sharp-libvips-darwin-x64@1.3.4': - optional: true - '@img/sharp-libvips-linux-arm64@1.2.4': optional: true '@img/sharp-libvips-linux-arm64@1.3.3': optional: true - '@img/sharp-libvips-linux-arm64@1.3.4': - optional: true - '@img/sharp-libvips-linux-arm@1.2.4': optional: true '@img/sharp-libvips-linux-arm@1.3.3': optional: true - '@img/sharp-libvips-linux-arm@1.3.4': - optional: true - '@img/sharp-libvips-linux-ppc64@1.2.4': optional: true '@img/sharp-libvips-linux-ppc64@1.3.3': optional: true - '@img/sharp-libvips-linux-ppc64@1.3.4': - optional: true - '@img/sharp-libvips-linux-riscv64@1.2.4': optional: true '@img/sharp-libvips-linux-riscv64@1.3.3': optional: true - '@img/sharp-libvips-linux-riscv64@1.3.4': - optional: true - '@img/sharp-libvips-linux-s390x@1.2.4': optional: true '@img/sharp-libvips-linux-s390x@1.3.3': optional: true - '@img/sharp-libvips-linux-s390x@1.3.4': - optional: true - '@img/sharp-libvips-linux-x64@1.2.4': optional: true '@img/sharp-libvips-linux-x64@1.3.3': optional: true - '@img/sharp-libvips-linux-x64@1.3.4': - optional: true - '@img/sharp-libvips-linuxmusl-arm64@1.2.4': optional: true '@img/sharp-libvips-linuxmusl-arm64@1.3.3': optional: true - '@img/sharp-libvips-linuxmusl-arm64@1.3.4': - optional: true - '@img/sharp-libvips-linuxmusl-x64@1.2.4': optional: true '@img/sharp-libvips-linuxmusl-x64@1.3.3': optional: true - '@img/sharp-libvips-linuxmusl-x64@1.3.4': - optional: true - '@img/sharp-linux-arm64@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-arm64': 1.2.4 @@ -32059,11 +32738,6 @@ snapshots: '@img/sharp-libvips-linux-arm64': 1.3.3 optional: true - '@img/sharp-linux-arm64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-arm64': 1.3.4 - optional: true - '@img/sharp-linux-arm@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-arm': 1.2.4 @@ -32074,11 +32748,6 @@ snapshots: '@img/sharp-libvips-linux-arm': 1.3.3 optional: true - '@img/sharp-linux-arm@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-arm': 1.3.4 - optional: true - '@img/sharp-linux-ppc64@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-ppc64': 1.2.4 @@ -32089,11 +32758,6 @@ snapshots: '@img/sharp-libvips-linux-ppc64': 1.3.3 optional: true - '@img/sharp-linux-ppc64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-ppc64': 1.3.4 - optional: true - '@img/sharp-linux-riscv64@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-riscv64': 1.2.4 @@ -32104,11 +32768,6 @@ snapshots: '@img/sharp-libvips-linux-riscv64': 1.3.3 optional: true - '@img/sharp-linux-riscv64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-riscv64': 1.3.4 - optional: true - '@img/sharp-linux-s390x@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-s390x': 1.2.4 @@ -32119,11 +32778,6 @@ snapshots: '@img/sharp-libvips-linux-s390x': 1.3.3 optional: true - '@img/sharp-linux-s390x@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-s390x': 1.3.4 - optional: true - '@img/sharp-linux-x64@0.34.5': optionalDependencies: '@img/sharp-libvips-linux-x64': 1.2.4 @@ -32134,11 +32788,6 @@ snapshots: '@img/sharp-libvips-linux-x64': 1.3.3 optional: true - '@img/sharp-linux-x64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linux-x64': 1.3.4 - optional: true - '@img/sharp-linuxmusl-arm64@0.34.5': optionalDependencies: '@img/sharp-libvips-linuxmusl-arm64': 1.2.4 @@ -32149,11 +32798,6 @@ snapshots: '@img/sharp-libvips-linuxmusl-arm64': 1.3.3 optional: true - '@img/sharp-linuxmusl-arm64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linuxmusl-arm64': 1.3.4 - optional: true - '@img/sharp-linuxmusl-x64@0.34.5': optionalDependencies: '@img/sharp-libvips-linuxmusl-x64': 1.2.4 @@ -32164,11 +32808,6 @@ snapshots: '@img/sharp-libvips-linuxmusl-x64': 1.3.3 optional: true - '@img/sharp-linuxmusl-x64@0.35.5': - optionalDependencies: - '@img/sharp-libvips-linuxmusl-x64': 1.3.4 - optional: true - '@img/sharp-wasm32@0.34.5': dependencies: '@emnapi/runtime': 1.11.3 @@ -32179,48 +32818,29 @@ snapshots: '@emnapi/runtime': 1.11.3 optional: true - '@img/sharp-wasm32@0.35.5': - dependencies: - '@emnapi/runtime': 1.11.3 - optional: true - '@img/sharp-webcontainers-wasm32@0.35.4': dependencies: '@img/sharp-wasm32': 0.35.4 optional: true - '@img/sharp-webcontainers-wasm32@0.35.5': - dependencies: - '@img/sharp-wasm32': 0.35.5 - optional: true - '@img/sharp-win32-arm64@0.34.5': optional: true '@img/sharp-win32-arm64@0.35.4': optional: true - '@img/sharp-win32-arm64@0.35.5': - optional: true - '@img/sharp-win32-ia32@0.34.5': optional: true '@img/sharp-win32-ia32@0.35.4': optional: true - '@img/sharp-win32-ia32@0.35.5': - optional: true - '@img/sharp-win32-x64@0.34.5': optional: true '@img/sharp-win32-x64@0.35.4': optional: true - '@img/sharp-win32-x64@0.35.5': - optional: true - '@import-maps/resolve@2.0.0': {} '@inlang/paraglide-js@2.4.0(babel-plugin-macros@3.1.0)': @@ -32328,7 +32948,7 @@ snapshots: '@jridgewell/gen-mapping@0.3.13': dependencies: - '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/sourcemap-codec': 1.6.0 '@jridgewell/trace-mapping': 0.3.31 '@jridgewell/remapping@2.3.5': @@ -32350,7 +32970,7 @@ snapshots: '@jridgewell/trace-mapping@0.3.31': dependencies: '@jridgewell/resolve-uri': 3.1.2 - '@jridgewell/sourcemap-codec': 1.5.5 + '@jridgewell/sourcemap-codec': 1.6.0 '@jridgewell/trace-mapping@0.3.9': dependencies: @@ -32532,6 +33152,55 @@ snapshots: - encoding - supports-color + '@mdx-js/loader@3.1.1(supports-color@10.2.2)(webpack@5.110.3)': + dependencies: + '@mdx-js/mdx': 3.1.1(supports-color@10.2.2) + source-map: 0.7.6 + optionalDependencies: + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + transitivePeerDependencies: + - supports-color + + '@mdx-js/mdx@3.1.1(supports-color@10.2.2)': + dependencies: + '@types/estree': 1.0.9 + '@types/estree-jsx': 1.0.5 + '@types/hast': 3.0.5 + '@types/mdx': 2.0.14 + acorn: 8.18.0 + collapse-white-space: 2.1.0 + devlop: 1.1.0 + estree-util-is-identifier-name: 3.0.0 + estree-util-scope: 1.0.1 + estree-walker: 3.0.3 + hast-util-to-jsx-runtime: 2.3.6(supports-color@10.2.2) + markdown-extensions: 2.0.0 + recma-build-jsx: 1.0.0 + recma-jsx: 1.0.1(acorn@8.18.0) + recma-stringify: 1.0.0 + rehype-recma: 1.0.0(supports-color@10.2.2) + remark-mdx: 3.1.1(supports-color@10.2.2) + remark-parse: 11.0.0(supports-color@10.2.2) + remark-rehype: 11.1.2 + source-map: 0.7.6 + unified: 11.0.5 + unist-util-position-from-estree: 2.0.0 + unist-util-stringify-position: 4.0.0 + unist-util-visit: 5.1.0 + vfile: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@mdx-js/rollup@3.1.1(rollup@4.63.1)(supports-color@10.2.2)': + dependencies: + '@mdx-js/mdx': 3.1.1(supports-color@10.2.2) + '@rollup/pluginutils': 5.1.4(rollup@4.63.1) + rollup: 4.63.1 + source-map: 0.7.6 + vfile: 6.0.3 + transitivePeerDependencies: + - supports-color + '@microsoft/api-extractor-model@7.29.6(@types/node@25.0.9)': dependencies: '@microsoft/tsdoc': 0.15.1 @@ -32637,37 +33306,37 @@ snapshots: '@mui/core-downloads-tracker@6.4.7': {} - '@mui/material@6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@mui/material@6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 '@mui/core-downloads-tracker': 6.4.7 - '@mui/system': 6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9) + '@mui/system': 6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3) '@mui/types': 7.2.21(@types/react@19.2.9) - '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.9) + '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.3) '@popperjs/core': 2.11.8 '@types/react-transition-group': 4.4.12(@types/react@19.2.9) clsx: 2.1.1 csstype: 3.1.3 prop-types: 15.8.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) react-is: 19.0.0 - react-transition-group: 4.4.5(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + react-transition-group: 4.4.5(react-dom@19.2.3(react@19.2.3))(react@19.2.3) optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) - '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) + '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) '@types/react': 19.2.9 - '@mui/private-theming@6.4.6(@types/react@19.2.9)(react@19.2.9)': + '@mui/private-theming@6.4.6(@types/react@19.2.9)(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 - '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.9) + '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.3) prop-types: 15.8.1 - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@mui/styled-engine@6.4.6(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(react@19.2.9)': + '@mui/styled-engine@6.4.6(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 '@emotion/cache': 11.14.0 @@ -32675,39 +33344,39 @@ snapshots: '@emotion/sheet': 1.4.0 csstype: 3.2.3 prop-types: 15.8.1 - react: 19.2.9 + react: 19.2.3 optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) - '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) + '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) - '@mui/system@6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)': + '@mui/system@6.4.7(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 - '@mui/private-theming': 6.4.6(@types/react@19.2.9)(react@19.2.9) - '@mui/styled-engine': 6.4.6(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(react@19.2.9) + '@mui/private-theming': 6.4.6(@types/react@19.2.9)(react@19.2.3) + '@mui/styled-engine': 6.4.6(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@emotion/styled@11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(react@19.2.3) '@mui/types': 7.2.21(@types/react@19.2.9) - '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.9) + '@mui/utils': 6.4.6(@types/react@19.2.9)(react@19.2.3) clsx: 2.1.1 csstype: 3.2.3 prop-types: 15.8.1 - react: 19.2.9 + react: 19.2.3 optionalDependencies: - '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) - '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.9)(supports-color@10.2.2) + '@emotion/react': 11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) + '@emotion/styled': 11.14.0(@emotion/react@11.14.0(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2))(@types/react@19.2.9)(react@19.2.3)(supports-color@10.2.2) '@types/react': 19.2.9 '@mui/types@7.2.21(@types/react@19.2.9)': optionalDependencies: '@types/react': 19.2.9 - '@mui/utils@6.4.6(@types/react@19.2.9)(react@19.2.9)': + '@mui/utils@6.4.6(@types/react@19.2.9)(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 '@mui/types': 7.2.21(@types/react@19.2.9) '@types/prop-types': 15.7.14 clsx: 2.1.1 prop-types: 15.8.1 - react: 19.2.9 + react: 19.2.3 react-is: 19.0.0 optionalDependencies: '@types/react': 19.2.9 @@ -32719,7 +33388,7 @@ snapshots: dependencies: '@emnapi/core': 1.11.3 '@emnapi/runtime': 1.11.3 - '@tybys/wasm-util': 0.10.3 + '@tybys/wasm-util': 0.10.2 optional: true '@napi-rs/wasm-runtime@0.2.4': @@ -32728,6 +33397,27 @@ snapshots: '@emnapi/runtime': 1.11.3 '@tybys/wasm-util': 0.9.0 + '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0)': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@tybys/wasm-util': 0.10.2 + optional: true + + '@napi-rs/wasm-runtime@1.1.4(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': + dependencies: + '@emnapi/core': 1.11.3 + '@emnapi/runtime': 1.11.3 + '@tybys/wasm-util': 0.10.2 + optional: true + + '@napi-rs/wasm-runtime@1.1.5(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1)': + dependencies: + '@emnapi/core': 1.11.1 + '@emnapi/runtime': 1.11.1 + '@tybys/wasm-util': 0.10.3 + optional: true + '@napi-rs/wasm-runtime@1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': dependencies: '@emnapi/core': 1.11.3 @@ -32786,7 +33476,7 @@ snapshots: validate-npm-package-name: 5.0.1 yaml: 2.9.0 yargs: 17.7.2 - zod: 4.6.6 + zod: 4.5.4 '@netlify/database-dev@1.0.1': dependencies: @@ -33004,10 +33694,10 @@ snapshots: '@netlify/types@3.0.0': {} - '@netlify/vite-plugin-tanstack-start@1.3.19(@tanstack/solid-start@packages+solid-start)(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@netlify/vite-plugin-tanstack-start@1.3.19(@tanstack/solid-start@packages+solid-start)(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: - '@netlify/vite-plugin': 3.0.1(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + '@netlify/vite-plugin': 3.0.1(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) optionalDependencies: '@tanstack/solid-start': link:packages/solid-start transitivePeerDependencies: @@ -33038,12 +33728,12 @@ snapshots: - supports-color - uploadthing - '@netlify/vite-plugin@3.0.1(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@netlify/vite-plugin@3.0.1(babel-plugin-macros@3.1.0)(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@netlify/dev': 5.1.0(db0@0.4.1)(ioredis@5.11.1(supports-color@10.2.2))(rollup@4.63.1)(srvx@1.0.5)(supports-color@10.2.2) '@netlify/dev-utils': 6.0.1 dedent: 1.7.2(babel-plugin-macros@3.1.0) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - '@azure/app-configuration' - '@azure/cosmos' @@ -33106,7 +33796,7 @@ snapshots: unixify: 1.0.0 urlpattern-polyfill: 8.0.2 yargs: 17.7.2 - zod: 4.6.6 + zod: 4.5.4 transitivePeerDependencies: - bare-abort-controller - bare-buffer @@ -33158,43 +33848,43 @@ snapshots: '@nodelib/fs.scandir': 2.1.5 fastq: 1.19.0 - '@nx/devkit@24.0.0(nx@24.0.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2))(@swc/core@1.15.33(@swc/helpers@0.5.23)))': + '@nx/devkit@23.2.0(nx@23.2.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0))(@swc/core@1.15.33(@swc/helpers@0.5.23)))': dependencies: ejs: 5.0.1 minimatch: 10.2.5 - nx: 24.0.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2))(@swc/core@1.15.33(@swc/helpers@0.5.23)) + nx: 23.2.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0))(@swc/core@1.15.33(@swc/helpers@0.5.23)) semver: 7.8.5 tslib: 2.8.1 yargs-parser: 21.1.1 - '@nx/nx-darwin-arm64@24.0.0': + '@nx/nx-darwin-arm64@23.2.0': optional: true - '@nx/nx-darwin-x64@24.0.0': + '@nx/nx-darwin-x64@23.2.0': optional: true - '@nx/nx-freebsd-x64@24.0.0': + '@nx/nx-freebsd-x64@23.2.0': optional: true - '@nx/nx-linux-arm-gnueabihf@24.0.0': + '@nx/nx-linux-arm-gnueabihf@23.2.0': optional: true - '@nx/nx-linux-arm64-gnu@24.0.0': + '@nx/nx-linux-arm64-gnu@23.2.0': optional: true - '@nx/nx-linux-arm64-musl@24.0.0': + '@nx/nx-linux-arm64-musl@23.2.0': optional: true - '@nx/nx-linux-x64-gnu@24.0.0': + '@nx/nx-linux-x64-gnu@23.2.0': optional: true - '@nx/nx-linux-x64-musl@24.0.0': + '@nx/nx-linux-x64-musl@23.2.0': optional: true - '@nx/nx-win32-arm64-msvc@24.0.0': + '@nx/nx-win32-arm64-msvc@23.2.0': optional: true - '@nx/nx-win32-x64-msvc@24.0.0': + '@nx/nx-win32-x64-msvc@23.2.0': optional: true '@one-ini/wasm@0.1.1': {} @@ -33335,7 +34025,7 @@ snapshots: '@oxc-resolver/binding-wasm32-wasi@11.19.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)': dependencies: - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) + '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) transitivePeerDependencies: - '@emnapi/core' - '@emnapi/runtime' @@ -33564,11 +34254,11 @@ snapshots: '@prisma/client-runtime-utils@7.0.0': {} - '@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))': + '@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))': dependencies: '@prisma/client-runtime-utils': 7.0.0 optionalDependencies: - prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) typescript: '@typescript/typescript6@6.0.2' '@prisma/config@7.0.0': @@ -33635,11 +34325,11 @@ snapshots: '@prisma/query-plan-executor@6.18.0': {} - '@prisma/studio-core-licensed@0.8.0(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@prisma/studio-core-licensed@0.8.0(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@types/react': 19.2.9 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) '@protobufjs/aspromise@1.1.2': {} @@ -33672,705 +34362,705 @@ snapshots: '@radix-ui/primitive@1.1.2': {} - '@radix-ui/react-accessible-icon@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-accessible-icon@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-accordion@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-accordion@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collapsible': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collapsible': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-alert-dialog@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-alert-dialog@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-arrow@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-arrow@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-aspect-ratio@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-aspect-ratio@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-avatar@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-avatar@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-checkbox@1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-checkbox@1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-collapsible@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-collapsible@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-collection@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-collection@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-compose-refs@1.1.2(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-compose-refs@1.1.2(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-context-menu@2.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-context-menu@2.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-context@1.1.2(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-context@1.1.2(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-dialog@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-dialog@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) aria-hidden: 1.2.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-direction@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-direction@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-dismissable-layer@1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-dismissable-layer@1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-escape-keydown': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-escape-keydown': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-dropdown-menu@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-dropdown-menu@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-focus-guards@1.1.2(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-focus-guards@1.1.2(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-focus-scope@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-focus-scope@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-form@0.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-form@0.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-label': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-label': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-hover-card@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-hover-card@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-id@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-id@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-label@2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-label@2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-menu@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-menu@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) aria-hidden: 1.2.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-menubar@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-menubar@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-navigation-menu@1.2.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-navigation-menu@1.2.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-popover@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-popover@1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) aria-hidden: 1.2.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-popper@1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-popper@1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@floating-ui/react-dom': 2.1.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-arrow': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-rect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) + '@floating-ui/react-dom': 2.1.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-arrow': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-rect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) '@radix-ui/rect': 1.1.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-portal@1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-portal@1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-presence@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-presence@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-primitive@2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-primitive@2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-progress@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-progress@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-radio-group@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-radio-group@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-roving-focus@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-roving-focus@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-scroll-area@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-scroll-area@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/number': 1.1.1 '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-select@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-select@2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/number': 1.1.1 '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) aria-hidden: 1.2.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll: 2.6.3(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-separator@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-separator@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-slider@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-slider@1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/number': 1.1.1 '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-slot@1.2.0(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-slot@1.2.0(@types/react@19.2.9)(react@19.2.3)': dependencies: - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-switch@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-switch@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-previous': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-tabs@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-tabs@1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-toast@1.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-toast@1.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-toggle-group@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-toggle-group@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toggle': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toggle': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-toggle@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-toggle@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-toolbar@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-toolbar@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-separator': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toggle-group': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-separator': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toggle-group': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-tooltip@1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-tooltip@1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-id': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-callback-ref@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-controllable-state@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-controllable-state@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-escape-keydown@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-previous@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-previous@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-rect@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-rect@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: '@radix-ui/rect': 1.1.1 - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-use-size@1.1.1(@types/react@19.2.9)(react@19.2.9)': + '@radix-ui/react-use-size@1.1.1(@types/react@19.2.9)(react@19.2.3)': dependencies: - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - react: 19.2.9 + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + react: 19.2.3 optionalDependencies: '@types/react': 19.2.9 - '@radix-ui/react-visually-hidden@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/react-visually-hidden@1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) '@radix-ui/rect@1.1.1': {} - '@radix-ui/themes@3.3.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@radix-ui/themes@3.3.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@radix-ui/colors': 3.0.0 classnames: 2.5.1 - radix-ui: 1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - react-remove-scroll-bar: 2.3.8(@types/react@19.2.9)(react@19.2.9) + radix-ui: 1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + react-remove-scroll-bar: 2.3.8(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) @@ -34420,31 +35110,21 @@ snapshots: '@rolldown/binding-win32-x64-msvc@1.2.13': optional: true - '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@babel/core': 7.29.0(supports-color@10.2.2) picomatch: 4.0.7 rolldown: 1.2.13 optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) picomatch: 4.0.7 rolldown: 1.2.13 optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - optional: true - - '@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': - dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - picomatch: 4.0.7 - rolldown: 1.2.13 - optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - optional: true + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) '@rolldown/pluginutils@1.0.0-rc.2': {} @@ -34537,14 +35217,28 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.63.1': optional: true - '@rsbuild/core@2.3.1': + '@rsbuild/core@2.0.14': dependencies: - '@rspack/core': 2.3.1(@swc/helpers@0.5.23) + '@rspack/core': 2.0.8(@swc/helpers@0.5.23) '@swc/helpers': 0.5.23 transitivePeerDependencies: - '@module-federation/runtime-tools' - '@rsbuild/plugin-babel@1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2)': + '@rsbuild/core@2.1.1': + dependencies: + '@rspack/core': 2.1.1(@swc/helpers@0.5.23) + '@swc/helpers': 0.5.23 + transitivePeerDependencies: + - '@module-federation/runtime-tools' + + '@rsbuild/core@2.2.5': + dependencies: + '@rspack/core': 2.2.7(@swc/helpers@0.5.23) + '@swc/helpers': 0.5.23 + transitivePeerDependencies: + - '@module-federation/runtime-tools' + + '@rsbuild/plugin-babel@1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2)': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/plugin-proposal-decorators': 7.29.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) @@ -34553,20 +35247,77 @@ snapshots: '@types/babel__core': 7.20.5 reduce-configs: 1.1.1 optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.1.1 transitivePeerDependencies: - supports-color - '@rsbuild/plugin-react@2.0.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))': + '@rsbuild/plugin-babel@1.1.2(@rsbuild/core@2.2.5)(supports-color@10.2.2)': dependencies: - '@rspack/plugin-react-refresh': 2.0.0(@rspack/core@2.3.1(@swc/helpers@0.5.23))(react-refresh@0.18.0) + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/plugin-proposal-decorators': 7.29.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/plugin-transform-class-properties': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/preset-typescript': 7.28.5(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@types/babel__core': 7.20.5 + reduce-configs: 1.1.1 + optionalDependencies: + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - supports-color + + '@rsbuild/plugin-babel@1.2.1(@rsbuild/core@2.1.1)(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/plugin-proposal-decorators': 7.29.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/plugin-transform-class-properties': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/preset-typescript': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@types/babel__core': 7.20.5 + reduce-configs: 1.1.2 + optionalDependencies: + '@rsbuild/core': 2.1.1 + transitivePeerDependencies: + - supports-color + + '@rsbuild/plugin-babel@1.2.1(@rsbuild/core@2.2.5)(supports-color@10.2.2)': + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/plugin-proposal-decorators': 7.29.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/plugin-transform-class-properties': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/preset-typescript': 7.29.7(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@types/babel__core': 7.20.5 + reduce-configs: 1.1.2 + optionalDependencies: + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - supports-color + + '@rsbuild/plugin-react@2.0.0(@rsbuild/core@2.0.14)(@rspack/core@2.2.7(@swc/helpers@0.5.23))': + dependencies: + '@rspack/plugin-react-refresh': 2.0.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-refresh@0.18.0) react-refresh: 0.18.0 optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.0.14 transitivePeerDependencies: - '@rspack/core' - '@rsbuild/plugin-sass@2.0.1(@rsbuild/core@2.3.1)': + '@rsbuild/plugin-react@2.0.0(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23))': + dependencies: + '@rspack/plugin-react-refresh': 2.0.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-refresh@0.18.0) + react-refresh: 0.18.0 + optionalDependencies: + '@rsbuild/core': 2.1.1 + transitivePeerDependencies: + - '@rspack/core' + + '@rsbuild/plugin-react@2.0.0(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23))': + dependencies: + '@rspack/plugin-react-refresh': 2.0.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-refresh@0.18.0) + react-refresh: 0.18.0 + optionalDependencies: + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - '@rspack/core' + + '@rsbuild/plugin-sass@2.0.1(@rsbuild/core@2.2.5)': dependencies: deepmerge: 4.3.1 loader-utils: 2.0.4 @@ -34574,108 +35325,167 @@ snapshots: reduce-configs: 2.0.1 sass-embedded: 1.105.1 optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.2.5 - '@rsbuild/plugin-solid@1.1.1(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(solid-js@1.9.12)(supports-color@10.2.2)': + '@rsbuild/plugin-solid@1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(solid-js@1.9.12)(supports-color@10.2.2)': dependencies: - '@rsbuild/plugin-babel': 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) - babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) - solid-refresh: 0.7.8(solid-js@1.9.12) + '@rsbuild/plugin-babel': 1.2.1(@rsbuild/core@2.1.1)(supports-color@10.2.2) + babel-preset-solid: 1.9.16(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) + solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.1.1 transitivePeerDependencies: - '@babel/core' - solid-js - supports-color - '@rsbuild/plugin-tailwindcss@2.0.3(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(webpack@5.110.3)': + '@rsbuild/plugin-solid@1.2.2(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.2.5)(solid-js@1.9.12)(supports-color@10.2.2)': dependencies: - '@tailwindcss/webpack': 4.3.1(@rspack/core@2.3.1(@swc/helpers@0.5.23))(webpack@5.110.3) + '@rsbuild/plugin-babel': 1.2.1(@rsbuild/core@2.2.5)(supports-color@10.2.2) + babel-preset-solid: 1.9.16(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) + solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - '@babel/core' + - solid-js + - supports-color + + '@rsbuild/plugin-tailwindcss@2.0.3(@rsbuild/core@2.0.14)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(webpack@5.110.3)': + dependencies: + '@tailwindcss/webpack': 4.3.1(@rspack/core@2.2.7(@swc/helpers@0.5.23))(webpack@5.110.3) + optionalDependencies: + '@rsbuild/core': 2.0.14 transitivePeerDependencies: - '@rspack/core' - webpack - '@rsbuild/plugin-vue-jsx@2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.3.1)(supports-color@10.2.2)': + '@rsbuild/plugin-vue-jsx@2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.1.1)(supports-color@10.2.2)': dependencies: - '@rsbuild/plugin-babel': 1.1.2(@rsbuild/core@2.3.1)(supports-color@10.2.2) + '@rsbuild/plugin-babel': 1.1.2(@rsbuild/core@2.1.1)(supports-color@10.2.2) '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) babel-plugin-vue-jsx-hmr: 1.0.0(supports-color@10.2.2) optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.1.1 transitivePeerDependencies: - '@babel/core' - supports-color - '@rsbuild/plugin-vue@1.2.7(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2))': + '@rsbuild/plugin-vue-jsx@2.0.0(@babel/core@7.29.7(supports-color@10.2.2))(@rsbuild/core@2.2.5)(supports-color@10.2.2)': dependencies: - rspack-vue-loader: 17.5.0(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + '@rsbuild/plugin-babel': 1.1.2(@rsbuild/core@2.2.5)(supports-color@10.2.2) + '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + babel-plugin-vue-jsx-hmr: 1.0.0(supports-color@10.2.2) optionalDependencies: - '@rsbuild/core': 2.3.1 + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - '@babel/core' + - supports-color + + '@rsbuild/plugin-vue@1.2.7(@rsbuild/core@2.1.1)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2))': + dependencies: + rspack-vue-loader: 17.5.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + optionalDependencies: + '@rsbuild/core': 2.1.1 transitivePeerDependencies: - '@rspack/core' - '@vue/compiler-sfc' - vue + '@rsbuild/plugin-vue@1.2.7(@rsbuild/core@2.2.5)(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2))': + dependencies: + rspack-vue-loader: 17.5.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)) + optionalDependencies: + '@rsbuild/core': 2.2.5 + transitivePeerDependencies: + - '@rspack/core' + - '@vue/compiler-sfc' + - vue + + '@rspack/binding-darwin-arm64@2.0.8': + optional: true + + '@rspack/binding-darwin-arm64@2.1.1': + optional: true + '@rspack/binding-darwin-arm64@2.2.7': optional: true - '@rspack/binding-darwin-arm64@2.3.1': + '@rspack/binding-darwin-x64@2.0.8': + optional: true + + '@rspack/binding-darwin-x64@2.1.1': optional: true '@rspack/binding-darwin-x64@2.2.7': optional: true - '@rspack/binding-darwin-x64@2.3.1': + '@rspack/binding-linux-arm64-gnu@2.0.8': + optional: true + + '@rspack/binding-linux-arm64-gnu@2.1.1': optional: true '@rspack/binding-linux-arm64-gnu@2.2.7': optional: true - '@rspack/binding-linux-arm64-gnu@2.3.1': + '@rspack/binding-linux-arm64-musl@2.0.8': + optional: true + + '@rspack/binding-linux-arm64-musl@2.1.1': optional: true '@rspack/binding-linux-arm64-musl@2.2.7': optional: true - '@rspack/binding-linux-arm64-musl@2.3.1': - optional: true - '@rspack/binding-linux-ppc64-gnu@2.2.7': optional: true - '@rspack/binding-linux-ppc64-gnu@2.3.1': + '@rspack/binding-linux-riscv64-gnu@2.1.1': optional: true '@rspack/binding-linux-riscv64-gnu@2.2.7': optional: true - '@rspack/binding-linux-riscv64-gnu@2.3.1': + '@rspack/binding-linux-riscv64-musl@2.1.1': optional: true '@rspack/binding-linux-riscv64-musl@2.2.7': optional: true - '@rspack/binding-linux-riscv64-musl@2.3.1': - optional: true - '@rspack/binding-linux-s390x-gnu@2.2.7': optional: true - '@rspack/binding-linux-s390x-gnu@2.3.1': + '@rspack/binding-linux-x64-gnu@2.0.8': + optional: true + + '@rspack/binding-linux-x64-gnu@2.1.1': optional: true '@rspack/binding-linux-x64-gnu@2.2.7': optional: true - '@rspack/binding-linux-x64-gnu@2.3.1': + '@rspack/binding-linux-x64-musl@2.0.8': + optional: true + + '@rspack/binding-linux-x64-musl@2.1.1': optional: true '@rspack/binding-linux-x64-musl@2.2.7': optional: true - '@rspack/binding-linux-x64-musl@2.3.1': + '@rspack/binding-wasm32-wasi@2.0.8': + dependencies: + '@emnapi/core': 1.10.0 + '@emnapi/runtime': 1.10.0 + '@napi-rs/wasm-runtime': 1.1.4(@emnapi/core@1.10.0)(@emnapi/runtime@1.10.0) + optional: true + + '@rspack/binding-wasm32-wasi@2.1.1': + dependencies: + '@emnapi/core': 1.11.1 + '@emnapi/runtime': 1.11.1 + '@napi-rs/wasm-runtime': 1.1.5(@emnapi/core@1.11.1)(@emnapi/runtime@1.11.1) optional: true '@rspack/binding-wasm32-wasi@2.2.7': @@ -34685,30 +35495,60 @@ snapshots: '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) optional: true - '@rspack/binding-wasm32-wasi@2.3.1': - dependencies: - '@emnapi/core': 1.11.3 - '@emnapi/runtime': 1.11.3 - '@napi-rs/wasm-runtime': 1.1.6(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) + '@rspack/binding-win32-arm64-msvc@2.0.8': + optional: true + + '@rspack/binding-win32-arm64-msvc@2.1.1': optional: true '@rspack/binding-win32-arm64-msvc@2.2.7': optional: true - '@rspack/binding-win32-arm64-msvc@2.3.1': + '@rspack/binding-win32-ia32-msvc@2.0.8': + optional: true + + '@rspack/binding-win32-ia32-msvc@2.1.1': optional: true '@rspack/binding-win32-ia32-msvc@2.2.7': optional: true - '@rspack/binding-win32-ia32-msvc@2.3.1': + '@rspack/binding-win32-x64-msvc@2.0.8': + optional: true + + '@rspack/binding-win32-x64-msvc@2.1.1': optional: true '@rspack/binding-win32-x64-msvc@2.2.7': optional: true - '@rspack/binding-win32-x64-msvc@2.3.1': - optional: true + '@rspack/binding@2.0.8': + optionalDependencies: + '@rspack/binding-darwin-arm64': 2.0.8 + '@rspack/binding-darwin-x64': 2.0.8 + '@rspack/binding-linux-arm64-gnu': 2.0.8 + '@rspack/binding-linux-arm64-musl': 2.0.8 + '@rspack/binding-linux-x64-gnu': 2.0.8 + '@rspack/binding-linux-x64-musl': 2.0.8 + '@rspack/binding-wasm32-wasi': 2.0.8 + '@rspack/binding-win32-arm64-msvc': 2.0.8 + '@rspack/binding-win32-ia32-msvc': 2.0.8 + '@rspack/binding-win32-x64-msvc': 2.0.8 + + '@rspack/binding@2.1.1': + optionalDependencies: + '@rspack/binding-darwin-arm64': 2.1.1 + '@rspack/binding-darwin-x64': 2.1.1 + '@rspack/binding-linux-arm64-gnu': 2.1.1 + '@rspack/binding-linux-arm64-musl': 2.1.1 + '@rspack/binding-linux-riscv64-gnu': 2.1.1 + '@rspack/binding-linux-riscv64-musl': 2.1.1 + '@rspack/binding-linux-x64-gnu': 2.1.1 + '@rspack/binding-linux-x64-musl': 2.1.1 + '@rspack/binding-wasm32-wasi': 2.1.1 + '@rspack/binding-win32-arm64-msvc': 2.1.1 + '@rspack/binding-win32-ia32-msvc': 2.1.1 + '@rspack/binding-win32-x64-msvc': 2.1.1 '@rspack/binding@2.2.7': optionalDependencies: @@ -34727,22 +35567,17 @@ snapshots: '@rspack/binding-win32-ia32-msvc': 2.2.7 '@rspack/binding-win32-x64-msvc': 2.2.7 - '@rspack/binding@2.3.1': + '@rspack/core@2.0.8(@swc/helpers@0.5.23)': + dependencies: + '@rspack/binding': 2.0.8 optionalDependencies: - '@rspack/binding-darwin-arm64': 2.3.1 - '@rspack/binding-darwin-x64': 2.3.1 - '@rspack/binding-linux-arm64-gnu': 2.3.1 - '@rspack/binding-linux-arm64-musl': 2.3.1 - '@rspack/binding-linux-ppc64-gnu': 2.3.1 - '@rspack/binding-linux-riscv64-gnu': 2.3.1 - '@rspack/binding-linux-riscv64-musl': 2.3.1 - '@rspack/binding-linux-s390x-gnu': 2.3.1 - '@rspack/binding-linux-x64-gnu': 2.3.1 - '@rspack/binding-linux-x64-musl': 2.3.1 - '@rspack/binding-wasm32-wasi': 2.3.1 - '@rspack/binding-win32-arm64-msvc': 2.3.1 - '@rspack/binding-win32-ia32-msvc': 2.3.1 - '@rspack/binding-win32-x64-msvc': 2.3.1 + '@swc/helpers': 0.5.23 + + '@rspack/core@2.1.1(@swc/helpers@0.5.23)': + dependencies: + '@rspack/binding': 2.1.1 + optionalDependencies: + '@swc/helpers': 0.5.23 '@rspack/core@2.2.7(@swc/helpers@0.5.23)': dependencies: @@ -34750,25 +35585,19 @@ snapshots: optionalDependencies: '@swc/helpers': 0.5.23 - '@rspack/core@2.3.1(@swc/helpers@0.5.23)': - dependencies: - '@rspack/binding': 2.3.1 - optionalDependencies: - '@swc/helpers': 0.5.23 - '@rspack/lite-tapable@1.1.0': {} - '@rspack/plugin-react-refresh@2.0.0(@rspack/core@2.3.1(@swc/helpers@0.5.23))(react-refresh@0.18.0)': + '@rspack/plugin-react-refresh@2.0.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-refresh@0.18.0)': dependencies: react-refresh: 0.18.0 optionalDependencies: - '@rspack/core': 2.3.1(@swc/helpers@0.5.23) + '@rspack/core': 2.2.7(@swc/helpers@0.5.23) '@rushstack/node-core-library@5.7.0(@types/node@25.0.9)': dependencies: ajv: 8.13.0 ajv-draft-04: 1.0.0(ajv@8.13.0) - ajv-formats: 3.0.1 + ajv-formats: 3.0.1(ajv@8.13.0) fs-extra: 7.0.1 import-lazy: 4.0.0 jju: 1.4.0 @@ -34846,6 +35675,20 @@ snapshots: - encoding - supports-color + '@sentry/bundler-plugin-core@4.6.1(supports-color@7.2.0)': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@sentry/babel-plugin-component-annotate': 4.6.1 + '@sentry/cli': 2.58.4(supports-color@7.2.0) + dotenv: 16.6.1 + find-up: 5.0.0 + glob: 10.5.0 + magic-string: 0.30.8 + unplugin: 1.0.1 + transitivePeerDependencies: + - encoding + - supports-color + '@sentry/cli-darwin@2.58.4': optional: true @@ -34890,6 +35733,26 @@ snapshots: - encoding - supports-color + '@sentry/cli@2.58.4(supports-color@7.2.0)': + dependencies: + https-proxy-agent: 5.0.1(supports-color@7.2.0) + node-fetch: 2.7.0 + progress: 2.0.3 + proxy-from-env: 1.1.0 + which: 2.0.2 + optionalDependencies: + '@sentry/cli-darwin': 2.58.4 + '@sentry/cli-linux-arm': 2.58.4 + '@sentry/cli-linux-arm64': 2.58.4 + '@sentry/cli-linux-i686': 2.58.4 + '@sentry/cli-linux-x64': 2.58.4 + '@sentry/cli-win32-arm64': 2.58.4 + '@sentry/cli-win32-i686': 2.58.4 + '@sentry/cli-win32-x64': 2.58.4 + transitivePeerDependencies: + - encoding + - supports-color + '@sentry/core@10.32.0': {} '@sentry/core@7.120.4': @@ -34897,12 +35760,12 @@ snapshots: '@sentry/types': 7.120.4 '@sentry/utils': 7.120.4 - '@sentry/react@10.32.0(react@19.2.9)': + '@sentry/react@10.32.0(react@19.2.3)': dependencies: '@sentry/browser': 10.32.0 '@sentry/core': 10.32.0 hoist-non-react-statics: 3.3.2 - react: 19.2.9 + react: 19.2.3 '@sentry/solid@10.32.0(@tanstack/solid-router@packages+solid-router)(solid-js@1.9.12)': dependencies: @@ -34930,6 +35793,14 @@ snapshots: - encoding - supports-color + '@sentry/vite-plugin@4.6.1(supports-color@7.2.0)': + dependencies: + '@sentry/bundler-plugin-core': 4.6.1(supports-color@7.2.0) + unplugin: 1.0.1 + transitivePeerDependencies: + - encoding + - supports-color + '@sentry/vue@10.32.0(@tanstack/vue-router@packages+vue-router)(vue@3.5.25(typescript@5.8.3))': dependencies: '@sentry/browser': 10.32.0 @@ -35041,11 +35912,11 @@ snapshots: '@standard-schema/spec@1.1.0': {} - '@stylistic/eslint-plugin@5.10.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))': + '@stylistic/eslint-plugin@5.10.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))': dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) '@typescript-eslint/types': 8.57.1 - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) eslint-visitor-keys: 4.2.1 espree: 10.4.0 estraverse: 5.3.0 @@ -35118,13 +35989,13 @@ snapshots: '@swc/core': 1.15.33(@swc/helpers@0.5.23) '@swc/types': 0.1.26 - '@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)': + '@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)': dependencies: '@swc-node/core': 1.14.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26) '@swc-node/sourcemap-support': 0.6.1 '@swc/core': 1.15.33(@swc/helpers@0.5.23) colorette: 2.0.20 - debug: 4.4.3(supports-color@10.2.2) + debug: 4.4.3(supports-color@7.2.0) oxc-resolver: 11.19.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3) pirates: 4.0.7 tslib: 2.8.1 @@ -35216,7 +36087,7 @@ snapshots: jiti: 2.7.0 lightningcss: 1.32.0 magic-string: 0.30.21 - source-map-js: 1.2.1 + source-map-js: 1.2.2 tailwindcss: 4.2.2 '@tailwindcss/node@4.3.1': @@ -35226,7 +36097,7 @@ snapshots: jiti: 2.7.0 lightningcss: 1.32.0 magic-string: 0.30.21 - source-map-js: 1.2.1 + source-map-js: 1.2.2 tailwindcss: 4.3.1 '@tailwindcss/oxide-android-arm64@4.2.2': @@ -35339,29 +36210,22 @@ snapshots: postcss: 8.5.8 tailwindcss: 4.2.2 - '@tailwindcss/vite@4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@tailwindcss/vite@4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@tailwindcss/node': 4.2.2 '@tailwindcss/oxide': 4.2.2 tailwindcss: 4.2.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - '@tailwindcss/vite@4.2.2(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': - dependencies: - '@tailwindcss/node': 4.2.2 - '@tailwindcss/oxide': 4.2.2 - tailwindcss: 4.2.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - '@tailwindcss/webpack@4.3.1(@rspack/core@2.3.1(@swc/helpers@0.5.23))(webpack@5.110.3)': + '@tailwindcss/webpack@4.3.1(@rspack/core@2.2.7(@swc/helpers@0.5.23))(webpack@5.110.3)': dependencies: '@alloc/quick-lru': 5.2.0 '@tailwindcss/node': 4.3.1 '@tailwindcss/oxide': 4.3.1 tailwindcss: 4.3.1 optionalDependencies: - '@rspack/core': 2.3.1(@swc/helpers@0.5.23) - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + '@rspack/core': 2.2.7(@swc/helpers@0.5.23) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) '@tanstack/devtools-client@0.0.4': dependencies: @@ -35428,11 +36292,11 @@ snapshots: - csstype - utf-8-validate - '@tanstack/eslint-config@0.3.2(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)': + '@tanstack/eslint-config@0.3.2(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@eslint/js': 9.36.0 '@stylistic/eslint-plugin': 5.4.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) - eslint-plugin-import-x: 4.16.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) eslint-plugin-n: 17.23.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) globals: 16.4.0 typescript-eslint: 8.44.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) @@ -35444,16 +36308,16 @@ snapshots: - supports-color - typescript - '@tanstack/eslint-config@0.4.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)': + '@tanstack/eslint-config@0.4.0(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: - '@eslint/js': 10.0.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) - '@stylistic/eslint-plugin': 5.10.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) - eslint-plugin-import-x: 4.16.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - eslint-plugin-n: 17.24.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) + '@eslint/js': 10.0.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + '@stylistic/eslint-plugin': 5.10.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint-plugin-n: 17.24.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) globals: 17.4.0 - typescript-eslint: 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - vue-eslint-parser: 10.4.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + typescript-eslint: 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + vue-eslint-parser: 10.4.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - '@typescript-eslint/utils' - eslint-import-resolver-node @@ -35472,48 +36336,48 @@ snapshots: '@tanstack/query-devtools@5.91.1': {} - '@tanstack/react-devtools@0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)': + '@tanstack/react-devtools@0.7.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(csstype@3.2.3)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)': dependencies: '@tanstack/devtools': 0.6.14(csstype@3.2.3)(solid-js@1.9.12) '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) transitivePeerDependencies: - bufferutil - csstype - solid-js - utf-8-validate - '@tanstack/react-query-devtools@5.67.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9)': + '@tanstack/react-query-devtools@5.67.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3)': dependencies: '@tanstack/query-devtools': 5.67.2 - '@tanstack/react-query': 5.102.0(react@19.2.9) - react: 19.2.9 + '@tanstack/react-query': 5.102.0(react@19.2.3) + react: 19.2.3 - '@tanstack/react-query-devtools@5.90.2(@tanstack/react-query@5.102.0(react@19.2.9))(react@19.2.9)': + '@tanstack/react-query-devtools@5.90.2(@tanstack/react-query@5.102.0(react@19.2.3))(react@19.2.3)': dependencies: '@tanstack/query-devtools': 5.90.1 - '@tanstack/react-query': 5.102.0(react@19.2.9) - react: 19.2.9 + '@tanstack/react-query': 5.102.0(react@19.2.3) + react: 19.2.3 - '@tanstack/react-query@5.102.0(react@19.2.9)': + '@tanstack/react-query@5.102.0(react@19.2.3)': dependencies: '@tanstack/query-core': 5.102.0 - react: 19.2.9 + react: 19.2.3 - '@tanstack/react-store@0.11.2(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@tanstack/react-store@0.11.2(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@tanstack/store': 0.11.2 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - use-sync-external-store: 1.6.0(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + use-sync-external-store: 1.6.0(react@19.2.3) - '@tanstack/react-virtual@3.13.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@tanstack/react-virtual@3.13.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@tanstack/virtual-core': 3.13.0 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) '@tanstack/solid-devtools@0.7.14(csstype@3.2.3)(solid-js@1.9.12)': dependencies: @@ -35548,48 +36412,60 @@ snapshots: '@tanstack/virtual-core@3.13.13': {} - '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) transitivePeerDependencies: - '@types/node' - rollup - supports-color - typescript - '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) transitivePeerDependencies: - '@types/node' - rollup - supports-color - typescript - '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) transitivePeerDependencies: - '@types/node' - rollup - supports-color - typescript - '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(rollup@4.63.1)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-dts: 4.2.3(@types/node@25.0.9)(rollup@4.63.1)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - vite-tsconfig-paths: 6.1.1(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-dts: 4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: 6.1.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + transitivePeerDependencies: + - '@types/node' + - rollup + - supports-color + - typescript + + '@tanstack/vite-config@0.5.2(@types/node@25.0.9)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + dependencies: + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite-plugin-dts: 4.2.3(@types/node@25.0.9)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-plugin-externalize-deps: 0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite-tsconfig-paths: 6.1.1(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) transitivePeerDependencies: - '@types/node' - rollup @@ -35614,11 +36490,11 @@ snapshots: '@tanstack/vue-query': 5.102.0(vue@3.5.25(typescript@5.8.3)) vue: 3.5.25(typescript@5.8.3) - '@tanstack/vue-query-devtools@6.1.2(@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@6.0.2)))(vue@3.5.25(typescript@6.0.2))': + '@tanstack/vue-query-devtools@6.1.2(@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@7.0.2)))(vue@3.5.25(typescript@7.0.2))': dependencies: '@tanstack/query-devtools': 5.91.1 - '@tanstack/vue-query': 5.102.0(vue@3.5.25(typescript@6.0.2)) - vue: 3.5.25(typescript@6.0.2) + '@tanstack/vue-query': 5.102.0(vue@3.5.25(typescript@7.0.2)) + vue: 3.5.25(typescript@7.0.2) '@tanstack/vue-query@5.102.0(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: @@ -35636,13 +36512,13 @@ snapshots: vue: 3.5.25(typescript@5.8.3) vue-demi: 0.14.10(vue@3.5.25(typescript@5.8.3)) - '@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@6.0.2))': + '@tanstack/vue-query@5.102.0(vue@3.5.25(typescript@7.0.2))': dependencies: '@tanstack/match-sorter-utils': 8.19.4 '@tanstack/query-core': 5.102.0 '@vue/devtools-api': 6.6.4 - vue: 3.5.25(typescript@6.0.2) - vue-demi: 0.14.10(vue@3.5.25(typescript@6.0.2)) + vue: 3.5.25(typescript@7.0.2) + vue-demi: 0.14.10(vue@3.5.25(typescript@7.0.2)) '@tanstack/vue-store@0.11.2(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: @@ -35698,24 +36574,24 @@ snapshots: picocolors: 1.1.1 redent: 3.0.0 optionalDependencies: - vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - '@testing-library/react@16.2.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@testing-library/react@16.2.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 '@testing-library/dom': 10.4.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) - '@testing-library/react@16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@testing-library/react@16.3.0(@testing-library/dom@10.4.1)(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@babel/runtime': 7.26.7 '@testing-library/dom': 10.4.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) @@ -35738,15 +36614,20 @@ snapshots: dependencies: typescript: '@typescript/typescript6@6.0.2' - '@trpc/tanstack-react-query@11.4.3(@tanstack/react-query@5.102.0(react@19.2.9))(@trpc/client@11.4.3(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2))(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@trpc/tanstack-react-query@11.4.3(@tanstack/react-query@5.102.0(react@19.2.3))(@trpc/client@11.4.3(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2))(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: - '@tanstack/react-query': 5.102.0(react@19.2.9) + '@tanstack/react-query': 5.102.0(react@19.2.3) '@trpc/client': 11.4.3(@trpc/server@11.4.3(@typescript/typescript6@6.0.2))(@typescript/typescript6@6.0.2) '@trpc/server': 11.4.3(@typescript/typescript6@6.0.2) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) typescript: '@typescript/typescript6@6.0.2' + '@tybys/wasm-util@0.10.2': + dependencies: + tslib: 2.8.1 + optional: true + '@tybys/wasm-util@0.10.3': dependencies: tslib: 2.8.1 @@ -35813,6 +36694,10 @@ snapshots: '@types/cookie@0.6.0': {} + '@types/debug@4.1.13': + dependencies: + '@types/ms': 2.1.0 + '@types/deep-eql@4.0.2': {} '@types/eslint-scope@3.7.7': @@ -35825,6 +36710,10 @@ snapshots: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 + '@types/estree-jsx@1.0.5': + dependencies: + '@types/estree': 1.0.9 + '@types/estree@1.0.7': {} '@types/estree@1.0.8': {} @@ -35858,6 +36747,10 @@ snapshots: '@types/express-serve-static-core': 5.0.6 '@types/serve-static': 2.2.0 + '@types/hast@3.0.5': + dependencies: + '@types/unist': 3.0.3 + '@types/html-minifier-terser@6.1.0': {} '@types/http-errors@2.0.4': {} @@ -35877,8 +36770,16 @@ snapshots: '@types/json-schema@7.0.15': {} + '@types/mdast@4.0.4': + dependencies: + '@types/unist': 3.0.3 + + '@types/mdx@2.0.14': {} + '@types/mime@1.3.5': {} + '@types/ms@2.1.0': {} + '@types/node-forge@1.3.14': dependencies: '@types/node': 25.0.9 @@ -35951,6 +36852,10 @@ snapshots: '@types/triple-beam@1.3.5': {} + '@types/unist@2.0.11': {} + + '@types/unist@3.0.3': {} + '@types/ws@8.5.14': dependencies: '@types/node': 25.0.9 @@ -35989,16 +36894,16 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/eslint-plugin@8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)': + '@typescript-eslint/eslint-plugin@8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: '@eslint-community/regexpp': 4.12.2 - '@typescript-eslint/parser': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + '@typescript-eslint/parser': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) '@typescript-eslint/scope-manager': 8.57.1 - '@typescript-eslint/type-utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + '@typescript-eslint/type-utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) '@typescript-eslint/visitor-keys': 8.57.1 - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) - ignore: 7.0.12 + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + ignore: 7.0.5 natural-compare: 1.4.0 ts-api-utils: 2.4.0(@typescript/typescript6@6.0.2) typescript: '@typescript/typescript6@6.0.2' @@ -36053,14 +36958,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2)': + '@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)': dependencies: '@typescript-eslint/scope-manager': 8.57.1 '@typescript-eslint/types': 8.57.1 - '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2) + '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0) '@typescript-eslint/visitor-keys': 8.57.1 - debug: 4.4.3(supports-color@10.2.2) - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color @@ -36110,6 +37015,15 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/project-service@8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.57.1(@typescript/typescript6@6.0.2) + '@typescript-eslint/types': 8.57.1 + debug: 4.4.3(supports-color@7.2.0) + typescript: '@typescript/typescript6@6.0.2' + transitivePeerDependencies: + - supports-color + '@typescript-eslint/project-service@8.57.1(supports-color@10.2.2)(typescript@5.9.3)': dependencies: '@typescript-eslint/tsconfig-utils': 8.57.1(typescript@5.9.3) @@ -36234,6 +37148,18 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/type-utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@typescript-eslint/types': 8.57.1 + '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0) + '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + ts-api-utils: 2.4.0(@typescript/typescript6@6.0.2) + typescript: '@typescript/typescript6@6.0.2' + transitivePeerDependencies: + - supports-color + '@typescript-eslint/types@8.23.0': {} '@typescript-eslint/types@8.44.1': {} @@ -36250,7 +37176,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.9 - semver: 7.8.5 + semver: 7.8.2 ts-api-utils: 2.4.0(@typescript/typescript6@6.0.2) typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: @@ -36266,7 +37192,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.9 - semver: 7.8.5 + semver: 7.8.2 ts-api-utils: 2.1.0(@typescript/typescript6@6.0.2) typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: @@ -36282,7 +37208,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.9 - semver: 7.8.5 + semver: 7.8.2 ts-api-utils: 2.1.0(typescript@5.8.3) typescript: 5.8.3 transitivePeerDependencies: @@ -36298,7 +37224,7 @@ snapshots: fast-glob: 3.3.3 is-glob: 4.0.3 minimatch: 9.0.9 - semver: 7.8.5 + semver: 7.8.2 ts-api-utils: 2.1.0(typescript@5.9.2) typescript: 5.9.2 transitivePeerDependencies: @@ -36312,7 +37238,7 @@ snapshots: '@typescript-eslint/visitor-keys': 8.53.0 debug: 4.4.3(supports-color@10.2.2) minimatch: 9.0.9 - semver: 7.8.5 + semver: 7.8.2 tinyglobby: 0.2.17 ts-api-utils: 2.4.0(typescript@5.9.2) typescript: 5.9.2 @@ -36334,6 +37260,21 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/typescript-estree@8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0)': + dependencies: + '@typescript-eslint/project-service': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0) + '@typescript-eslint/tsconfig-utils': 8.57.1(@typescript/typescript6@6.0.2) + '@typescript-eslint/types': 8.57.1 + '@typescript-eslint/visitor-keys': 8.57.1 + debug: 4.4.3(supports-color@7.2.0) + minimatch: 10.2.5 + semver: 7.8.5 + tinyglobby: 0.2.17 + ts-api-utils: 2.4.0(@typescript/typescript6@6.0.2) + typescript: '@typescript/typescript6@6.0.2' + transitivePeerDependencies: + - supports-color + '@typescript-eslint/typescript-estree@8.57.1(supports-color@10.2.2)(typescript@5.9.3)': dependencies: '@typescript-eslint/project-service': 8.57.1(supports-color@10.2.2)(typescript@5.9.3) @@ -36415,6 +37356,17 @@ snapshots: transitivePeerDependencies: - supports-color + '@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + '@typescript-eslint/scope-manager': 8.57.1 + '@typescript-eslint/types': 8.57.1 + '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + typescript: '@typescript/typescript6@6.0.2' + transitivePeerDependencies: + - supports-color + '@typescript-eslint/visitor-keys@8.23.0': dependencies: '@typescript-eslint/types': 8.23.0 @@ -36499,6 +37451,8 @@ snapshots: dependencies: '@typescript/old': typescript@6.0.2 + '@ungap/structured-clone@1.4.0': {} + '@unrs/resolver-binding-android-arm-eabi@1.11.1': optional: true @@ -36577,142 +37531,154 @@ snapshots: - rollup - supports-color - '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.7 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) optionalDependencies: - '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.0(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) babel-plugin-react-compiler: 1.0.0 - '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.7 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) optionalDependencies: - '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) babel-plugin-react-compiler: 1.0.0 - '@vitejs/plugin-react@6.0.1(@rolldown/plugin-babel@0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)))(babel-plugin-react-compiler@1.0.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': - dependencies: - '@rolldown/pluginutils': 1.0.0-rc.7 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - optionalDependencies: - '@rolldown/plugin-babel': 0.2.3(@babel/core@7.29.7(supports-color@10.2.2))(rolldown@1.2.13)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - babel-plugin-react-compiler: 1.0.0 - - '@vitejs/plugin-rsc@0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitejs/plugin-rsc@0.5.37(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@rolldown/pluginutils': 1.0.1 - es-module-lexer: 3.0.4 + es-module-lexer: 3.0.3 estree-walker: 3.0.3 - magic-string: 1.4.5 + magic-string: 1.4.3 obug: 3.0.0 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - srvx: 1.0.8 + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + srvx: 1.0.5 strip-literal: 4.0.0 turbo-stream: 3.2.1 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - '@vitejs/plugin-rsc@0.5.39(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': - dependencies: - '@rolldown/pluginutils': 1.0.1 - es-module-lexer: 3.0.4 - estree-walker: 3.0.3 - magic-string: 1.4.5 - obug: 3.0.0 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - srvx: 1.0.8 - strip-literal: 4.0.0 - turbo-stream: 3.2.1 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - - '@vitejs/plugin-vue-jsx@4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': + '@vitejs/plugin-vue-jsx@4.2.0(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) '@rolldown/pluginutils': 1.0.1 '@vue/babel-plugin-jsx': 1.5.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(@typescript/typescript6@6.0.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': + '@vitejs/plugin-vue-jsx@4.2.0(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@rolldown/pluginutils': 1.0.1 + '@vue/babel-plugin-jsx': 1.5.0(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vue: 3.5.25(@typescript/typescript6@6.0.2) + transitivePeerDependencies: + - supports-color + + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2)) '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) '@rolldown/pluginutils': 1.0.0-rc.9 '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(@typescript/typescript6@6.0.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3))': + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3))': dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2)) '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) '@rolldown/pluginutils': 1.0.0-rc.9 '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(typescript@5.8.3) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3))': + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2)) - '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) '@rolldown/pluginutils': 1.0.0-rc.9 - '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vue: 3.5.25(@typescript/typescript6@6.0.2) + transitivePeerDependencies: + - supports-color + + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3))': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@rolldown/pluginutils': 1.0.0-rc.9 + '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vue: 3.5.25(typescript@5.8.3) + transitivePeerDependencies: + - supports-color + + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3))': + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@rolldown/pluginutils': 1.0.0-rc.9 + '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(typescript@5.9.3) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@5.1.5(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@6.0.2))': + '@vitejs/plugin-vue-jsx@5.1.5(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@7.0.2))': dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2)) - '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/plugin-syntax-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/plugin-transform-typescript': 7.28.6(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) '@rolldown/pluginutils': 1.0.0-rc.9 - '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vue: 3.5.25(typescript@6.0.2) + '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vue: 3.5.25(typescript@7.0.2) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': + '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(@typescript/typescript6@6.0.2))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(@typescript/typescript6@6.0.2) - '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3))': + '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.8.3))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(typescript@5.8.3) - '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3))': + '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@5.9.3))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) vue: 3.5.25(typescript@5.9.3) - '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@6.0.2))': + '@vitejs/plugin-vue@6.0.5(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(vue@3.5.25(typescript@7.0.2))': dependencies: '@rolldown/pluginutils': 1.0.0-rc.2 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vue: 3.5.25(typescript@6.0.2) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vue: 3.5.25(typescript@7.0.2) '@vitest/expect@4.1.4': dependencies: @@ -36724,17 +37690,17 @@ snapshots: tinyrainbow: 3.2.0 optional: true - '@vitest/mocker@4.1.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitest/mocker@4.1.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@vitest/spy': 4.1.4 estree-walker: 3.0.3 magic-string: 0.30.21 optionalDependencies: msw: 2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) optional: true - '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.4 @@ -36742,9 +37708,9 @@ snapshots: magic-string: 1.4.3 optionalDependencies: msw: 2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.4 @@ -36752,19 +37718,9 @@ snapshots: magic-string: 1.4.3 optionalDependencies: msw: 2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': - dependencies: - '@jridgewell/trace-mapping': 0.3.31 - '@vitest/spy': 5.0.4 - estree-walker: 3.0.3 - magic-string: 1.4.3 - optionalDependencies: - msw: 2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.4 @@ -36772,7 +37728,17 @@ snapshots: magic-string: 1.4.3 optionalDependencies: msw: 2.15.0(@types/node@25.0.9)(typescript@5.9.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + + '@vitest/mocker@5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))': + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + '@vitest/spy': 5.0.4 + estree-walker: 3.0.3 + magic-string: 1.4.3 + optionalDependencies: + msw: 2.15.0(@types/node@25.0.9)(typescript@6.0.2) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) '@vitest/pretty-format@4.1.4': dependencies: @@ -36811,7 +37777,7 @@ snapshots: sirv: 3.0.2 tinyglobby: 0.2.17 tinyrainbow: 3.2.0 - vitest: 4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vitest: 4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optional: true '@vitest/ui@5.0.4(vitest@5.0.4)': @@ -36822,7 +37788,7 @@ snapshots: pathe: 2.0.3 sirv: 3.0.2 tinyrainbow: 3.2.0 - vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vitest: 5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitest/utils@4.1.4': dependencies: @@ -36909,6 +37875,22 @@ snapshots: transitivePeerDependencies: - supports-color + '@vue/babel-plugin-jsx@1.5.0(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.28.6 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + '@vue/babel-helper-vue-transform-on': 1.5.0 + '@vue/babel-plugin-resolve-type': 1.5.0(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@vue/shared': 3.5.25 + optionalDependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + '@vue/babel-plugin-jsx@2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/helper-module-imports': 7.27.1(supports-color@10.2.2) @@ -36925,6 +37907,22 @@ snapshots: transitivePeerDependencies: - supports-color + '@vue/babel-plugin-jsx@2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/helper-module-imports': 7.27.1(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.27.1 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/template': 7.29.7 + '@babel/traverse': 7.29.8(supports-color@7.2.0) + '@babel/types': 7.29.8 + '@vue/babel-helper-vue-transform-on': 2.0.1 + '@vue/babel-plugin-resolve-type': 2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + '@vue/shared': 3.5.25 + optionalDependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + '@vue/babel-plugin-resolve-type@1.5.0(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/code-frame': 7.29.7 @@ -36936,11 +37934,33 @@ snapshots: transitivePeerDependencies: - supports-color + '@vue/babel-plugin-resolve-type@1.5.0(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) + '@babel/helper-plugin-utils': 7.28.6 + '@babel/parser': 7.29.8 + '@vue/compiler-sfc': 3.5.25 + transitivePeerDependencies: + - supports-color + '@vue/babel-plugin-resolve-type@2.0.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2)': dependencies: '@babel/code-frame': 7.29.7 '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/helper-module-imports': 7.27.1(supports-color@10.2.2) + '@babel/helper-module-imports': 7.29.7(supports-color@10.2.2) + '@babel/helper-plugin-utils': 7.28.6 + '@babel/parser': 7.29.8 + '@vue/compiler-sfc': 3.5.25 + transitivePeerDependencies: + - supports-color + + '@vue/babel-plugin-resolve-type@2.0.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0)': + dependencies: + '@babel/code-frame': 7.29.7 + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.29.7(supports-color@7.2.0) '@babel/helper-plugin-utils': 7.28.6 '@babel/parser': 7.29.8 '@vue/compiler-sfc': 3.5.25 @@ -37054,11 +38074,11 @@ snapshots: '@vue/shared': 3.5.25 vue: 3.5.25(typescript@5.9.3) - '@vue/server-renderer@3.5.25(vue@3.5.25(typescript@6.0.2))': + '@vue/server-renderer@3.5.25(vue@3.5.25(typescript@7.0.2))': dependencies: '@vue/compiler-ssr': 3.5.25 '@vue/shared': 3.5.25 - vue: 3.5.25(typescript@6.0.2) + vue: 3.5.25(typescript@7.0.2) '@vue/shared@3.5.25': {} @@ -37145,7 +38165,7 @@ snapshots: '@webpack-cli/configtest@2.1.1(webpack-cli@5.1.4)(webpack@5.110.3)': dependencies: - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.110.3) optional: true @@ -37156,7 +38176,7 @@ snapshots: '@webpack-cli/info@2.0.2(webpack-cli@5.1.4)(webpack@5.110.3)': dependencies: - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.110.3) optional: true @@ -37167,10 +38187,10 @@ snapshots: '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.2.4)(webpack@5.110.3)': dependencies: - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.110.3) optionalDependencies: - webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3) + webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3) optional: true '@webpack-cli/serve@2.0.5(webpack-cli@5.1.4)(webpack-dev-server@5.2.4)(webpack@5.97.1)': @@ -37178,7 +38198,7 @@ snapshots: webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.27.4)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.97.1) optionalDependencies: - webpack-dev-server: 5.2.4(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) + webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) '@whatwg-node/disposablestack@0.0.6': dependencies: @@ -37220,13 +38240,13 @@ snapshots: iron-webcrypto: 2.0.0 jose: 6.1.3 - '@workos/authkit-tanstack-react-start@0.5.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)': + '@workos/authkit-tanstack-react-start@0.5.0(@tanstack/react-router@packages+react-router)(@tanstack/react-start@packages+react-start)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)': dependencies: '@tanstack/react-router': link:packages/react-router '@tanstack/react-start': link:packages/react-start '@workos/authkit-session': 0.3.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) '@xtuc/ieee754@1.2.0': {} @@ -37266,6 +38286,10 @@ snapshots: dependencies: acorn: 8.15.0 + acorn-jsx@5.3.2(acorn@8.18.0): + dependencies: + acorn: 8.18.0 + acorn@8.14.1: {} acorn@8.15.0: {} @@ -37278,6 +38302,12 @@ snapshots: transitivePeerDependencies: - supports-color + agent-base@6.0.2(supports-color@7.2.0): + dependencies: + debug: 4.4.3(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + agent-base@7.1.3: {} ajv-draft-04@1.0.0(ajv@8.13.0): @@ -37288,12 +38318,16 @@ snapshots: dependencies: ajv: 8.18.0 - ajv-formats@2.1.1: - dependencies: + ajv-formats@2.1.1(ajv@8.18.0): + optionalDependencies: ajv: 8.18.0 - ajv-formats@3.0.1: - dependencies: + ajv-formats@3.0.1(ajv@8.13.0): + optionalDependencies: + ajv: 8.13.0 + + ajv-formats@3.0.1(ajv@8.17.1): + optionalDependencies: ajv: 8.17.1 ajv-keywords@3.5.2(ajv@6.12.6): @@ -37434,6 +38468,8 @@ snapshots: ast-module-types@6.0.1: {} + astring@1.9.0: {} + async-mutex@0.5.0: dependencies: tslib: 2.8.1 @@ -37488,9 +38524,9 @@ snapshots: aws-ssl-profiles@1.1.2: {} - axios@1.18.1(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2): + axios@1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2): dependencies: - follow-redirects: 1.16.0(debug@4.4.3(supports-color@10.2.2)) + follow-redirects: 1.16.0(debug@4.4.3(supports-color@7.2.0)) form-data: 4.0.6 https-proxy-agent: 5.0.1(supports-color@10.2.2) proxy-from-env: 2.1.0 @@ -37498,6 +38534,16 @@ snapshots: - debug - supports-color + axios@1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0): + dependencies: + follow-redirects: 1.16.0(debug@4.4.3(supports-color@7.2.0)) + form-data: 4.0.6 + https-proxy-agent: 5.0.1(supports-color@7.2.0) + proxy-from-env: 2.1.0 + transitivePeerDependencies: + - debug + - supports-color + b4a@1.6.7: {} babel-dead-code-elimination@1.0.12(supports-color@10.2.2): @@ -37513,7 +38559,22 @@ snapshots: dependencies: '@babel/core': 7.28.5(supports-color@10.2.2) find-up: 5.0.0 - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) + + babel-loader@10.0.0(@babel/core@7.29.7(supports-color@10.2.2))(webpack@5.110.3): + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + find-up: 5.0.0 + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + + babel-plugin-jsx-dom-expressions@0.40.11(@babel/core@7.29.7(supports-color@10.2.2)): + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2)) + '@babel/types': 7.29.8 + html-entities: 2.3.3 + parse5: 7.3.0 babel-plugin-jsx-dom-expressions@0.40.3(@babel/core@7.28.5(supports-color@10.2.2)): dependencies: @@ -37533,6 +38594,15 @@ snapshots: html-entities: 2.3.3 parse5: 7.3.0 + babel-plugin-jsx-dom-expressions@0.40.3(@babel/core@7.29.7(supports-color@7.2.0)): + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/helper-module-imports': 7.18.6 + '@babel/plugin-syntax-jsx': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0)) + '@babel/types': 7.29.8 + html-entities: 2.3.3 + parse5: 7.3.0 + babel-plugin-macros@3.1.0: dependencies: '@babel/runtime': 7.26.7 @@ -37564,6 +38634,22 @@ snapshots: optionalDependencies: solid-js: 1.9.12 + babel-preset-solid@1.9.10(@babel/core@7.29.7(supports-color@7.2.0))(solid-js@1.9.12): + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + babel-plugin-jsx-dom-expressions: 0.40.3(@babel/core@7.29.7(supports-color@7.2.0)) + optionalDependencies: + solid-js: 1.9.12 + + babel-preset-solid@1.9.16(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12): + dependencies: + '@babel/core': 7.29.7(supports-color@10.2.2) + babel-plugin-jsx-dom-expressions: 0.40.11(@babel/core@7.29.7(supports-color@10.2.2)) + optionalDependencies: + solid-js: 1.9.12 + + bail@2.0.2: {} + balanced-match@1.0.2: {} balanced-match@4.0.3: {} @@ -37614,14 +38700,14 @@ snapshots: jsonpointer: 5.0.1 leven: 3.1.0 - better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)): + better-auth@1.6.19(@opentelemetry/api@1.9.1)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(@tanstack/solid-start@packages+solid-start)(mysql2@3.15.3)(next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(solid-js@1.9.12)(vitest@4.1.4)(vue@3.5.25(@typescript/typescript6@6.0.2)): dependencies: '@better-auth/core': 1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0) '@better-auth/drizzle-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2) '@better-auth/kysely-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(kysely@0.29.2) '@better-auth/memory-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2) '@better-auth/mongo-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2) - '@better-auth/prisma-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + '@better-auth/prisma-adapter': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@prisma/client@7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)))(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@better-auth/telemetry': 1.6.19(@better-auth/core@1.6.19(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1)(@opentelemetry/api@1.9.1)(better-call@1.3.6(zod@4.5.4))(jose@6.1.3)(kysely@0.29.2)(nanostores@1.3.0))(@better-auth/utils@0.4.2)(@better-fetch/fetch@1.3.1) '@better-auth/utils': 0.4.2 '@better-fetch/fetch': 1.3.1 @@ -37634,15 +38720,15 @@ snapshots: nanostores: 1.3.0 zod: 4.5.4 optionalDependencies: - '@prisma/client': 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)) + '@prisma/client': 7.0.0(@typescript/typescript6@6.0.2)(prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)) '@tanstack/solid-start': link:packages/solid-start mysql2: 3.15.3 - next: 16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1) - prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + next: 16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1) + prisma: 7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) solid-js: 1.9.12 - vitest: 4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vitest: 4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) vue: 3.5.25(@typescript/typescript6@6.0.2) transitivePeerDependencies: - '@cloudflare/workers-types' @@ -37730,10 +38816,6 @@ snapshots: dependencies: balanced-match: 1.0.2 - brace-expansion@5.0.12: - dependencies: - balanced-match: 4.0.4 - brace-expansion@5.0.9: dependencies: balanced-match: 4.0.4 @@ -37792,7 +38874,7 @@ snapshots: confbox: 0.2.2 defu: 6.1.4 dotenv: 16.6.1 - exsolve: 1.1.1 + exsolve: 1.1.3 giget: 2.0.0 jiti: 2.7.0 ohash: 2.0.11 @@ -37833,17 +38915,7 @@ snapshots: caniuse-lite@1.0.30001760: {} - cf@1.0.0-beta.28(@types/node@25.0.9): - dependencies: - '@cloudflare/build-output-utils': 0.9.10 - '@cloudflare/config': 0.30.2 - '@cloudflare/runtime-types': 0.1.23(@types/node@25.0.9) - blake3-wasm: 2.1.5 - miniflare: 5.20261104.0-beta(@types/node@25.0.9) - transitivePeerDependencies: - - '@types/node' - - bufferutil - - utf-8-validate + ccount@2.0.1: {} chai@6.3.0: {} @@ -37866,6 +38938,14 @@ snapshots: char-spinner@1.0.1: {} + character-entities-html4@2.1.0: {} + + character-entities-legacy@3.0.0: {} + + character-entities@2.0.2: {} + + character-reference-invalid@2.0.1: {} + chardet@2.1.1: {} cheerio-select@2.1.0: @@ -37992,6 +39072,8 @@ snapshots: cluster-key-slot@1.1.1: optional: true + collapse-white-space@2.1.0: {} + color-convert@2.0.1: dependencies: color-name: 1.1.4 @@ -38025,6 +39107,8 @@ snapshots: dependencies: delayed-stream: 1.0.0 + comma-separated-tokens@2.0.3: {} + commander@10.0.1: {} commander@11.1.0: {} @@ -38141,43 +39225,43 @@ snapshots: convert-source-map@2.0.0: {} - convex-helpers@0.1.104(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9))(hono@4.13.9)(react@19.2.9)(zod@3.25.76): + convex-helpers@0.1.104(@standard-schema/spec@1.1.0)(@typescript/typescript6@6.0.2)(convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3))(hono@4.13.9)(react@19.2.3)(zod@3.25.76): dependencies: - convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9) + convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3) optionalDependencies: '@standard-schema/spec': 1.1.0 hono: 4.13.9 - react: 19.2.9 + react: 19.2.3 typescript: '@typescript/typescript6@6.0.2' zod: 3.25.76 - convex-solidjs@0.0.3(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9)(solid-js@1.9.12): + convex-solidjs@0.0.3(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3)(solid-js@1.9.12): dependencies: '@solid-primitives/context': 0.3.2(solid-js@1.9.12) - convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9) + convex: 1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3) solid-js: 1.9.12 transitivePeerDependencies: - '@auth0/auth0-react' - '@clerk/clerk-react' - react - convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + convex@1.19.0(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: esbuild: 0.23.0 jwt-decode: 3.1.2 prettier: 3.4.2 optionalDependencies: - '@clerk/clerk-react': 5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@clerk/clerk-react': 5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) - convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9))(react@19.2.9): + convex@1.28.2(@clerk/clerk-react@5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3))(react@19.2.3): dependencies: esbuild: 0.25.4 prettier: 3.8.1 optionalDependencies: - '@clerk/clerk-react': 5.59.3(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 + '@clerk/clerk-react': 5.59.3(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 cookie-es@1.2.3: {} @@ -38262,7 +39346,7 @@ snapshots: postcss-value-parser: 4.2.0 semver: 7.7.3 optionalDependencies: - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) css-select@4.3.0: dependencies: @@ -38288,7 +39372,7 @@ snapshots: css-tree@3.2.1: dependencies: mdn-data: 2.27.1 - source-map-js: 1.2.1 + source-map-js: 1.2.2 css-what@6.1.0: {} @@ -38358,12 +39442,22 @@ snapshots: optionalDependencies: supports-color: 10.2.2 + debug@4.4.3(supports-color@7.2.0): + dependencies: + ms: 2.1.3 + optionalDependencies: + supports-color: 7.2.0 + decache@4.6.2: dependencies: callsite: 1.0.0 decimal.js@10.6.0: {} + decode-named-character-reference@1.3.0: + dependencies: + character-entities: 2.0.2 + dedent@1.5.1(babel-plugin-macros@3.1.0): optionalDependencies: babel-plugin-macros: 3.1.0 @@ -38399,6 +39493,8 @@ snapshots: deepmerge@4.3.1: {} + default-browser-id@5.0.0: {} + default-browser-id@5.0.1: {} default-browser@5.2.1: @@ -38515,6 +39611,10 @@ snapshots: dettle@1.0.5: {} + devlop@1.1.0: + dependencies: + dequal: 2.0.3 + dexie@4.2.1: {} diff@9.0.0: {} @@ -38692,7 +39792,7 @@ snapshots: env-runner@0.2.3: dependencies: crossws: 0.4.12(srvx@1.0.5) - exsolve: 1.1.1 + exsolve: 1.1.3 httpxy: 0.5.5 srvx: 1.0.5 @@ -38730,7 +39830,9 @@ snapshots: es-module-lexer@3.0.3: {} - es-module-lexer@3.0.4: {} + es-object-atoms@1.1.1: + dependencies: + es-errors: 1.3.0 es-object-atoms@1.1.2: dependencies: @@ -38743,23 +39845,37 @@ snapshots: has-tostringtag: 1.0.2 hasown: 2.0.4 - esbuild-plugin-solid@0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@10.2.2): + esast-util-from-estree@2.0.0: dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) - '@babel/preset-typescript': 7.27.1(@babel/core@7.29.7(supports-color@10.2.2))(supports-color@10.2.2) - babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) + '@types/estree-jsx': 1.0.5 + devlop: 1.1.0 + estree-util-visit: 2.0.0 + unist-util-position-from-estree: 2.0.0 + + esast-util-from-js@2.0.1: + dependencies: + '@types/estree-jsx': 1.0.5 + acorn: 8.18.0 + esast-util-from-estree: 2.0.0 + vfile-message: 4.0.3 + + esbuild-plugin-solid@0.6.0(esbuild@0.27.4)(solid-js@1.9.12)(supports-color@7.2.0): + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@babel/preset-typescript': 7.27.1(@babel/core@7.29.7(supports-color@7.2.0))(supports-color@7.2.0) + babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@7.2.0))(solid-js@1.9.12) esbuild: 0.27.4 solid-js: 1.9.12 transitivePeerDependencies: - supports-color - esbuild-plugin-vue3@0.5.1(cheerio@1.0.0)(sass@1.97.2)(vue@3.5.25(@typescript/typescript6@6.0.2)): + esbuild-plugin-vue3@0.5.1(cheerio@1.0.0)(sass@1.105.1)(vue@3.5.25(@typescript/typescript6@6.0.2)): dependencies: typescript: 4.9.5 vue: 3.5.25(@typescript/typescript6@6.0.2) optionalDependencies: cheerio: 1.0.0 - sass: 1.97.2 + sass: 1.105.1 esbuild@0.23.0: optionalDependencies: @@ -38932,6 +40048,35 @@ snapshots: '@esbuild/win32-ia32': 0.28.1 '@esbuild/win32-x64': 0.28.1 + esbuild@0.28.2: + optionalDependencies: + '@esbuild/aix-ppc64': 0.28.2 + '@esbuild/android-arm': 0.28.2 + '@esbuild/android-arm64': 0.28.2 + '@esbuild/android-x64': 0.28.2 + '@esbuild/darwin-arm64': 0.28.2 + '@esbuild/darwin-x64': 0.28.2 + '@esbuild/freebsd-arm64': 0.28.2 + '@esbuild/freebsd-x64': 0.28.2 + '@esbuild/linux-arm': 0.28.2 + '@esbuild/linux-arm64': 0.28.2 + '@esbuild/linux-ia32': 0.28.2 + '@esbuild/linux-loong64': 0.28.2 + '@esbuild/linux-mips64el': 0.28.2 + '@esbuild/linux-ppc64': 0.28.2 + '@esbuild/linux-riscv64': 0.28.2 + '@esbuild/linux-s390x': 0.28.2 + '@esbuild/linux-x64': 0.28.2 + '@esbuild/netbsd-arm64': 0.28.2 + '@esbuild/netbsd-x64': 0.28.2 + '@esbuild/openbsd-arm64': 0.28.2 + '@esbuild/openbsd-x64': 0.28.2 + '@esbuild/openharmony-arm64': 0.28.2 + '@esbuild/sunos-x64': 0.28.2 + '@esbuild/win32-arm64': 0.28.2 + '@esbuild/win32-ia32': 0.28.2 + '@esbuild/win32-x64': 0.28.2 + escalade@3.2.0: {} escape-html@1.0.3: {} @@ -38955,6 +40100,11 @@ snapshots: eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) semver: 7.8.5 + eslint-compat-utils@0.5.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)): + dependencies: + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + semver: 7.8.5 + eslint-import-context@0.1.9(unrs-resolver@1.11.1): dependencies: get-tsconfig: 4.10.1 @@ -38969,7 +40119,14 @@ snapshots: eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) eslint-compat-utils: 0.5.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) - eslint-plugin-import-x@4.16.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): + eslint-plugin-es-x@7.8.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)): + dependencies: + '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + '@eslint-community/regexpp': 4.12.1 + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-compat-utils: 0.5.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + + eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): dependencies: '@typescript-eslint/types': 8.53.0 comment-parser: 1.4.1 @@ -38978,9 +40135,28 @@ snapshots: eslint-import-context: 0.1.9(unrs-resolver@1.11.1) is-glob: 4.0.3 minimatch: 10.2.5 - semver: 7.8.5 + semver: 7.8.2 stable-hash-x: 0.2.0 unrs-resolver: 1.11.1 + optionalDependencies: + '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) + transitivePeerDependencies: + - supports-color + + eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): + dependencies: + '@typescript-eslint/types': 8.53.0 + comment-parser: 1.4.1 + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-import-context: 0.1.9(unrs-resolver@1.11.1) + is-glob: 4.0.3 + minimatch: 10.2.5 + semver: 7.8.2 + stable-hash-x: 0.2.0 + unrs-resolver: 1.11.1 + optionalDependencies: + '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) transitivePeerDependencies: - supports-color @@ -38994,22 +40170,22 @@ snapshots: globals: 15.14.0 globrex: 0.1.2 ignore: 5.3.2 - semver: 7.8.5 + semver: 7.8.2 ts-declaration-location: 1.0.7(@typescript/typescript6@6.0.2) transitivePeerDependencies: - typescript - eslint-plugin-n@17.24.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)): + eslint-plugin-n@17.24.0(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)): dependencies: - '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) + '@eslint-community/eslint-utils': 4.9.1(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) enhanced-resolve: 5.18.3 - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) - eslint-plugin-es-x: 7.8.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + eslint-plugin-es-x: 7.8.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) get-tsconfig: 4.10.1 globals: 15.14.0 globrex: 0.1.2 ignore: 5.3.2 - semver: 7.8.5 + semver: 7.8.2 ts-declaration-location: 1.0.7(@typescript/typescript6@6.0.2) transitivePeerDependencies: - typescript @@ -39152,9 +40328,11 @@ snapshots: transitivePeerDependencies: - supports-color - eslint-plugin-unused-imports@4.1.4(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2)): + eslint-plugin-unused-imports@4.1.4(@typescript-eslint/eslint-plugin@8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)): dependencies: - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) + optionalDependencies: + '@typescript-eslint/eslint-plugin': 8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) eslint-plugin-vue@9.33.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): dependencies: @@ -39233,6 +40411,48 @@ snapshots: transitivePeerDependencies: - supports-color + eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0): + dependencies: + '@eslint-community/eslint-utils': 4.9.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0)) + '@eslint-community/regexpp': 4.12.1 + '@eslint/config-array': 0.19.2(supports-color@7.2.0) + '@eslint/config-helpers': 0.1.0 + '@eslint/core': 0.12.0 + '@eslint/eslintrc': 3.3.0(supports-color@7.2.0) + '@eslint/js': 9.22.0 + '@eslint/plugin-kit': 0.2.7 + '@humanfs/node': 0.16.6 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.2 + '@types/estree': 1.0.8 + '@types/json-schema': 7.0.15 + ajv: 6.12.6 + chalk: 4.1.2 + cross-spawn: 7.0.6 + debug: 4.4.3(supports-color@7.2.0) + escape-string-regexp: 4.0.0 + eslint-scope: 8.3.0 + eslint-visitor-keys: 4.2.1 + espree: 10.4.0 + esquery: 1.6.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 8.0.0 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + lodash.merge: 4.6.2 + minimatch: 3.1.2 + natural-compare: 1.4.0 + optionator: 0.9.4 + optionalDependencies: + jiti: 2.7.0 + transitivePeerDependencies: + - supports-color + espree@10.4.0: dependencies: acorn: 8.15.0 @@ -39259,6 +40479,35 @@ snapshots: estraverse@5.3.0: {} + estree-util-attach-comments@3.0.0: + dependencies: + '@types/estree': 1.0.9 + + estree-util-build-jsx@3.0.1: + dependencies: + '@types/estree-jsx': 1.0.5 + devlop: 1.1.0 + estree-util-is-identifier-name: 3.0.0 + estree-walker: 3.0.3 + + estree-util-is-identifier-name@3.0.0: {} + + estree-util-scope@1.0.1: + dependencies: + '@types/estree': 1.0.9 + devlop: 1.1.0 + + estree-util-to-js@2.0.0: + dependencies: + '@types/estree-jsx': 1.0.5 + astring: 1.9.0 + source-map: 0.7.6 + + estree-util-visit@2.0.0: + dependencies: + '@types/estree-jsx': 1.0.5 + '@types/unist': 3.0.3 + estree-walker@2.0.2: {} estree-walker@3.0.3: @@ -39364,9 +40613,9 @@ snapshots: transitivePeerDependencies: - supports-color - exsolve@1.1.1: {} + exsolve@1.1.3: {} - exsolve@1.2.0: {} + extend@3.0.2: {} extendable-error@0.1.7: {} @@ -39394,7 +40643,7 @@ snapshots: dependencies: '@fastify/merge-json-schemas': 0.2.1 ajv: 8.17.1 - ajv-formats: 3.0.1 + ajv-formats: 3.0.1(ajv@8.17.1) fast-uri: 3.0.6 json-schema-ref-resolver: 3.0.0 rfdc: 1.4.1 @@ -39438,7 +40687,7 @@ snapshots: process-warning: 5.0.0 rfdc: 1.4.1 secure-json-parse: 4.1.0 - semver: 7.8.5 + semver: 7.8.2 toad-cache: 3.7.0 fastq@1.19.0: @@ -39587,6 +40836,10 @@ snapshots: optionalDependencies: debug: 4.4.3(supports-color@10.2.2) + follow-redirects@1.16.0(debug@4.4.3(supports-color@7.2.0)): + optionalDependencies: + debug: 4.4.3(supports-color@7.2.0) + for-each@0.3.5: dependencies: is-callable: 1.2.7 @@ -39618,15 +40871,15 @@ snapshots: forwarded@0.2.0: {} - framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + framer-motion@11.18.2(@emotion/is-prop-valid@1.3.1)(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: motion-dom: 11.18.1 motion-utils: 11.18.1 tslib: 2.8.1 optionalDependencies: '@emotion/is-prop-valid': 1.3.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) fresh@0.5.2: {} @@ -39829,6 +41082,51 @@ snapshots: dependencies: function-bind: 1.1.2 + hast-util-to-estree@3.1.3(supports-color@10.2.2): + dependencies: + '@types/estree': 1.0.9 + '@types/estree-jsx': 1.0.5 + '@types/hast': 3.0.5 + comma-separated-tokens: 2.0.3 + devlop: 1.1.0 + estree-util-attach-comments: 3.0.0 + estree-util-is-identifier-name: 3.0.0 + hast-util-whitespace: 3.0.0 + mdast-util-mdx-expression: 2.0.1(supports-color@10.2.2) + mdast-util-mdx-jsx: 3.2.0(supports-color@10.2.2) + mdast-util-mdxjs-esm: 2.0.1(supports-color@10.2.2) + property-information: 7.2.0 + space-separated-tokens: 2.0.2 + style-to-js: 1.1.21 + unist-util-position: 5.0.0 + zwitch: 2.0.4 + transitivePeerDependencies: + - supports-color + + hast-util-to-jsx-runtime@2.3.6(supports-color@10.2.2): + dependencies: + '@types/estree': 1.0.9 + '@types/hast': 3.0.5 + '@types/unist': 3.0.3 + comma-separated-tokens: 2.0.3 + devlop: 1.1.0 + estree-util-is-identifier-name: 3.0.0 + hast-util-whitespace: 3.0.0 + mdast-util-mdx-expression: 2.0.1(supports-color@10.2.2) + mdast-util-mdx-jsx: 3.2.0(supports-color@10.2.2) + mdast-util-mdxjs-esm: 2.0.1(supports-color@10.2.2) + property-information: 7.2.0 + space-separated-tokens: 2.0.2 + style-to-js: 1.1.21 + unist-util-position: 5.0.0 + vfile-message: 4.0.3 + transitivePeerDependencies: + - supports-color + + hast-util-whitespace@3.0.0: + dependencies: + '@types/hast': 3.0.5 + hdr-histogram-js@3.0.1: dependencies: '@assemblyscript/loader': 0.19.23 @@ -39967,10 +41265,10 @@ snapshots: transitivePeerDependencies: - supports-color - http-proxy-middleware@2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@10.2.2)): + http-proxy-middleware@2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@7.2.0)): dependencies: '@types/http-proxy': 1.17.15 - http-proxy: 1.18.1(debug@4.4.3(supports-color@10.2.2)) + http-proxy: 1.18.1(debug@4.4.3(supports-color@7.2.0)) is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.8 @@ -39998,6 +41296,14 @@ snapshots: transitivePeerDependencies: - debug + http-proxy@1.18.1(debug@4.4.3(supports-color@7.2.0)): + dependencies: + eventemitter3: 4.0.7 + follow-redirects: 1.16.0(debug@4.4.3(supports-color@7.2.0)) + requires-port: 1.0.0 + transitivePeerDependencies: + - debug + http-shutdown@1.2.2: {} http-status-codes@2.3.0: {} @@ -40009,6 +41315,13 @@ snapshots: transitivePeerDependencies: - supports-color + https-proxy-agent@5.0.1(supports-color@7.2.0): + dependencies: + agent-base: 6.0.2(supports-color@7.2.0) + debug: 4.4.3(supports-color@7.2.0) + transitivePeerDependencies: + - supports-color + https-proxy-agent@7.0.6(supports-color@10.2.2): dependencies: agent-base: 7.1.3 @@ -40052,16 +41365,12 @@ snapshots: ignore@5.3.2: {} - ignore@7.0.12: {} - ignore@7.0.5: {} image-meta@0.2.2: {} immer@10.1.1: {} - immutable@5.1.4: {} - immutable@5.1.9: {} import-fresh@3.3.0: @@ -40098,6 +41407,8 @@ snapshots: inline-style-parser@0.2.4: {} + inline-style-parser@0.2.7: {} + internal-slot@1.1.0: dependencies: es-errors: 1.3.0 @@ -40175,6 +41486,13 @@ snapshots: dependencies: uint8array-extras: 1.5.0 + is-alphabetical@2.0.1: {} + + is-alphanumerical@2.0.1: + dependencies: + is-alphabetical: 2.0.1 + is-decimal: 2.0.1 + is-arguments@1.2.0: dependencies: call-bound: 1.0.4 @@ -40212,6 +41530,8 @@ snapshots: call-bound: 1.0.4 has-tostringtag: 1.0.2 + is-decimal@2.0.1: {} + is-docker@3.0.0: {} is-extglob@2.1.1: {} @@ -40222,6 +41542,8 @@ snapshots: dependencies: is-extglob: 2.1.1 + is-hexadecimal@2.0.1: {} + is-html@2.0.0: dependencies: html-tags: 3.3.1 @@ -40804,6 +42126,8 @@ snapshots: long@5.3.1: {} + longest-streak@3.1.0: {} + loose-envify@1.4.0: dependencies: js-tokens: 4.0.0 @@ -40844,14 +42168,12 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.6.0 - magic-string@1.4.5: - dependencies: - '@jridgewell/sourcemap-codec': 1.6.0 - manage-path@2.0.0: {} map-obj@5.0.2: {} + markdown-extensions@2.0.0: {} + markdown-link-extractor@4.0.3: dependencies: html-link-extractor: 1.0.5 @@ -40874,6 +42196,107 @@ snapshots: math-intrinsics@1.1.0: {} + mdast-util-from-markdown@2.1.0(supports-color@10.2.2): + dependencies: + '@types/mdast': 4.0.4 + '@types/unist': 3.0.3 + decode-named-character-reference: 1.3.0 + devlop: 1.1.0 + mdast-util-to-string: 4.0.0 + micromark: 4.0.3(supports-color@10.2.2) + micromark-util-decode-numeric-character-reference: 2.0.2 + micromark-util-decode-string: 2.0.1 + micromark-util-normalize-identifier: 2.0.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + unist-util-stringify-position: 4.0.0 + transitivePeerDependencies: + - supports-color + + mdast-util-mdx-expression@2.0.1(supports-color@10.2.2): + dependencies: + '@types/estree-jsx': 1.0.5 + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + devlop: 1.1.0 + mdast-util-from-markdown: 2.1.0(supports-color@10.2.2) + mdast-util-to-markdown: 2.2.0 + transitivePeerDependencies: + - supports-color + + mdast-util-mdx-jsx@3.2.0(supports-color@10.2.2): + dependencies: + '@types/estree-jsx': 1.0.5 + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + '@types/unist': 3.0.3 + ccount: 2.0.1 + devlop: 1.1.0 + mdast-util-from-markdown: 2.1.0(supports-color@10.2.2) + mdast-util-to-markdown: 2.2.0 + parse-entities: 4.0.2 + stringify-entities: 4.0.4 + unist-util-stringify-position: 4.0.0 + vfile-message: 4.0.3 + transitivePeerDependencies: + - supports-color + + mdast-util-mdx@3.0.0(supports-color@10.2.2): + dependencies: + mdast-util-from-markdown: 2.1.0(supports-color@10.2.2) + mdast-util-mdx-expression: 2.0.1(supports-color@10.2.2) + mdast-util-mdx-jsx: 3.2.0(supports-color@10.2.2) + mdast-util-mdxjs-esm: 2.0.1(supports-color@10.2.2) + mdast-util-to-markdown: 2.2.0 + transitivePeerDependencies: + - supports-color + + mdast-util-mdxjs-esm@2.0.1(supports-color@10.2.2): + dependencies: + '@types/estree-jsx': 1.0.5 + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + devlop: 1.1.0 + mdast-util-from-markdown: 2.1.0(supports-color@10.2.2) + mdast-util-to-markdown: 2.2.0 + transitivePeerDependencies: + - supports-color + + mdast-util-phrasing@4.1.0: + dependencies: + '@types/mdast': 4.0.4 + unist-util-is: 6.0.1 + + mdast-util-to-hast@13.2.1: + dependencies: + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + '@ungap/structured-clone': 1.4.0 + devlop: 1.1.0 + micromark-util-sanitize-uri: 2.0.1 + trim-lines: 3.0.1 + unist-util-position: 5.0.0 + unist-util-visit: 5.1.0 + vfile: 6.0.3 + + mdast-util-to-markdown@2.2.0: + dependencies: + '@types/mdast': 4.0.4 + '@types/unist': 3.0.3 + longest-streak: 3.1.0 + mdast-util-phrasing: 4.1.0 + mdast-util-to-string: 4.0.0 + micromark-util-character: 2.1.1 + micromark-util-classify-character: 2.0.1 + micromark-util-decode-string: 2.0.1 + micromark-util-html-tag-name: 2.0.1 + unist-util-visit: 5.1.0 + zwitch: 2.0.4 + + mdast-util-to-string@4.0.0: + dependencies: + '@types/mdast': 4.0.4 + mdn-data@2.0.28: {} mdn-data@2.27.1: {} @@ -40907,6 +42330,218 @@ snapshots: methods@1.1.2: {} + micromark-core-commonmark@2.0.4: + dependencies: + decode-named-character-reference: 1.3.0 + devlop: 1.1.0 + micromark-factory-destination: 2.0.1 + micromark-factory-label: 2.0.1 + micromark-factory-space: 2.1.0 + micromark-factory-title: 2.0.1 + micromark-factory-whitespace: 2.0.1 + micromark-util-character: 2.1.1 + micromark-util-chunked: 2.0.1 + micromark-util-classify-character: 2.0.1 + micromark-util-edit-map: 1.0.0 + micromark-util-html-tag-name: 2.0.1 + micromark-util-normalize-identifier: 2.0.1 + micromark-util-resolve-all: 2.0.1 + micromark-util-subtokenize: 2.1.0 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-extension-mdx-expression@3.0.1: + dependencies: + '@types/estree': 1.0.9 + devlop: 1.1.0 + micromark-factory-mdx-expression: 2.0.3 + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-events-to-acorn: 2.0.3 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-extension-mdx-jsx@3.0.2: + dependencies: + '@types/estree': 1.0.9 + devlop: 1.1.0 + estree-util-is-identifier-name: 3.0.0 + micromark-factory-mdx-expression: 2.0.3 + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-events-to-acorn: 2.0.3 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + vfile-message: 4.0.3 + + micromark-extension-mdx-md@2.0.0: + dependencies: + micromark-util-types: 2.0.3 + + micromark-extension-mdxjs-esm@3.0.0: + dependencies: + '@types/estree': 1.0.9 + devlop: 1.1.0 + micromark-core-commonmark: 2.0.4 + micromark-util-character: 2.1.1 + micromark-util-events-to-acorn: 2.0.3 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + unist-util-position-from-estree: 2.0.0 + vfile-message: 4.0.3 + + micromark-extension-mdxjs@3.0.0: + dependencies: + acorn: 8.18.0 + acorn-jsx: 5.3.2(acorn@8.18.0) + micromark-extension-mdx-expression: 3.0.1 + micromark-extension-mdx-jsx: 3.0.2 + micromark-extension-mdx-md: 2.0.0 + micromark-extension-mdxjs-esm: 3.0.0 + micromark-util-combine-extensions: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-destination@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-label@2.0.1: + dependencies: + devlop: 1.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-mdx-expression@2.0.3: + dependencies: + '@types/estree': 1.0.9 + devlop: 1.1.0 + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-events-to-acorn: 2.0.3 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + unist-util-position-from-estree: 2.0.0 + vfile-message: 4.0.3 + + micromark-factory-space@2.1.0: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-types: 2.0.3 + + micromark-factory-title@2.0.1: + dependencies: + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-whitespace@2.0.1: + dependencies: + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-character@2.1.1: + dependencies: + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-chunked@2.0.1: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-classify-character@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-combine-extensions@2.0.1: + dependencies: + micromark-util-chunked: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-decode-numeric-character-reference@2.0.2: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-decode-string@2.0.1: + dependencies: + decode-named-character-reference: 1.3.0 + micromark-util-character: 2.1.1 + micromark-util-decode-numeric-character-reference: 2.0.2 + micromark-util-symbol: 2.0.1 + + micromark-util-edit-map@1.0.0: + dependencies: + micromark-util-types: 2.0.3 + + micromark-util-encode@2.0.1: {} + + micromark-util-events-to-acorn@2.0.3: + dependencies: + '@types/estree': 1.0.9 + '@types/unist': 3.0.3 + devlop: 1.1.0 + estree-util-visit: 2.0.0 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + vfile-message: 4.0.3 + + micromark-util-html-tag-name@2.0.1: {} + + micromark-util-normalize-identifier@2.0.1: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-resolve-all@2.0.1: + dependencies: + micromark-util-types: 2.0.3 + + micromark-util-sanitize-uri@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-encode: 2.0.1 + micromark-util-symbol: 2.0.1 + + micromark-util-subtokenize@2.1.0: + dependencies: + devlop: 1.1.0 + micromark-util-chunked: 2.0.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-symbol@2.0.1: {} + + micromark-util-types@2.0.3: {} + + micromark@4.0.3(supports-color@10.2.2): + dependencies: + '@types/debug': 4.1.13 + debug: 4.4.3(supports-color@10.2.2) + decode-named-character-reference: 1.3.0 + devlop: 1.1.0 + micromark-core-commonmark: 2.0.4 + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-chunked: 2.0.1 + micromark-util-combine-extensions: 2.0.1 + micromark-util-decode-numeric-character-reference: 2.0.2 + micromark-util-edit-map: 1.0.0 + micromark-util-encode: 2.0.1 + micromark-util-normalize-identifier: 2.0.1 + micromark-util-resolve-all: 2.0.1 + micromark-util-sanitize-uri: 2.0.1 + micromark-util-subtokenize: 2.1.0 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + transitivePeerDependencies: + - supports-color + micromatch@4.0.8: dependencies: braces: 3.0.3 @@ -40948,19 +42583,6 @@ snapshots: - bufferutil - utf-8-validate - miniflare@5.20261104.0-beta(@types/node@25.0.9): - dependencies: - '@cspotcode/source-map-support': 0.8.1 - sharp: 0.35.5(@types/node@25.0.9) - undici: 7.30.1 - workerd: 1.20261104.1 - ws: 8.21.0 - youch: 4.1.0-beta.10 - transitivePeerDependencies: - - '@types/node' - - bufferutil - - utf-8-validate - minimalistic-assert@1.0.1: {} minimatch@10.2.5: @@ -40985,22 +42607,22 @@ snapshots: minimist@1.2.8: {} - minimizer-webpack-plugin@5.10.0(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack@5.110.3): + minimizer-webpack-plugin@5.10.0(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack@5.110.3): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 schema-utils: 4.3.3 terser: 5.51.2 - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.15.33(@swc/helpers@0.5.23) clean-css: 5.3.3 csso: 5.0.5 - esbuild: 0.28.1 + esbuild: 0.28.2 html-minifier-terser: 6.1.0 lightningcss: 1.33.0 postcss: 8.5.29 - sharp: 0.35.5(@types/node@25.0.9) + sharp: 0.35.4(@types/node@25.0.9) svgo: 4.0.0 minipass@7.1.2: {} @@ -41018,7 +42640,7 @@ snapshots: mlly@1.8.0: dependencies: - acorn: 8.15.0 + acorn: 8.18.0 pathe: 2.0.3 pkg-types: 1.3.1 ufo: 1.6.4 @@ -41095,6 +42717,32 @@ snapshots: - '@types/node' optional: true + msw@2.15.0(@types/node@25.0.9)(typescript@6.0.2): + dependencies: + '@inquirer/confirm': 6.3.2(@types/node@25.0.9) + '@mswjs/interceptors': 0.41.9 + '@open-draft/deferred-promise': 3.0.0 + '@types/statuses': 2.0.6 + cookie: 1.1.1 + graphql: 16.14.2 + headers-polyfill: 5.0.1 + is-node-process: 1.2.0 + outvariant: 1.4.3 + path-to-regexp: 6.3.0 + picocolors: 1.1.1 + rettime: 0.11.11 + statuses: 2.0.2 + strict-event-emitter: 0.5.1 + tough-cookie: 6.0.1 + type-fest: 5.9.0 + until-async: 3.0.2 + yargs: 17.7.2 + optionalDependencies: + typescript: 6.0.2 + transitivePeerDependencies: + - '@types/node' + optional: true + msw@2.7.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2): dependencies: '@bundled-es-modules/cookie': 2.0.1 @@ -41175,16 +42823,16 @@ snapshots: netlify-redirector@0.5.0: {} - next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.105.1): + next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.3(react@19.2.3))(react@19.2.3)(sass@1.105.1): dependencies: '@next/env': 16.3.4 '@swc/helpers': 0.5.23 baseline-browser-mapping: 2.11.23 caniuse-lite: 1.0.30001760 postcss: 8.5.23 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.3) optionalDependencies: '@next/swc-darwin-arm64': 16.3.4 '@next/swc-darwin-x64': 16.3.4 @@ -41203,36 +42851,6 @@ snapshots: - '@babel/core' - '@types/node' - babel-plugin-macros - optional: true - - next@16.3.4(@babel/core@7.29.7(supports-color@10.2.2))(@opentelemetry/api@1.9.1)(@playwright/test@1.63.0)(@types/node@25.0.9)(babel-plugin-macros@3.1.0)(babel-plugin-react-compiler@1.0.0)(react-dom@19.2.9(react@19.2.9))(react@19.2.9)(sass@1.97.2): - dependencies: - '@next/env': 16.3.4 - '@swc/helpers': 0.5.23 - baseline-browser-mapping: 2.11.23 - caniuse-lite: 1.0.30001760 - postcss: 8.5.23 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - styled-jsx: 5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.9) - optionalDependencies: - '@next/swc-darwin-arm64': 16.3.4 - '@next/swc-darwin-x64': 16.3.4 - '@next/swc-linux-arm64-gnu': 16.3.4 - '@next/swc-linux-arm64-musl': 16.3.4 - '@next/swc-linux-x64-gnu': 16.3.4 - '@next/swc-linux-x64-musl': 16.3.4 - '@next/swc-win32-arm64-msvc': 16.3.4 - '@next/swc-win32-x64-msvc': 16.3.4 - '@opentelemetry/api': 1.9.1 - '@playwright/test': 1.63.0 - babel-plugin-react-compiler: 1.0.0 - sass: 1.97.2 - sharp: 0.35.4(@types/node@25.0.9) - transitivePeerDependencies: - - '@babel/core' - - '@types/node' - - babel-plugin-macros nf3@0.3.24: {} @@ -41341,7 +42959,7 @@ snapshots: nwsapi@2.2.16: {} - nx@24.0.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2))(@swc/core@1.15.33(@swc/helpers@0.5.23)): + nx@23.2.0(@swc-node/register@1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0))(@swc/core@1.15.33(@swc/helpers@0.5.23)): dependencies: '@clack/core': 1.4.3 '@clack/prompts': 1.7.0 @@ -41353,14 +42971,19 @@ snapshots: '@tybys/wasm-util': 0.9.0 '@yarnpkg/lockfile': 1.1.0 '@zkochan/js-yaml': 0.0.7 + agent-base: 6.0.2(supports-color@7.2.0) ansi-regex: 5.0.1 ansi-styles: 4.3.0 argparse: 2.0.1 + asynckit: 0.4.0 + axios: 1.18.1(debug@4.4.3(supports-color@7.2.0))(supports-color@7.2.0) balanced-match: 4.0.3 base64-js: 1.5.1 bl: 4.1.0 - brace-expansion: 5.0.12 + brace-expansion: 5.0.9 buffer: 5.7.1 + bundle-name: 4.1.0 + call-bind-apply-helpers: 1.0.2 chalk: 4.1.2 cli-cursor: 3.1.0 cli-spinners: 2.6.1 @@ -41368,50 +42991,82 @@ snapshots: clone: 1.0.4 color-convert: 2.0.1 color-name: 1.1.4 + combined-stream: 1.0.8 + debug: 4.4.3(supports-color@7.2.0) + default-browser: 5.2.1 + default-browser-id: 5.0.0 defaults: 1.0.4 + define-lazy-prop: 3.0.0 + delayed-stream: 1.0.0 dotenv: 16.4.7 dotenv-expand: 12.0.3 + dunder-proto: 1.0.1 ejs: 5.0.1 emoji-regex: 8.0.0 end-of-stream: 1.4.5 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.1 + es-set-tostringtag: 2.1.0 escalade: 3.2.0 escape-string-regexp: 1.0.5 fast-string-truncated-width: 3.0.3 fast-string-width: 3.0.2 fast-wrap-ansi: 0.2.0 figures: 3.2.0 + flat: 5.0.2 + follow-redirects: 1.16.0(debug@4.4.3(supports-color@7.2.0)) + form-data: 4.0.6 fs-constants: 1.0.0 + function-bind: 1.1.2 get-caller-file: 2.0.5 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + gopd: 1.2.0 has-flag: 4.0.0 + has-symbols: 1.1.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + https-proxy-agent: 5.0.1(supports-color@7.2.0) ieee754: 1.2.1 - ignore: 7.0.12 + ignore: 7.0.5 inherits: 2.0.4 + is-docker: 3.0.0 is-fullwidth-code-point: 3.0.0 + is-inside-container: 1.0.0 is-interactive: 1.0.0 is-unicode-supported: 0.1.0 + is-wsl: 3.1.0 isexe: 2.0.0 json5: 2.2.3 jsonc-parser: 3.3.1 lines-and-columns: 2.0.3 log-symbols: 4.1.0 + math-intrinsics: 1.1.0 + mime-db: 1.52.0 + mime-types: 2.1.35 mimic-fn: 2.1.0 minimatch: 10.2.5 minimist: 1.2.8 + ms: 2.1.3 npm-run-path: 4.0.1 once: 1.4.0 onetime: 5.1.2 + open: 10.1.0 ora: 5.4.1 path-key: 3.1.1 picocolors: 1.1.1 + proxy-from-env: 2.1.0 readable-stream: 3.6.2 require-directory: 2.1.1 resolve.exports: 2.0.3 restore-cursor: 3.1.0 + run-applescript: 7.0.0 safe-buffer: 5.2.1 - semver: 7.8.5 + semver: 7.8.4 signal-exit: 3.0.7 sisteransi: 1.0.5 - smol-toml: 1.9.0 + smol-toml: 1.6.1 string-width: 4.2.3 string_decoder: 1.3.0 strip-ansi: 6.0.1 @@ -41421,7 +43076,6 @@ snapshots: tmp: 0.2.7 tsconfig-paths: 4.2.0 tslib: 2.8.1 - undici: 7.29.0 util-deprecate: 1.0.2 wcwidth: 1.0.1 which: 3.0.1 @@ -41432,17 +43086,17 @@ snapshots: yargs: 17.7.2 yargs-parser: 21.1.1 optionalDependencies: - '@nx/nx-darwin-arm64': 24.0.0 - '@nx/nx-darwin-x64': 24.0.0 - '@nx/nx-freebsd-x64': 24.0.0 - '@nx/nx-linux-arm-gnueabihf': 24.0.0 - '@nx/nx-linux-arm64-gnu': 24.0.0 - '@nx/nx-linux-arm64-musl': 24.0.0 - '@nx/nx-linux-x64-gnu': 24.0.0 - '@nx/nx-linux-x64-musl': 24.0.0 - '@nx/nx-win32-arm64-msvc': 24.0.0 - '@nx/nx-win32-x64-msvc': 24.0.0 - '@swc-node/register': 1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@10.2.2) + '@nx/nx-darwin-arm64': 23.2.0 + '@nx/nx-darwin-x64': 23.2.0 + '@nx/nx-freebsd-x64': 23.2.0 + '@nx/nx-linux-arm-gnueabihf': 23.2.0 + '@nx/nx-linux-arm64-gnu': 23.2.0 + '@nx/nx-linux-arm64-musl': 23.2.0 + '@nx/nx-linux-x64-gnu': 23.2.0 + '@nx/nx-linux-x64-musl': 23.2.0 + '@nx/nx-win32-arm64-msvc': 23.2.0 + '@nx/nx-win32-x64-msvc': 23.2.0 + '@swc-node/register': 1.11.1(@emnapi/core@1.11.3)(@emnapi/runtime@1.11.3)(@swc/core@1.15.33(@swc/helpers@0.5.23))(@swc/types@0.1.26)(@typescript/typescript6@6.0.2)(supports-color@7.2.0) '@swc/core': 1.15.33(@swc/helpers@0.5.23) nypm@0.6.0: @@ -41643,6 +43297,16 @@ snapshots: dependencies: callsites: 3.1.0 + parse-entities@4.0.2: + dependencies: + '@types/unist': 2.0.11 + character-entities-legacy: 3.0.0 + character-reference-invalid: 2.0.1 + decode-named-character-reference: 1.3.0 + is-alphanumerical: 2.0.1 + is-decimal: 2.0.1 + is-hexadecimal: 2.0.1 + parse-gitignore@2.0.0: {} parse-imports@2.2.1: @@ -41782,7 +43446,7 @@ snapshots: pkg-types@2.3.0: dependencies: confbox: 0.2.2 - exsolve: 1.1.1 + exsolve: 1.1.3 pathe: 2.0.3 pkijs@3.4.0: @@ -41809,7 +43473,7 @@ snapshots: postcss: 8.5.6 semver: 7.7.3 optionalDependencies: - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) transitivePeerDependencies: - typescript @@ -41857,7 +43521,7 @@ snapshots: dependencies: nanoid: 3.3.18 picocolors: 1.1.1 - source-map-js: 1.2.1 + source-map-js: 1.2.2 postcss@8.5.29: dependencies: @@ -41881,7 +43545,7 @@ snapshots: dependencies: nanoid: 3.3.11 picocolors: 1.1.1 - source-map-js: 1.2.1 + source-map-js: 1.2.2 postgres@3.4.7: {} @@ -41946,12 +43610,12 @@ snapshots: ansi-styles: 5.2.0 react-is: 17.0.2 - prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + prisma@7.0.0(@types/react@19.2.9)(@typescript/typescript6@6.0.2)(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: '@prisma/config': 7.0.0 '@prisma/dev': 0.13.0(@typescript/typescript6@6.0.2) '@prisma/engines': 7.0.0 - '@prisma/studio-core-licensed': 0.8.0(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) + '@prisma/studio-core-licensed': 0.8.0(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) mysql2: 3.15.3 postgres: 3.4.7 optionalDependencies: @@ -41986,6 +43650,8 @@ snapshots: retry: 0.12.0 signal-exit: 3.0.7 + property-information@7.2.0: {} + proto-list@1.2.4: {} protobufjs@7.4.0: @@ -42066,60 +43732,60 @@ snapshots: quote-unquote@1.0.0: {} - radix-ui@1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + radix-ui@1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: '@radix-ui/primitive': 1.1.2 - '@radix-ui/react-accessible-icon': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-accordion': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-alert-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-aspect-ratio': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-avatar': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-checkbox': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-collapsible': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-context-menu': 2.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-dropdown-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-form': 0.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-hover-card': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-label': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-menubar': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-navigation-menu': 1.2.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-popover': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-progress': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-radio-group': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-scroll-area': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-select': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-separator': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slider': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-switch': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-tabs': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toast': 1.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toggle': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toggle-group': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-toolbar': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-tooltip': 1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-escape-keydown': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.9) - '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.9(react@19.2.9))(react@19.2.9) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + '@radix-ui/react-accessible-icon': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-accordion': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-alert-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-aspect-ratio': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-avatar': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-checkbox': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-collapsible': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-collection': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-context-menu': 2.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-dialog': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-dismissable-layer': 1.1.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-dropdown-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-focus-guards': 1.1.2(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-focus-scope': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-form': 0.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-hover-card': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-label': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-menu': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-menubar': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-navigation-menu': 1.2.6(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-popover': 1.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-popper': 1.2.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-portal': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-presence': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-primitive': 2.0.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-progress': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-radio-group': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-roving-focus': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-scroll-area': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-select': 2.1.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-separator': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slider': 1.2.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-slot': 1.2.0(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-switch': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-tabs': 1.1.4(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toast': 1.2.7(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toggle': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toggle-group': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-toolbar': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-tooltip': 1.2.0(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-controllable-state': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-escape-keydown': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-use-size': 1.1.1(@types/react@19.2.9)(react@19.2.3) + '@radix-ui/react-visually-hidden': 1.1.3(@types/react-dom@19.2.3(@types/react@19.2.9))(@types/react@19.2.9)(react-dom@19.2.3(react@19.2.3))(react@19.2.3) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 '@types/react-dom': 19.2.3(@types/react@19.2.9) @@ -42151,17 +43817,23 @@ snapshots: defu: 6.1.4 destr: 2.0.5 - react-dom@19.2.9(react@19.2.9): + react-dom@19.2.3(react@19.2.3): dependencies: - react: 19.2.9 + react: 19.2.3 scheduler: 0.27.0 - react-hot-toast@2.5.1(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + react-error-boundary@6.1.6(@types/react@19.2.9)(react@19.2.3): + dependencies: + react: 19.2.3 + optionalDependencies: + '@types/react': 19.2.9 + + react-hot-toast@2.5.1(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: csstype: 3.1.3 goober: 2.1.16(csstype@3.1.3) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) react-is@16.13.1: {} @@ -42174,62 +43846,62 @@ snapshots: gl-matrix: 3.4.4 pprof-format: 2.2.1 protobufjs: 7.5.4 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) react-refresh@0.18.0: {} - react-remove-scroll-bar@2.3.8(@types/react@19.2.9)(react@19.2.9): + react-remove-scroll-bar@2.3.8(@types/react@19.2.9)(react@19.2.3): dependencies: - react: 19.2.9 - react-style-singleton: 2.2.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-style-singleton: 2.2.3(@types/react@19.2.9)(react@19.2.3) tslib: 2.8.1 optionalDependencies: '@types/react': 19.2.9 - react-remove-scroll@2.6.3(@types/react@19.2.9)(react@19.2.9): + react-remove-scroll@2.6.3(@types/react@19.2.9)(react@19.2.3): dependencies: - react: 19.2.9 - react-remove-scroll-bar: 2.3.8(@types/react@19.2.9)(react@19.2.9) - react-style-singleton: 2.2.3(@types/react@19.2.9)(react@19.2.9) + react: 19.2.3 + react-remove-scroll-bar: 2.3.8(@types/react@19.2.9)(react@19.2.3) + react-style-singleton: 2.2.3(@types/react@19.2.9)(react@19.2.3) tslib: 2.8.1 - use-callback-ref: 1.3.3(@types/react@19.2.9)(react@19.2.9) - use-sidecar: 1.1.3(@types/react@19.2.9)(react@19.2.9) + use-callback-ref: 1.3.3(@types/react@19.2.9)(react@19.2.3) + use-sidecar: 1.1.3(@types/react@19.2.9)(react@19.2.3) optionalDependencies: '@types/react': 19.2.9 - react-server-dom-rspack@0.1.1(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + react-server-dom-rspack@0.0.2(@rspack/core@2.2.7(@swc/helpers@0.5.23))(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: '@rspack/core': 2.2.7(@swc/helpers@0.5.23) - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) - react-style-singleton@2.2.3(@types/react@19.2.9)(react@19.2.9): + react-style-singleton@2.2.3(@types/react@19.2.9)(react@19.2.3): dependencies: get-nonce: 1.0.1 - react: 19.2.9 + react: 19.2.3 tslib: 2.8.1 optionalDependencies: '@types/react': 19.2.9 - react-transition-group@4.4.5(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + react-transition-group@4.4.5(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: '@babel/runtime': 7.26.7 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) - react-tweet@3.3.0(react-dom@19.2.9(react@19.2.9))(react@19.2.9): + react-tweet@3.3.0(react-dom@19.2.3(react@19.2.3))(react@19.2.3): dependencies: '@swc/helpers': 0.5.15 clsx: 2.1.1 - react: 19.2.9 - react-dom: 19.2.9(react@19.2.9) - swr: 2.3.4(react@19.2.9) + react: 19.2.3 + react-dom: 19.2.3(react@19.2.3) + swr: 2.3.4(react@19.2.3) - react@19.2.9: {} + react@19.2.3: {} read-package-up@11.0.0: dependencies: @@ -42308,6 +43980,35 @@ snapshots: dependencies: resolve: 1.22.11 + recma-build-jsx@1.0.0: + dependencies: + '@types/estree': 1.0.9 + estree-util-build-jsx: 3.0.1 + vfile: 6.0.3 + + recma-jsx@1.0.1(acorn@8.18.0): + dependencies: + acorn: 8.18.0 + acorn-jsx: 5.3.2(acorn@8.18.0) + estree-util-to-js: 2.0.0 + recma-parse: 1.0.0 + recma-stringify: 1.0.0 + unified: 11.0.5 + + recma-parse@1.0.0: + dependencies: + '@types/estree': 1.0.9 + esast-util-from-js: 2.0.1 + unified: 11.0.5 + vfile: 6.0.3 + + recma-stringify@1.0.0: + dependencies: + '@types/estree': 1.0.9 + estree-util-to-js: 2.0.0 + unified: 11.0.5 + vfile: 6.0.3 + redaxios@0.5.1: {} redent@3.0.0: @@ -42325,6 +44026,8 @@ snapshots: reduce-configs@1.1.1: {} + reduce-configs@1.1.2: {} + reduce-configs@2.0.1: {} reflect-metadata@0.2.2: {} @@ -42342,10 +44045,42 @@ snapshots: gopd: 1.2.0 set-function-name: 2.0.2 + rehype-recma@1.0.0(supports-color@10.2.2): + dependencies: + '@types/estree': 1.0.9 + '@types/hast': 3.0.5 + hast-util-to-estree: 3.1.3(supports-color@10.2.2) + transitivePeerDependencies: + - supports-color + reinterval@1.1.0: {} relateurl@0.2.7: {} + remark-mdx@3.1.1(supports-color@10.2.2): + dependencies: + mdast-util-mdx: 3.0.0(supports-color@10.2.2) + micromark-extension-mdxjs: 3.0.0 + transitivePeerDependencies: + - supports-color + + remark-parse@11.0.0(supports-color@10.2.2): + dependencies: + '@types/mdast': 4.0.4 + mdast-util-from-markdown: 2.1.0(supports-color@10.2.2) + micromark-util-types: 2.0.3 + unified: 11.0.5 + transitivePeerDependencies: + - supports-color + + remark-rehype@11.1.2: + dependencies: + '@types/hast': 3.0.5 + '@types/mdast': 4.0.4 + mdast-util-to-hast: 13.2.1 + unified: 11.0.5 + vfile: 6.0.3 + remeda@2.21.3: dependencies: type-fest: 4.41.0 @@ -42487,7 +44222,6 @@ snapshots: '@rollup/rollup-win32-x64-gnu': 4.63.1 '@rollup/rollup-win32-x64-msvc': 4.63.1 fsevents: 2.3.3 - optional: true rou3@0.7.12: {} @@ -42507,31 +44241,17 @@ snapshots: rrweb-cssom@0.8.0: {} - rsbuild-plugin-cloudflare@0.0.4(@rsbuild/core@2.3.1)(@types/node@25.0.9)(workerd@1.20261104.1): - dependencies: - '@cloudflare/build-output-utils': 0.9.10 - '@cloudflare/config': 0.30.2 - '@cloudflare/runtime-types': 0.1.23(@types/node@25.0.9) - '@cloudflare/unenv-preset': 2.16.2(unenv@2.0.0-rc.24)(workerd@1.20261104.1) - '@rsbuild/core': 2.3.1 - miniflare: 5.20261104.0-beta(@types/node@25.0.9) - unenv: 2.0.0-rc.24 - ws: 8.21.0 - transitivePeerDependencies: - - '@types/node' - - bufferutil - - utf-8-validate - - workerd - - rspack-vue-loader@17.5.0(@rspack/core@2.3.1(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)): + rspack-vue-loader@17.5.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.25)(vue@3.5.25(@typescript/typescript6@6.0.2)): dependencies: '@rspack/lite-tapable': 1.1.0 chalk: 4.1.2 optionalDependencies: - '@rspack/core': 2.3.1(@swc/helpers@0.5.23) + '@rspack/core': 2.2.7(@swc/helpers@0.5.23) '@vue/compiler-sfc': 3.5.25 vue: 3.5.25(@typescript/typescript6@6.0.2) + run-applescript@7.0.0: {} + run-applescript@7.1.0: {} run-parallel@1.2.0: @@ -42662,15 +44382,6 @@ snapshots: source-map-js: 1.2.2 optionalDependencies: '@parcel/watcher': 2.5.1 - optional: true - - sass@1.97.2: - dependencies: - chokidar: 4.0.3 - immutable: 5.1.4 - source-map-js: 1.2.2 - optionalDependencies: - '@parcel/watcher': 2.5.1 sax@1.4.1: {} @@ -42690,7 +44401,7 @@ snapshots: dependencies: '@types/json-schema': 7.0.15 ajv: 8.18.0 - ajv-formats: 2.1.1 + ajv-formats: 2.1.1(ajv@8.18.0) ajv-keywords: 5.1.0(ajv@8.18.0) secure-json-parse@4.1.0: {} @@ -42714,6 +44425,8 @@ snapshots: semver@7.8.2: {} + semver@7.8.4: {} + semver@7.8.5: {} send@0.19.0(supports-color@10.2.2): @@ -42891,39 +44604,6 @@ snapshots: '@types/node': 25.0.9 optional: true - sharp@0.35.5(@types/node@25.0.9): - dependencies: - '@img/colour': 1.1.0 - detect-libc: 2.1.2 - semver: 7.8.5 - optionalDependencies: - '@img/sharp-darwin-arm64': 0.35.5 - '@img/sharp-darwin-x64': 0.35.5 - '@img/sharp-freebsd-wasm32': 0.35.5 - '@img/sharp-libvips-darwin-arm64': 1.3.4 - '@img/sharp-libvips-darwin-x64': 1.3.4 - '@img/sharp-libvips-linux-arm': 1.3.4 - '@img/sharp-libvips-linux-arm64': 1.3.4 - '@img/sharp-libvips-linux-ppc64': 1.3.4 - '@img/sharp-libvips-linux-riscv64': 1.3.4 - '@img/sharp-libvips-linux-s390x': 1.3.4 - '@img/sharp-libvips-linux-x64': 1.3.4 - '@img/sharp-libvips-linuxmusl-arm64': 1.3.4 - '@img/sharp-libvips-linuxmusl-x64': 1.3.4 - '@img/sharp-linux-arm': 0.35.5 - '@img/sharp-linux-arm64': 0.35.5 - '@img/sharp-linux-ppc64': 0.35.5 - '@img/sharp-linux-riscv64': 0.35.5 - '@img/sharp-linux-s390x': 0.35.5 - '@img/sharp-linux-x64': 0.35.5 - '@img/sharp-linuxmusl-arm64': 0.35.5 - '@img/sharp-linuxmusl-x64': 0.35.5 - '@img/sharp-webcontainers-wasm32': 0.35.5 - '@img/sharp-win32-arm64': 0.35.5 - '@img/sharp-win32-ia32': 0.35.5 - '@img/sharp-win32-x64': 0.35.5 - '@types/node': 25.0.9 - shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -42989,8 +44669,6 @@ snapshots: smol-toml@1.6.1: {} - smol-toml@1.9.0: {} - sockjs@0.3.24: dependencies: faye-websocket: 0.11.4 @@ -43022,11 +44700,14 @@ snapshots: transitivePeerDependencies: - supports-color - solid-refresh@0.7.8(solid-js@1.9.12): + solid-refresh@0.6.3(solid-js@1.9.12)(supports-color@7.2.0): dependencies: '@babel/generator': 7.29.8 + '@babel/helper-module-imports': 7.27.1(supports-color@7.2.0) '@babel/types': 7.29.8 solid-js: 1.9.12 + transitivePeerDependencies: + - supports-color sonic-boom@4.2.0: dependencies: @@ -43047,6 +44728,8 @@ snapshots: source-map@0.7.6: {} + space-separated-tokens@2.0.2: {} + spawn-command@0.0.2: {} spawndamnit@3.0.1: @@ -43102,8 +44785,6 @@ snapshots: srvx@1.0.5: {} - srvx@1.0.8: {} - stable-hash-x@0.2.0: {} stack-trace@0.0.10: {} @@ -43179,6 +44860,11 @@ snapshots: dependencies: safe-buffer: 5.2.1 + stringify-entities@4.0.4: + dependencies: + character-entities-html4: 2.1.0 + character-entities-legacy: 3.0.0 + strip-ansi@6.0.1: dependencies: ansi-regex: 5.0.1 @@ -43209,16 +44895,24 @@ snapshots: style-loader@4.0.0(webpack@5.97.1): dependencies: - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) + + style-to-js@1.1.21: + dependencies: + style-to-object: 1.0.14 + + style-to-object@1.0.14: + dependencies: + inline-style-parser: 0.2.7 style-to-object@1.0.8: dependencies: inline-style-parser: 0.2.4 - styled-jsx@5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.9): + styled-jsx@5.1.6(@babel/core@7.29.7(supports-color@10.2.2))(babel-plugin-macros@3.1.0)(react@19.2.3): dependencies: client-only: 0.0.1 - react: 19.2.9 + react: 19.2.3 optionalDependencies: '@babel/core': 7.29.7(supports-color@10.2.2) babel-plugin-macros: 3.1.0 @@ -43258,11 +44952,11 @@ snapshots: '@swc/counter': 0.1.3 webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.27.4)(webpack-cli@5.1.4) - swr@2.3.4(react@19.2.9): + swr@2.3.4(react@19.2.3): dependencies: dequal: 2.0.3 - react: 19.2.9 - use-sync-external-store: 1.6.0(react@19.2.9) + react: 19.2.3 + use-sync-external-store: 1.6.0(react@19.2.3) symbol-tree@3.2.4: {} @@ -43341,22 +45035,22 @@ snapshots: '@swc/core': 1.15.33(@swc/helpers@0.5.23) esbuild: 0.27.4 - terser-webpack-plugin@5.3.11(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack@5.97.1): + terser-webpack-plugin@5.3.11(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack@5.97.1): dependencies: '@jridgewell/trace-mapping': 0.3.31 jest-worker: 27.5.1 schema-utils: 4.3.3 serialize-javascript: 6.0.2 terser: 5.37.0 - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) + webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4) optionalDependencies: '@swc/core': 1.15.33(@swc/helpers@0.5.23) - esbuild: 0.28.1 + esbuild: 0.28.2 terser@5.37.0: dependencies: '@jridgewell/source-map': 0.3.6 - acorn: 8.15.0 + acorn: 8.18.0 commander: 2.20.3 source-map-support: 0.5.21 @@ -43479,8 +45173,12 @@ snapshots: tree-kill@1.2.2: {} + trim-lines@3.0.1: {} + triple-beam@1.4.1: {} + trough@2.2.0: {} + ts-api-utils@2.1.0(@typescript/typescript6@6.0.2): dependencies: typescript: '@typescript/typescript6@6.0.2' @@ -43579,13 +45277,13 @@ snapshots: transitivePeerDependencies: - supports-color - typescript-eslint@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): + typescript-eslint@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - '@typescript-eslint/eslint-plugin': 8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - '@typescript-eslint/parser': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2) - '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2) - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + '@typescript-eslint/eslint-plugin': 8.57.1(@typescript-eslint/parser@8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0))(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + '@typescript-eslint/parser': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + '@typescript-eslint/typescript-estree': 8.57.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0) + '@typescript-eslint/utils': 8.57.1(@typescript/typescript6@6.0.2)(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) typescript: '@typescript/typescript6@6.0.2' transitivePeerDependencies: - supports-color @@ -43649,10 +45347,6 @@ snapshots: undici@7.27.2: {} - undici@7.29.0: {} - - undici@7.30.1: {} - unenv@2.0.0-rc.24: dependencies: pathe: 2.0.3 @@ -43663,6 +45357,43 @@ snapshots: unicorn-magic@0.4.0: {} + unified@11.0.5: + dependencies: + '@types/unist': 3.0.3 + bail: 2.0.2 + devlop: 1.1.0 + extend: 3.0.2 + is-plain-obj: 4.1.0 + trough: 2.2.0 + vfile: 6.0.3 + + unist-util-is@6.0.1: + dependencies: + '@types/unist': 3.0.3 + + unist-util-position-from-estree@2.0.0: + dependencies: + '@types/unist': 3.0.3 + + unist-util-position@5.0.0: + dependencies: + '@types/unist': 3.0.3 + + unist-util-stringify-position@4.0.0: + dependencies: + '@types/unist': 3.0.3 + + unist-util-visit-parents@6.0.2: + dependencies: + '@types/unist': 3.0.3 + unist-util-is: 6.0.1 + + unist-util-visit@5.1.0: + dependencies: + '@types/unist': 3.0.3 + unist-util-is: 6.0.1 + unist-util-visit-parents: 6.0.2 + universalify@0.1.2: {} universalify@0.2.0: {} @@ -43687,20 +45418,18 @@ snapshots: picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 - unplugin@3.7.0(@rsbuild/core@2.3.1)(@rspack/core@2.3.1(@swc/helpers@0.5.23))(esbuild@0.28.1)(rolldown@1.2.13)(rollup@4.63.1)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(webpack@5.110.3): + unplugin@3.3.0(@rspack/core@2.2.7(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.13)(rollup@4.63.1)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0))(webpack@5.110.3): dependencies: '@jridgewell/remapping': 2.3.5 - '@rolldown/pluginutils': 1.0.1 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - '@rsbuild/core': 2.3.1 - '@rspack/core': 2.3.1(@swc/helpers@0.5.23) - esbuild: 0.28.1 + '@rspack/core': 2.2.7(@swc/helpers@0.5.23) + esbuild: 0.28.2 rolldown: 1.2.13 rollup: 4.63.1 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) unrs-resolver@1.11.1: dependencies: @@ -43774,24 +45503,24 @@ snapshots: urlpattern-polyfill@8.0.2: {} - use-callback-ref@1.3.3(@types/react@19.2.9)(react@19.2.9): + use-callback-ref@1.3.3(@types/react@19.2.9)(react@19.2.3): dependencies: - react: 19.2.9 + react: 19.2.3 tslib: 2.8.1 optionalDependencies: '@types/react': 19.2.9 - use-sidecar@1.1.3(@types/react@19.2.9)(react@19.2.9): + use-sidecar@1.1.3(@types/react@19.2.9)(react@19.2.3): dependencies: detect-node-es: 1.1.0 - react: 19.2.9 + react: 19.2.3 tslib: 2.8.1 optionalDependencies: '@types/react': 19.2.9 - use-sync-external-store@1.6.0(react@19.2.9): + use-sync-external-store@1.6.0(react@19.2.3): dependencies: - react: 19.2.9 + react: 19.2.3 util-deprecate@1.0.2: {} @@ -43809,6 +45538,10 @@ snapshots: optionalDependencies: typescript: '@typescript/typescript6@6.0.2' + valibot@1.0.0-beta.15(typescript@7.0.2): + optionalDependencies: + typescript: 7.0.2 + valibot@1.1.0(@typescript/typescript6@6.0.2): optionalDependencies: typescript: '@typescript/typescript6@6.0.2' @@ -43824,7 +45557,17 @@ snapshots: vary@1.1.2: {} - vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vfile-message@4.0.3: + dependencies: + '@types/unist': 3.0.3 + unist-util-stringify-position: 4.0.0 + + vfile@6.0.3: + dependencies: + '@types/unist': 3.0.3 + vfile-message: 4.0.3 + + vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@microsoft/api-extractor': 7.47.7(@types/node@25.0.9) '@rollup/pluginutils': 5.1.4(rollup@4.63.1) @@ -43837,13 +45580,13 @@ snapshots: magic-string: 0.30.21 typescript: '@typescript/typescript6@6.0.2' optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@microsoft/api-extractor': 7.47.7(@types/node@25.0.9) '@rollup/pluginutils': 5.1.4(rollup@4.63.1) @@ -43856,13 +45599,13 @@ snapshots: magic-string: 0.30.21 typescript: '@typescript/typescript6@6.0.2' optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(rollup@4.63.1)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@microsoft/api-extractor': 7.47.7(@types/node@25.0.9) '@rollup/pluginutils': 5.1.4(rollup@4.63.1) @@ -43875,13 +45618,32 @@ snapshots: magic-string: 0.30.21 typescript: '@typescript/typescript6@6.0.2' optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-plugin-dts@4.2.3(@types/node@25.0.9)(rollup@4.63.1)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-dts@4.2.3(@types/node@25.0.9)(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + dependencies: + '@microsoft/api-extractor': 7.47.7(@types/node@25.0.9) + '@rollup/pluginutils': 5.1.4(rollup@4.63.1) + '@volar/typescript': 2.4.26(@typescript/typescript6@6.0.2) + '@vue/language-core': 2.1.6(@typescript/typescript6@6.0.2) + compare-versions: 6.1.1 + debug: 4.4.3(supports-color@7.2.0) + kolorist: 1.8.0 + local-pkg: 0.5.1 + magic-string: 0.30.21 + typescript: '@typescript/typescript6@6.0.2' + optionalDependencies: + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + transitivePeerDependencies: + - '@types/node' + - rollup + - supports-color + + vite-plugin-dts@4.2.3(@types/node@25.0.9)(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@microsoft/api-extractor': 7.47.7(@types/node@25.0.9) '@rollup/pluginutils': 5.1.4(rollup@4.63.1) @@ -43894,25 +45656,21 @@ snapshots: magic-string: 0.30.21 typescript: 5.9.2 optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - '@types/node' - rollup - supports-color - vite-plugin-externalize-deps@0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-externalize-deps@0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-externalize-deps@0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-externalize-deps@0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vite-plugin-externalize-deps@0.10.0(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): - dependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - vite-plugin-solid@2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-solid@2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@types/babel__core': 7.20.5 @@ -43920,14 +45678,29 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.9.12 solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optionalDependencies: '@testing-library/jest-dom': 6.6.3 transitivePeerDependencies: - supports-color - vite-plugin-solid@2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-solid@2.11.10(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + dependencies: + '@babel/core': 7.29.7(supports-color@7.2.0) + '@types/babel__core': 7.20.5 + babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@7.2.0))(solid-js@1.9.12) + merge-anything: 5.1.7 + solid-js: 1.9.12 + solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + optionalDependencies: + '@testing-library/jest-dom': 6.6.3 + transitivePeerDependencies: + - supports-color + + vite-plugin-solid@2.11.10(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@types/babel__core': 7.20.5 @@ -43935,14 +45708,14 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.9.12 solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optionalDependencies: '@testing-library/jest-dom': 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) transitivePeerDependencies: - supports-color - vite-plugin-solid@2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-solid@2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@types/babel__core': 7.20.5 @@ -43950,29 +45723,29 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.9.12 solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optionalDependencies: '@testing-library/jest-dom': 6.6.3 transitivePeerDependencies: - supports-color - vite-plugin-solid@2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-solid@2.11.11(@testing-library/jest-dom@6.6.3)(solid-js@1.9.12)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: - '@babel/core': 7.29.7(supports-color@10.2.2) + '@babel/core': 7.29.7(supports-color@7.2.0) '@types/babel__core': 7.20.5 - babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@10.2.2))(solid-js@1.9.12) + babel-preset-solid: 1.9.10(@babel/core@7.29.7(supports-color@7.2.0))(solid-js@1.9.12) merge-anything: 5.1.7 solid-js: 1.9.12 - solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@7.2.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optionalDependencies: '@testing-library/jest-dom': 6.6.3 transitivePeerDependencies: - supports-color - vite-plugin-solid@2.11.11(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-plugin-solid@2.11.11(@testing-library/jest-dom@7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4))(solid-js@1.9.12)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@babel/core': 7.29.7(supports-color@10.2.2) '@types/babel__core': 7.20.5 @@ -43980,54 +45753,54 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.9.12 solid-refresh: 0.6.3(solid-js@1.9.12)(supports-color@10.2.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vitefu: 1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) optionalDependencies: '@testing-library/jest-dom': 7.0.1(@testing-library/dom@10.4.1)(vitest@5.0.4) transitivePeerDependencies: - supports-color - vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: debug: 4.4.3(supports-color@10.2.2) globrex: 0.1.2 tsconfck: 3.1.4(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - supports-color - typescript - vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: debug: 4.4.3(supports-color@10.2.2) globrex: 0.1.2 tsconfck: 3.1.4(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - supports-color - typescript - vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@10.2.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-tsconfig-paths@6.1.1(@typescript/typescript6@6.0.2)(supports-color@7.2.0)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: - debug: 4.4.3(supports-color@10.2.2) + debug: 4.4.3(supports-color@7.2.0) globrex: 0.1.2 tsconfck: 3.1.4(@typescript/typescript6@6.0.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - supports-color - typescript - vite-tsconfig-paths@6.1.1(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vite-tsconfig-paths@6.1.1(supports-color@10.2.2)(typescript@5.9.2)(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: debug: 4.4.3(supports-color@10.2.2) globrex: 0.1.2 tsconfck: 3.1.4(typescript@5.9.2) - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) transitivePeerDependencies: - supports-color - typescript - vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0): + vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 @@ -44039,13 +45812,13 @@ snapshots: esbuild: 0.27.4 fsevents: 2.3.3 jiti: 2.7.0 - sass: 1.97.2 + sass: 1.105.1 sass-embedded: 1.105.1 terser: 5.51.2 tsx: 4.20.3 yaml: 2.9.0 - vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0): + vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 @@ -44054,7 +45827,7 @@ snapshots: tinyglobby: 0.2.17 optionalDependencies: '@types/node': 25.0.9 - esbuild: 0.28.1 + esbuild: 0.28.2 fsevents: 2.3.3 jiti: 2.7.0 sass: 1.105.1 @@ -44063,44 +45836,18 @@ snapshots: tsx: 4.20.3 yaml: 2.9.0 - vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0): - dependencies: - lightningcss: 1.33.0 - picomatch: 4.0.7 - postcss: 8.5.29 - rolldown: 1.2.13 - tinyglobby: 0.2.17 + vitefu@1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): optionalDependencies: - '@types/node': 25.0.9 - esbuild: 0.28.1 - fsevents: 2.3.3 - jiti: 2.7.0 - sass: 1.97.2 - sass-embedded: 1.105.1 - terser: 5.51.2 - tsx: 4.20.3 - yaml: 2.9.0 + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu@1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitefu@1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - vitefu@1.1.1(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): - optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - vitefu@1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): - optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - vitefu@1.1.3(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): - optionalDependencies: - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - - vitest@4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@4.1.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@4.1.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@vitest/expect': 4.1.4 - '@vitest/mocker': 4.1.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 4.1.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) '@vitest/pretty-format': 4.1.4 '@vitest/runner': 4.1.4 '@vitest/snapshot': 4.1.4 @@ -44117,7 +45864,7 @@ snapshots: tinyexec: 1.3.1 tinyglobby: 0.2.17 tinyrainbow: 3.2.0 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 2.3.0 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44128,10 +45875,10 @@ snapshots: - msw optional: true - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -44142,7 +45889,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.27.4)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44152,10 +45899,10 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -44166,7 +45913,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44176,10 +45923,10 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@25.0.1(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -44190,31 +45937,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) - why-is-node-running: 3.2.1 - optionalDependencies: - '@opentelemetry/api': 1.9.1 - '@types/node': 25.0.9 - '@vitest/ui': 5.0.4(vitest@5.0.4) - jsdom: 25.0.1(supports-color@10.2.2) - transitivePeerDependencies: - - msw - - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@27.0.0(supports-color@10.2.2))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): - dependencies: - '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) - chai: 6.3.0 - es-module-lexer: 2.3.2 - expect-type: 1.4.0 - magic-string: 1.4.3 - obug: 3.0.0 - picomatch: 4.0.7 - std-env: 4.3.0 - tinybench: 6.2.2 - tinyexec: 1.3.1 - tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44224,10 +45947,10 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(@typescript/typescript6@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -44238,7 +45961,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.97.2)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44248,10 +45971,10 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): dependencies: '@types/chai': 5.2.2 - '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@5.9.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -44262,7 +45985,31 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.1)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) + why-is-node-running: 3.2.1 + optionalDependencies: + '@opentelemetry/api': 1.9.1 + '@types/node': 25.0.9 + '@vitest/ui': 5.0.4(vitest@5.0.4) + jsdom: 29.1.1(@noble/hashes@2.0.1) + transitivePeerDependencies: + - msw + + vitest@5.0.4(@opentelemetry/api@1.9.1)(@types/node@25.0.9)(@vitest/ui@5.0.4)(jsdom@29.1.1(@noble/hashes@2.0.1))(msw@2.15.0(@types/node@25.0.9)(typescript@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)): + dependencies: + '@types/chai': 5.2.2 + '@vitest/mocker': 5.0.4(msw@2.15.0(@types/node@25.0.9)(typescript@6.0.2))(vite@8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0)) + chai: 6.3.0 + es-module-lexer: 2.3.2 + expect-type: 1.4.0 + magic-string: 1.4.3 + obug: 3.0.0 + picomatch: 4.0.7 + std-env: 4.3.0 + tinybench: 6.2.2 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + vite: 8.3.4(@types/node@25.0.9)(esbuild@0.28.2)(jiti@2.7.0)(sass-embedded@1.105.1)(sass@1.105.1)(terser@5.51.2)(tsx@4.20.3)(yaml@2.9.0) why-is-node-running: 3.2.1 optionalDependencies: '@opentelemetry/api': 1.9.1 @@ -44284,9 +46031,9 @@ snapshots: dependencies: vue: 3.5.25(typescript@5.8.3) - vue-demi@0.14.10(vue@3.5.25(typescript@6.0.2)): + vue-demi@0.14.10(vue@3.5.25(typescript@7.0.2)): dependencies: - vue: 3.5.25(typescript@6.0.2) + vue: 3.5.25(typescript@7.0.2) vue-eslint-parser@10.2.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): dependencies: @@ -44296,19 +46043,19 @@ snapshots: eslint-visitor-keys: 4.2.1 espree: 10.4.0 esquery: 1.6.0 - semver: 7.8.5 + semver: 7.8.2 transitivePeerDependencies: - supports-color - vue-eslint-parser@10.4.0(eslint@9.22.0(jiti@2.7.0)(supports-color@10.2.2))(supports-color@10.2.2): + vue-eslint-parser@10.4.0(eslint@9.22.0(jiti@2.7.0)(supports-color@7.2.0))(supports-color@7.2.0): dependencies: - debug: 4.4.3(supports-color@10.2.2) - eslint: 9.22.0(jiti@2.7.0)(supports-color@10.2.2) + debug: 4.4.3(supports-color@7.2.0) + eslint: 9.22.0(jiti@2.7.0)(supports-color@7.2.0) eslint-scope: 8.3.0 eslint-visitor-keys: 4.2.1 espree: 10.4.0 esquery: 1.6.0 - semver: 7.8.5 + semver: 7.8.2 transitivePeerDependencies: - supports-color @@ -44373,15 +46120,15 @@ snapshots: optionalDependencies: typescript: 5.9.3 - vue@3.5.25(typescript@6.0.2): + vue@3.5.25(typescript@7.0.2): dependencies: '@vue/compiler-dom': 3.5.25 '@vue/compiler-sfc': 3.5.25 '@vue/runtime-dom': 3.5.25 - '@vue/server-renderer': 3.5.25(vue@3.5.25(typescript@6.0.2)) + '@vue/server-renderer': 3.5.25(vue@3.5.25(typescript@7.0.2)) '@vue/shared': 3.5.25 optionalDependencies: - typescript: 6.0.2 + typescript: 7.0.2 w3c-xmlserializer@5.0.0: dependencies: @@ -44430,10 +46177,10 @@ snapshots: import-local: 3.2.0 interpret: 3.1.1 rechoir: 0.8.0 - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-merge: 5.10.0 optionalDependencies: - webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3) + webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3) optional: true webpack-cli@5.1.4(webpack-dev-server@5.2.4)(webpack@5.97.1): @@ -44453,7 +46200,7 @@ snapshots: webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.27.4)(webpack-cli@5.1.4) webpack-merge: 5.10.0 optionalDependencies: - webpack-dev-server: 5.2.4(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) + webpack-dev-server: 5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1) webpack-dev-middleware@7.4.2(webpack@5.110.3): dependencies: @@ -44464,8 +46211,7 @@ snapshots: range-parser: 1.2.1 schema-utils: 4.3.3 optionalDependencies: - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) - optional: true + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-dev-middleware@7.4.2(webpack@5.97.1): dependencies: @@ -44478,7 +46224,7 @@ snapshots: optionalDependencies: webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.27.4)(webpack-cli@5.1.4) - webpack-dev-server@5.2.4(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3): + webpack-dev-server@5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.110.3): dependencies: '@types/bonjour': 3.5.13 '@types/connect-history-api-fallback': 1.5.4 @@ -44496,7 +46242,7 @@ snapshots: connect-history-api-fallback: 2.0.0 express: 4.22.2(supports-color@10.2.2) graceful-fs: 4.2.11 - http-proxy-middleware: 2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@10.2.2)) + http-proxy-middleware: 2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@7.2.0)) ipaddr.js: 2.2.0 launch-editor: 2.9.1 open: 10.1.0 @@ -44509,16 +46255,15 @@ snapshots: webpack-dev-middleware: 7.4.2(webpack@5.110.3) ws: 8.20.0 optionalDependencies: - webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) + webpack: 5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4) webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.110.3) transitivePeerDependencies: - bufferutil - debug - supports-color - utf-8-validate - optional: true - webpack-dev-server@5.2.4(debug@4.4.3(supports-color@10.2.2))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1): + webpack-dev-server@5.2.4(debug@4.4.3(supports-color@7.2.0))(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1): dependencies: '@types/bonjour': 3.5.13 '@types/connect-history-api-fallback': 1.5.4 @@ -44536,46 +46281,7 @@ snapshots: connect-history-api-fallback: 2.0.0 express: 4.22.2(supports-color@10.2.2) graceful-fs: 4.2.11 - http-proxy-middleware: 2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@10.2.2)) - ipaddr.js: 2.2.0 - launch-editor: 2.9.1 - open: 10.1.0 - p-retry: 6.2.1 - schema-utils: 4.3.3 - selfsigned: 5.5.0 - serve-index: 1.9.1(supports-color@10.2.2) - sockjs: 0.3.24 - spdy: 4.0.2(supports-color@10.2.2) - webpack-dev-middleware: 7.4.2(webpack@5.97.1) - ws: 8.20.0 - optionalDependencies: - webpack: 5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4) - webpack-cli: 5.1.4(webpack-dev-server@5.2.4)(webpack@5.97.1) - transitivePeerDependencies: - - bufferutil - - debug - - supports-color - - utf-8-validate - - webpack-dev-server@5.2.4(supports-color@10.2.2)(webpack-cli@5.1.4)(webpack@5.97.1): - dependencies: - '@types/bonjour': 3.5.13 - '@types/connect-history-api-fallback': 1.5.4 - '@types/express': 4.17.25 - '@types/express-serve-static-core': 4.19.6 - '@types/serve-index': 1.9.4 - '@types/serve-static': 1.15.7 - '@types/sockjs': 0.3.36 - '@types/ws': 8.5.14 - ansi-html-community: 0.0.8 - bonjour-service: 1.3.0 - chokidar: 3.6.0 - colorette: 2.0.20 - compression: 1.8.1(supports-color@10.2.2) - connect-history-api-fallback: 2.0.0 - express: 4.22.2(supports-color@10.2.2) - graceful-fs: 4.2.11 - http-proxy-middleware: 2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@10.2.2)) + http-proxy-middleware: 2.0.9(@types/express@4.17.25)(debug@4.4.3(supports-color@7.2.0)) ipaddr.js: 2.2.0 launch-editor: 2.9.1 open: 10.1.0 @@ -44612,7 +46318,7 @@ snapshots: webpack-virtual-modules@0.6.2: {} - webpack@5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4): + webpack@5.110.3(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack-cli@5.1.4): dependencies: '@types/estree': 1.0.9 '@types/json-schema': 7.0.15 @@ -44627,7 +46333,7 @@ snapshots: events: 3.3.0 graceful-fs: 4.2.11 mime-db: 1.54.0 - minimizer-webpack-plugin: 5.10.0(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.1)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.5(@types/node@25.0.9))(svgo@4.0.0)(webpack@5.110.3) + minimizer-webpack-plugin: 5.10.0(@swc/core@1.15.33(@swc/helpers@0.5.23))(clean-css@5.3.3)(csso@5.0.5)(esbuild@0.28.2)(html-minifier-terser@6.1.0)(lightningcss@1.33.0)(postcss@8.5.29)(sharp@0.35.4(@types/node@25.0.9))(svgo@4.0.0)(webpack@5.110.3) neo-async: 2.6.2 schema-utils: 4.3.3 tapable: 2.3.3 @@ -44685,7 +46391,7 @@ snapshots: - esbuild - uglify-js - webpack@5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack-cli@5.1.4): + webpack@5.97.1(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack-cli@5.1.4): dependencies: '@types/eslint-scope': 3.7.7 '@types/estree': 1.0.7 @@ -44707,7 +46413,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.11(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.1)(webpack@5.97.1) + terser-webpack-plugin: 5.3.11(@swc/core@1.15.33(@swc/helpers@0.5.23))(esbuild@0.28.2)(webpack@5.97.1) watchpack: 2.4.2 webpack-sources: 3.2.3 optionalDependencies: @@ -44831,14 +46537,6 @@ snapshots: '@cloudflare/workerd-linux-arm64': 1.20260317.1 '@cloudflare/workerd-windows-64': 1.20260317.1 - workerd@1.20261104.1: - optionalDependencies: - '@cloudflare/workerd-darwin-64': 1.20261104.1 - '@cloudflare/workerd-darwin-arm64': 1.20261104.1 - '@cloudflare/workerd-linux-64': 1.20261104.1 - '@cloudflare/workerd-linux-arm64': 1.20261104.1 - '@cloudflare/workerd-windows-64': 1.20261104.1 - wrangler@4.75.0: dependencies: '@cloudflare/kv-asset-handler': 0.4.2 @@ -44879,8 +46577,6 @@ snapshots: ws@8.20.0: {} - ws@8.21.0: {} - xml-name-validator@4.0.0: {} xml-name-validator@5.0.0: {} @@ -44958,6 +46654,8 @@ snapshots: cookie: 1.1.1 youch-core: 0.3.3 + yuku@0.22.1: {} + zeptomatch@2.0.2: dependencies: grammex: 3.1.11 @@ -44976,11 +46674,11 @@ snapshots: zod@4.5.4: {} - zod@4.6.6: {} - - zustand@5.0.12(@types/react@19.2.9)(immer@10.1.1)(react@19.2.9)(use-sync-external-store@1.6.0(react@19.2.9)): + zustand@5.0.12(@types/react@19.2.9)(immer@10.1.1)(react@19.2.3)(use-sync-external-store@1.6.0(react@19.2.3)): optionalDependencies: '@types/react': 19.2.9 immer: 10.1.1 - react: 19.2.9 - use-sync-external-store: 1.6.0(react@19.2.9) + react: 19.2.3 + use-sync-external-store: 1.6.0(react@19.2.3) + + zwitch@2.0.4: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index c5c9bae1df..1d6e03cc20 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,5 +1,7 @@ cleanupUnusedCatalogs: true minimumReleaseAge: 1440 +minimumReleaseAgeExclude: + - 'yuku' # compiler-test-utils needs the semantic API first released 2026-10-22 (0.22.x); remove once older than the release-age window linkWorkspacePackages: true preferWorkspacePackages: true blockExoticSubdeps: true @@ -36,15 +38,15 @@ catalog: '@babel/types': ^7.29.8 '@arethetypeswrong/cli': ^0.18.4 '@eslint-react/eslint-plugin': ^1.26.2 - '@rsbuild/core': ^2.3.1 + '@rsbuild/core': ^2.2.5 '@tanstack/vite-config': 0.5.2 '@testing-library/jest-dom': ^7.0.1 '@testing-library/react': ^16.2.0 '@vitejs/plugin-react': ^6.0.1 '@vitejs/plugin-vue-jsx': ^4.1.2 '@vitest/ui': ^5.0.4 - react: ~19.2.9 - react-dom: ~19.2.9 + react: ^19.2.3 + react-dom: ^19.2.3 '@types/react': ^19.2.8 '@types/react-dom': ^19.2.3 eslint: ^9.22.0 diff --git a/scripts/benchmarks/bundle-size/build.mjs b/scripts/benchmarks/bundle-size/build.mjs index dfb32c923a..092087cec7 100644 --- a/scripts/benchmarks/bundle-size/build.mjs +++ b/scripts/benchmarks/bundle-size/build.mjs @@ -10,11 +10,22 @@ const repoRoot = fileURLToPath(new URL('../../../', import.meta.url)) * @param {import('./run.mjs').Execute} [execute] */ export function build(args, execute = spawnSync) { + const pnpmPath = process.env.npm_execpath /** @type {import('./run.mjs').CommandOptions} */ const options = { cwd: repoRoot, env: process.env, stdio: 'inherit' } const result = execute( - process.env.npm_execpath || 'pnpm', - ['exec', 'nx', 'run', '@benchmarks/bundle-size:measure', ...args], + pnpmPath + ? process.execPath + : process.platform === 'win32' + ? 'pnpm.cmd' + : 'pnpm', + [ + ...(pnpmPath ? [pnpmPath] : []), + 'nx', + 'run', + '@benchmarks/bundle-size:measure', + ...args, + ], options, ) if (result.status !== 0) { diff --git a/scripts/benchmarks/bundle-size/build.test.mjs b/scripts/benchmarks/bundle-size/build.test.mjs index 779824c35a..74b1649152 100644 --- a/scripts/benchmarks/bundle-size/build.test.mjs +++ b/scripts/benchmarks/bundle-size/build.test.mjs @@ -17,8 +17,7 @@ test('generates a fresh report after a successful Nx run, including cache hits', ) assert.equal(status, 0) assert.equal(calls.length, 2) - assert.deepEqual(calls[0], [ - 'exec', + assert.deepEqual(calls[0]?.slice(-5), [ 'nx', 'run', '@benchmarks/bundle-size:measure', diff --git a/scripts/benchmarks/bundle-size/measure.mjs b/scripts/benchmarks/bundle-size/measure.mjs index 4a990feaf9..73631eb90b 100644 --- a/scripts/benchmarks/bundle-size/measure.mjs +++ b/scripts/benchmarks/bundle-size/measure.mjs @@ -479,7 +479,6 @@ function buildRequiredPackages({ repoRoot, scenarios, skipPackageBuilds }) { ) const args = [ - 'exec', 'nx', 'run-many', '--target=build', @@ -495,7 +494,7 @@ function buildRequiredPackages({ repoRoot, scenarios, skipPackageBuilds }) { args.push('--skipNxCache') } - execFileSync(process.env.npm_execpath || 'pnpm', args, { + execFileSync(process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm', args, { cwd: repoRoot, stdio: 'inherit', env: process.env, diff --git a/scripts/benchmarks/bundle-size/run.mjs b/scripts/benchmarks/bundle-size/run.mjs index a4a0cc73d2..2e6d42c977 100644 --- a/scripts/benchmarks/bundle-size/run.mjs +++ b/scripts/benchmarks/bundle-size/run.mjs @@ -180,17 +180,26 @@ Arguments after -- go to the selected unit tests, not the measurement.`) } if (values['test-projects']) { - const status = step('tests', process.env.npm_execpath || 'pnpm', [ - 'exec', - 'nx', - 'run-many', - '--target=test:unit', - `--projects=${values['test-projects']}`, - '--parallel=1', - '--outputStyle=stream', - '--skipRemoteCache', - ...(testArgs.length > 0 ? ['--', ...testArgs] : []), - ]) + const pnpmPath = process.env.npm_execpath + const status = step( + 'tests', + pnpmPath + ? process.execPath + : process.platform === 'win32' + ? 'pnpm.cmd' + : 'pnpm', + [ + ...(pnpmPath ? [pnpmPath] : []), + 'nx', + 'run-many', + '--target=test:unit', + `--projects=${values['test-projects']}`, + '--parallel=1', + '--outputStyle=stream', + '--skipRemoteCache', + ...(testArgs.length > 0 ? ['--', ...testArgs] : []), + ], + ) if (status !== 0) { return status }
{[renderable, composite, flight].map((render, index) => caller)}
{[flight, renderable, composite].map((render, index) => caller)}